Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
StyleCop Type Member Layout for Resharper 9
<?xml version="1.0" encoding="utf-16"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="COM interfaces" Priority="2000">
<TypePattern.Match>
<And>
<Kind Is="Interface" />
<Or>
<HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" />
<HasAttribute Name="System.Runtime.InteropServices.ComImport" />
</Or>
</And>
</TypePattern.Match>
</TypePattern>
<TypePattern DisplayName="P/Invoke structs" Priority="2000">
<TypePattern.Match>
<And>
<Or>
<Kind Is="Struct" />
<Kind Is="Class" />
</Or>
<HasAttribute Name="System.Runtime.InteropServices.StructLayoutAttribute" />
</And>
</TypePattern.Match>
</TypePattern>
<TypePattern DisplayName="P/Invoke classes (xxxNativeMethods)" Priority="2000">
<TypePattern.Match>
<And>
<Kind Is="Class" />
<Name Is=".*NativeMethods" />
</And>
</TypePattern.Match>
</TypePattern>
<TypePattern DisplayName="DataMembers" Priority="2000">
<TypePattern.Match>
<And>
<Or>
<Kind Is="Field" />
<Kind Is="Property" />
</Or>
<HasAttribute Name="System.Runtime.Serialization.DataMemberAttribute " />
</And>
</TypePattern.Match>
</TypePattern>
<TypePattern DisplayName="NUnit Test Fixtures" Priority="2000">
<TypePattern.Match>
<And>
<Kind Is="Class" />
<HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="True" />
<HasAttribute Name="NUnit.Framework.TestCaseFixtureAttribute" Inherited="True" />
</And>
</TypePattern.Match>
<Entry DisplayName="Setup/Teardown Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Or>
<HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="True" />
<HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="True" />
<HasAttribute Name="NUnit.Framework.FixtureSetUpAttribute" Inherited="True" />
<HasAttribute Name="NUnit.Framework.FixtureTearDownAttribute" Inherited="True" />
</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" />
</And>
</Entry.Match>
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
</TypePattern>
<TypePattern DisplayName="StyleCop Layout" Priority="1000" RemoveRegions="All">
<TypePattern.Match>
<Or>
<Kind Is="Class" />
<Kind Is="Struct" />
<Kind Is="Interface" />
</Or>
</TypePattern.Match>
<Entry DisplayName="Constants">
<Entry.Match>
<Kind Is="Constant" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Static fields">
<Entry.Match>
<And>
<Kind Is="Field" />
<Static />
</And>
</Entry.Match>
<Entry.SortBy>
<Kind Order="Constant Field" />
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Readonly />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Fields">
<Entry.Match>
<Kind Is="Field" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Readonly />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Constructors and destructors" Priority="200">
<Entry.Match>
<Or>
<Kind Is="Constructor" />
<Kind Is="Destructor" />
</Or>
</Entry.Match>
<Entry.SortBy>
<Static />
<Kind Order="Constructor Destructor" />
<Access Order="Public Internal ProtectedInternal Protected Private" />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Delegates">
<Entry.Match>
<Kind Is="Delegate" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public events">
<Entry.Match>
<And>
<Kind Is="Event" />
<Access Is="Public" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface events">
<Entry.Match>
<And>
<Kind Is="Event" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Other events">
<Entry.Match>
<Kind Is="Event" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Enums">
<Entry.Match>
<Kind Is="Enum" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interfaces">
<Entry.Match>
<Kind Is="Interface" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<Access Is="Public" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Other properties">
<Entry.Match>
<Kind Is="Property" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public indexers" Priority="1000">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<Access Is="Public" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface indexers" Priority="1000">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Other indexers" Priority="1000">
<Entry.Match>
<Kind Is="Indexer" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Access Is="Public" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Other methods">
<Entry.Match>
<Kind Is="Method" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Operators">
<Entry.Match>
<Kind Is="Operator" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Nested structs" Priority="600">
<Entry.Match>
<Kind Is="Struct" />
</Entry.Match>
<Entry.SortBy>
<Static />
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Nested classes" Priority="700">
<Entry.Match>
<Kind Is="Class" />
</Entry.Match>
<Entry.SortBy>
<Static />
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="All other members" />
</TypePattern>
</Patterns>
@collinbarrett

This comment has been minimized.

Copy link

@collinbarrett collinbarrett commented Jun 28, 2018

Thanks for this! Do you know if this is still fairly up to date with a recent version of StyleCop and ReSharper 2018?

@cervengoc

This comment has been minimized.

Copy link

@cervengoc cervengoc commented Dec 30, 2019

Thank you for this, you saved a few hours of work.

Seems to work great in R# 2019.3 and latest StyleCop. I just had to remove the <Name /> sorting option from every member as we do not use this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.