OpenCover / opencover

A code coverage tool for .NET 2 and above (WINDOWS OS only), support for 32 and 64 processes with both branch and sequence points
https://blog.many-monkeys.com
Other
1.31k stars 247 forks source link

Filter question #73

Closed BradStiles closed 12 years ago

BradStiles commented 12 years ago

I just downloaded and installed version 3.0.121, and I have a question about filters. From reading the usage document, if I have a filter "-[Base.NameSpace.SubNameSpace]TypeName", then a type named Base.NameSpace.SubNameSpace.TypeName should be excluded from coverage, correct? However, it still shows up in the resultant XML looking like this:

<FullName>Base.NameSpace.SubNameSpace.TypeName</FullName> <Methods> <Method visited="false" cyclomaticComplexity="0" sequenceCoverage="0" branchCoverage="0" isConstructor="true" isStatic="false" isGetter="false" isSetter="false"> <MetadataToken>100663311</MetadataToken> <Name>System.Void Base.NameSpace.SubNameSpace.TypeName::.ctor(System.Object,System.IntPtr)</Name> <SequencePoints /> <BranchPoints /> <MethodPoint vc="0" uspid="57" ordinal="0" offset="0" /> </Method> <Method visited="false" cyclomaticComplexity="0" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> <MetadataToken>100663312</MetadataToken> <Name>System.Void Base.NameSpace.SubNameSpace.TypeName::Invoke(System.String)</Name> <SequencePoints /> <BranchPoints /> <MethodPoint vc="0" uspid="58" ordinal="0" offset="0" /> </Method> <Method visited="false" cyclomaticComplexity="0" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> <MetadataToken>100663313</MetadataToken> <Name>System.IAsyncResult Base.NameSpace.SubNameSpace.TypeName::BeginInvoke(System.String,System.AsyncCallback,System.Object)</Name> <SequencePoints /> <BranchPoints /> <MethodPoint vc="0" uspid="59" ordinal="0" offset="0" /> </Method> <Method visited="false" cyclomaticComplexity="0" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> <MetadataToken>100663314</MetadataToken> <Name>System.Void Base.NameSpace.SubNameSpace.TypeName::EndInvoke(System.IAsyncResult)</Name> <SequencePoints /> <BranchPoints /> <MethodPoint vc="0" uspid="60" ordinal="0" offset="0" /> </Method> </Methods> </Class>

The source file for the piece I want excluded is named "Delegates.cs", and contains only the following:

namespace Base.NameSpace.SubNameSpace { public delegate void TypeName(string message); }

The source file is located in the "Base.NameSpace.SubNameSpace" directory in the file system, and the assembly that it's in is named Base.NameSpace.SubNameSpace.dll.

If you can tell me what I'm doing wrong here, I'd appreciate it.

sawilde commented 12 years ago

the filter is [module/assembly-filter]namespace/type-filter this to include your assembly and all types I would

+[Base.NameSpace.SubNameSpace]*

or for a specific type, perhaps

+[Base.NameSpace.SubNameSpace]*TypeName

or even

+[Base.NameSpace.SubNameSpace]Base.NameSpace.SubNameSpace.TypeName

you'll have to experiment with what works best for you and your project.

The issue comes as most people tend to create a module with the name that just happens to be their root namespace, just no requirement to do so, and then intermix the two

BradStiles commented 12 years ago

Thanks for the pointers. FWIW, both of your examples that supplied the TypeName, in whole or in part, worked.

   -[Base.NameSpace.SubNameSpace]*TypeName    -[Base.NameSpace.SubNameSpace]Base.NameSpace.SubNameSpace.TypeName

I just have to remember that it requires the complete type name, and not just the end name. :)

Thanks again.

sawilde commented 12 years ago

and also the [XXX] is actually the module name

BradStiles commented 12 years ago

"Module Name" == "Assembly Name"?

sawilde commented 12 years ago

Usually yes, I use tools like ILSpy to see if that is the case if my filters aren't working based on that assumption. Very rare for VS based projects

BradStiles reply@reply.github.com wrote:

"Module Name" == "Assembly Name"?


Reply to this email directly or view it on GitHub: https://github.com/sawilde/opencover/issues/73#issuecomment-4471871