Skip to content

Commit 6c3776f

Browse files
authored
Merge pull request #6895 from microsoft/Troy-Ferrell-patch-2
Update coding guidelines to use =>
2 parents 0344e6e + 4a3e9d1 commit 6c3776f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Documentation/Contributing/CodingGuidelines.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Always declare an access modifier for all fields, properties and methods.
171171
protected int myVariable = 0;
172172

173173
// property should have protected setter
174-
public int MyVariable { get { return myVariable; } }
174+
public int MyVariable => myVariable;
175175

176176
// No public / private access modifiers
177177
void Foo() { }
@@ -437,8 +437,24 @@ private float myValue; // <- Notice we co-located the backing field above our co
437437
/// </summary>
438438
public float MyValue
439439
{
440-
get{ return myValue; }
441-
set{ myValue = value }
440+
get => myValue;
441+
set => myValue = value;
442+
}
443+
444+
/// <summary>
445+
/// Getter/Setters not wrapping a value directly should contain documentation comments just as public functions would
446+
/// </summary>
447+
public float AbsMyValue
448+
{
449+
get
450+
{
451+
if (MyValue < 0)
452+
{
453+
return -MyValue;
454+
}
455+
456+
return MyValue
457+
}
442458
}
443459
```
444460

0 commit comments

Comments
 (0)