Skip to content

Commit 1ff3b7a

Browse files
updated coding gudelines
1 parent c780ab8 commit 1ff3b7a

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

CodingGuidelines.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This ensures documentation is properly generated and disseminated for all all cl
3838
3939
## MRTK namespace rules
4040

41-
The vNext structure adheres to a strict namespace culture of mapping the namespace 1-1 with the folder structure of the project. This ensures that classes are easy to discover and maintain. It also ensures the dependencies of any class are laid out in the beginning usings of the file.
41+
The vNext structure adheres to a strict namespace culture of mapping the namespace 1-1 with the folder structure of the project. This ensures that classes are easy to discover and maintain. It also ensures the dependencies of any class are laid out in the beginning using definitions of the file.
4242

4343
![](/External/ReadMeImages/MRTK-NameSpaceExample.png)
4444

@@ -47,7 +47,7 @@ The vNext structure adheres to a strict namespace culture of mapping the namespa
4747
// Copyright (c) Microsoft Corporation. All rights reserved.
4848
// Licensed under the MIT License. See LICENSE in the project root for license information.
4949
50-
namespace Microsoft.MixedReality.Toolkit.Internal.Definitons
50+
namespace Microsoft.MixedReality.Toolkit.Internal.Definitions
5151
{
5252
/// <summary>
5353
/// The ButtonAction defines the set of actions exposed by a controller.
@@ -69,7 +69,7 @@ Additionally, ensure that spaces are added for conditional / loop functions like
6969
### Don't:
7070

7171
```
72-
private Foo()
72+
private Foo () // < - space between Foo and ()
7373
{
7474
if(Bar==null) // <- no space between if and ()
7575
{
@@ -100,6 +100,31 @@ private Foo()
100100
}
101101
```
102102

103+
## Spacing
104+
105+
Please be sure not to add additional spaces between square brackets and parenthesis:
106+
107+
### Don't:
108+
109+
```
110+
private Foo()
111+
{
112+
int[ ] var = new int [ 9 ];
113+
Vector2 vector = new Vector2 ( 0f, 10f );
114+
}
115+
116+
```
117+
118+
### Do:
119+
120+
```
121+
private Foo()
122+
{
123+
int[] var = new int[9];
124+
Vector2 vector = new Vector2(0f, 10f);
125+
}
126+
```
127+
103128
## Naming Conventions
104129

105130
Always use `PascalCase` for public / protected / virtual properties, and `camelCase` for private properties and fields.
@@ -126,9 +151,19 @@ Always declare an access modifier for all fields, properties and methods.
126151

127152
>All Unity API Methods should be `private` by default, unless you need to override them in a derived class. In this case `protected` should be used.
128153
154+
>Fields should always be `private`, with `public` or `protected` property accessors.
155+
156+
>Use [expression-bodied members](https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#expression-bodied-function-members) and [auto properties](https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#auto-property-enhancements) where possible
157+
129158
### Don't:
130159

131160
```
161+
// protected field should be private
162+
protected int myVariable = 0;
163+
164+
// property should have protected setter
165+
public int MyVariable { get { return myVariable; } }
166+
132167
// No public / private access modifiers
133168
void Foo() { }
134169
void Bar() { }
@@ -137,6 +172,8 @@ void Bar() { }
137172
### Do:
138173

139174
```
175+
public int MyVariable { get; protected set; } = 0;
176+
140177
private void Foo() { }
141178
public void Bar() { }
142179
protected virtual void FooBar() { }
@@ -240,9 +277,9 @@ public class MyClass
240277
}
241278
```
242279

243-
## Initilize Enums.
280+
## Initialize Enums.
244281

245-
To ensure all Enum's are initialized correctly starting at 0, .NET gives you a tidy shortcut to automatically initilize the enum by just adding the first (starter) value.
282+
To ensure all Enum's are initialized correctly starting at 0, .NET gives you a tidy shortcut to automatically initialize the enum by just adding the first (starter) value.
246283

247284
> E.G. Value 1 = 0 (Remaining values are not required)
248285
@@ -303,7 +340,7 @@ public enum SDKType
303340
/// </summary>
304341
Other,
305342
/// <summary>
306-
/// The Windows 10 Mixed reality SDK provided by the Universal Windows Platform (UWP), for Immersive MR headsets and Hololens.
343+
/// The Windows 10 Mixed reality SDK provided by the Universal Windows Platform (UWP), for Immersive MR headsets and HoloLens.
307344
/// </summary>
308345
WindowsMR,
309346
/// <summary>

0 commit comments

Comments
 (0)