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

Do not choose constructors with an "Obsolete" attribute #224

Closed
wants to merge 1 commit into from

Conversation

jjbott
Copy link

@jjbott jjbott commented Oct 21, 2016

This heavily discourages Ninject from choosing constructors that are marked obsolete. I'm willing to bet that when Ninject chooses an obsolete constructor it was an unintentional mistake, and can go unnoticed.

I've replicated our specific mistake in the unit test, but there are multiple other scenarios. In our scenario an implicit binding can be created and used, but in the general case we'd rather have Ninject fail instead of using the obsolete constructor.

@BrunoJuchli
Copy link
Contributor

What's the performance impact? Why is this feature important? Why can't the code be changed - why is there an obsolete constructor at all? Is the benefit worth the performance impact?

@jjbott
Copy link
Author

jjbott commented Oct 22, 2016

If there is one I haven't noticed it, and the performance tests pass (I realize there aren't any). Because using anything marked obsolete without explicitly requesting it (which can still be done by using [Inject]) is incorrect behavior in any context, especially from the perspective of an IoC container where it may not be obvious it is choosing the wrong thing. I can only give a specific answer from the perspective of my code, where legacy code that can not yet use Ninject has no choice but to instantiate objects the wrong way, but in general the obsolete attribute is used when deprecating functions that are still in use by legacy code. I haven't seen a performance impact (although I assume there is an imperceptible difference), so it comes down to whether choosing to use obsolete functions is considered correct.

@scott-xu scott-xu closed this in 969b20b Sep 11, 2017
@scott-xu scott-xu self-assigned this Sep 16, 2017
@scott-xu scott-xu added this to the 4.0 milestone Sep 16, 2017
@scott-xu
Copy link
Member

Fixed in 969b20b

glenkeane-94 pushed a commit to glenkeane-94/Nin-ject that referenced this pull request Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants