-
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
Fixed an issue where the AspNetCoreSharedFrameworkResolver was never called in .net core 3.1 #655
Conversation
It's weird this tests should fail https://github.com/tonerdo/coverlet/blob/master/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs#L457 I did also manual check, but I was on 2.2, I'll do some more check to understand if make sense move on top...my idea was search before on "defaults" location(took from default DependencyModel code) and after try with my one. |
@jhartmann123 are you building 2.2 app with 3.1 runtime? |
Nope, all projects target I also tried the same constellation with my repro (where coverlet had no issues with). Also used some libs which reference net core 2.2 (like hangfire, swagger/swashbuckle) in my repro to no avail - everything worked there. |
I see |
No, its an ASP.net core API project ( |
Oh I did a mess so, we need a repro, I just debugged tests and works as expected I don't understand why yours not...maybe I should add asm version to log, but the behaviour you described is conform to exception. |
Ok, so I reverted the last change (as it really didn't make lots of sense) and continued on my journey to create a repro. No chance. I only get the issue on that specific project and I still don't know why. So I jumped back into debugging - and got a result as you see. I still don't know what exactly the issue was, because its late and I'm tired, but I'll leave it here for review. The changes explained: Removed the
The story behind the resolving part: I checked, what So for easier debugging I just did the same manually (iterate over the resolvers, first result wins), also removed the check for the lib type "project" and to my surprise everything started working. Any combination of filtering for "project" or using the composite resolver again caused the error to reappear. Tbh, I don't know why - but as it is not the first time I had to fight with .net core 2 resolving, I'll take any solution :) [edit] fixed lib type in last two paragraphs: |
Thanks for your deep analysis, I'll continue from here! |
Found the issue: I restarted debugging from your current master state. The breakpoint in the screenshot is just before resolving the "unresolvable" lib. Note from the Watch-Window: Also note: Both If |
Just compared the deps files between .net core 3.0 and 3.1. Turns out, it slightly changed. Example entry for 3.0:
Same entry for 3.1:
So I guess the .NET Core 2.2 |
… issue where deps files for .NET Core 3.1 deps files
I've just commited a workaround, based on the master branch. Its a bit less intrusive than the solution from yesterday. |
But in your test project have you added Seem that 3.1 version is without compilation context, only "runtime dependecies" |
Yes, I've added this property in both, Test and API-Project. [edit] ... while it is unneccessary for the API-Project:
|
I do actually have some entries with runtime/compile, but only if they reference an older framework, like
|
Strange...I have to understand if docs is old and behaviour is changed. |
@jhartmann123 I did some test I created an api+test project adding some dummy test but if I compile 3.0-3.1 I get same deps file for unit test project...the only difference are versions...can you try to do the same with your project? My sample AspNetTest.zip and the two deps files 30_XUnitTestProject1.deps.json.txt |
Ah, they actually return different versions. With your deps file I get 3.1.0 (as expected), with my deps file I get 2.1.0 - and its the only one. There isn't a second one with 3.1.0 getting returned in CompileLibraries :/ |
Updated repro a bit with more fiddling around: |
@jhartmann123 returning to #655 (comment) that could be the core of the issue can you share a piece of deps of missing libs(if it doesn't expose sensible data)?I would like to understand when asm list is loaded and when not. My concern is that the deps is redacted in very "complex way"(the possible refs/deps/runtime version matrix) and so I would like to be sure that https://github.com/dotnet/core-setup/blob/074c3bece80ca300e2f9d053b18748b6537d6f67/src/managed/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs#L91 is correct and expected for some context, my idea is to open a ticket on core-setup repro to ask, maybe they help us to understand if your workaround is acceptable, or something better can be done(for instance search also in lower runtime shared forlders, in tests above we saw that deps doesn't reflect "real loaded libs" so some rules seem hard coded inside runtime load code). |
Omg. Found it. (The fourth time :) ) If a library name isn't unique, ".Reference", ".Reference1", ".Reference2" and so on gets appended. My "missing" assembly can be resolved with a |
You mean different version are included but with .ReferenceX appended? |
Yes. And different versions of the dependency injection lib are once referenced by the web project (core 3.1) and by serilog (core 2.2) there are two entries. Could be even more. Here a current repro |
Sorry for vanishing for so long on this topic. I actually planned to update this to properly support the Now, I've just updated the packages in our project, including the coverlet packages, and suprisingly I got the coverage reports back. Is there still anything to do on this topic or was it acutally resolved? |
I didn't work on it anymore because I was waiting info from ms team on other issue(that return true on resolver, but no answer at the moment dotnet/runtime#1047). |
Ok, then I'll close it for now. Thanks for all the support :) |
Thank you for using Coverlet! |
Continuing from #654 (comment)
See also CecilAssemblyResolver:185:
string path = library.ResolveReferencePaths(_compositeResolver.Value).FirstOrDefault();
AspNetCoreSharedFrameworkResolver.TryResolveAssemblyPaths() was never called when it was the last entry in the compositeResolver. Just moving it up to be the first resolver fixes the issue.