Skip to content

Nullable reference types not detected properly on some nested types #24686

Closed

Description

In ValueConvertersEndToEndTestBase, one class has many nullable and non-nullable reference types--see below. Initially these were being discovered correctly, but as the class got bigger all the non-nullable reference types ceased to be annotated by the compiler (or at least we don't discover the annotation correctly) and all the types become nullable.

protected class ConvertingEntity
{
    public Guid Id { get; set; }

    public bool BoolAsString { get; set; }
    public bool BoolAsNullableString { get; set; }
    public bool? NullableBoolAsString { get; set; }
    public bool? NullableBoolAsNullableString { get; set; }

    public bool BoolAsChar { get; set; }
    public bool BoolAsNullableChar { get; set; }
    public bool? NullableBoolAsChar { get; set; }
    public bool? NullableBoolAsNullableChar { get; set; }

    public bool BoolAsInt { get; set; }
    public bool BoolAsNullableInt { get; set; }
    public bool? NullableBoolAsInt { get; set; }
    public bool? NullableBoolAsNullableInt { get; set; }

    public int IntAsLong { get; set; }
    public int IntAsNullableLong { get; set; }
    public int? NullableIntAsLong { get; set; }
    public int? NullableIntAsNullableLong { get; set; }

    public byte[] BytesAsString { get; set; } = null!;
    public byte[] BytesAsNullableString { get; set; } = null!;
    public byte[]? NullableBytesAsString { get; set; }
    public byte[]? NullableBytesAsNullableString { get; set; }

    public char CharAsString { get; set; }
    public char CharAsNullableString { get; set; }
    public char? NullableCharAsString { get; set; }
    public char? NullableCharAsNullableString { get; set; }

    public DateTimeOffset DateTimeOffsetToBinary { get; set; }
    public DateTimeOffset DateTimeOffsetToNullableBinary { get; set; }
    public DateTimeOffset? NullableDateTimeOffsetToBinary { get; set; }
    public DateTimeOffset? NullableDateTimeOffsetToNullableBinary { get; set; }

    public DateTimeOffset DateTimeOffsetToString { get; set; }
    public DateTimeOffset DateTimeOffsetToNullableString { get; set; }
    public DateTimeOffset? NullableDateTimeOffsetToString { get; set; }
    public DateTimeOffset? NullableDateTimeOffsetToNullableString { get; set; }

    public DateTime DateTimeToBinary { get; set; }
    public DateTime DateTimeToNullableBinary { get; set; }
    public DateTime? NullableDateTimeToBinary { get; set; }
    public DateTime? NullableDateTimeToNullableBinary { get; set; }

    public DateTime DateTimeToString { get; set; }
    public DateTime DateTimeToNullableString { get; set; }
    public DateTime? NullableDateTimeToString { get; set; }
    public DateTime? NullableDateTimeToNullableString { get; set; }

    public TheExperience EnumToString { get; set; }
    public TheExperience EnumToNullableString { get; set; }
    public TheExperience? NullableEnumToString { get; set; }
    public TheExperience? NullableEnumToNullableString { get; set; }

    public TheExperience EnumToNumber { get; set; }
    public TheExperience EnumToNullableNumber { get; set; }
    public TheExperience? NullableEnumToNumber { get; set; }
    public TheExperience? NullableEnumToNullableNumber { get; set; }

    public Guid GuidToString { get; set; }
    public Guid GuidToNullableString { get; set; }
    public Guid? NullableGuidToString { get; set; }
    public Guid? NullableGuidToNullableString { get; set; }

    public Guid GuidToBytes { get; set; }
    public Guid GuidToNullableBytes { get; set; }
    public Guid? NullableGuidToBytes { get; set; }
    public Guid? NullableGuidToNullableBytes { get; set; }

    public IPAddress IPAddressToString { get; set; } = null!;
    public IPAddress IPAddressToNullableString { get; set; } = null!;
    public IPAddress? NullableIPAddressToString { get; set; }
    public IPAddress? NullableIPAddressToNullableString { get; set; }

    public IPAddress IPAddressToBytes { get; set; } = null!;
    public IPAddress IPAddressToNullableBytes { get; set; } = null!;
    public IPAddress? NullableIPAddressToBytes { get; set; }
    public IPAddress? NullableIPAddressToNullableBytes { get; set; }

    public PhysicalAddress PhysicalAddressToString { get; set; } = null!;
    public PhysicalAddress PhysicalAddressToNullableString { get; set; } = null!;
    public PhysicalAddress? NullablePhysicalAddressToString { get; set; }
    public PhysicalAddress? NullablePhysicalAddressToNullableString { get; set; }

    public PhysicalAddress PhysicalAddressToBytes { get; set; } = null!;
    public PhysicalAddress PhysicalAddressToNullableBytes { get; set; } = null!;
    public PhysicalAddress? NullablePhysicalAddressToBytes { get; set; }
    public PhysicalAddress? NullablePhysicalAddressToNullableBytes { get; set; }

    public ulong NumberToString { get; set; }
    public ulong NumberToNullableString { get; set; }
    public ulong? NullableNumberToString { get; set; }
    public ulong? NullableNumberToNullableString { get; set; }

    public sbyte NumberToBytes { get; set; }
    public sbyte NumberToNullableBytes { get; set; }
    public sbyte? NullableNumberToBytes { get; set; }
    public sbyte? NullableNumberToNullableBytes { get; set; }

    public string StringToBool { get; set; } = null!;
    public string StringToNullableBool { get; set; } = null!;
    public string? NullableStringToBool { get; set; }
    public string? NullableStringToNullableBool { get; set; }

    public string StringToBytes { get; set; } = null!;
    public string StringToNullableBytes { get; set; } = null!;
    public string? NullableStringToBytes { get; set; }
    public string? NullableStringToNullableBytes { get; set; }

    public string StringToChar { get; set; } = null!;
    public string StringToNullableChar { get; set; } = null!;
    public string? NullableStringToChar { get; set; }
    public string? NullableStringToNullableChar { get; set; }

    public string StringToDateTime { get; set; } = null!;
    public string StringToNullableDateTime { get; set; } = null!;
    public string? NullableStringToDateTime { get; set; }
    public string? NullableStringToNullableDateTime { get; set; }

    public string StringToDateTimeOffset { get; set; } = null!;
    public string StringToNullableDateTimeOffset { get; set; } = null!;
    public string? NullableStringToDateTimeOffset { get; set; }
    public string? NullableStringToNullableDateTimeOffset { get; set; }

    public string StringToEnum { get; set; } = null!;
    public string StringToNullableEnum { get; set; } = null!;
    public string? NullableStringToEnum { get; set; }
    public string? NullableStringToNullableEnum { get; set; }

    public string StringToGuid { get; set; } = null!;
    public string StringToNullableGuid { get; set; } = null!;
    public string? NullableStringToGuid { get; set; }
    public string? NullableStringToNullableGuid { get; set; }

    public string StringToNumber { get; set; } = null!;
    public string StringToNullableNumber { get; set; } = null!;
    public string? NullableStringToNumber { get; set; }
    public string? NullableStringToNullableNumber { get; set; }

    public string StringToTimeSpan { get; set; } = null!;
    public string StringToNullableTimeSpan { get; set; } = null!;
    public string? NullableStringToTimeSpan { get; set; }
    public string? NullableStringToNullableTimeSpan { get; set; }

    public TimeSpan TimeSpanToTicks { get; set; }
    public TimeSpan TimeSpanToNullableTicks { get; set; }
    public TimeSpan? NullableTimeSpanToTicks { get; set; }
    public TimeSpan? NullableTimeSpanToNullableTicks { get; set; }

    public TimeSpan TimeSpanToString { get; set; }
    public TimeSpan TimeSpanToNullableString { get; set; }
    public TimeSpan? NullableTimeSpanToString { get; set; }
    public TimeSpan? NullableTimeSpanToNullableString { get; set; }

    public Uri UriToString { get; set; } = null!;
    public Uri UriToNullableString { get; set; } = null!;
    public Uri? NullableUriToString { get; set; }
    public Uri? NullableUriToNullableString { get; set; }

    public string? NullStringToNonNullString { get; set; }
    public string NonNullStringToNullString { get; set; } = null!;

    public int NonNullIntToNullString { get; set; }
    public int NonNullIntToNonNullString { get; set; }
    public int? NullIntToNullString { get; set; }
    public int? NullIntToNonNullString { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

area-model-buildingclosed-fixedThe issue has been fixed and is/will be included in the release indicated by the issue milestone.type-bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions