Nullable annotation at the file level/deliberate mis-annotating functions #8170
-
I had previously wondered at why there's no string ValueOrDefault(string key, Func<string> default); It really wants to be string? ValueOrDefault(string key, Func<string?> default);
string ValueOrDefault(string key, Func<string?> default); but that's impossible. The next best idea I had was:
That is, deliberately mis-annotating it so we don't have to deal with the fact it can't be declared; but then its own implementation can't be I've made this as a discussion item because these are rather brute force ideas and there's probably something better out there. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
#nullable enable annotations
- https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#nullable-context