ArchRoslyn.Analyzers 0.4.0

dotnet add package ArchRoslyn.Analyzers --version 0.4.0
NuGet\Install-Package ArchRoslyn.Analyzers -Version 0.4.0
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="ArchRoslyn.Analyzers" Version="0.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArchRoslyn.Analyzers --version 0.4.0
#r "nuget: ArchRoslyn.Analyzers, 0.4.0"
#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 ArchRoslyn.Analyzers as a Cake Addin
#addin nuget:?package=ArchRoslyn.Analyzers&version=0.4.0

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

Nuget codecov

Roslyn Architecture Analyzer

The ultimate goal of this project is to augment Roslyn C# compiler with additional architecture-related rules. Unlike the more common unit-test based approach, I envision this analyzers to be a part of the main compilation process, with near-instant feedback for developer. These rules should be:

  • Fast
  • Portable
  • Configurable by the end-user

Right now project consists of only one simple analyzer, inspired by an InternalsVisibleTo attribute. If you need more advanced capabilities, you should check out ArchUnitNET or NetArchTest.

CannotBeReferencedBy attribute

This is an assembly attribute that takes one string argument with a name of assembly and forbids direct and transitive references from the specified assembly to the assembly marked with this attribute. Basically, this attribute is an antipode of InternalsVisibleTo attribute.

Usage instructions

Install ArchRoslyn.Analyzer into all your projects to enable validation of rules imposed by an attribute.

Analyzer package contains both analyzer and an attribute and it's required to install analyzer in all of your projects because of Roslyn analyzer API limitations. Diagnostic analyzers only work on a single compilation at a time, and they can't access other compilations directly. That is why we have to workaround and share state between analyzer runs for different compilation. Also this design implies that it is possible for shared state to become incoherent in case of aggressive caching of compilation in IDE. Nevertheless, for a fresh run of a dotnet build this should work fine.

List of ideas

  • Explore unit-testing lib APIs for inspiration and possible adoption as an interface for Roslyn-based rules.
  • How to expand CannotBeReferencedBy attributes to allow more generic configuration? - e.g. layers, folders, wildcards, etc.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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.0 435 6/28/2022
0.2.3 385 6/22/2022
0.2.2 372 6/22/2022
0.2.1 366 6/19/2022
0.2.0 413 6/19/2022
0.1.1 411 6/14/2022