Skip to content

Intellisense, Syntax highlight and Error Window are badly broken with incremental source generator in Visual Studio 17.0.4 #58523

@dotfede

Description

@dotfede

Version Used:

Visual Studio 2022 17.0.4
Microsoft.CodeAnalysis.Analyzers 3.3.3
Microsoft.CodeAnalysis.CSharp.Workspaces 4.0.1

Steps to Reproduce:

  1. Clone the repro project
  2. Open SourceGenerator.IntellisenseBug.Demo.sln in Visual Studio 2022 17.0.4
  3. Build the solution
  4. Observe the following behavior:

IntellisenseBugDemo

Expected Behavior:

  • Intellisense and syntax highlight should continue to work with source-generated code.
  • Visual Studio should not report errors in the Errors Window when the build actually succeeds, as per the Output Window.
  • List of generated files should be shown in solution explorer under Analyzers -> SourceGen.IntellisenseBug.Demo instead of "this generator is not generating any files." message.

Actual Behavior:

  • Everything works fine up until variable c11 is declared.
  • Intellisense and syntax highlight is broken when c11 is declared, and never recover afterwards.
  • Visual Studio reports errors in the Errors Window, but the build successfully passes
  • Solution Explorer shows "this generator is not generating files." message instead of properly showing the generated file.

More details:

The source generator creates a single file with several empty C# classes named Class1, Class2, Class3 and so forth, depending on the number of classes declared in the consuming project in the first variable declaration:

  • var classes = 5; means there will be Class1 to Class5
  • var classes = 10; means there will be Class1 to Class10
  • and so on.

Using <ProjectReference/> and <PackageReference/> to consume the source generator, in both cases the behavior is the same.

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions