codecentric / net_automatic_interface

.Net Source Generator for Automatic Interfaces
MIT License
62 stars 14 forks source link

Prevent duplicates when overriding or shadowing methods #51

Closed simonmckenzie closed 3 months ago

simonmckenzie commented 5 months ago

This addresses issue #50.

This is my second attempt at this - the first attempt (#49) involved excluding IsOverride methods, but this does not work with method shadowing, which becomes complex, since a new method can have different accessibility to the method it shadows, and there's no direct link in the syntax tree between a shadowing method and the method it shadows.

The approach I've used here is the same as the existing approach for deduplicating property definitions:

https://github.com/codecentric/net_automatic_interface/blob/218ba179f9ae7ad9b005202956444b7aa6437447/AutomaticInterface/AutomaticInterface/Builder.cs#L226-L239

The only difference is that it uses ISymbol.ToDisplayString to generate the deduplication key.

The parameters I've used for the display string generation will create display strings like this, with just the method name and the parameter types and directions:

Hello(ref String, Int32, Double)

simonmckenzie commented 5 months ago

Hi @ChristianSauer, sorry to bother you, but does this PR look ok to you? I'm happy to discuss it if you'd like some changes to the approach.

simonmckenzie commented 4 months ago

Hi @ChristianSauer,

Checking in on this PR - will you have a chance to look at it soon? My team can't use AutomaticInterface because of this problem - it'd be great to be able to use it again!

Thanks, Simon

ChristianSauer commented 3 months ago

Ok, I finally found time to review this - sorry, was a shitty few last months for me.

simonmckenzie commented 3 months ago

Thank you @ChristianSauer. Much appreciated. All the best.