You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullabilityInfoContext returns incorrect result for some unannotated private members #63847
NullabilityInfoContext contains code which aborts analysis when the module indicates that nullability annotations have been omitted for private/internal members.
While it makes sense to consider this information, it ignores a few edge-cases that are otherwise respected by the class:
Value type nullability can still be determined without nullable annotations
Code analysis attributes (e. g. DisallowNull) may still be present that could be used to determine nullability without compiler-generated nullable annotations.
Reproduction Steps
publicvoidMain(){varcontext=newNullabilityInfoContext();vardirectoryInfo=context.Create(typeof(FileSystemEntry).GetProperty("Directory")!);Console.WriteLine(directoryInfo.ReadState);// NotNull as expected (property is ReadOnlySpan<char>)Console.WriteLine(directoryInfo.WriteState);// Unknown (should be NotNull because property is a non-nullable value type)}
Expected behavior
The write state should be NotNull because the property is a non-nullable value type.
Actual behavior
The write state is unknown because the setter is private and private annotations are not available.
Regression?
No response
Known Workarounds
No response
Configuration
VS 17.0.2, .NET 6, Windows 10 x64.
I don't have any reason to believe this is configuration specific.
Activity
Fix several bugs in NullabilityInfoContext.