Skip to content

[Regression] IDE0031: False positive on .NET 11 Preview1 #82482

@bkoelman

Description

@bkoelman

Version Used:
.NET 11 Preview 1 with VS Insiders 2026 [11513.90]

This is a regression. The problem does not occur using stable .NET 10 and stable VS 2026.

Steps to Reproduce:
A suggestion is offered to convert:

if (_session != null)
{
    _session.Disposed -= SessionOnDisposed;
    _session = null;
}

to:

_session?.Disposed -= SessionOnDisposed;
_session = null;

Diagnostic Id:
IDE0031: Null check can be simplified

Expected Behavior:
No suggestion to change the existing code.

Actual Behavior:
A suggestion is offered. We've increased the severity to Warning in Release builds. Combined with warnaserror, this breaks the build.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions