Skip to content
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

Bring back cross-wiring in SimpleInjector.Integration.AspNetCore #437

Closed
dotnetjunkie opened this issue Jul 13, 2017 · 7 comments
Closed

Comments

@dotnetjunkie
Copy link
Collaborator

The beta releases of Simple Injector's ASP.NET Core integration library contained a CrossWire method that allowed to simplify registration of services that should be resolved from the ASP.NET Core container. This feature was however removed before RTM because of its limitations and because it promotes a model where people would do a lot of cross-wirings, instead of hiding those services behind application-specific abstractions.

In colaboration with @TheBigRic, I've been looking at the integration path of Identity Framework core. Ric and I found out that cross-wiring Identity types such as UserManager<T> and SignInManager<T> was extremely cumbersome without having this functionality as part of the integration library. Although much of the problems is caused by design flaws in Identity Framework and its default Visual Studio template, both are hard to work around for a user that just wants to bootstrap everything. This makes the experience of using Simple Injector in this case very cumbersome.

For this reason, the CrossWire functionality has to returns. Important behavior for this feature is:

  • The cross-wired dependencies should have the same lifestyle as they have in the ASP.NET Core configuration system, to prevent false positives in Simple Injector's Captive Dependency warnings.
  • The DisposableTransientComponent warning should be suppressed for transient cross-wired dependencies that implement IDisposable, since the Core configuration system is responsible for disposing them.
  • Cross-wired dependencies should be resolved from the ASP.NET request scope, in case there is a request.
  • Verification should not fail on cross-wired dependencies when there is no HttpContext available.
@TheBigRic
Copy link
Collaborator

That is some nice piece of code you produced there!

Will it help you if I took the burden of documenting this new feature? Maybe with some sample code how you can use this to make the default VS template with Identity can be made working.

@dotnetjunkie
Copy link
Collaborator Author

Will it help you if I took the burden of documenting this new feature?

Absolutely! That would certainly help. Thanks.

@dotnetjunkie
Copy link
Collaborator Author

Pushed to Nuget

@dotnetjunkie dotnetjunkie changed the title Bring back cross-wiring Bring back cross-wiring in SimpleInjector.Integration.AspNetCore Jul 14, 2017
@tim-elvidge
Copy link

Looking forwards to trying all this out, thanks for all the work @dotnetjunkie and @TheBigRic documentation.

@QuantumHive
Copy link

@TheBigRic looking forward to the docs, I'll try it out too and report feedback if needed.

@TheBigRic
Copy link
Collaborator

The documentation is available here

@tim-elvidge
Copy link

@TheBigRic thanks for the bootstrap worked a treat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants