-
Notifications
You must be signed in to change notification settings - Fork 0
Styling Guide
Zenvin edited this page Dec 10, 2021
·
8 revisions
- Commit messages using imperative present tense with first letter capitalized, that is e.g.
Add running,Change inventory system - Branches use lower-kebab-case and are written as nouns, that is e.g.
task/boss-balance,task/inventory-addition
- Use empty objects prefixed with
---to create headers - Use spaces in names and use capital letter like
PlayerandEnd Level Trigger - Avoid types in asset names
- PascalCase for everything but:
- camelCase for private variables, local variables and parameters
- _camelCaseWithUnderscore for backing fields
-
Nouns for types
- Single-word type names should preferably be used for POCOs
- Suffixes like
-Controlleror-Managercan be used as fitting - Arbitrary names (e.g.
UserInterface) are to be avoided - Abbreviations may be used for common terms (e.g. "User Interface" ➜ "UI")
- Verbs for methods
- Adjectives for interfaces
- Use those prefixes:
-
I...- Interfaces -
Try...- Methods with out parameters that return bool -
Co_- Coroutines
-
- Use those suffixes:
-
...Async- Async methods returning Task
-
- Use explicit
private - You can use
varwhen that makes the code nicer without hindering readability - Inline attribute in case only one is present, place the attribute above the member otherwise
- Always place the code within a namespace, do not leave anything in global scope
- Use
usingover using namespaces in code, that is avoidSystem.Collections.Generic.Listand similar in code - Remove unused
usingstatements
- Indent by 4 spaces
- Put the bracket on a new line
- If you use one line if statements, break the line after the condition
- Prefer if statements with
{ }unless it hinders readability - Guard clauses should not use
{ } - Put a space between keywords and arguments like so:
if (condition) -
Do not use
regions - Do use lambdas and expression body properties when it makes sense
- Do not use expression body methods
- By member type: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1201.md
- By access modifier: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md
- Fields denoted with the
[SerializeField]attribute should appear above all other fields
- Last element of a list or enum should also be followed with
, - Use PascalCase for enum options
- Flags should have explicit values introduced via shift operator like so
SomeEnumOption = 1 << 5