pkg
hebel/ ExxerRules.Analyzers v1.0.0 docs d <> code . compare c
Comprehensive Roslyn analyzer suite enforcing Modern Development Conventions (MDC) with 20 production-ready analyzers covering Clean Architecture, functional patterns, testing standards, performance optimization, and modern C# best practices. Includes Result<T> pattern enforcement, repository pattern validation, async/await best practices, and comprehensive testing standards compliance.
Get Started dotnet CLI PackageReference Package Manager
$ dotnet add package ExxerRules.AnalyzersReadme ExxerRules - Modern Development Conventions Analyzers
Comprehensive Roslyn analyzer suite enforcing Modern Development Conventions (MDC) with 20 production-ready analyzers.
🎯 What is ExxerRules?
ExxerRules is a comprehensive suite of Roslyn analyzers that automatically enforce Modern Development Conventions (MDC) in your C# codebase. Built using rigorous Test-Driven Development with 51/51 tests passing (100% success rate) , it covers everything from Clean Architecture boundaries to functional programming patterns.
⚡ Quick Start
Installation
<PackageReference Include="ExxerRules.Analyzers" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Immediate Benefits
✅ Automatic code quality enforcement - No more manual code reviews for standards
✅ Clean Architecture validation - Prevent architectural violations at build time
✅ Functional programming patterns - Enforce Result<T> instead of exceptions
✅ Modern testing standards - XUnit v3, Shouldly, NSubstitute enforcement
✅ Performance optimization - ConfigureAwait, efficient LINQ patterns
✅ Zero configuration - Works out of the box with sensible defaults
📊 Complete Analyzer Coverage
🧪 Testing Standards (5 analyzers)
EXXER100 TestNamingConvention Enforce Should_Action_When_Condition naming EXXER101 UseXUnitV3 Upgrade from XUnit v2 to v3 EXXER102 UseShouldly Use Shouldly instead of FluentAssertions EXXER103 UseNSubstitute Use NSubstitute instead of Moq EXXER104 DoNotMockDbContext Use InMemory provider instead of mocking EF
⚡ Functional Patterns (1 analyzer) ID Analyzer Description EXXER003 DoNotThrowExceptions Use Result<T> pattern instead of exceptions
🛡️ Null Safety (1 analyzer) ID Analyzer Description EXXER200 ValidateNullParameters Validate null parameters at method entry
🔄 Async Best Practices (2 analyzers) ID Analyzer Description EXXER300 AcceptCancellationToken Async methods should accept CancellationToken EXXER301 UseConfigureAwaitFalse Use ConfigureAwait(false) in library code
📚 Documentation (1 analyzer) ID Analyzer Description EXXER400 RequireXmlDocumentation Public members should have XML documentation
✨ Code Quality (4 analyzers) ID Analyzer Description EXXER500 AvoidMagicNumbers Use named constants instead of magic numbers EXXER501 UseExpressionBodies Use expression-bodied members where appropriate EXXER503 DoNotUseRegions Prefer sub-classes instead of regions EXXER702 UseModernPatternMatching Use declaration patterns (if (x is string s))
🏗️ Architecture (2 analyzers) ID Analyzer Description EXXER600 DomainNoInfrastructure Domain layer should not reference Infrastructure EXXER601 UseRepositoryPattern Use Repository pattern with focused interfaces
🚀 Performance (2 analyzers) ID Analyzer Description EXXER700 UseEfficientLinq Avoid multiple enumerations, use efficient patterns EXXER301 UseConfigureAwaitFalse (Covered in Async section)
📝 Logging (2 analyzers) ID Analyzer Description EXXER800 UseStructuredLogging Use structured logging with parameters EXXER801 DoNotUseConsoleWriteLine Use proper logging instead of Console.WriteLine
🎨 Code Examples
❌ Before ExxerRules // EXXER003: Throwing exceptions
public string ProcessData(string input)
{
if (string.IsNullOrEmpty(input))
throw new ArgumentException("Input cannot be null"); // ❌ Exception
return input.ToUpper();
}
// EXXER600: Architecture violation
using MyApp.Infrastructure.Data; // ❌ Domain referencing Infrastructure
namespace MyApp.Domain.Services
{
public class OrderService
{
private readonly DbContext _context; // ❌ Direct DbContext usage
}
}
// EXXER102: Wrong testing framework
[Fact]
public void TestMethod()
{
result.Should().Be("expected"); // ❌ FluentAssertions
}
✅ After ExxerRules // ✅ Result<T> pattern
public Result<string> ProcessData(string input)
{
if (string.IsNullOrEmpty(input))
return Result.Fail("Input cannot be null"); // ✅ Result<T>
return Result.Ok(input.ToUpper());
}
// ✅ Clean Architecture
using MyApp.Domain.Interfaces; // ✅ Domain referencing abstractions
namespace MyApp.Domain.Services
{
public class OrderService
{
private readonly IOrderRepository _repository; // ✅ Repository pattern
}
}
// ✅ Shouldly assertions
[Fact]
public void Should_ReturnExpectedValue_When_ValidInput()
{
result.ShouldBe("expected"); // ✅ Shouldly
}
🔧 Configuration
EditorConfig Integration # Enable all ExxerRules analyzers
[*.cs]
dotnet_analyzer_diagnostic.EXXER003.severity = error # Result<T> pattern (critical)
dotnet_analyzer_diagnostic.EXXER600.severity = error # Clean Architecture (critical)
dotnet_analyzer_diagnostic.EXXER100.severity = warning # Test naming
dotnet_analyzer_diagnostic.EXXER501.severity = suggestion # Expression bodies
MSBuild Configuration <PropertyGroup>
<!-- Treat ExxerRules warnings as errors for critical patterns -->
<WarningsAsErrors>EXXER003;EXXER600;EXXER601</WarningsAsErrors>
<!-- Customize severity levels -->
<EXXER003>error</EXXER003>
<EXXER600>error</EXXER600>
<EXXER700>warning</EXXER700>
</PropertyGroup>
🏢 Enterprise Features
Clean Architecture Enforcement
✅ Domain layer isolation
✅ Dependency direction validation
✅ Repository pattern compliance
✅ Infrastructure abstraction
Functional Programming Support
✅ Result<T> pattern enforcement
✅ Exception-free error handling
✅ Composable error flows
✅ Railway-oriented programming
Modern Testing Standards
✅ XUnit v3 migration path
✅ Shouldly assertion consistency
✅ NSubstitute mocking standards
✅ Test naming conventions
✅ EF Core testing best practices
Performance Optimization
✅ Async/await best practices
✅ LINQ efficiency patterns
✅ ConfigureAwait compliance
✅ Memory allocation awareness
📈 Benefits for Your Team Benefit Before ExxerRules After ExxerRules Code Reviews Manual standards checking Automated enforcement Architecture Violations slip through Caught at compile time Testing Inconsistent frameworks Unified modern standards Performance Runtime discovery Build-time detection Onboarding Weeks to learn standards Immediate guidance Technical Debt Accumulates over time Prevented automatically
🚀 Advanced Usage
Custom Rule Sets <ItemGroup>
<AdditionalFiles Include="exxer.ruleset" />
</ItemGroup>
CI/CD Integration - name: Build with ExxerRules
run: |
dotnet build --configuration Release \
--verbosity normal \
--property WarningsAsErrors="EXXER003;EXXER600"
Team Customization <!-- Directory.Build.props -->
<PropertyGroup>
<!-- Enable ExxerRules for entire solution -->
<EnableExxerRules>true</EnableExxerRules>
<!-- Customize for different project types -->
<EnableArchitectureRules Condition="'$(ProjectType)' == 'Domain'">true</EnableArchitectureRules>
<EnableTestingRules Condition="'$(ProjectType)' == 'Tests'">true</EnableTestingRules>
</PropertyGroup>
🤝 Contributing
Development Principles
✅ Test-Driven Development - All analyzers developed with TDD (51/51 tests passing)
✅ Clean Code - Follow the same standards we enforce
✅ Performance First - Minimal analyzer overhead
✅ Developer Experience - Clear diagnostic messages and actionable suggestions
📄 License This project is licensed under the MIT License - see the LICENSE file for details.
🎯 Support
Made with ❤️ by the ExxerAI team using Test-Driven Development
"Clean code is not written by following a set of rules. Clean code is written by professionals who care about their craft." - Robert C. Martin