Content-Length: 262213 | pFad | http://github.com/coverlet-coverage/coverlet/issues/1727

2E [BUG] Constructorless ControllerBase implementations produce no code coverage · Issue #1727 · coverlet-coverage/coverlet · GitHub
Skip to content

[BUG] Constructorless ControllerBase implementations produce no code coverage #1727

Open
@chrish619

Description

@chrish619

Describe the bug
When producing code coverage for a WebApi/MVC project, if a Controller has no explicit constructor, it may not produce any code coverage results for the entire file.

These Controllers/Classes seem to be affected by the ExcludeByAttribute=CompilerGeneratedAttribute switch - as removing this option produces code coverage for these files.

To Reproduce
Sample Repository: https://github.com/chrish619/coverlet-coverage-issue-20250103/

Controller must inherit from either ControllerBase, or another constructor-less Controller abstraction.
ExcludeByAttribute in either MSBuild property flags, or a runsettings file, must contain CompilerGeneratedAttribute.

Expected behavior
WebApi/MVC Controllers without an explicit constructor, should produce code coverage results.

Actual behavior
WebApi/MVC Controllers without an explicit constructor produces no code coverage results when
ExcludeByAttribute=CompilerGeneratedAttribute is used.
These Controllers may use Actions with [FromServices] dependency injection - whilst also not declaring a constructor.

WebApi/MVC Controllers with an explicit constructor will always produce code coverage results.

Configuration (please complete the following information):
Please provide more information on your .NET configuration:

  • Which coverlet package and version was used? 6.0.2/6.0.3
  • Which version of .NET is the code running on? .Net8/.Net9
  • What OS and version, and what distro if applicable? Windows 10
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? Specifically caused by ExcludeByAttribute=CompilerGeneratedAttribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/coverlet-coverage/coverlet/issues/1727

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy