-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Feature/985 lifetime scopes and build callbacks #1049
Feature/985 lifetime scopes and build callbacks #1049
Conversation
Update fork
…emove the option when building a lifetime scope
I have extracted all but the |
This PR will remove the build callback methods from the lifetime scope builder parameter rather than actually supporting build callbacks on the lifetime scope creation event. Is that the way we want this to go? I saw that @tillig said it was by design on the issue thread to not call those callbacks, so maybe. I see the argument for wanting build callbacks, but the lifetime scope isn't 'built' per se. I feel like the proposed module changes do put a significant responsibility on the developer to know which derived class to use (as you said in the raised issue). If the aim is to tell developers their callbacks won't work, might it be simpler just to add an internal derived class for If the aim should be to actually support build callbacks for lifetime scopes, then we're going to need to go down a different path. |
The problem is that the callback is for a Personally I don't like throwing exceptions because of a wrong API usage. This is what the compiler can do for you. I much rather have a compile time error than a runtime one. So either it should be impossible to add a build callback when starting a new lifetime scope, or have the build callback take a parameter of type That being said, this PR is mostly to see what it will take to actually fix this. There seems to be some underlying design issue with how Autofac works. I'm not entirely happy with the result. It is a lot of changes for a relatively simple problem. But I can't see a better one at the moment. |
Ah, yes, sorry. I forgot that the callback takes the container rather than the scope. I agree with you about preferring compile-time errors over exceptions, I'm just trying to balance change complexity with what we're trying to achieve. Hypothetically, if we switched the build callback to take an The |
Fixed by #1054. |
No description provided.