dotnet/roslyn-sdk

Source generator silently fails but test result says generated output doesn't match

Arthri opened this issue · 1 comments

XUnit. When a source generator runs into an uncaught exception and Roslyn excludes its output from compilation, a diagnostic is raised, but test results check generated outputs before diagnostics so failing source generator will produce this message:

Expected source file list to match
-Sougen\Sougen.ExceptionGenerator\Soup.cs
-Sougen\Sougen.ExceptionGenerator\CarrotSoup.cs
-Sougen\Sougen.ExceptionGenerator\TomatoSoup.cs
-Sougen\Sougen.ExceptionGenerator\PotatoSoup.cs
-Sougen\Sougen.ExceptionGenerator\CelerySoup.cs
-Sougen\Sougen.ExceptionGenerator\GarlicSoup.cs
-Sougen\Sougen.ExceptionGenerator\LentilSoup.cs
+
+
+
+
+
+
+

I suggest that the test result somehow indicate the source generator failed so the cause of the message is more obvious.

A repo containing the repro is available here https://github.com/Arthri/dm01 . The test class is ExceptionGeneratorTests

💡 When this occurs, you can also set TestBehaviors.SkipGeneratedSourcesCheck and it will ignore the content of the generated files and move on to diagnostics validation.