vs-mef icon indicating copy to clipboard operation
vs-mef copied to clipboard

Analyzer could detect duplicate imports

Open drewnoakes opened this issue 2 years ago • 2 comments

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.

drewnoakes avatar Sep 06 '21 05:09 drewnoakes

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 avatar Sep 07 '21 14:09 AArnott

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.

AArnott avatar Sep 07 '21 14:09 AArnott