Skip to content

VS 2022 Preview Roslyn crashes when using a non-existent attribute after if followed by else on a new line #78749

@NeroXc92

Description

@NeroXc92

Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version: 17.14.3 Preview 1.0

If you place square brackets with a non-existent attribute (e.g., [crash]) after an if statement without a valid expression, all Roslyn code analyzers crash and stop working.

Conditions required:

  • Use of { }
  • A non-existent attribute (e.g. [crash]) on a new line after if
  • Presence of else

Minimal code to reproduce:

{
    if (devsBad)
        // [crash]
    else return;
}

To trigger the issue, just uncomment the line // [crash] .
Once uncommented, many Roslyn analyzers will stop functioning.

Affected analyzers (full list):
analizers.txt

Screenshots:
Image
Image

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions