You all know how much I like the features and capabilities that Roslyn has made available to us, primarily Analyzers and Refactorings.

Josef Pihrt has just released a Analyzer and Refactoring pack that you might find interesting. The best part? He’s released the source too… 🙂

Roslyn Tools

Roslyn-based library that offers more than 50 analyzers and more than 70 refactorings for C#.

Distribution
Source Code

Source code is available on GitHub.

Analyzers

idtitledefault severityis enabled by default
RCS1001Add braces to a statement.Infox
RCS1002Remove braces from a statement.Hiddenx
RCS1003Add braces to if-else chain.Infox
RCS1004Remove braces from if-else chain.Hiddenx
RCS1005Simplify nested using statement.Hiddenx
RCS1006Simplify else clause containing if statement.Hiddenx
RCS1007Avoid embedded statement.Warning
RCS1008Declare explicit type (when the type is not obvious).Hiddenx
RCS1009Declare explicit type in foreach (when the type is not obvious).Hiddenx
RCS1010Declare implicit type (when the type is obvious).Hiddenx
RCS1012Declare explicit type (even if the type is obvious).Hidden
RCS1013Use predefined type.Info
RCS1014Avoid implicit array creation.Infox
RCS1015Use nameof operator.Infox

…. [Click through to see the rest]

Refactorings

titlesyntaxscope
Add braces to embedded statementdo statement, else clause, fixed statement, for statement, foreach statement, if statement, lock statement, using statement, while statement
Add braces to if-else chainif-else chaintop if keyword
Add braces to switch sectionswitch section
Add braces to switch sectionsswitch statementswitch keyword
Add cast according to parameter typeargument
Add parameter nameargument
Add parameter name to each argumentargument list
Add parenthesesexpressionselected expression
Add using statementlocal declaration of type that implements IDisposable
Convert “” to string.Emptyempty string literal
Convert auto-property to property with backing fieldauto-property
Convert conditional expression to if-elseconditional expression

[click through to see the whole list]

Wondering how active Phil is in updating these?

JosefPihrt/Pihrtsoft.CodeAnalysis

image

And here’s a few more links you might find interesting:







Source link