ExcludeFromCodeCoverage.Fody 1.1.1

Fody add-in to decorate public members with ExcludeFromCodeCoverage attribute based on definition (esp. for generated classes e.g. by xsd.exe or other tools where it is not possible to influence the output)

There is a newer version of this package available.
See the version list below for details.

Requires NuGet 2.8 or higher.

Install-Package ExcludeFromCodeCoverage.Fody -Version 1.1.1
dotnet add package ExcludeFromCodeCoverage.Fody --version 1.1.1
<PackageReference Include="ExcludeFromCodeCoverage.Fody" Version="1.1.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExcludeFromCodeCoverage.Fody --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ExcludeFromCodeCoverage.Fody

Fody extension to decorate public members of specific types with ExcludeFromCodeCoverageAttribute by using AOP

Usage

Just add assembly scoped attribute into solution e.g. like:


//Exclude all public members of all types in specific namespace
[assembly: AttachExcludeFromCodeCoverage("namespace")]

//Exclude all public members of all types in specific namespace and all subordinate namespaces
[assembly: AttachExcludeFromCodeCoverage("namespace.*")]

//Exclude all public members of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass))]

//Exclude specific members of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass), "Property")]

//Exclude members begining with 'Property' of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass), "Property.*")]

//Exclude all public members of specific type in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "SomeClass")]

//Exclude all public members of mathching types in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "Some.*")]

//Exclude specific members of specific types in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "Some.*", "Prop.*")]

For string parameters you can use regex syntax
Simple options are:

".*SomeValue" - suffixed by 
"SomeValue.*" - prefixed by

What it does

It's quite easy...
Fody is an weaving tool which is one of the Aspect Oriented Techniques (AOP).
Once the code is compliled Fody is taking it and modyfying it's IL code again.

This plugin is just taking AttachExcludeFromCodeCoverage attribute and is searching for all types matching the definition.
All public members (methods, properties) of matching types are decorated with [ExcludeFromCodeCoverage] attribute.
AttachExcludeFromCodeCoverage attribute itself is removed.

After this postcompilation intervention all decorated members are excluded from code coverage.
This is highly beneficial for code that is generated by some generation tool where the developer does not have ability to influence the way how the code is generated

Why public members and not whole types?

Reason is simple...
You can use partial classes and have your own logic in separate classes, so it is better to decorate individual members so that you have flexibility and have your custom code being included into code coverage analysis

ExcludeFromCodeCoverage.Fody

Fody extension to decorate public members of specific types with ExcludeFromCodeCoverageAttribute by using AOP

Usage

Just add assembly scoped attribute into solution e.g. like:


//Exclude all public members of all types in specific namespace
[assembly: AttachExcludeFromCodeCoverage("namespace")]

//Exclude all public members of all types in specific namespace and all subordinate namespaces
[assembly: AttachExcludeFromCodeCoverage("namespace.*")]

//Exclude all public members of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass))]

//Exclude specific members of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass), "Property")]

//Exclude members begining with 'Property' of specific type
[assembly: AttachExcludeFromCodeCoverage(typeof(SomeClass), "Property.*")]

//Exclude all public members of specific type in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "SomeClass")]

//Exclude all public members of mathching types in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "Some.*")]

//Exclude specific members of specific types in namespace
[assembly: AttachExcludeFromCodeCoverage("ExcludeFromCodeCoverage.Tests", "Some.*", "Prop.*")]

For string parameters you can use regex syntax
Simple options are:

".*SomeValue" - suffixed by 
"SomeValue.*" - prefixed by

What it does

It's quite easy...
Fody is an weaving tool which is one of the Aspect Oriented Techniques (AOP).
Once the code is compliled Fody is taking it and modyfying it's IL code again.

This plugin is just taking AttachExcludeFromCodeCoverage attribute and is searching for all types matching the definition.
All public members (methods, properties) of matching types are decorated with [ExcludeFromCodeCoverage] attribute.
AttachExcludeFromCodeCoverage attribute itself is removed.

After this postcompilation intervention all decorated members are excluded from code coverage.
This is highly beneficial for code that is generated by some generation tool where the developer does not have ability to influence the way how the code is generated

Why public members and not whole types?

Reason is simple...
You can use partial classes and have your own logic in separate classes, so it is better to decorate individual members so that you have flexibility and have your custom code being included into code coverage analysis

Release Notes

1.1.0 - improvements, correct .net versioning, documentation
     1.1.1 - dependency issue

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.2 6,113 9/29/2017
1.1.1 251 9/29/2017