New nullability annotation to capture GetType(..., throwOnError: true) semantics #8844
Replies: 4 comments
-
@jaredpar should this go in the dotnet/csharplang repo? |
Beta Was this translation helpful? Give feedback.
-
FWIW, we discussed exactly such an attribute for exactly this (and other similar) cases in corelib when designing the initial set of attributes, and it was deemed too niche / too limited of an impact to be worth the extra complexity / cost. |
Beta Was this translation helpful? Give feedback.
-
Perhaps new methods, like |
Beta Was this translation helpful? Give feedback.
-
Arguably, the problem here is the API design choice to use FWIW, a team I once worked on (developing in Delphi) used the convention that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When you call
Assembly.GetType("Foo", throwOnError: true)
, there is a guarantee that it will either throw (not return) or return a non-null value.It would be nice for
throwOnError: true
to not require!
whenever it is used, but the current nullability attributes don't provide a way of saying, "Not null if the named parameter is true."Does something along these lines have merit?
Beta Was this translation helpful? Give feedback.
All reactions