pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
745 stars 112 forks source link

JetBrains dotCover fails to gather coverage of tests with aspects Kind.Around #150

Closed sergeprozorov closed 3 years ago

sergeprozorov commented 3 years ago

Hello,

The issue might be related to #107, but the error message I see is different. Additionally, I provide a reliable way to reproduce it. The scenario is following

Run the unit tests from AspectInjector.SampleApps with code coverage. You can see that code coverage report is empty. image

If you run a test session without CacheTests with code coverage, you will see some results there. image

In order to see the error message itself being produced by dotCover, I have used the approach described here, because it is the simplest for me. The message is following.

[JetBrains dotCover] Coverage session finished with errors: Jump to invalid address
[location] = C:\BuildAgent\work\82554ce5cfd8f0cd\Profiler\Kernel\Windows\Native\Solution\core\src\IL\InjectILMethod.MainPass.cpp(388)
[function] = unsigned int __cdecl InjectILMethod::Translate(unsigned int,bool)
[token] = 06000012, MethodDef
[method name] = CalculateTask
[module name] = C:\work\temp\aspect-injector\samples\tests\Aspests.Tests\bin\Debug\netcoreapp2.1\Aspests.Tests.dll
[type name] = Aspests.Tests.CacheTests+TestClass.

Additionally, I would like to mention that it is not only dotCover that fails to collect code coverage. One of my colleagues has also tried OpenCover with a similar result. It is pity but this issue is a blocker for us currently, as it breaks our CI workflow.

pamidur commented 3 years ago

ok, it seems that the dotCover modifies the assembly to gather the coverage results, which make sense. The problem it seems that dotCover conflicts with AspectInjector somehow.

Thanks for reliable way get it

pamidur commented 3 years ago

@lanegoolsby , @sergeprozorov please test https://github.com/pamidur/aspect-injector/releases/tag/2.5.1-pre1

sergeprozorov commented 3 years ago

@pamidur Yes, the issue appears to be fixed. I have checked it on a couple of projects (on AspectInjector.SampleApps too). Code coverage works now in the both VS UI and dotCover CLI. Thank you, great work!

pamidur commented 3 years ago

this 2.5.1-pre1 should be stable despite it is pre-release, So I guess you might safely use it until full release is out. Possible issues are only with debug process:

I have experienced none of above tho. Please report if find any bugs))