View on GitHub

Arnolyzer

Clean-code Roslyn-based analyzer for C# 6

Arnolyzer on nuget

Arnolyzer Analyzers

Introduction

Arnolyzer is a Roslyn-based C# code analyzer that aims to provide a set of rules that encourage modern, functional-orientated, coding standards in C#. Pure functions; no inheritance; no global state; adherence to SOLID principles; immutable variables; and short, concise sections of code.

Current Release - 1.1.0

The current release of Arnolyzer is 1.1.0, which is available as a nuget package.

This release includes the following: Modification of the analyzer names to include a code for each. This then linked in with the documentation pages.

The aim is to improve the discoverability of the analyzers for search engines, with the hope that clicking on an error in Visual Studio will take the developer to the documentation for that analyzer.

Previous Releases

Details of previous releases can be viewed at Previous releases.

Installation

For detailed instructions on how to install and configure the Arnolyzer analyzers, please refer to the installation guide.

Contributing

For details on how to contribute to the Analyzer Analyzers project, please refer to Contributing to this project.

Analyzer Categories

The Arnolyzer analyzers are grouped by category. For details on each category, the thinking behind why following the rules of each category is a good idea, and the analyzers that enforce these rules, see:

Analyzers

What’s implemented

Thus far, the analyzers implemented are:

Pure-Function Analyzers * AA1000 - Static Methods Should Not Be Void * AA1001 - Static Methods Should Have At Least One Parameter

Encapsulation Analyzers * AA1100 - Interface Properties Should Be Read-Only * AA1101 - Class Properties Should Be Publicly Read-Only * AA1102 - Inner Types Must Be Private

Liskov Substitution Principle Analyzers * AA2000 - Do Not Use Not Implemented Exception * AA2001 - Do Not Use Not Supported Exception

Single Responsibilty Analyzers * AA2100 - Method Parameters Must Not Be Ref Or Out * AA2103 - Method Should Not Contain And * AA2104 - File Must Only Contain One Type Definition

For details of each of these, please follow the respective links.

What’s planned

The following analyzers are planned for future releases of Arnolyzer, but haven’t yet been implemented:

Pure-Function Analyzers * AA1002 - Static Methods Should Not Access State * AA1003 - Static Methods Should Not Create State

Immutability Analyzers * AA1300 - Parameters Should Not Be Modified * AA1301 - Variables Should Be Assigned Once Only

Global State Analyzers * AA1200 - Avoid Using Static Fields * AA1201 - Avoid Using Static Properties

Single Responsibilty Analyzers * AA2101 - Method Too Long * AA2102 - File Too Long

In addition to this list of planned analyzers, there are two key areas of further work planned:

  1. There are situations where the code needs to violate some of these rules and so a means to suppress the rule is needed. This will be achieved via attributes. So far, very few rules take advantage of this.
  2. The are situations where simple code fixes can be offered to fix violations. This area of work hasn’t been started at all, yet.