Softeq / dotnet-guidelines

A set of coding guidelines for C#, design principles, and layout rules.
Other
13 stars 1 forks source link

Support coding guidelines for C# 8.0 #11

Open wcoder opened 4 years ago

wcoder commented 4 years ago

https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8

oleg-zaitsev commented 4 years ago

@wcoder, I think we allow using all the features by default or you mean something else?

wcoder commented 4 years ago

I mean these topics:

Switch expressions

formatting

return o switch
{
    Point p when p.X == 0 && p.Y == 0 => "origin",
    Point p                           => $"({p.X}, {p.Y})",
    _                                 => "unknown"
};

Deconstruction

(int x, int y) = GetPoint();

or

var (x, y) = GetPoint();

Using

using var reader = new StringReader(...);
// ...

or

using (var reader = new StringReader(...))
{
    // ...
}

Nullable

Can be a lot of discussion about using Nullable reference types

...

smolyakoff commented 4 years ago

I can add that in our back-end team 2 out of 3 developers prefer to avoid new using declaration syntax. So it makes sense to add a new rule for this.