RapidArchitecture 0.1.0
dotnet add package RapidArchitecture --version 0.1.0
NuGet\Install-Package RapidArchitecture -Version 0.1.0
<PackageReference Include="RapidArchitecture" Version="0.1.0" />
<PackageVersion Include="RapidArchitecture" Version="0.1.0" />
<PackageReference Include="RapidArchitecture" />
paket add RapidArchitecture --version 0.1.0
#r "nuget: RapidArchitecture, 0.1.0"
#:package RapidArchitecture@0.1.0
#addin nuget:?package=RapidArchitecture&version=0.1.0
#tool nuget:?package=RapidArchitecture&version=0.1.0
RapidArchitecture - Fluent Architecture Rules for Roslyn
This package enables developers to create fluent rules for their architecture, leveraging Roslyn to generate errors, warnings, and other diagnostics. It allows you to define custom architecture rules in a clean and fluent syntax, providing feedback directly within your development environment.
Installation
Make sure to create a new project that will store your Analyzer rules. This project can look like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<RootNamespace>**REPLACE WITH YOUR ASSEMBLY NAME**</RootNamespace>
<AssemblyName>**REPLACE WITH YOUR ASSEMBLY NAME**</AssemblyName>
</PropertyGroup>
</Project>
You can install this package via NuGet:
dotnet add package RapidArchitecture
Next you can reference your newly created Analyzer project from the projects that you want to analyze. Add the following configuration to your project reference:
<ItemGroup>
<ProjectReference Include="**PATH TO PROJECT**" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
</ItemGroup>
Usage
Once installed, you can create your own architecture rules using a fluent API. You can create new rules from within an analyzer class. Here is an example of a simple rule that checks if a type name contains a specific string:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using RapidArchitecture.Analyzers.Architecture;
using RapidArchitecture.Analyzers.Builders.Extensions;
namespace Rapidata.Analyzers.Rules;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ArchitectureRules : ArchitectureAnalyzer
{
public ArchitectureRules()
{
RuleFor(Types().ImplementingInterface("IMessage"))
.Must()
.HaveNameMatching(x => x.EndsWith("Message"))
.WithMessage("Type name must end with 'Message'");
RuleFor(Types().ImplementingInterface("IEvent"))
.Must()
.HaveNameMatching(x => x.EndsWith("Event"))
.WithMessage("Type name must end with 'Event'");
}
}
Contributing
If you'd like to contribute, please feel free to submit a pull request. We welcome any improvements or suggestions.
License
This package is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.