SharpDetect 2.2.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet tool install --global SharpDetect --version 2.2.0
                    
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 SharpDetect --version 2.2.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=SharpDetect&version=2.2.0
                    
nuke :add-package SharpDetect --version 2.2.0
                    

SharpDetect

License GitHub Actions NuGet Stable Version NuGet Preview Version

Overview

SharpDetect is a dynamic analysis tool for .NET applications that detects concurrency issues such as data races and deadlocks. It attaches a native CoreCLR profiler to the target process and routes runtime events through analysis plugins.

Installation

SharpDetect is distributed as a .NET Tool on NuGet:

dotnet tool install --global SharpDetect # Latest stable release
dotnet tool install --global SharpDetect --prerelease # Latest preview

Quick Start

1. Create a Program to Analyze

Create and build a new console .NET application with the following code:

// Two threads write to a shared field with no synchronization — a data race.
var t1 = new Thread(() => { Example.Test.Field = 1; });
var t2 = new Thread(() => { Example.Test.Field = 2; });

t1.Start();
t2.Start();
t1.Join();
t2.Join();

namespace Example
{
    static class Test { public static int Field; }
}

2. Run Analysis

Use the sharpdetect run command to run the analysis:

sharpdetect run \
  --target "bin/Debug/net10.0/TestApp.dll" \
  --plugin "FastTrack"

The command above launches target application, attaches profiler and configures analysis pipeline with the FastTrack plugin for data race detection.

3. View the Report

Each racy field is printed as one line while the target runs. When the target exits, a summary of the detected races and the path to the generated report are printed:

data race on Example.Test.Field: write by T2 at Program.cs:2 ↔ write by T3 at Program.cs:3

FastTrack: 1 data race in 1 field
  1. Example.Test.Field  (1 race)
     - T2  Write Program.<>c.<<Main>$>b__0_0()  Program.cs:2
       T3  Write Program.<>c.<<Main>$>b__0_1()  Program.cs:3
       1 occurrence · static field
Report: /home/user/TestApp/SharpDetect_Report_20261117_164559_335.html
Issues found.

The exit code is 5 when issues were found and 0 when none were.

Reports are self-contained HTML files. Each report includes:

  • The affected field
  • The participating threads
  • Stack traces of the conflicting accesses (or a single frame when stack-trace collection is disabled)

The same stack traces are printed to the console with -v detailed:

[PID=64385] Data race on static field Example.Test.Field
    Earlier write by thread T2:
        at Program.<>c.<<Main>$>b__0_0() in /home/user/TestApp/Program.cs:2
        at System.Threading.Thread.StartHelper.RunWorker() (+2 more)
    Later write by thread T3:
        at Program.<>c.<<Main>$>b__0_1() in /home/user/TestApp/Program.cs:3
        at System.Threading.Thread.StartHelper.RunWorker() (+2 more)

Documentation

More details for running and configuring analysis is described in docs folder.

Analysis Plugins

Data Race Detection — FastTrack

The FastTrack plugin detects data races using the FastTrack algorithm (Flanagan & Freund, 2009). See supported synchronization primitives and limitations.

Configuration

To customize instrumentation scope, generate an analysis configuration file:

sharpdetect init \
  --plugin "FastTrack" \
  --target "<path/to/YourExecutableDotNetAssembly.dll>" \
  --output "AnalysisConfiguration.json"

Deadlock Detection

The Deadlock plugin detects deadlocks by tracking lock acquisition order across threads and identifying circular wait conditions. See supported synchronization primitives and limitations.

Configuration

To customize instrumentation scope, generate an analysis configuration file:

sharpdetect init \
  --plugin "Deadlock" \
  --target "<path/to/YourExecutableDotNetAssembly.dll>" \
  --output "AnalysisConfiguration.json"

Building from Source

Prerequisites

Build Instructions

git clone https://github.com/acizmarik/sharpdetect.git
cd sharpdetect
git submodule update --init --recursive

cd src
dotnet cake.cs

Platform Support

SharpDetect supports analysis of programs targeting .NET 8, 9, and 10. Supported operating systems are Windows and Linux (glibc 2.34 or newer). Supported architecture is x64.

Acknowledgments

SharpDetect is built with the help of numerous open-source libraries and components. For detailed licensing information and full copyright notices, please see THIRD-PARTY-NOTICES.md.

License

This project is licensed under the Apache-2.0 license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
2.3.0-prerelease-01 105 11/29/2026
2.2.0 115 11/22/2026
2.2.0-prerelease-09 104 11/8/2026
2.2.0-prerelease-08 106 11/3/2026
2.2.0-prerelease-07 119 10/19/2026
2.2.0-prerelease-06 148 8/9/2026
2.2.0-prerelease-05 140 7/31/2026
2.2.0-prerelease-04 141 7/27/2026
2.2.0-prerelease-03 142 7/19/2026
2.2.0-prerelease-02 146 7/10/2026
2.2.0-prerelease-01 148 7/7/2026
2.1.4 195 7/5/2026
2.1.3 162 6/21/2026
2.1.2 150 6/14/2026
2.1.1 151 5/29/2026
2.1.0 156 5/20/2026
2.1.0-prerelease-07 151 5/19/2026
2.1.0-prerelease-06 165 4/26/2026
2.1.0-prerelease-05 173 3/17/2026
2.1.0-prerelease-04 159 3/9/2026
Loading failed