unitycontainer / aspnet-webapi

Unity.AspNet.WebApi package
Apache License 2.0
9 stars 11 forks source link

Dependency on Micrsoft.AspNet.WebApi.WebHost not always needed #18

Open delpher opened 4 years ago

delpher commented 4 years ago

UnityDependencyResolver can also be used with a self-hosting on OWIN but this package has a dependency on Microsoft.AspNet.WebApi which in its turn depends on Microsoft.AspNet.WebApi.WebHost. UnityDependencyResolver, however, has no dependency on any particular hosting environment. Please, consider extracting UnityDependencyResolver into a separate package.

ENikS commented 4 years ago

It could be addressed but it would help if you provide more context. I know very little about the subject.

delpher commented 4 years ago

It could be addressed but it would help if you provide more context. I know very little about the subject.

Ok, let me create some sample project and I'll get back to you.

delpher commented 4 years ago

I have created Sample. This is a console app, that can be started on it's own without IIS. In the Startup.cs class there is a registration of UnityDependencyResolver by setting it as DependencyResolver in HttpConfiguration.

When I install your package, it will add dependency to Microsoft.Aspnet.WebApi that depends on Microsoft.AspNet.WebApi.WebHost which is not needed to run this project. All necessary abstractions for UnityDependencyResolver can be found in Microsoft.AspNet.WebApi.Core package, which can be installed separately.

Therefore it would be nice, if you extract UnityDependecnyResolver into separate package, that only depends upon Microsoft.AspNet.WebApi.Core. This way, this package can be used in a self-host projects, that don't run nor depend on web hosting platform such as IIS.

I've made this screenshot to illustrate dependency graph: Screenshot

ENikS commented 4 years ago

Perhaps you could submit a PR? You seems to know what you are doing.