-
Notifications
You must be signed in to change notification settings - Fork 35
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
BUG: An instance of analyzer ... cannot be created for linked source files #701
Comments
Thanks! I uploaded your repro here: https://github.com/nunit/nunit.issues/tree/main/Analyzer/IssueAnalyzer701 When I run the repro "as is", which corresponds afaic see with your next to last row, it should fail. But it doesn't. Given that I have understood you correctly, it "works on my machine". What I have seen in some cases is that the Visual Studio cache under the |
Thank you for the fast reply. Your response makes me wonder if it is files left behind if not properly cleaned? Regardless of the fault, all test cases pass on my machine as in your sample, both in Visual Studio and on the console with So after getting the failure, I close VS2022, manually delete all
|
Yes, that makes sense. But this is a VS error. I don't think we can do anything about it. PS: If it is enough to delete bin and obj, a Build Clean should also work. PS2: I don't get the CS8032. |
Thanks @OsirisTerje. After lots of testing, adding more configurations, double checking clean (using git, seems more reliable than a clean build), the problem doesn't occur, except when:
CS8032 is the error code that VS is giving, as per the screenshot I posted. Something similar posted at dotnet/roslyn-analyzers#6395 I agree, that the problem seems to do with transitory files. I'll close this task. Thanks for testing on your side, else I'll never had the idea that it was some junk on the filesystem. |
Also note that we have had the issue that the dlls in the nuget packages didn't have any version numbers - this was fixed in #508 - but I fear that this could make the problem worse (but this is more a guess than actually knowledge) |
If I have a solution file, that has three projects nunitanalyzertest.zip:
I get an error such as:
And the following exception appears
Also occurs for the three frameworks that I use (net462, net6.0, net8.0)
Compatibility tests:
Please find attached the simplest project I can create. I tested it with Visual Studio 19.2 (latest available).
Workaround
I think the issue arises from the line in RJCP.NUnitAnalyzerTestSample.Test2.csproj
If I copy the file and change this to:
it appears to work as expected. So likely the issue is related to linked files outside of the project tree.
My use case to do this is to test the same code under different environments dependent on the .csproj file. I can't merge them to a single .csproj file, they have to be separate and link the source code.
The text was updated successfully, but these errors were encountered: