What is the difference between 'DependencyContext' and 'basic-reference-assemblies'?
Hello. I am using DependencyContext .Default .CompileLibraries to get references. which namespace in Microsoft.Extensions.DependencyModel.
It works(However, there are some fields or attributes whose metadata cannot be found during dynamic compilation).
What is the difference between Microsoft.Extensions.DependencyModel and basic-reference-assemblies?
Can you link to any docs to that API? I'm unfamiliar with that so hard to say how it relates to this project.
@jaredpar https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.Extensions.DependencyModel
When I used dynamic compilation before, the roslyn error could not find the object reference. For dynamic compilation is a very troublesome thing, currently I use
foreach (var asm in DependencyContext
.Default
.CompileLibraries
.SelectMany(cl => cl.ResolveReferencePaths()))
{
DomainManagement.Default.AddReferencesFromDllFile(asm);
}
this code to solve the problem.
When I use the dll file provided by DependencyContext to reflect private fields, such as _size of List<int>. It will indicate that this field cannot be found. So I have to reload typeof (List<int>). Assenbly.Location into the reference to find _size;. I suspect DependencyContext can't provide metadata other than public level, or I'm not familiar with it.