Skip to content

Roslyn shows false errors from missing source generated files after build #80717

@TessenR

Description

@TessenR

Version Used:

Microsoft Visual Studio Professional
Version 17.14.16
Version 17.14.16 Preview 1.0
Version: 18.0.0 Insiders [11104.47]

Steps to Reproduce:

  1. Open the attached solution SourceGeneratorTest.zip
  2. Open Program.cs in the editor
  3. Rebuild the solution

To reproduce again delete bin and obj folder from the Generator project folder before opening the solution.

Expected Behavior:
After rebuilding the project without errors, code analysis and the error list don't show any errors

Actual Behavior:
Roslyn shows the generator as not generating any files in solution explorer.
Roslyn shows errors caused by missing types provided by the source generator.

devenv_WgCisHf2ZK.mp4

Notes:

  • after a second build, or upon saving the file (even though there are no actual changes) Roslyn recognizes files from the source generator
  • it also recognizes it if you first rebuild the solution and then navigate to Program.cs

I believe that it is similar to #80714 - Roslyn doesn't queue an update after reloading an assembly with the source generator, causing it to wait indefinitely for some next event (such as new build request) that would trigger it.

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