Relative Content

Tag Archive for c#nullable

Dereferencing a nullable type

I’ve written a function that parses some arguments into a valid “thing”. If the arguments can’t be parsed into a valid thing, then this function will return a null.

Dereferencing a nullable type

I’ve written a function that parses some arguments into a valid “thing”. If the arguments can’t be parsed into a valid thing, then this function will return a null.

Dereferencing a nullable type

I’ve written a function that parses some arguments into a valid “thing”. If the arguments can’t be parsed into a valid thing, then this function will return a null.

C# nullability analysis – inconsistent tooltip

I’ve found a strange inconsistency between the nullability of a variable in the hover-over tooltip in Visual Studio / sharplab.io and the compiler’s handling of the variable re nullability.

Possible error in C# compiler warning output for nullability checking

Type type = typeof(Program); type = type.BaseType; // [CS8600] Converting null literal or possible null value to non-nullable type. do { type = type.BaseType; // [CS8602] Dereference of a possibly null reference. + [CS8600] Converting null literal or possible null value to non-nullable type. } while(true); In the program above I would expect the same […]

Possible error in C# compiler warning output for nullability checking

Type type = typeof(Program); type = type.BaseType; // [CS8600] Converting null literal or possible null value to non-nullable type. do { type = type.BaseType; // [CS8602] Dereference of a possibly null reference. + [CS8600] Converting null literal or possible null value to non-nullable type. } while(true); In the program above I would expect the same […]

Why C# null-state analysis fails for member access?

In the below code, why does the compiler null-state analysis fails to deduce that Age is not null and warning is produced? Even though the “if” explicitly verifies that. What would be the recommended way to resolve this warning here?

Nullable Generic Typing

I’m getting some unexpected results when using the nullable reference types feature with generics.