-
Notifications
You must be signed in to change notification settings - Fork 331
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
Code coverage should exclude auto generated entrypoint #813
Comments
Might get fixed with #792 which will remove auto generated code from test projects. |
Adding all coverage impacting issues for 15.5. |
I just came across this today. I believe it's related to #519. Does marking it as an enhancement mean it's not going to be fixed (this is typically what enhancement means at my organization :P) |
CodeCoverage does not know that a certain code is autogenerated if it does not have "CompilerGenerated" Attribute on top of them. This is by design |
The code is autogenerated by the msbuild step in vstest/src/package/nuspec/Microsoft.NET.Test.Sdk.targets installed by the nuspec package so an attribute should either be added as part of the autogenerated file or the autogeneration should be removed. |
@peteri reopening this issue. I'll take further look to understand why we need code, or how can we add the attribute |
This issue added the comments so style cop ignores it, I suspect that it probably just needs the attribute adding. The other comments on the linked roslyn issue seem to suggest the autogenerated program.cs is still needed. |
It should have the GeneratedCodeAttribute attribute, not CompilerGeneratedAttribute though, right? Reference: https://blogs.msdn.microsoft.com/codeanalysis/2007/04/27/correct-usage-of-the-compilergeneratedattribute-and-the-generatedcodeattribute/ |
@samsmithnz , thanks for bringing it up. I agree it should be GenerateCodeAttribute, we plan to resolve this in next release to Test Platform., |
@mayankbansal018 Any further infos on that? |
@gingters I've raised required PR's for this issue. We are hoping to resolve this in 15.6 RTM |
@gingters, For VS IDE we missed the deadline for 2017 update 6, this will get fixed in update 7 |
fixed in latest Microsoft.Net.Test.SDK(15.8) VS 2017 |
I think msbuild (or whatever visual studio 2019 uses) does not add ExcludeFromCodeCoverage tag in auto generated csharp files. I was expecting to test project to build:
After reading that lasted updates fix the problem, I changed
to latest Test SDK:
and Tests.Program.cs is not being generated anymore at \obj\Debug\netcoreapp2.0 hence there is no code coverage metric being shown in Code Metrics Result. So it seems to be possible to exclude from code coverage the autogenerated (Program) files of test project, by updating the Test SDK. |
Description
Code coverage for .net core projects is including
AutoGeneratedProgram
in coverage metrics. It should be excluded.Steps to reproduce
Expected behavior
Coverage includes user code only.
Actual behavior
Environment
VS 2017 15.3 Preview 1
The text was updated successfully, but these errors were encountered: