CleanCodeDeveloper.Analyzers 0.3.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package CleanCodeDeveloper.Analyzers --version 0.3.5                
NuGet\Install-Package CleanCodeDeveloper.Analyzers -Version 0.3.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CleanCodeDeveloper.Analyzers" Version="0.3.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CleanCodeDeveloper.Analyzers --version 0.3.5                
#r "nuget: CleanCodeDeveloper.Analyzers, 0.3.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CleanCodeDeveloper.Analyzers as a Cake Addin
#addin nuget:?package=CleanCodeDeveloper.Analyzers&version=0.3.5

// Install CleanCodeDeveloper.Analyzers as a Cake Tool
#tool nuget:?package=CleanCodeDeveloper.Analyzers&version=0.3.5                

Clean Code Developer Roslyn Analyzers

This project started as an article for the german dotnetpro[https://dotnetpro.de] magazine. It contains Roslyn Analyzers for Clean Code Developer[https://clean-code-developer.com] principles.

The current version analyzes if methods violate the IOSP: Integration Operation Segregation Principle. The principle states that a method is either an integration method or an operation. Integration methods call other methods that are defined and implemented in the solution. If one of your methods calls another of your methods its responsibility is to integrate. On the other hand an operation must not call one of your own methods. An operation calls APIs and contains expressions like "x + 2 < 42". API calls are calls to foreign methods that are not defined in your code. For example Console.WriteLine or object.ToString are API calls.

The reasoning behind the IOSP is the following: if we strictly separate integration from operation this leads to a better understanding of the code structure. This is because the abstraction level is clearly separated into high level vs. low level code. Integration methods are on a high level. They only call other methods in order to integrate them. Thus it is easy to understand such a high level integration method. On the other hand an operation is easy to read because it contains code only on a low level. Given that an operation must also conform to the SRP (Single Responsibility Principle) it is easy to read and understand an operation because it contains only low level code that solves a specific problem. In order to understand an operation it is not necessary to understand other methods from the solution. It is only necessary to understand calls to runtime or framework functionality.

The second advantage of conforming to the IOSP is testability. If we strictly separate integration from operation we can test the operations in isolation. Because operations don't call other methods from our solution every operation is a separate functional unit. Thus we don't need any mocks in order to separate an operation from its dependencies. It has no dependancies otherwise it would mix operational code with integration. The integeration methods don't contain any logic. So it is not necessary to separate the integration methods from their dependencies. The only job of the integration methods is to integrate calls to other methods. So we test the integration methods with integration tests.

Integration methods can contain control structures like foreach, for, while, if or case statements. They must not contain any expressions. It is ok to call a function that contains the expression:

if(x + 2 == 42) { ... }

vs.

if(ThisIsTheAnswer(x)) { ... }
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.4.2 167 8/15/2024
0.4.1 99 8/5/2024
0.4.0 71 8/5/2024
0.3.6 68 8/3/2024
0.3.5 112 7/30/2024
0.3.4 81 7/30/2024
0.3.3 82 7/30/2024
0.3.2 96 7/28/2024
0.3.0 119 7/8/2024
0.2.1 108 7/8/2024
0.2.0 143 4/5/2024
0.1.0 178 3/28/2024
0.0.6 1,852 10/25/2020
0.0.5 496 10/19/2020
0.0.4 475 10/3/2020
0.0.3 574 9/26/2020
0.0.2 585 9/26/2020

Integration Operation Segregation Principle (IOSP) is verified for methods