I have a class library project which has the following extension method -
public static async Task DoSomethingAsync(this WebApplication app)
{
//
}
I was curious how a class library project is resolving the WebApplication
type, which I knew resided in the Microsoft.AspNetCore.dll
. I failed to find any clue. What I found though is the project has the Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
NuGet package installed, and if I remove this package, it can no longer resolve the WebApplication
type.
I checked the transitive dependencies of this package on NuGet Package Manager and didn't find anything that could give me a hint how it could resolve a type in Microsoft.AspNetCore.dll
-
Apparently this Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
package is also resolving the IAuthorizationService
type for me which resides in Microsoft.AspNetCore.Authorization.dll
, and I couldn't figure out how.
Can anyone help me get my head around how the package referencing or type resolving happening here?
I have a class library project which has the following extension method -
public static async Task DoSomethingAsync(this WebApplication app)
{
//
}
I was curious how a class library project is resolving the WebApplication
type, which I knew resided in the Microsoft.AspNetCore.dll
. I failed to find any clue. What I found though is the project has the Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
NuGet package installed, and if I remove this package, it can no longer resolve the WebApplication
type.
I checked the transitive dependencies of this package on NuGet Package Manager and didn't find anything that could give me a hint how it could resolve a type in Microsoft.AspNetCore.dll
-
Apparently this Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
package is also resolving the IAuthorizationService
type for me which resides in Microsoft.AspNetCore.Authorization.dll
, and I couldn't figure out how.
Can anyone help me get my head around how the package referencing or type resolving happening here?
Share Improve this question edited Feb 2 at 20:35 Guru Stron 143k11 gold badges168 silver badges209 bronze badges asked Feb 1 at 22:33 atiyaratiyar 8,3157 gold badges40 silver badges82 bronze badges1 Answer
Reset to default 1Adding Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
results in the ASP.NET Core brought as a dependency to your project. If you check the .csproj file for it @github you will see that it references several projects which are not mentioned in the dependencies of the nuget:
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" />
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
<Reference Include="Microsoft.AspNetCore.Http.Extensions" />
<!-- ... -->
</ItemGroup>
All of them have IsAspNetCoreApp
property set to True
(and IsPackable
to false) in their .csproj files which means that all of them are parts of the shared ASP.NET Core framework (link 1, link 2) which is not distributed as packages. Not sure how it works exactly but that's it basically.
Also note that usually you will bring the ASP.NET Core shared framework to a class library via FrameworkReference
.