Skip to content
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

[BUG] Refit 6 causes code coverage with coverlet to stop working #1073

Closed
martincostello opened this issue Feb 10, 2021 · 4 comments
Closed
Labels

Comments

@martincostello
Copy link
Contributor

martincostello commented Feb 10, 2021

Describe the bug

In a project using Refit 6.0.8 and coverlet.msbuild 3.0.2, upon updating from Refit 5.2.4, code coverage is no longer being collected for the assembly containing Refit interfaces.

In the first instance I'm raising the issue here as the delta in the project where I'm having this issue is the Refit version, with coverlet.msbuild being the same version as before and working as expected with Refit 5.2.4.

If it's a latent issue with coverlet.msbuild that's just being uncovered by the latest version of Refit, then I can open an issue on the coverlet repo.

Using coverlet's troubleshooting guide here, I narrowed my investigation down to this line of interest:

[coverlet] Unable to instrument module: C:\Coding\Projects\MyProject\tests\MyProject.Tests\bin\debug\net5.0\MyProject.dll, pdb without local source files, [C:\Coding\Projects\MyProject\src\MyProject\InterfaceStubGenerator.Core\Refit.Generator.InterfaceStubGenerator\IMyApi.g.cs]

As there's no file on disk here, that sort of makes sense, but causes an issue as it breaks all code coverage for the project for the sake of the one interface.

I'm guessing this is something to do with the usage of source generators. It might be that there's an MSBuild variable I need to set somewhere to either skip this (I tried skipping the individual file with an ExcludeByFile filter of **/*.g.cs but it didn't seem to work).

It looks like this initially skipped detection in my CI jobs (where there is a coverage threshold) because if there are no modules coverlet is reporting 100%/NAN% coverage, which is greater than the threshold so the build passes despite there being no actual coverage data at all. I'll open a separate issue with coverlet for this one, if there isn't already. coverlet-coverage/coverlet#1083

Steps To Reproduce

Clone https://github.com/martincostello/alexa-london-travel and run ./build.ps1.

The build script will eventually output something like this:

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | NaN% | NaN%   | NaN%   |
+---------+------+--------+--------+

Example build: https://github.com/martincostello/alexa-london-travel/runs/1869767942?check_suite_focus=true#step:4:78

This seems to be affecting multiple repos I have using Refit, not just this one.

Here's another example: https://github.com/martincostello/alexa-london-travel-site/runs/1870035564?check_suite_focus=true#step:4:160

Expected behavior

Assemblies containing Refit interfaces are instrumented correctly.

For the referenced repository, it should output something like this from build.ps1:

+--------------------+-------+--------+--------+
| Module             | Line  | Branch | Method |
+--------------------+-------+--------+--------+
| LondonTravel.Skill | 99.1% | 94.82% | 97.9%  |
+--------------------+-------+--------+--------+

+---------+-------+--------+--------+
|         | Line  | Branch | Method |
+---------+-------+--------+--------+
| Total   | 99.1% | 94.82% | 97.9%  |
+---------+-------+--------+--------+
| Average | 99.1% | 94.82% | 97.9%  |
+---------+-------+--------+--------+

Example build: https://github.com/martincostello/alexa-london-travel/runs/1869465349?check_suite_focus=true#step:4:80

Screenshots

N/A

@clairernovotny
Copy link
Member

Please file this on the coverlet repo, it's a bug on their end and there's nothing we can do.

@martincostello
Copy link
Contributor Author

Opened coverlet-coverage/coverlet#1084.

Please add any relevant context regarding source generators (if there's anything useful that can be added regarding what Refit does with them of course!).

@clairernovotny clairernovotny added external and removed bug Something isn't working labels Feb 10, 2021
@clairernovotny
Copy link
Member

Closing as external in favor of the bug on the Coverlet side.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants