-
Notifications
You must be signed in to change notification settings - Fork 261
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
GenerateTestingPlatformEntryPoint has no effect on class library project #4259
Comments
That looks like VSTest. Could you try |
@Youssef1313 is right, you haven't opt-in the new testing platform so @drieseng Just to confirm, are you seeing the |
It the analyzer's fault I think. This would be a duplicate of dotnet/roslyn-analyzers#7192 |
@Youssef1313, setting the GenerateProgramFile MSBuild property only makes things worse. CS5001: Program does not contain a static 'Main' method suitable for an entry point I've updated my test repo accordingly. @Evangelink, I'm indeed seeing that. I've updated my test repo to enable the analyzers. If you remove the CA1515 could indeed be updated to ignore test classes, but if the AutoGeneratedProgram was not emitted then CA1515 would not have to be modified for my case. |
Yes, it's actually an analyzer's fault IMO, as I mentioned in the previous comment. Sorry for confusing you. I don't see an issue on our side. We could implement a suppressor for the analyzer if really necessary, but I'm viewing this more to be an analyzer bug. My personal opinion is to go for |
Note that I think the current behavior regarding generating an entry point has been like this for so long. This code has been there for at least 6 years |
@Youssef1313, why don't you consider it an issue that the AutoGeneratedProgram class is emitted even if GenerateTestingPlatformEntryPoint is set to false? That class looks like this: using System;
[Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode]
class AutoGeneratedProgram {static void Main(string[] args){}} Who is responsible for emitting this class, and how can I disable this? |
Because AutoGeneratedProgram is unrelated to GenerateTestingPlatformEntryPoint.
The way to disable AutoGeneratedProgram in VSTest is |
@Youssef1313, thanks for the clear feedback. One more question: how does one opt into Microsoft.Testing.Platform? |
See MSTest Runner overview for instructions. However, you will still be building as executable so it won't fix anything for CA1515, but it's good to migrate for other reasons, including performance. |
@drieseng I'm curious though, as the analyzer is disabled by default. Do you have something like |
@Youssef1313, indeed. |
Describe the bug
We currently do not use Microsoft.Testing.Platform, and as such our test projects are defined as class library instead of executable.
Since we've upgraded to the .NET 9.0 SDK, CA1515 is reported for our test classes. The root cause of this is that an AutoGeneratedProgram class is generated automatically which causes CA1515 to believe it's dealing with an executable/application.
We tried to instruct MSTest (or the Microsoft.Testing.Platform¨) not to emit this class by setting the GenerateTestingPlatformEntryPoint MSBuild property to false, but this has no effect at all.
Steps To Reproduce
Expected behavior
There's no AutoGeneratedProgram class.
Actual behavior
There's a AutoGeneratedProgram class.
The text was updated successfully, but these errors were encountered: