New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New nullability annotation to capture GetType(..., throwOnError: true) semantics #2835
Comments
@jaredpar should this go in the dotnet/csharplang repo? |
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. |
Perhaps new methods, like |
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 |
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?
The text was updated successfully, but these errors were encountered: