Re: type members layout for explict interface methods seriously broken

Hello,

I'm afraid I wasn't able to reproduce this behavior with the default pattern:
all members implementing a particular interface (no matter whether they implement
the interface implicitly or explicitly) get grouped together under the same
region. Could you please attach a small sample solution where ordering members
with the default pattern puts explicit interface implementations to the very
end of the file? Thank you!


Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

When my type implements methods from an inteface explicitly (void
IInterface.Method(){}) there is no way to get a decent and stylecop
compliant type member layout (ordering). At least I haven't found one.
Those methods will always be handled as if they where private methods
and be added at the very end of the file.

Of cours I work around it like this:
<!-- Explicit Interface Methods -->
<Entry>
<Match>
<And>
<Kind Is="method"/>
<ImplementsInterface/>
</And>
</Match>
<Sort>
<Name/>
</Sort>
</Entry>
<!Methods>
<Entry>
<Match>
<And>
<Or>
<Kind Is="method"/>
<Kind Is="operator"/>
<HandlesEvent />
</Or>
<Not>
<ImplementsInterface/>
</Not>
<Not>
<Kind Is="destructor"/>
</Not>
</And>
</Match>
<Sort>
<Access Order="public internal protected-internal
protected private" />
<Static/>
<Abstract/>
<Virtual/>
<Override/>
<Name/>
</Sort>
</Entry>
But this will separate the explicit interface implementation methods
from the normal interface implementaion methods wich is not good. I
don't want to get:

void IInterface.AMethodFromInterface(){};

void IInterface.BMethodFromInterface(){};

public void AMethodFromInterface(){};

public void AMethodNotFromInterface(){};

public void BMethodFromInterface(){};

public void BMethodNotFromInterface(){};

This separation will get even worse when I also have abstract,
virtual, override methods as they will be orderd too.

IMHO there are only two decent ways to order the members and still be
stylecop compliant.

Either keep all methods that implement the interface together
regardless of wether it is a explicit interface implementation or a
normal one (allthough this will really never work because I will still
have the abstract, virtual, override orderring wich scatters the
interface methods again):

void IInterface.AMethodFromInterface(){};

public void AMethodFromInterface(){};

void IInterface.BMethodFromInterface(){};

public void BMethodFromInterface(){};

public void AMethodNotFromInterface(){};

public void BMethodNotFromInterface(){};

Or just order everything alphabetically, regardless of whether it
is a normal or explicit interface implementation or not an interface
implementation at all:

void IInterface.AMethodFromInterface(){};

public void AMethodFromInterface(){};

public void AMethodNotFromInterface(){};

void IInterface.BMethodFromInterface(){};

public void BMethodFromInterface(){};

public void BMethodNotFromInterface(){};

Unfortunately I haven't could not make either one of these behaviors.
Any idea how?

---
Original message URL:
http://devnet.jetbrains.net/message/5273325#5273325



Please sign in to leave a comment.