-
Notifications
You must be signed in to change notification settings - Fork 54
Conventions
public class MyClass
{
public string Name {get;set;}
protected int _numberOfImages = 10;
}
- Indentation is 4 spaces.
- Don’t Tabs. Ever.
- Methods and Functions should include a verb and express an action.
- Class-Methodes and public properties in PascalCase (starting with can uppercase character)
- Private and protected members start with an
_(underscore) followed by lowercase character. - Avoid commented code without additional explanation comment.
Place opening curly brace on new line:
if (true)
{
...
}
else
{
...
}
For object-initializer put the curly braces below the created object:
var colordesc = new Texture2DDescription
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = Format.B8G8R8A8_UNorm
};
For Lambda-function with more than one line, place the curly braces below the lambda variable:
Inputs.ForEach(i =>
{
...
});
or
await Task.Run(() =>
{
...
});
Add an X prefix to XAML-Elements:
<canvas x:Name="XElementCanvas">
...
</canvas>
The order of methods / function withing a class should be from common / public on top to specific / privat at the bottom.
If possible, use #regions to structure your code.
- Uppercase/CamelCase
- Avoid abbreviations
Avoid exclamation marks and trailing ellipsis (unless the action is ongoing):
Created missing directory 'Config'! <-- Ugly`
Created missing directory 'Config'... <-- WRONG`
Creating missing directory 'Config'. <-- Better`
Put strings-values, filenames, and directories into '':
Creating Config... <-- WRONG
Creating missing directory 'Config'. <-- Better
Write sentences and end them with a period:
CFound DirectX Device with feature level {0} <-- WRONG
CFound DirectX Device with feature level {0}. <-- Better
Avoid abbreviations:
Op {0} is referenced but not existing!
Referenced undefined operator: {0}. <-- Better
Assume others will read your message
found op impl in core: {0} <--- WTF?!
Avoid unneccessary capitals
{0} : FAILED to update reference
Failed to update test reference for {0}. <-- Better
- Debug: Stuff, but NOT Noise
- Info: Noteworthy exceptions that should be presented to the user.
- Warn: Problems that need attention and can be fixed by the user
- Error: Errors that prevent proper execution
- ResetToDefaultEvent -
- ResetToDefaultHandler
- FloatEditButton_ResetToDefaultHandler - if the source of the event is important, it should be named first, separated by Underscore.
- ExecuteResetToDefault - If the execution of a command is required to be called from several sources (eventhandlers, context menus, etc.) it should be extracted from the Handler into its own method.