cadrell0
cadrell0

Reputation: 17307

ReSharper interface naming

In ReSharper, if I using the "Implement Interface" action on a class it creates a region named Implementation of IInterface. However, if I implement the interface manually then run a code cleanup, it wraps my interface members in a region named IInterface Members.

Why does it use two different naming conventions? If there a way to standardize this?

Upvotes: 0

Views: 633

Answers (1)

Metro Smurf
Metro Smurf

Reputation: 38335

According to the R# docs for Reordering Type Members, the code clean up should reorder and wrap the implemented interface in a named region:

R# ImplementsInterface XML Rules

This XML code matches members that implement an interface, surrounds them with regions and sorts by the name of the implemented interface. The ${ImplementsInterface} variable contains the name of the interface being implemented. If you do not want to insert regions around interface implementations, remove the Group tag and ReSharper will just sort members according to the name of the interface they are implementing.

Check your settings and see if you may have overridden the default behavior. On the other hand, I have not personally testing the code clean up with the reordering and region wrapping, so this is somewhat of a best guess. But, hopefully it can point you in the right direction.

Edit
After reviewing the documentation in more detail and exploring all the editable templates with R#, I don't think there is a way to edit the text for the region's label.

I decompiled the JetBrains.ReSharper.Feature.Services.CSharp.dll and found what I believe to the be the source of the region's label:

  • Namespace: JetBrains.ReSharper.Feature.Services.CSharp.Generate
  • Class: CSharpGeneratorContext
  • Method: InsertWithRegions or CSharpGeneratorContext

Both methods have the string "Implementation of " + <some code> embedded in the dll, so it appears you will not be able to edit the default text.

Upvotes: 1

Related Questions