DeadCode 1.0.1

dotnet tool install --global DeadCode --version 1.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DeadCode --version 1.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DeadCode&version=1.0.1
                    
nuke :add-package DeadCode --version 1.0.1
                    

DeadCode

A .NET global tool that identifies unused code through static and dynamic analysis, generating LLM-ready cleanup plans.

Installation

dotnet tool install --global DeadCode

Quick Start

# Build your project
dotnet build -c Release

# Run full analysis
deadcode full --assemblies ./bin/Release/net9.0/*.dll --executable ./bin/Release/net9.0/MyApp.exe

# View the generated report
cat analysis/report.json

Features

  • Static Analysis: Extracts all methods from compiled assemblies
  • Dynamic Profiling: Captures runtime execution data using dotnet-trace
  • Safety Classification: Categorizes methods by removal safety
  • LLM-Ready Output: Generates minimal JSON optimized for AI code cleanup
  • Beautiful CLI: Rich terminal interface with progress indicators

Basic Usage

Extract method inventory

deadcode extract bin/Release/net9.0/*.dll -o inventory.json

Example inventory.json:

{
  "assemblyName": "MyApp",
  "methods": [
    {
      "id": "MyApp.Services.DataService::ProcessData(System.String)",
      "name": "ProcessData",
      "declaringType": "MyApp.Services.DataService",
      "visibility": "Public",
      "sourceLocation": {
        "file": "Services/DataService.cs",
        "line": 45
      }
    },
    {
      "id": "MyApp.Helpers.StringHelper::FormatOutput(System.String)",
      "name": "FormatOutput",
      "declaringType": "MyApp.Helpers.StringHelper",
      "visibility": "Private",
      "sourceLocation": {
        "file": "Helpers/StringHelper.cs",
        "line": 12
      }
    }
  ]
}

### Profile execution
```bash
deadcode profile MyApp.exe --args "arg1 arg2" -o traces/

Or use scenarios for comprehensive testing:

deadcode profile MyApp.exe --scenarios scenarios.json -o traces/

Example scenarios.json:

{
  "scenarios": [
    {
      "name": "basic-functionality",
      "arguments": ["--help", "--verbose"],
      "duration": 30,
      "description": "Test help and basic commands"
    },
    {
      "name": "data-processing",
      "arguments": ["process", "--input", "data.csv", "--output", "results.json"],
      "description": "Test main data processing workflow"
    },
    {
      "name": "api-endpoints",
      "arguments": ["serve", "--port", "8080"],
      "duration": 60,
      "description": "Test API server with various endpoints"
    }
  ]
}

### Analyze for unused code
```bash
deadcode analyze -i inventory.json -t traces/ -o report.json

Documentation

For detailed documentation, examples, and advanced usage, visit: https://github.com/endjin/deadcode

License

Apache License 2.0 - Copyright © 2024 Endjin Limited

Requirements

  • .NET 9.0 SDK or later
  • Windows, Linux, or macOS
Product 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.1 150 8/4/2025
1.0.0 142 8/4/2025