Skip to content

Fix S8969 FP: assignment from nullable out parameter #9824

Description

@akurone

Description

hi,
S8969 reports false positive when value comes from a nullable out parameter. (VS 2026 18.8.1, .net SDK 10.0.302)

Reproducer

//think of something like try get from a dictionary
static bool SomeMtd([NotNullWhen(true)] out object? x)
{
  x = new();
 return true;
}
//...
object x = null!;
if(!SomeMtd(out x!))
return;
//...

omitting the ! in out parameter triggers CS8601:

//...
if(!SomeMtd(out x)) //CS8601
//...

not %100 sure but CS8601 seems right to be conservative here: non-nullable x might come back as null from that method.

Product and Version

10.30.0.144632

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