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 reports incorrect result when mixing AllowNull and DisallowNull #63846
The result does not match how the compiler interprets the attributes. See the reproduction.
Reproduction Steps
publicvoidMain(){varcontext=newNullabilityInfoContext();varhasAllowAndDisallowInfo=context.Create(typeof(HasMultipleCodeAnalysisAttributes).GetField("HasAllowAndDisallow")!);Console.WriteLine(hasAllowAndDisallowInfo.ReadState);// NotNull as expectedConsole.WriteLine(hasAllowAndDisallowInfo.WriteState);// Nullable; should be NotNull}privateclassHasMultipleCodeAnalysisAttributes{[AllowNull,DisallowNull]publicstringHasAllowAndDisallow=string.Empty;}
Expected behavior
We should expect a NotNull write state because this is how the C# compiler interprets it:
Activity
Fix several bugs in NullabilityInfoContext.