https://github.com/rafaatsouza/erosion-finder
A library to find architectural erosion across C# code
https://github.com/rafaatsouza/erosion-finder
architectural-analysis architectural-enforcement architecture csharp dotnet roslyn roslyn-analyzer
Last synced: 7 months ago
JSON representation
A library to find architectural erosion across C# code
- Host: GitHub
- URL: https://github.com/rafaatsouza/erosion-finder
- Owner: rafaatsouza
- License: mit
- Created: 2020-09-14T15:36:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-26T23:31:21.000Z (over 4 years ago)
- Last Synced: 2025-03-06T05:37:26.987Z (7 months ago)
- Topics: architectural-analysis, architectural-enforcement, architecture, csharp, dotnet, roslyn, roslyn-analyzer
- Language: C#
- Homepage:
- Size: 228 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ErosionFinder
==================================


[](https://www.nuget.org/packages/ErosionFinder/)ErosionFinder is a library to find architectural erosion across C# code; it uses the Roslyn API to navigate throught all components from some C# solution, and checks for architectural violations based on informed rules.
There is also a command-line interface, which can be viewed [here](https://github.com/rafaatsouza/erosion-finder-cli).
Installation
------------[ErosionFinder is available on NuGet](https://www.nuget.org/packages/ErosionFinder). It can be installed with:
```
Install-Package ErosionFinder
```Example
------------
```csharp
using ErosionFinder;
using ErosionFinder.Data.Models;
using Microsoft.Build.Locator;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;namespace Sample
{
static class Program
{
static Program()
{
MSBuildLocator.RegisterDefaults();
}static async Task Main(string[] args)
{
var serviceLayerRegex = new Regex(@"(TargetSolutionNamespace)(.+)(\w*(Service([s]{1})?)\b)");
var modelLayerRegex = new Regex(@"(TargetSolutionNamespace)(.+)(\w*(Model([s]{1})?)\b)");var constraints = new ArchitecturalConstraints()
{
Layers = new Dictionary()
{
{ "Services", new NamespacesRegularExpressionGrouped(serviceLayerRegex) },
{ "Models", new NamespacesRegularExpressionGrouped(modelLayerRegex) }
},
Rules = new List()
{
new ArchitecturalRule("Services", "Models", RuleOperator.OnlyCanRelate,
RelationType.ReturnByFunction, RelationType.ReceiptByMethodArgument)
}
};var solutionFilePath = @"C:\Users\MyUser\Documents\TargetSolution\TargetSolution.sln";
var result = await ErosionFinderMethods.CheckArchitecturalConformanceAsync(
solutionFilePath, constraints, default);
}
}
}
```*Icon made by [Freepik](https://www.flaticon.com/authors/freepik) from https://www.flaticon.com*