Skip to content

Instantly share code, notes, and snippets.

@alfredbaudisch
Forked from VacuumBreather/CsUnityFileLayout.xml
Created September 13, 2022 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredbaudisch/96d2ed107e272ee58fb2465f87794737 to your computer and use it in GitHub Desktop.
Save alfredbaudisch/96d2ed107e272ee58fb2465f87794737 to your computer and use it in GitHub Desktop.
Rider C# File Layout for Unity classes
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"
xmlns:unity="urn:schemas-jetbrains-com:member-reordering-patterns-unity">
<!-- StyleCop Unity Classes Layout -->
<TypePattern DisplayName="StyleCop Unity Classes Layout" RemoveRegions="All" Priority="150">
<TypePattern.Match>
<unity:SerializableClass />
</TypePattern.Match>
<Region Name="Constants and Fields">
<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>
<And>
<Kind Is="Field" />
<Not>
<unity:SerializedField />
</Not>
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Readonly />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Serialized Fields" Priority="150">
<Entry DisplayName="Serialized Fields">
<Entry.Match>
<unity:SerializedField />
</Entry.Match>
</Entry>
</Region>
<Region Name="Constructors and Destructors">
<Entry DisplayName="Constructors and destructors">
<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>
</Region>
<Region Name="Public Events and Delegates">
<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>
</Region>
<Region Name="Protected Events">
<Entry DisplayName="Protected events">
<Entry.Match>
<And>
<Kind Is="Event" />
<Or>
<Access Is="Protected" />
<Access Is="ProtectedInternal" />
</Or>
</And>
</Entry.Match>
</Entry>
</Region>
<Region Name="Private Events">
<Entry DisplayName="Private events">
<Entry.Match>
<And>
<Kind Is="Event" />
<Access Is="Private" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Enums">
<Entry DisplayName="Enums">
<Entry.Match>
<Kind Is="Enum" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Interfaces">
<Entry DisplayName="Interfaces">
<Entry.Match>
<Kind Is="Interface" />
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Public Properties">
<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>
</Region>
<Region Name="Protected Properties">
<Entry DisplayName="Protected properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<Or>
<Access Is="Protected" />
<Access Is="ProtectedInternal" />
</Or>
</And>
</Entry.Match>
</Entry>
</Region>
<Region Name="Private Properties">
<Entry DisplayName="Private properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<Access Is="Private" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Public Indexers">
<Entry DisplayName="Public indexers">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<Access Is="Public" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Protected Indexers">
<Entry DisplayName="Protected indexers">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<Or>
<Access Is="Protected" />
<Access Is="ProtectedInternal" />
</Or>
</And>
</Entry.Match>
</Entry>
</Region>
<Region Name="Private Indexers">
<Entry DisplayName="Private indexers">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<Access Is="Private" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="${ImplementsInterface} Implementation" Priority="100">
<Region.GroupBy>
<ImplementsInterface />
</Region.GroupBy>
<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="Interface properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface indexers" Priority="100">
<Entry.Match>
<And>
<Kind Is="Indexer" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="True" />
<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>
</Region>
<Region Name="Setup and Teardown">
<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>
</Region>
<Region Name="Tests">
<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>
</Region>
<Region Name="Public Methods">
<Entry DisplayName="Public operators">
<Entry.Match>
<And>
<Kind Is="Operator" />
<Or>
<Access Is="Public" />
<Access Is="Internal" />
</Or>
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Virtual />
<Override />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Or>
<Access Is="Public" />
<Access Is="Internal" />
</Or>
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Virtual />
<Override />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Protected Methods">
<Entry DisplayName="Protected Operators">
<Entry.Match>
<And>
<Kind Is="Operator" />
<Or>
<Access Is="Protected" />
<Access Is="ProtectedInternal" />
</Or>
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Virtual />
<Override />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Protected Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Or>
<Access Is="Protected" />
<Access Is="ProtectedInternal" />
</Or>
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Virtual />
<Override />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Event Handlers" Priority="100">
<Entry DisplayName="Event handlers">
<Entry.Match>
<And>
<Kind Is="Method" />
<Access Is="Private" />
<HandlesEvent />
</And>
</Entry.Match>
<Entry.SortBy>
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Unity Methods" Priority="150">
<Entry DisplayName="Unity Methods">
<Entry.Match>
<unity:EventFunction />
</Entry.Match>
<Entry.SortBy>
<unity:EventFunctionName />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Private Methods">
<Entry DisplayName="Private operators">
<Entry.Match>
<And>
<Kind Is="Operator" />
<Access Is="Private" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Name />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Private methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Access Is="Private" />
</And>
</Entry.Match>
<Entry.SortBy>
<Access />
<Static />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Region Name="Nested Types">
<Entry DisplayName="Nested structs">
<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">
<Entry.Match>
<Kind Is="Class" />
</Entry.Match>
<Entry.SortBy>
<Static />
<Access Order="Public Internal ProtectedInternal Protected Private" />
<Name />
</Entry.SortBy>
</Entry>
</Region>
<Entry DisplayName="All other members" />
</TypePattern>
</Patterns>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment