-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnalyzerTesting: Make the generated syntax trees of source generators available #1074
Comments
…source generators available
…source generators available
…source generators available
…source generators available
I believe microsoft/vs-extension-testing offers what you are looking for: |
Yes, you already can do many things if you dig into the details and rewrite the test framework, but it's very annoying that you need to do this again and again for every test - see #1080 |
That example mimics the very basic approach, but not with the full power and comfort of VerifyTests Also this sample rewrites a big part of the test, and of course depends on the test verifier, so it has to be rewritten for every verifier. I already know how to do it with a custom written test, I was looking for a solution that runs out of the box, with the default test framework. |
This is similar to #1087, in that I'm not planning to directly implement it in the short term, but hopefully the future API to test the incrementality of source generators will allow for more direct validation of syntax trees produced by the source generators. |
Actually as mentioned in the already closed PR #1075 I have a good enough solution here: https://github.com/tom-englert/RoslynAnalyzerTesting.CSharp.Extensions/blob/master/source/AnalyzerTesting.CSharp.Extensions/CSharpIncrementalGeneratorSnapshotTest.cs |
The current approach to test source generators by providing the expected generated code upfront is not very convenient, since the generated sources can be very large, making the test unreadable.
It would be great to support another scenario, where the analyzer test is run with
TestBehaviors.SkipGeneratedSourcesCheck
, and then the generated sources can be fetched and verified with custom logic, e.g. using https://github.com/VerifyTests/ like in this sample https://github.com/Fody/PropertyChanged/blob/dee9d81bab0202dc2e5d985910072ad6e6c94fa4/PropertyChanged.Fody.Analyzer.Tests/CodeGeneratorTest.cs#L55-L71The text was updated successfully, but these errors were encountered: