jeudi 1 août 2019

NullableAttribute not added to Property Info with Nullable reference types

I have a C# 8 class (in .NET Core 3 preview 7):

#nullable enable
        class TypeWithNullableRefs
        {
            public string NonNullableString { get; } = "";

            public string? NullableString { get; }
        }
#nullable restore

I'm trying to detect the nullability via the NullableAttribute attribute that is added via the new feature of nullable reference types.

When I debug the PropertyInfo of the first NonNullableString field I get no attributes:

enter image description here

Why isn't there any NullableAttribute?


A reproducible project can be found by following these steps.





Aucun commentaire:

Enregistrer un commentaire