DDDAdvisor.CLI
1.0.4
dotnet tool install --global DDDAdvisor.CLI --version 1.0.4
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local DDDAdvisor.CLI --version 1.0.4
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DDDAdvisor.CLI&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package DDDAdvisor.CLI --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🧠 DDDAdvisor.CLI - Command-Line Tool
Comprehensive Domain-Driven Design analysis for your entire .NET solution.
DDDAdvisor.CLI is a powerful command-line tool that analyzes your entire .NET solution for DDD best practices, generates detailed reports, and calculates a DDD Health Score. Perfect for CI/CD pipelines, code reviews, and architectural assessments.
✨ Features
- 🔍 Solution-Wide Analysis - Analyze entire .NET solutions in seconds
- 📊 DDD Health Score - Get a quantifiable metric (0-100) for your DDD implementation
- 🎨 Beautiful Console Output - Gorgeous, color-coded reports powered by Spectre.Console
- 📈 Multiple Output Formats - Console, YAML, and JSON output
- ⚙️ Configurable Rules - Customize analysis via JSON configuration
- 🚀 CI/CD Ready - Exit codes and YAML output perfect for pipelines
- 📋 Detailed Reports - See every issue with file paths and line numbers
🚀 Installation
Global .NET Tool (Recommended)
dotnet tool install -g DDDAdvisor.CLI
Update Existing Installation
dotnet tool update -g DDDAdvisor.CLI
Local Tool Installation
# Install as local tool
dotnet new tool-manifest
dotnet tool install DDDAdvisor.CLI
# Run with dotnet tool
dotnet dddadvisor analyze
📖 Commands Reference
dddadvisor analyze
Analyzes a .NET solution for DDD best practices.
Syntax
dddadvisor analyze [path] [options]
Arguments
- path (optional) - Path to the solution (.sln) or project (.csproj) file
- Default: Current directory
- Examples:
dddadvisor analyze(analyzes current directory)dddadvisor analyze ./MySolution.slndddadvisor analyze C:\Projects\MyApp
Options
| Option | Alias | Description | Default |
|---|---|---|---|
--detailed |
-d |
Show detailed analysis report with all issues | false |
--output <format> |
-o |
Output format: console, yaml, or json |
console |
--config <path> |
-c |
Path to configuration file (dddadvisor.json) | Auto |
Examples
# Analyze current directory (finds .sln automatically)
dddadvisor analyze
# Analyze specific solution
dddadvisor analyze path/to/MySolution.sln
# Get detailed report with all issues
dddadvisor analyze --detailed
# Generate YAML output (for CI/CD)
dddadvisor analyze --output yaml
# Use custom configuration file
dddadvisor analyze --config custom-config.json
# Combine options
dddadvisor analyze MySolution.sln --detailed --output yaml
dddadvisor init
Creates a default configuration file in the current directory.
Syntax
dddadvisor init
What It Does
Creates a dddadvisor.json file with default settings:
{
"rules": {
"AnemicEntity": true,
"MutableValueObject": true,
"LayerDependencies": true,
"DirectRepositoryAccess": true,
"EntityExposedFromApi": true,
"LargeApplicationService": true
},
"layerMappings": {
"Domain": ".*Domain.*",
"Application": ".*Application.*",
"Infrastructure": ".*Infrastructure.*",
"Presentation": ".*API.*|.*Web.*|.*Controllers.*"
},
"failOnErrors": false,
"minimumHealthScore": 0
}
Example
cd MyProject
dddadvisor init
# Creates: MyProject/dddadvisor.json
📊 Output Examples
Standard Console Output
🧠 DDDAdvisor v1.0.3 Analysis Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 DDD Health Score: 🟡 78 / 100 (Good)
╭────────────────────────┬────────────╮
│ Metric │ Value │
├────────────────────────┼────────────┤
│ Files Analyzed │ 142 │
│ Symbols Analyzed │ 387 │
│ Execution Time │ 1,247ms │
│ Total Issues │ 15 │
│ Aggregates Detected │ 8 │
│ Value Objects Detected │ 12 │
╰────────────────────────┴────────────╯
📋 Issues by Severity
├── ✗ 1 error(s)
├── ⚠ 8 warning(s)
└── 💡 6 suggestion(s)
🔍 Top Issues:
⚠ DDD001: Anemic Entity Detected (5 occurrences)
Entity has no domain behavior (only properties).
📁 Domain/Entities/Customer.cs:12
📁 Domain/Entities/Order.cs:25
📁 Domain/Entities/Product.cs:8
📁 Domain/Entities/Invoice.cs:15
📁 Domain/Entities/Payment.cs:20
✗ DDD201: Direct Repository Access in Controller (1 occurrence)
Controller directly depends on repository 'IOrderRepository'.
📁 API/Controllers/OrdersController.cs:18
⚠ DDD202: Entity Exposed from API (2 occurrences)
Domain entity returned from API endpoint (use DTOs).
📁 API/Controllers/CustomersController.cs:32
📁 API/Controllers/ProductsController.cs:45
Detailed Report (--detailed)
🧠 DDDAdvisor v1.0.3 Detailed Analysis
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
... [Summary section same as above] ...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 All Issues (15 total)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✗ DDD201: Direct Repository Access in Controller
Severity: Error
Message: Controller 'OrdersController' directly depends on repository 'IOrderRepository'.
Use an application service layer instead.
Location: API/Controllers/OrdersController.cs:18:13
⚠ DDD001: Anemic Entity Detected
Severity: Warning
Message: Entity 'Customer' contains no domain behavior (only properties).
Add methods that encapsulate business logic.
Location: Domain/Entities/Customer.cs:12:18
⚠ DDD001: Anemic Entity Detected
Severity: Warning
Message: Entity 'Order' contains no domain behavior (only properties).
Location: Domain/Entities/Order.cs:25:18
... [continues for all issues] ...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 Recommendations
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• Add domain behavior to entities (5 entities need attention)
• Introduce application services to avoid direct repository access
• Use DTOs for API responses instead of exposing domain entities
• Consider extracting value objects where appropriate
⚙️ Configuration
Configuration File Structure
Create dddadvisor.json in your solution root:
{
"rules": {
"AnemicEntity": true,
"MutableValueObject": true,
"LayerDependencies": true,
"DirectRepositoryAccess": true,
"EntityExposedFromApi": true,
"LargeApplicationService": true
},
"severityOverrides": {
"DDD001": "Warning",
"DDD002": "Warning",
"DDD003": "Info",
"DDD101": "Error",
"DDD102": "Error",
"DDD201": "Error",
"DDD202": "Warning",
"DDD203": "Info"
},
"layerMappings": {
"Domain": ".*Domain.*",
"Application": ".*Application.*",
"Infrastructure": ".*Infrastructure.*",
"Presentation": ".*API.*|.*Web.*|.*Controllers.*"
},
"excludePaths": [
"**/obj/**",
"**/bin/**",
"**/Migrations/**",
"**/Generated/**",
"**/*.Designer.cs"
],
"failOnErrors": true,
"minimumHealthScore": 70
}
Configuration Options Explained
| Option | Type | Description |
|---|---|---|
| rules | Object | Enable/disable specific rules |
| severityOverrides | Object | Change severity levels (Error, Warning, Info) |
| layerMappings | Object | Regex patterns to identify architectural layers |
| excludePaths | Array of strings | Glob patterns for paths to exclude from analysis |
| failOnErrors | Boolean | Exit with code 1 if any errors are found |
| minimumHealthScore | Number (0-100) | Exit with code 1 if health score is below this |
Layer Mappings
Layer mappings use regular expressions to identify your architectural layers:
{
"layerMappings": {
"Domain": ".*\\.Domain(\\.|$)",
"Application": ".*\\.Application(\\.|$)",
"Infrastructure": ".*\\.(Infrastructure|Persistence|Data)(\\.|$)",
"Presentation": ".*\\.(API|Web|Controllers)(\\.|$)"
}
}
🎯 DDD Rules Reference
| Rule ID | Title | Severity | Category | Description |
|---|---|---|---|---|
| DDD001 | Anemic Entity | Warning | Domain Model | Entity with no domain behavior |
| DDD002 | Mutable Value Object | Warning | Domain Model | Value object with settable properties |
| DDD003 | Missing Aggregate Root | Info | Domain Model | Entity could be an aggregate root |
| DDD101 | Domain Depends on Infrastructure | Error | Layering | Domain layer references Infrastructure |
| DDD102 | Circular Dependency | Error | Layering | Circular reference between layers |
| DDD201 | Direct Repository Access | Error | Application | Controller accesses repository directly |
| DDD202 | Entity Exposed from API | Warning | Application | Domain entity returned from API endpoint |
| DDD203 | Large Application Service | Info | Application | Service with too many responsibilities |
📊 Understanding the Health Score
The DDD Health Score is calculated based on:
- Issue Severity - Errors penalize more than warnings
- Issue Distribution - Issues spread across many files indicate systemic problems
- Code Size - Score is normalized by solution size
- Best Practices - Rewards for proper use of aggregates, value objects, etc.
| Score Range | Rating | Description |
|---|---|---|
| 90-100 | Excellent | Exemplary DDD implementation |
| 75-89 | Good | Solid DDD practices with minor improvements |
| 60-74 | Fair | Basic DDD structure, needs attention |
| 40-59 | Poor | Significant DDD violations |
| 0-39 | Critical | Major architectural issues |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.4 | 142 | 10/11/2025 |