dlebansais.CSharpLatest

Roslyn-based analysis of C# code to suggest the use of features in the latest version of the language


Keywords
analyzers, roslyn, roslyn-analyzers
License
0BSD
Install
Install-Package dlebansais.CSharpLatest -Version 2.1.2

Documentation

CSharpLatest

Roslyn-based analysis of C# code to suggest the use of features in the latest version of the language.

Build status codecov CodeFactor NuGet

How to install

To install this analyzer, in Visual Studio:

  • Open menu Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution. The NuGet - Solution window appears.
  • In the top right corner, make sure Package Source is selected to be either nuget.org or All.
  • Click the Browse tab and in the search prompt type CSharpLatest.
  • A list of packages appears, one one them called dlebansais.CSharpLatest.
  • Click to select this package and in the right pane check projects you want to be analyzed.
  • Click the Install button.

How to uninstall

To uninstall this analyzer, in Visual Studio:

  • Open menu Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution. The NuGet - Solution window appears.
  • Click to select the dlebansais.CSharpLatest package and in the right pane uncheck projects you no longer want to be analyzed.
  • Click the Uninstall button.

List of diagnostics

Code Diagnostic
CSL1000 Variables that are not modified should be made constants.
CSL1001 Use is null instead of == null
CSL1002 Use is not null instead of != null
CSL1003 Consider using primary contructors to simplify your code.
CSL1004 Consider using records to simplify your code.
CSL1005 Simplify one line getter.
CSL1006 Simplify one line setter.
CSL1007 Add missing braces.
CSL1008 Remove unnecessary braces.
CSL1009 FieldBackedPropertyAttribute is missing argument.
CSL1010 init accessor not supported in FieldBackedPropertyAttribute.

CSL1000: Variables that are not modified should be made constants

This diagnostic comes directly from the Roslyn Analyzer Tutorial.

CSL1001: Use is null instead of == null

Feature available since C# 7.0: is operator

CSL1002: Use is not null instead of != null

Feature available since C# 9: logical patterns

CSL1003: Consider using primary contructors to simplify your code

Feature available since C# 12: primary constructors. Superseded by IDE0290.

CSL1004: Consider using records to simplify your code

Feature available since C# 9: records

CSL1005: Simplify one line getter

Feature available since C# 6 (and extended to accessors in 7): expression body. Superseded by IDE0025 and IDE0027.

CSL1006: Simplify one line setter

Feature available since C# 7: expression body. Superseded by IDE0027.

CSL1007: Add missing braces and CSL1008: Remove unnecessary braces

Improves on rule IDE0011.

CSL1009 and CSL1010

The FieldBackedProperty attribute can be used in code conditionally compiled with and without C#13+ ('Preview') to emulate the functionality of the field keyword.