marinasundstrom / CheckedExceptions

Enforce better exception handling in C#/.NET by ensuring exceptions are explicitly handled.
MIT License
7 stars 1 forks source link

ArgumentException overshadows ArgumentNullException in reporting #47

Closed marinasundstrom closed 1 day ago

marinasundstrom commented 6 days ago

ArgumentException overshadows ArgumentNullException in reporting, causing ArgumentNullException not to be reported. This is likely due to ArgumentNullException extending ArgumentException.

This is a quirk of the framework and its legacy that those exceptions happen to coincide.

In this case it was about Dictionary<TKey, TValue>.Add(TKey key, TValue value) declaring both for different reasons.

You don't have this problem when nullable is active. Since ArgumentNullException is not relevant there.

marinasundstrom commented 3 days ago

This is probably nothing we can do about. But this is a known problem. Designers of APIs should note this.

marinasundstrom commented 1 day ago

Not a bug per se. We close this for now.