Skip to content

Instantly share code, notes, and snippets.

@VacuumBreather
Last active December 6, 2023 21:59
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save VacuumBreather/013139478373189cff3ed8ebbee556cb to your computer and use it in GitHub Desktop.
Save VacuumBreather/013139478373189cff3ed8ebbee556cb 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">
<!-- Pattern to match classes used by Unity that contain serialised fields
and event function methods. Based on the standard "Default Pattern",
this will also order event functions before normal methods, and does
not reorder serialised fields, as this order is reflected in the Unity
editor's Inspector -->
<TypePattern DisplayName="Unity classes" Priority="100">
<TypePattern.Match>
<unity:SerializableClass />
</TypePattern.Match>
<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>
<Kind.Order>
<DeclarationKind>Constant</DeclarationKind>
<DeclarationKind>Field</DeclarationKind>
</Kind.Order>
</Kind>
</Entry.SortBy>
</Entry>
<Entry DisplayName="Serialized Fields">
<Entry.Match>
<!-- Keep serialised fields and auto-properties with serialised backing
fields together, unsorted, to maintain order in the Inspector
window -->
<Or>
<unity:SerializedField />
<unity:AutoPropertyWithSerializedBackingField />
</Or>
</Entry.Match>
<!-- No sorting -->
</Entry>
<Entry DisplayName="Non-serialised Fields">
<Entry.Match>
<And>
<Kind Is="Field" />
<Not>
<unity:SerializedField />
</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="Event Functions">
<Entry.Match>
<unity:EventFunction />
</Entry.Match>
<Entry.SortBy>
<!-- Prioritises common event functions. For alphabetical, replace with
<Name /> -->
<unity:EventFunctionName />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Interface Implementations" Priority="100">
<Entry.Match>
<And>
<Kind Is="Member" />
<ImplementsInterface />
</And>
</Entry.Match>
<Entry.SortBy>
<ImplementsInterface Immediate="true" />
</Entry.SortBy>
</Entry>
<Entry DisplayName="All other members" />
<Entry DisplayName="Nested Types">
<Entry.Match>
<Kind Is="Type" />
</Entry.Match>
</Entry>
</TypePattern>
</Patterns>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment