-
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
[Question] How to pass AnalyzerConfigOptions when unit testing #736
Comments
@jmarolf Does the testing library work for source generators? I thought it didn't. |
It wasn't correct, but I just added support in #734.
@Youssef1313 Yes, you can use Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit (or equivalent for other language/frameworks). |
This is great! May you update the README for usage examples? |
Filed #737 to add the packages to the list, but haven't added examples yet |
When working on a component of a SourceGenerator, I was writing unit tests to check for diagnostics getting raised on the compilation context created by a source code string. We have a downstream check that checks a compilation's AnalyzerConfigOptions for a specified assembly name. When you create a compilation context in a unit test, there's no project file to specify a property AssemblyName, so this check returns null and causes issues.
Here is where I do this and would like to pass some kind of
optionsProvider
containing a mapping for "AssemblyName" to something like "TestNamespace", and any other properties we might need.Please advise on how I would be able to do this. Let me know if you need more information.
I'm using these packages:
Microsoft.CodeAnalysis.CSharp.Workspaces, Version="3.8.0-4.20472.6"
Microsoft.CodeAnalysis.Analyzers, Version="3.3.0"
The text was updated successfully, but these errors were encountered: