DocKiller 9.2.0
dotnet add package DocKiller --version 9.2.0
NuGet\Install-Package DocKiller -Version 9.2.0
<PackageReference Include="DocKiller" Version="9.2.0" />
<PackageVersion Include="DocKiller" Version="9.2.0" />
<PackageReference Include="DocKiller" />
paket add DocKiller --version 9.2.0
#r "nuget: DocKiller, 9.2.0"
#:package DocKiller@9.2.0
#addin nuget:?package=DocKiller&version=9.2.0
#tool nuget:?package=DocKiller&version=9.2.0
DocKiller
A plug-and-play library for .NET that automatically documents method calls using attributes. DocKiller scans decorated methods and generates JSON mapping with method names, descriptions, origin classes, and call graphs.
Features
- Simple Attribute-Based Documentation: Decorate methods with
[MethodDoc]to include them in documentation - Automatic Call Graph Detection: Tracks which documented methods call other documented methods
- Hybrid Analysis: Supports both explicit call declarations (for async methods) and automatic IL-based detection (for sync methods)
- JSON Output: Generates clean, structured JSON documentation
- Cross-Layer Support: Works across all application layers (Domain, Application, Infrastructure, API)
- Zero Configuration: Just install, decorate methods, and call one extension method
Installation
Install via NuGet Package Manager:
dotnet add package DocKiller
Or via Package Manager Console:
Install-Package DocKiller
Quick Start
1. Decorate Your Methods
Add the [MethodDoc] attribute to any method you want to document:
using DocKiller.Attributes;
public class ProductService
{
[MethodDoc("Retrieves a paginated list of products from the database")]
public async Task<List<Product>> GetPaginatedProductsAsync(int page, int pageSize)
{
// Your implementation
}
}
2. Configure in Startup
In your Program.cs or startup configuration, add the documentation generation:
using DocKiller.Attributes;
var builder = WebApplication.CreateBuilder(args);
// Configure DocKiller to generate documentation
var outputPath = Path.Combine(Directory.GetCurrentDirectory(), "method-docs.json");
builder.Services.AddMethodDocumentation(outputPath);
var app = builder.Build();
app.Run();
3. Run Your Application
When your application starts, DocKiller will automatically generate a JSON file with all documented methods:
[
{
"method": "GetPaginatedProductsAsync",
"description": "Retrieves a paginated list of products from the database",
"originClass": "ProductService",
"calledMethods": []
}
]
Advanced Usage
Documenting Method Calls (Async Methods)
For async methods, use the Calls property to explicitly declare which documented methods are called:
public class ProductController : ControllerBase
{
private readonly IProductService _productService;
[MethodDoc("Returns paginated products based on filters",
Calls = new[] { "GetPaginatedProductsAsync" })]
public async Task<ActionResult<List<Product>>> GetProducts(int page, int pageSize)
{
var products = await _productService.GetPaginatedProductsAsync(page, pageSize);
return Ok(products);
}
}
public class ProductService : IProductService
{
[MethodDoc("Retrieves a paginated list of products from the database")]
public async Task<List<Product>> GetPaginatedProductsAsync(int page, int pageSize)
{
// Your implementation
}
}
This generates:
[
{
"method": "GetProducts",
"description": "Returns paginated products based on filters",
"originClass": "ProductController",
"calledMethods": ["GetPaginatedProductsAsync"]
},
{
"method": "GetPaginatedProductsAsync",
"description": "Retrieves a paginated list of products from the database",
"originClass": "ProductService",
"calledMethods": []
}
]
Synchronous Methods (Automatic Detection)
For synchronous methods, DocKiller can automatically detect calls to other documented methods via IL analysis:
public class OrderService
{
[MethodDoc("Calculates the total price of an order")]
public decimal CalculateTotal(Order order)
{
var subtotal = CalculateSubtotal(order);
var tax = CalculateTax(subtotal);
return subtotal + tax;
}
[MethodDoc("Calculates the subtotal of order items")]
public decimal CalculateSubtotal(Order order)
{
return order.Items.Sum(i => i.Price * i.Quantity);
}
[MethodDoc("Calculates tax on a given amount")]
public decimal CalculateTax(decimal amount)
{
return amount * 0.1m;
}
}
DocKiller will automatically detect that CalculateTotal calls both CalculateSubtotal and CalculateTax.
Filtering by Namespace
You can optionally filter documentation to specific namespaces:
var outputPath = Path.Combine(Directory.GetCurrentDirectory(), "method-docs.json");
builder.Services.AddMethodDocumentation(outputPath, namespaceFilter: "MyApp.Services");
How It Works
- Attribute Decoration: Methods are decorated with
[MethodDoc]attribute - Reflection Scanning: At startup, DocKiller uses reflection to find all decorated methods
- Call Analysis:
- For methods with explicit
Callsproperty: Uses the provided list - For other methods: Analyzes IL bytecode to detect method calls automatically
- For methods with explicit
- JSON Generation: Creates a structured JSON file mapping all methods and their relationships
Why DocKiller?
- Documentation as Code: Keep documentation close to implementation
- Call Graph Visualization: Understand method dependencies at a glance
- API Documentation: Generate endpoint documentation automatically
- Code Analysis: Track method usage and dependencies
- Integration Ready: JSON output can be consumed by other tools or UIs
Requirements
- .NET 9.0 or higher
- Any .NET project type (Web API, Console, Class Library, etc.)
License
MIT License - feel free to use in personal and commercial projects.
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Support
For issues, questions, or feature requests, please open an issue on the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 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. |
-
net6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.5.0)
- System.Management (>= 6.0.0)
- System.Text.Json (>= 6.0.11)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.5.0)
- System.Management (>= 6.0.0)
- System.Text.Json (>= 6.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.