Closed HavenDV closed 2 years ago
This would also add compatibility with https://github.com/VerifyTests/Verify.SourceGenerators, which is much more convenient in terms of validating Snapshot tests, but not convenient in setting state, especially when it comes to managing references
I believe the WRITE_EXPECTED
directive here achieves the desired outcome:
https://github.com/microsoft/vs-extension-testing/blob/main/src/Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator.UnitTests/Verifiers/CSharpSourceGeneratorVerifier%601%2BTest.cs
This is useful for cases where the project uses
TestBehaviors.SkipGeneratedSourcesCheck
and it is not possible to useTestState.GeneratedSources
due to frequent generator changes. But programmatic access in such cases allows you to handle the erroneous case and, for example, display erroneous GeneratedTrees as temporary files with correct code highlighting, and not in tests. I think this requires access to the GeneratorDriver obtained after calling RunGenerators.