Skip to content

IDE0058 and null propagation - Inconsistent, request fix. #80766

@333fred

Description

@333fred

Discussed in #80765

Originally posted by UniqeId6542 October 16, 2025

class Data { public bool Value { get; set; } }

void Foo(Data? data)
{
    data!.Value = true; // OK
    bool b1 = data!.Value = true; // OK
    _ = data!.Value = true; // OK
    data?.Value = true; // IDE0058
    bool? b2 = data?.Value = true; // OK
    _ = data?.Value = true; // OK
}

For null conditional assignments, I'd like it to NOT produce IDE0058 - the same as normal assignments.

I have IDE0058 set to make a warning so as to avoid missed data from method returns. But I don't want to have to "handle" the data from a null conditional assignment. And, I notice that normal assignments don't produce this message even though they also have a form of data return from the expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions