Is null-state static analysis half-done? #4964
Replies: 4 comments 35 replies
-
I'm not sure what this means tbh. Nullable value types definitely have a null value. That's the reason they're called 'nullable' :-) |
Beta Was this translation helpful? Give feedback.
-
I know of no such preference in .net. The preference is to use 'default' for things that may not be null (for example value types, or unconstrained generics). Did things that can be null, 'null' is perfectly fine to use |
Beta Was this translation helpful? Give feedback.
-
I genuinely cannot find where on the net this quoted statement comes from. However, I firmly disagree with it. |
Beta Was this translation helpful? Give feedback.
-
In other words, when the arg is static void NotNull_NullableAnnotated([NotNull] string? s)
{
if (s is null) throw new Exception();
} // no CS8777 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was grubbing among such said null-state static analysis, for instance Attributes for null-state static analysis and I can tell some acumens so far:
nullable
value types
which do not havenull
value butdefault
value?null
keyword when in .NET environment is preferable to usedefault
whenever possible. This goes even for case if attributes worked just withreference type
(and they do not).nullable-annotation
ofreference type
is part of method signature.nullable
value types
magically can havenull
value.6. Some cases enforce annotation contract just fine. For instance
by ref
.…
Beta Was this translation helpful? Give feedback.
All reactions