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

Analyzer could detect duplicate imports #257

Open
drewnoakes opened this issue Sep 6, 2021 · 2 comments
Open

Analyzer could detect duplicate imports #257

drewnoakes opened this issue Sep 6, 2021 · 2 comments

Comments

@drewnoakes
Copy link
Member

drewnoakes commented Sep 6, 2021

I found a MEF part today that imported the same object via two constructor parameters, but with different names.

The same is possible for parameter property injection.

While harmless, it's a little messy and may lead to confusion. An analyzer could detect this.

@AArnott
Copy link
Member

AArnott commented Sep 7, 2021

The same is possible for parameter injection.

I don't understand this bit. What is parameter injection if it isn't involving an importing constructor?

Another variant on this would be an importing property and an equivalent importing constructor parameter, or just two equivalent importing properties.

@AArnott
Copy link
Member

AArnott commented Sep 7, 2021

Strictly speaking, an exporting member may produce unique values each time it is pulled from, so two "identical" imports may in fact be valuable to the consumer in getting two unique instances. However this is by far a very niche case, so an analyzer to catch what would commonly be a (minor) bug or at least a cosmetic anomaly may be useful.

My sense though is this is a low priority as it seems unlikely to result in a bug.

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