SharpDetect 2.1.0-prerelease-06
See the version list below for details.
dotnet tool install --global SharpDetect --version 2.1.0-prerelease-06
dotnet new tool-manifest
dotnet tool install --local SharpDetect --version 2.1.0-prerelease-06
#tool dotnet:?package=SharpDetect&version=2.1.0-prerelease-06&prerelease
nuke :add-package SharpDetect --version 2.1.0-prerelease-06
SharpDetect
Overview
SharpDetect is a dynamic analysis tool for .NET programs. It detects concurrency issues - data races and deadlocks. Monitoring and instrumentation support is implemented using custom profiler. Analysis is performed by plugins that evaluate runtime properties of the target program.
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 (targeting .NET 8, 9, or 10) with the following code:
// Two threads write to a shared field with no synchronization — a data race.
var thread1 = new Thread(() => { Example.Test.Field = 1; });
var thread2 = new Thread(() => { Example.Test.Field = 2; });
thread1.Start();
thread2.Start();
thread1.Join();
thread2.Join();
namespace Example
{
static class Test { public static int Field; }
}
2. Create an Analysis Configuration File
Use the sharpdetect init command to generate a configuration file:
sharpdetect init \
--plugin "FastTrack" \
--target "<path/to/YourExecutableDotNetAssembly.dll>" \
--output "AnalysisConfiguration.json"
Replace <path/to/YourExecutableDotNetAssembly.dll> with the path to your compiled assembly (e.g., bin/Debug/net10.0/MyApp.dll).
3. Run Analysis
Use the sharpdetect run command with configuration file from previous step to execute the analysis:
sharpdetect run AnalysisConfiguration.json
4. View the Report
When a data race is detected, a log message is emitted:
warn: SharpDetect.Plugins.DataRace.FastTrack.FastTrackPlugin[0]
[PID=65758] Data race on static field Example.Test.Field
Current write by thread T3:
at Program/<>c.<<Main>$>b__0_1:IL_0002
Previous write by thread T2:
at Program/<>c.<<Main>$>b__0_0:IL_0002
When the target program terminates, the path to the generated report is printed:
Report stored to file: /home/user/Workspace/SharpDetect_Report_20251223_095828.html.
Reports are self-contained HTML files. Each report includes the affected field, the racing threads and their stack frames at the point of the conflicting accesses.
Analysis Plugins
Data Race Detection — FastTrack
The FastTrack plugin detects data races using the FastTrack algorithm (Flanagan & Freund, 2009).
Supported Synchronization Primitives
System.Threading.MonitorSystem.Threading.LockSystem.Threading.SemaphoreSlimSystem.Threading.Volatile(includingvolatilefield modifier)
Supported Threading Primitives
System.Threading.ThreadSystem.Threading.Tasks.Task
Supported Memory Accesses
- Static fields (
LDSFLD,STSFLD) - Instance fields (
LDFLD,STFLD)
Usage
sharpdetect init \
--plugin "FastTrack" \
--target "<path/to/YourExecutableDotNetAssembly.dll>" \
--output "AnalysisConfiguration.json"
Known Limitations
- Memory accesses protected by unsupported primitives may be reported as false positives
- Analysis introduces overhead
Deadlock Detection
The Deadlock plugin detects deadlocks by tracking lock acquisition order across threads and identifying circular wait conditions.
Supported Synchronization Primitives
System.Threading.MonitorSystem.Threading.Lock
Supported Threading Primitives
System.Threading.Thread
Usage
sharpdetect init \
--plugin "Deadlock" \
--target "<path/to/YourExecutableDotNetAssembly.dll>" \
--output "AnalysisConfiguration.json"
Known Limitations
- Deadlocks involving unsupported primitives may not be detected
- Analysis introduces overhead
Building from Source
Prerequisites
- .NET 10 SDK
- C++20 compiler with CMake
- Platform-specific dependencies for Native AOT deployment
Build Instructions
git clone https://github.com/acizmarik/sharpdetect.git
cd sharpdetect
git submodule update --init --recursive
cd src
dotnet tool restore
dotnet cake
Platform Support
SharpDetect supports analysis of programs targeting .NET 8, 9, and 10. Supported operating systems are Windows and Linux. 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 | Versions 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. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.0 | 40 | 5/20/2026 |
| 2.1.0-prerelease-07 | 44 | 5/19/2026 |
| 2.1.0-prerelease-06 | 124 | 4/26/2026 |
| 2.1.0-prerelease-05 | 119 | 3/17/2026 |
| 2.1.0-prerelease-04 | 103 | 3/9/2026 |
| 2.1.0-prerelease-03 | 103 | 3/8/2026 |
| 2.1.0-prerelease-02 | 129 | 2/2/2026 |
| 2.1.0-prerelease-01 | 120 | 1/28/2026 |
| 2.0.3 | 130 | 1/28/2026 |
| 2.0.2 | 129 | 1/10/2026 |
| 2.0.1 | 121 | 1/10/2026 |
| 2.0.0 | 131 | 1/3/2026 |
| 2.0.0-prerelease-04 | 195 | 12/23/2025 |
| 2.0.0-prerelease-03 | 201 | 12/23/2025 |
| 2.0.0-prerelease-02 | 209 | 5/28/2025 |
| 2.0.0-prerelease-01 | 192 | 4/4/2025 |