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

Allow conditional registrations to be made even if AllowOverridingRegistrations is set to true #850

Closed
AroglDarthu opened this issue Sep 21, 2020 · 2 comments

Comments

@AroglDarthu
Copy link

This question is related to this question on stackoverflow.

Consider we have a fully functional, verified set of registrations that include conditionals. Obviously, there is no overlap between the conditional registrations because otherwise the container would have thrown an exception. It feels very odd that the container immediately throws an exception with these exact same registrations and the option AllowOverridingRegistrations set to true from the get-go. There is, of course, a very easy workaround for this scenario: set the option after making these registrations.

Now consider the exact same scenario as above. The option has been set at the end (so no exceptions) and we can start overriding some registrations for integration test purposes. All is well, except if you need an additional conditional registration.

  1. Even if it is a totally different abstraction, the registration will fail;
  2. Even if there have been no overrides yet, the registration will fail.

Would it be possible to allow making conditional registrations if the option AllowOverridingRegistrations is true under the following circumstances: No actual overrides have been made yet. That would at least overcome issue (2) above.

Would be awesome if issue (1) can be remedied as well.

@dotnetjunkie
Copy link
Collaborator

Good point. I marked this request as 'feature' and added it to the v5.1 milestone.

dotnetjunkie added a commit that referenced this issue Sep 26, 2020
…rations mode in case no registrations for the same service type exist. Fixes #850.
@dotnetjunkie dotnetjunkie added bug and removed feature labels Oct 15, 2020
@dotnetjunkie dotnetjunkie changed the title Allow conditional registrations to be made even if AllowOverridingRegistrations is set to true Allow conditional registrations to be made even if AllowOverridingRegistrations is set to true Oct 15, 2020
@dotnetjunkie
Copy link
Collaborator

This has just been fixed in v5.0.4.

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

2 participants