Throw Exceptions In Unexpected Locations - prodot/ReCommended-Extension GitHub Wiki
Shows a warning when exceptions are thrown in unexpected locations.
| Unexpected Location | Allowed exceptions (incl. all derivatives) |
|---|---|
| property getters |
InvalidOperationException, NotSupportedException
|
| indexer getters |
ArgumentException, InvalidOperationException, KeyNotFoundException, NotSupportedException
|
| event accessors |
ArgumentException, InvalidOperationException, NotSupportedException
|
| static constructors | none |
| finalizers | none |
equality operators (== and !=) |
none |
| implicit cast operators | none |
object.Equals method overrides |
none |
object.GetHashCode method overrides |
none |
object.ToString method overrides |
none |
IEquatable<T>.Equals method implementations |
none |
IEqualityComparer.Equals method implementations |
none |
IEqualityComparer.GetHashCode method implementations |
ArgumentException |
IEqualityComparer<T>.Equals method implementations |
none |
IEqualityComparer<T>.GetHashCode method implementations |
ArgumentException |
IDisposable.Dispose method implementations |
none |
IAsyncDisposable.DisposeAsync method implementations |
none |
Dispose(false) code paths |
none |
| finally blocks | none |
| exception filter expressions | none |
Note
No warning is shown when the UnreachableException is thrown.
Important
Known Limitations
- Only direct
throwexpressions and statements are evaluated. Exceptions thrown by called methods are not evaluated. - The
Dispose(false)code path is checked regardless of whether it's called by the finalizer.
Note
The analyzer can be configured or deactivated in the ReSharper Options or Rider Settings dialog.