Skip to content
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

Allow "SkipGeneratedSourcesCheck" for specific generator when a test is using multiple generators #1087

Open
Youssef1313 opened this issue Apr 19, 2023 · 5 comments
Labels
Area-MS.CA.Testing Microsoft.CodeAnalysis.Testing feature-request This issue tracks implementing a new feature

Comments

@Youssef1313
Copy link
Member

I have a case where I'm testing two generators in the same test, but I only want to verify the generated sources for one of them.

Currently, there is no way to do so.

@Youssef1313
Copy link
Member Author

@sharwell Is this a reasonable request? If you can suggest an API shape, I can try to implement this.

@sharwell
Copy link
Member

Can you provide more information about why it doesn't work to just validate both?

@sharwell
Copy link
Member

Eventually, the incremental testing features should allow selecting and validating the outputs from a specific generator. Those APIs haven't been designed yet though.

@Youssef1313
Copy link
Member Author

Youssef1313 commented Apr 20, 2023

@sharwell Scenario:

  • Uno Platform generates C# from XAML via a source generator.
  • CommunityToolkit.Mvvm helps implementing Mvvm pattern and generates observable property by their own source generators.

If I try to use a property generated by Mvvm in XAML file (e.g, in x:Bind), the XAML source generator can't see that info and fails to generate.

I'm working around that by unoplatform/uno#11854. The trick is that I'm adding code to anticipate what will be generated instead of failing. https://github.com/unoplatform/uno/blob/284f2a4401b0efe75ac0ccb0ba31093de7821ba8/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/ThirdPartyGenerators/CommunityToolkitMvvm/MvvmTypeProvider.cs

In tests, I'm referencing both Uno's XAML generator and CommunityToolkit.Mvvm's observable property generator. But it doesn't make sense to test the actual output from CommunityToolkit.Mvvm:

  1. It's not code I care about as long as it compiles properly.
  2. I don't want to have to update the expected output when I update the package version.
  3. It needed unnecessary tweak to CSGenerator that you suggested for some who asked. unoplatform/uno@284f2a4

@sharwell
Copy link
Member

I don't have any immediate plans to implement this, but I'll keep the use case in mind when we're building the new API to test incrementality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-MS.CA.Testing Microsoft.CodeAnalysis.Testing feature-request This issue tracks implementing a new feature
Projects
None yet
Development

No branches or pull requests

2 participants