You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CodingGuidelines.md
+43-6Lines changed: 43 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ This ensures documentation is properly generated and disseminated for all all cl
38
38
39
39
## MRTK namespace rules
40
40
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.
/// 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
69
69
### Don't:
70
70
71
71
```
72
-
private Foo()
72
+
private Foo () // < - space between Foo and ()
73
73
{
74
74
if(Bar==null) // <- no space between if and ()
75
75
{
@@ -100,6 +100,31 @@ private Foo()
100
100
}
101
101
```
102
102
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
+
103
128
## Naming Conventions
104
129
105
130
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.
126
151
127
152
>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.
128
153
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
+
129
158
### Don't:
130
159
131
160
```
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
+
132
167
// No public / private access modifiers
133
168
void Foo() { }
134
169
void Bar() { }
@@ -137,6 +172,8 @@ void Bar() { }
137
172
### Do:
138
173
139
174
```
175
+
public int MyVariable { get; protected set; } = 0;
176
+
140
177
private void Foo() { }
141
178
public void Bar() { }
142
179
protected virtual void FooBar() { }
@@ -240,9 +277,9 @@ public class MyClass
240
277
}
241
278
```
242
279
243
-
## Initilize Enums.
280
+
## Initialize Enums.
244
281
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.
246
283
247
284
> E.G. Value 1 = 0 (Remaining values are not required)
248
285
@@ -303,7 +340,7 @@ public enum SDKType
303
340
/// </summary>
304
341
Other,
305
342
/// <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.
0 commit comments