Skip to content

Deconstruction nullability warnings should be clearer #35349

@chsienki

Description

@chsienki

See Deconstruction_ExtensionMethod_03 in NullableReferenceTypesTests.cs

We report warning CS8604: Possible null reference argument for parameter 'p' in 'void E.Deconstruct<object, object>(Pair<object, object> p, out object t, out object u)' for a deconstruction with a nullable this parameter.

See Deconstruction_20 in NullableReferenceTypesTests.cs

We report warning CS8602: Dereference of a possibly null reference. for the deconstruction of a possible null value.

See Deconstruction_29 in NullableReferenceTypesTests.cs

We report warning CS8602: Dereference of a possibly null reference. for the deconstruction of the an inner value.

While these are all technically correct, they are quite confusing, and don't really help to identify the problem immediately. For consistency of the multiple cases and ease of understanding we should add a specific warning for deconstruction that makes it clear why it would result in a null reference exception.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions