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# 9.0 #15

Open wcoder opened 3 years ago

wcoder commented 3 years ago

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

Pattern matching enhancements

new

if (e is not null)
{
    // ...
}

or

if (e != null)
{
    // ...
}

Fit and finish features

new

var a = CreateA();

// ...

public A CreateA()
{
    // ...

    return new() // <-- here
    {
        Str = "some text"
    };
}

or

public A CreateA()
{
    // ...

    return new A // <-- here
    {
        Str = "some text"
    };
}

new

StringBuilder sb = new();

or

var sb = new StringBuilder();

TODO...