Open Barsonax opened 5 years ago
The ?.
operator can be used to easily add null checks to your code. Consider this duality code:
if (this.PackageLicenseAcceptRequired != null)
this.PackageLicenseAcceptRequired(this, args);
Which using the ?.
operator can also be written as:
this.PackageLicenseAcceptRequired?.Invoke(this, args);
Out variables can now be inlined. Consider this duality code:
bool agreed;
if (!this.licenseAccepted.TryGetValue(package.Name, out agreed) || !agreed)
Which can now be written like so:
if (!this.licenseAccepted.TryGetValue(package.Name, out bool agreed) || !agreed)
Summary
Now that we can use C# 7.3 we can make use of the new features. To name a few:
And many more (we had a nice list somewhere but I lost it). Some of these are currently explicitly blocked because of the
.editorconfig
. Consider changing these style rules to make use of the newer features.Documentation for the
.editorconfig
can be found here https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019Note: this issue is for discussing code style changes. These shouldn't change the meaning of the code but make it nicer to write.
Analysis