-
Notifications
You must be signed in to change notification settings - Fork 386
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
[coverlet] Unable to instrument module - NET 5 - Microsoft.Extensions.Logging.Abstractions #1231
Comments
I fixed this on Azure Devops (Linux build) with a copy of the dll as follows: This fixes two warnings:
Temp fix: - task: PowerShell@2
displayName: 'fix - [coverlet] Unable to instrument module - Microsoft.Extensions.Logging.Abstractions'
inputs:
pwsh: true
targetType: 'inline'
script: |
$dllToFix = "Microsoft.Extensions.Logging.Abstractions.dll"
$from = "Backend/MyApp.Infra.Tests/bin/Release/net5.0/refs/$dllToFix"
Copy-Item $from -Destination "Backend/MyApp.Domain.Tests/bin/Release/net5.0"
Copy-Item $from -Destination "Backend/MyApp.Infra.Tests/bin/Release/net5.0" it seems I have to copy the dll also one level up? (from update, tested, and I really need to copy from net5.0/refs to the net5.0 folder |
Hi @304NotModified thanks for reporting this. We'll take a look asap. |
@304NotModified are you able to provide a repro?I have an idea of the possible problem but I need a repro to validate it. |
It's a ASP.NET Core 5 application with multiple projects. I'm afraid it will take some time to create a repro. |
I am having the same issue:
As @304NotModified pointed out it seems that coverlet msbuild cannot find the DLL under |
If I understand it correctly, |
If you're able to provide a repro I can try to improve this one. |
As workaround I'm using such test pipeline: dotnet publish
cp -f ./bin/Debug/net6.0/refs/* ./bin/Debug/net6.0/
dotnet test --collect:\"XPlat Code Coverage\" -l:\"junit;LogFileName=results.xml\" -r /reports --settings coverlet.runsettings --diag /reports/test.log --no-restore You can simplify the last string to |
I'm afraid that creating reproduction is hard. I propose the following: coverlet tries to load from the refs folder, create a prerelease of coverlet, and I will be happy to test it :) |
Despite the fact that use publish+ref works I feel it too much as an "hack", I prefer something more useful in every scenario. |
As additional information, I reproduce the problem in my library. Check the action associated with: typely-io/Typely#28. I have the following structure: Typely.EfCore depends on Typely.Core. |
fixed in #1449 |
I've referenced the latest nightly build version in my
I have tried several workarounds, but the only one that works is copying the Do you guys still have the issue? @MarcoRossignoli when you say that this issue is fixed in #1449, is there any specific thing to do to get rid of this issue? |
@lg2de any idea of the @dovic95 issue? I would expect that we try to scan all the shared framework installed and that lib should be there for asp.net core "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.1\Microsoft.Extensions.Logging.Abstractions.dll" cc: @daveMueller @bert2 |
I'm currently not that motivated to investigate that issue again, because I was waiting half a year for a release of my fix. |
Got it thanks @lg2de for the quick response and contributions to coverlet! |
I just noticed that I wasn't getting code coverage for an assembly. I use Fine Code Coverage in Visual Studio and was taking a look at its logs. I found this exception:
I traced back in my commit history to where it started happening. The best I can tell is that I took a service that was for audit logging and changed its signature to take public Task IncomingRequestReceived(int clientId,
AuditLoggingReqeuestType requestType,
AuditLoggingRequestPurpose requestPurpose,
string? message = null,
string? queryString = null,
string? requestBody = null,
LogLevel logLevel = LogLevel.Debug)
{
this.logger.Log(logLevel,
"Incoming request recieved: Request type {RequestType} - Request purpose {RequestPurpose} - Message {Message} - Query string: {QueryString} - Request Body {RequestBody}",
requestType,
requestPurpose,
message,
queryString,
requestBody); I'm using the Moq library and have some verifications setup: this.mockAuditLoggerService
.Verify(s => s.IncomingRequestReceived(It.Is<int>(id => id == CLIENT_ID),
It.Is<AuditLoggingReqeuestType>(t => t == AuditLoggingReqeuestType.Refund),
It.Is<AuditLoggingRequestPurpose>(t => t == AuditLoggingRequestPurpose.Create),
It.IsAny<string?>(),
It.IsAny<string?>(),
It.IsAny<string?>(),
It.IsAny<LogLevel>()),
Times.Once()); Now, I don't know why this would make any difference. First I removed all the code in my test assembly that would reference the This is very interesting. I have Hopefully this is helpful in some way. |
For some test projects, but not all, we get
Tried:
<PreserveCompilationContext>true</PreserveCompilationContext>
to csprojs/p:CopyLocalLockFileAssemblies=true
todotnet test
Related:
PS I hope this helps to diagnose the issue #1196. I have run more than 10 builds (with 10 tries), but all have the same issue :(
The text was updated successfully, but these errors were encountered: