DtfDeterminismAnalyzer 1.0.1
dotnet add package DtfDeterminismAnalyzer --version 1.0.1
NuGet\Install-Package DtfDeterminismAnalyzer -Version 1.0.1
<PackageReference Include="DtfDeterminismAnalyzer" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="DtfDeterminismAnalyzer" Version="1.0.1" />
<PackageReference Include="DtfDeterminismAnalyzer"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add DtfDeterminismAnalyzer --version 1.0.1
#r "nuget: DtfDeterminismAnalyzer, 1.0.1"
#:package DtfDeterminismAnalyzer@1.0.1
#addin nuget:?package=DtfDeterminismAnalyzer&version=1.0.1
#tool nuget:?package=DtfDeterminismAnalyzer&version=1.0.1
DTF Determinism Analyzer
A production-ready Roslyn analyzer that validates Durable Task Framework (DTF) orchestration code for determinism constraints. Ensures your orchestrator functions follow replay-safe patterns required by Azure Durable Functions and Durable Task Framework.
🚀 Quick Start
Installation
<PackageReference Include="DtfDeterminismAnalyzer" PrivateAssets="all" />
or
dotnet add package DtfDeterminismAnalyzer
Automatic Detection
The analyzer automatically detects determinism violations in orchestrator functions:
Azure Durable Functions:
[FunctionName("MyOrchestrator")]
public static async Task<string> RunOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
{
var time = DateTime.Now; // ⚠️ DFA0001: Use context.CurrentUtcDateTime instead
var id = Guid.NewGuid(); // ⚠️ DFA0002: Use context.NewGuid() instead
// ✅ Corrected automatically with code fixes
var safeTime = context.CurrentUtcDateTime;
var safeId = context.NewGuid();
}
Durable Task Framework:
public static async Task<string> RunOrchestrationAsync(TaskOrchestrationContext context, string input)
{
var time = DateTime.Now; // ⚠️ DFA0001: Use context.CurrentUtcDateTime instead
var id = Guid.NewGuid(); // ⚠️ DFA0002: Use context.NewGuid() instead
// ✅ Corrected automatically with code fixes
var safeTime = context.CurrentUtcDateTime;
var safeId = context.NewGuid();
}
Code Fixes
Press Ctrl+. (Windows) or Cmd+. (macOS) to apply automatic fixes for common violations.
📖 Documentation
| Topic | Link |
|---|---|
| 📦 Installation & Setup | Installation Guide |
| 📋 All Rules & Examples | Complete Rules Documentation |
| ⚙️ Configuration | Configuration Guide |
| 🔧 Troubleshooting | Troubleshooting Guide |
| � Code Fixes | Code Fixes Guide |
| �💡 Code Examples | Complete Examples |
| 🛠️ Local Development | Local Development Guide |
✅ Supported Rules
| Rule | Description | Auto-Fix |
|---|---|---|
| DFA0001 | DateTime.Now, DateTime.UtcNow, Stopwatch | ✅ |
| DFA0002 | Guid.NewGuid() calls | ✅ |
| DFA0003 | Random without deterministic seed | ❌ |
| DFA0004 | Direct I/O operations | ❌ |
| DFA0005 | Environment variable access | ❌ |
| DFA0006 | Static mutable state access | ❌ |
| DFA0007 | Thread.Sleep and blocking operations | ✅ |
| DFA0008 | Non-durable async operations | ❌ |
| DFA0009 | Threading APIs (Task.Run, Thread) | ❌ |
| DFA0010 | Non-durable input bindings | ❌ |
🎯 Supported Frameworks
Azure Durable Functions (.NET 6+)
[FunctionName("Orchestrator")]
public static async Task<string> Run([OrchestrationTrigger] IDurableOrchestrationContext context)
Durable Task Framework (.NET Framework 4.6.1+, .NET Core 2.1+)
public class MyOrchestration : TaskOrchestration<string, string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
}
🛠️ IDE Support
- Visual Studio 2019+ (16.3+) and 2022
- VS Code with C# extension
- JetBrains Rider 2020.3+
⚙️ Quick Configuration
Create or update .editorconfig:
[*.cs]
# Critical determinism violations
dotnet_diagnostic.DFA0001.severity = error
dotnet_diagnostic.DFA0002.severity = error
dotnet_diagnostic.DFA0006.severity = error
# Important but non-breaking
dotnet_diagnostic.DFA0004.severity = warning
dotnet_diagnostic.DFA0007.severity = warning
📦 Sample Projects
Explore working examples in the repository:
- Azure Functions Sample - Complete Azure Functions project with 40+ violations for learning
- DTF Sample - Pure Durable Task Framework implementation
🤝 Contributing
We welcome contributions! See our Contributing Guidelines for details.
Development Setup:
git clone https://github.com/kokosda/dtf-determinism-analyzer.git
cd dtf-determinism-analyzer
Quick start with automated script (cross-platform):
.\scripts\test-codefixes.ps1
Manual setup:
dotnet build
dotnet test
For comprehensive development workflows, code fix testing, and cross-platform setup instructions, see the Local Development Guide.
📋 Project Status
- ✅ 200+ Unit Tests covering all analyzer rules and code fixes
- ✅ Automated CI/CD pipeline with GitHub Actions
- ✅ NuGet Package published and maintained
- ✅ Security Scanning with Dependabot and CodeQL
📚 Learn More
- Durable Functions Code Constraints - Microsoft Documentation
- Understanding Replay Behavior - Why determinism matters
📄 License
This project is licensed under the MIT License.
Made with ❤️ for the DTF community
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release with 10 determinism rules and automatic code fixes for DateTime, GUID, and Thread.Sleep violations.