Reorder methods by access modifier

Hello, 

I need assistance on how to make R# reorder the methods inside a class by access modifiers. I've spent couple of hours looking at the documentation for code syntax, layout patterns and even looking at old posts  but I haven't been able to make it work. 

In short, I want to see the methods ordered by access modifier (oversimplyfying: public, protected, private) as part of code clean up & formatting. 

Here's my current configuration: 

And this is my FIle layout XML for c#: 

<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
 <TypePattern DisplayName="Non-reorderable types">
   <TypePattern.Match>
     <Or>
       <And>
         <Kind Is="Interface" />
         <Or>
           <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" />
           <HasAttribute Name="System.Runtime.InteropServices.ComImport" />
         </Or>
       </And>
       <Kind Is="Struct" />
       <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" />
       <HasAttribute Name="JetBrains.Annotations.NoReorder" />
     </Or>
   </TypePattern.Match>
 </TypePattern>
 <TypePattern DisplayName="xUnit.net Test Classes" RemoveRegions="All">
   <TypePattern.Match>
     <And>
       <Kind Is="Class" />
       <HasMember>
         <And>
           <Kind Is="Method" />
           <HasAttribute Inherited="True" Name="Xunit.FactAttribute" />
           <HasAttribute Inherited="True" Name="Xunit.TheoryAttribute" />
         </And>
       </HasMember>
     </And>
   </TypePattern.Match>
   <Entry DisplayName="Setup/Teardown Methods">
     <Entry.Match>
       <Or>
         <Kind Is="Constructor" />
         <And>
           <Kind Is="Method" />
           <ImplementsInterface Name="System.IDisposable" />
         </And>
       </Or>
     </Entry.Match>
     <Entry.SortBy>
       <Kind Is="0" Order="Constructor" />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="All other members" />
   <Entry DisplayName="Test Methods" Priority="100">
     <Entry.Match>
       <And>
         <Kind Is="Method" />
         <HasAttribute Name="Xunit.FactAttribute" />
         <HasAttribute Name="Xunit.TheoryAttribute" />
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <Name />
     </Entry.SortBy>
   </Entry>
 </TypePattern>
 <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All">
   <TypePattern.Match>
     <And>
       <Kind Is="Class" />
       <Or>
         <HasAttribute Inherited="True" Name="NUnit.Framework.TestFixtureAttribute" />
         <HasAttribute Inherited="True" Name="NUnit.Framework.TestFixtureSourceAttribute" />
         <HasMember>
           <And>
             <Kind Is="Method" />
             <HasAttribute Name="NUnit.Framework.TestAttribute" />
             <HasAttribute Name="NUnit.Framework.TestCaseAttribute" />
             <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" />
           </And>
         </HasMember>
       </Or>
     </And>
   </TypePattern.Match>
   <Entry DisplayName="Setup/Teardown Methods">
     <Entry.Match>
       <And>
         <Kind Is="Method" />
         <Or>
           <HasAttribute Inherited="True" Name="NUnit.Framework.SetUpAttribute" />
           <HasAttribute Inherited="True" Name="NUnit.Framework.TearDownAttribute" />
           <HasAttribute Inherited="True" Name="NUnit.Framework.TestFixtureSetUpAttribute" />
           <HasAttribute Inherited="True" Name="NUnit.Framework.TestFixtureTearDownAttribute" />
           <HasAttribute Inherited="True" Name="NUnit.Framework.OneTimeSetUpAttribute" />
           <HasAttribute Inherited="True" Name="NUnit.Framework.OneTimeTearDownAttribute" />
         </Or>
       </And>
     </Entry.Match>
   </Entry>
   <Entry DisplayName="All other members" />
   <Entry DisplayName="Test Methods" Priority="100">
     <Entry.Match>
       <And>
         <Kind Is="Method" />
         <HasAttribute Name="NUnit.Framework.TestAttribute" />
         <HasAttribute Name="NUnit.Framework.TestCaseAttribute" />
         <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" />
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <Name />
     </Entry.SortBy>
   </Entry>
 </TypePattern>
 <TypePattern DisplayName="Default Pattern">
   <Entry DisplayName="Public Delegates" Priority="100">
     <Entry.Match>
       <And>
         <Access Is="Public" />
         <Kind Is="Delegate" />
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <Name />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Public Enums" Priority="100">
     <Entry.Match>
       <And>
         <Access Is="Public" />
         <Kind Is="Enum" />
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <Name />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Static Fields and Constants">
     <Entry.Match>
       <Or>
         <Kind Is="Constant" />
         <And>
           <Kind Is="Field" />
           <Static />
         </And>
       </Or>
     </Entry.Match>
     <Entry.SortBy>
       <Kind Is="0" Order="Constant Field" />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Fields">
     <Entry.Match>
       <And>
         <Kind Is="Field" />
         <Not>
           <Static />
         </Not>
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <Readonly />
       <Name />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Constructors">
     <Entry.Match>
       <Kind Is="Constructor" />
     </Entry.Match>
     <Entry.SortBy>
       <Static />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Properties, Indexers">
     <Entry.Match>
       <Or>
         <Kind Is="Property" />
         <Kind Is="Indexer" />
       </Or>
     </Entry.Match>
   </Entry>
   <Entry DisplayName="Interface Implementations" Priority="100">
     <Entry.Match>
       <And>
         <Kind Is="Member" />
         <ImplementsInterface />
       </And>
     </Entry.Match>
     <Entry.SortBy>
       <ImplementsInterface />
       <Access Is="0" />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="All other members">
     <Entry.Match>
       <Kind Is="Method" />
     </Entry.Match>
     <Entry.SortBy>
       <Access Is="0" />
     </Entry.SortBy>
   </Entry>
   <Entry DisplayName="Nested Types">
     <Entry.Match>
       <Kind Is="Type" />
     </Entry.Match>
   </Entry>
 </TypePattern>
</Patterns>

0

Please sign in to leave a comment.