Archon 0.1.2
dotnet add package Archon --version 0.1.2
NuGet\Install-Package Archon -Version 0.1.2
<PackageReference Include="Archon" Version="0.1.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Archon" Version="0.1.2" />
<PackageReference Include="Archon"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Archon --version 0.1.2
#r "nuget: Archon, 0.1.2"
#:package Archon@0.1.2
#addin nuget:?package=Archon&version=0.1.2
#tool nuget:?package=Archon&version=0.1.2
Archon
Roslyn analysers for enforcing architectural rules in C# projects.
Installation
dotnet add package Archon
Features
Archon provides Roslyn analysers that enforce namespace-based architectural rules:
ARCHON001: Internals Are Internal
Ensures that all types within namespaces containing .Internal are properly restricted with internal or private access modifiers. This prevents accidental exposure of internal implementation details.
- Severity: Error
- Namespace Pattern:
*.Internal*(e.g.,MyApp.Internal,MyApp.Services.Internal) - Allowed Modifiers:
internal,private,private protected - Special Handling: Nested types are exempt if their containing type is already
internalorprivate
ARCHON002: Publics Are Public
Ensures that top-level types within namespaces containing .Public are appropriately exposed with public or protected access modifiers. This enforces discoverability of your public API surface.
- Severity: Warning
- Namespace Pattern:
*.Public*(e.g.,MyApp.Public,MyApp.Api.Public) - Required Modifiers:
public,protected,protected internal - Scope: Only applies to top-level types (nested types are exempt)
Usage
Once installed, the analysers will automatically run during compilation and highlight violations in your IDE.
Configuration
Configure severity levels in your .editorconfig:
[*.cs]
# Enforce internal types in .Internal namespaces (default: error)
dotnet_diagnostic.ARCHON001.severity = error
# Enforce public types in .Public namespaces (default: warning)
dotnet_diagnostic.ARCHON002.severity = warning
Example
namespace MyApp.Internal
{
// ✅ Correct - internal type in .Internal namespace
internal class InternalService { }
// ❌ ARCHON001 violation - public type in .Internal namespace
public class PublicService { }
}
namespace MyApp.Public
{
// ✅ Correct - public type in .Public namespace
public class PublicApi { }
// ❌ ARCHON002 violation - internal type in .Public namespace
internal class InternalApi { }
}
Development
Prerequisites
- .NET 10.0 SDK or later
- (Optional)
actfor local CI/CD testing
Building
cd src
dotnet restore Archon.slnx
dotnet build Archon.slnx
Testing
cd src/Archon.Tests.Unit/bin/Release/net10.0
dotnet Archon.Tests.Unit.dll
Local CI/CD Testing
Test the CI pipeline locally:
./scripts/test-ci.sh
Test the CD pipeline locally:
./scripts/test-cd.sh
Licence
This project is licensed under the MIT Licence - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Learn more about Target Frameworks and .NET Standard.
This package has 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.