Skip to content

Coalesce expressions do not allow throw expressions on the right hand side #36467

@sharwell

Description

@sharwell

Version Used: 16.2 Preview 2

Steps to Reproduce:

diagnosticId = diagnosticId ?? throw new ArgumentNullException(nameof(diagnosticId));

Expected Behavior:

No suggestion is made to use ??= shorthand.

Actual Behavior:

A diagnostic appears, and the code fix changes the statement to the following invalid code:

diagnosticId ??= throw new ArgumentNullException(nameof(diagnosticId));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions