You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
I have a class which I want to exclude from coverage with the System.Diagnostics.ExcludeFromCodeCoverage attribute. So I place that attribute over my class and add -excludebyattribute:System.Diagnostics.ExcludeFromCodeCoverageAttribute to the OpenCover command line.
If my class is generating inner classes e.g. caused due to lambda expression (e.g. Task or Parallel.For) these are getting covered. Since I cannot place an attribute to a lambda expression I have to rewrite all the code to avoid using lambda expressions. Which is quite annoying.
Even better would be that OpenCover would support: Ignoring inner classes when exclusion attribute is placed on class
Sample code:
[ExcludeFromCodeCoverage]publicclassTest{publicvoidDoSomething(){InnerTestx=newInnerTest(10);inty=11;intz=12;vart=newTask(()=>{// This block is still getting coveredvartemp=Calc1(x.x,y);Calc2(z,temp);});t.Start();Parallel.For(1,10, i =>{// This block is still getting coveredCalc2(z,Calc1(i,12));});}privateintCalc1(intx,inty){returnx+y;}privateintCalc2(intz,inty){returnz+y;}// This type is still getting coveredprivateclassInnerTest{publicintx;publicInnerTest(intx){this.x=x;}}}
The text was updated successfully, but these errors were encountered:
Sam13
changed the title
Ignore by attribute should also ignore inner generated by lambda expressions
Ignore by attribute should also ignore inner classes generated by lambda expressions
Jul 24, 2015
Sam13
changed the title
Ignore by attribute should also ignore inner classes generated by lambda expressions
Ignore by attribute should also ignore inner / nested classes generated by lambda expressions
Jul 24, 2015
I use OpenCover 4.7.922 and collect coverage for class library based on NETFramework 4.5. My tests use NETFramework4.8.
I use my own SomeNamespace.SomeExcludeAttribute and I added it to opencover as -excludebyattribute:*.SomeExclude*. I use this attribute on methods only. Looks like all code in method is excluded, but not inner lambda functions. Can you help me in understanding what is wrong in my case?
I have a class which I want to exclude from coverage with the System.Diagnostics.ExcludeFromCodeCoverage attribute. So I place that attribute over my class and add -excludebyattribute:System.Diagnostics.ExcludeFromCodeCoverageAttribute to the OpenCover command line.
If my class is generating inner classes e.g. caused due to lambda expression (e.g. Task or Parallel.For) these are getting covered. Since I cannot place an attribute to a lambda expression I have to rewrite all the code to avoid using lambda expressions. Which is quite annoying.
Even better would be that OpenCover would support: Ignoring inner classes when exclusion attribute is placed on class
Sample code:
The text was updated successfully, but these errors were encountered: