AllowNullAttribute not working #37024
Labels
Area-Compilers
Area-Language Design
Feature - Nullable Reference Types
Nullable Reference Types
Resolution-By Design
The behavior reported in the issue matches the current design
Milestone
Similar to #36986
I'm converting Newtonsoft.Json to use nullable types and I can't get
AllowNullAttribute
to work. My remaining warnings are related to generic types.Note that I have many old targets so I'm using internal nullable attributes (located in NullableAttributes.cs).
NotNullAttribute
andNotNullWhenAttribute
work fine, but I can't getAllowNullAttribute
to work. I've tried it inSystem.Runtime.CompilerServices
andSystem.Diagnostics.CodeAnalysis
namespaces with no result.Version Used: VS2019 + Microsoft.Net.Compilers.Toolset=3.2.0-beta3-final
Steps to Reproduce:
JsonConverter<T>.WriteJson
method (JsonConverter.cs, line 97)Expected Behavior:
There should not be a nullable warning because [AllowNull] is on the parameter type.
Actual Behavior:
There is a warning casting
object?
toT
.The text was updated successfully, but these errors were encountered: