-
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
Debugging a Source Generator when added to an xUnit testing project does not work #972
Comments
I tried adding the generated files to the source control as explained here, by adding the following lines to the xUnit project .csproj file:
And the folder and files are not being generated. So I guess the issue is not really debugging, but a lack of support for xUnit? I am trying to make this work in this repo, maybe it helps identifying the issue: There, the project ExampleApplicationWithConsole.Tests is not a xUnit project, is just a regular Console Application with ".Tests" suffix in the name. When building it, the Generated folder with the generated files appear. In contrast, in the project ExampleApplicationWithxUnit.Tests which is actually a xUnit project, building it does not generate the folder and files. |
I've never noticed a problem debugging via the following steps:
In reviewing the steps by @JoanComasFdz above, I notice the following differences:
|
Thanks for the feedback @sharwell. Just to make sure we are talking about the same thing:
I mention this because of your sentences "add a source generator test to the project" and "debug the test via Test Explorer". Does the setup you propose allow to debug a source generator referenced in a xUnit project? |
Yes, but debugging that source generator would involve creating a second test project specifically for testing (and not using) that source generator. |
Version Used: VS2022 17.1.0, xUnit project in .NET6, SourceGenerator project in NetStandard2.0
Steps to Reproduce:
Debug
line.Expected Behavior: Once the Console App is launched, the breakpoints are hit and the Source Generator project can be debugged.
Actual Behavior: The Console App is launched and closed. No breakpoint is hit. Debugging the unit tests does not hit the breakpoint either
Notes:
Yes, I have the SDK installed and can debug Source Generators for a Console App and a Blazor App with no issues.
Also I tried:
Program
class with astatic void Main(string[] args)
method and setting it as Startup object in the xUnit project. Does not work.My end goal is to be able to add a source generator to a xUnit project that references another project (the project under test), and be able to analyze the types of the referenced project and create some extra classes.
The text was updated successfully, but these errors were encountered: