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.
<PackageReference Include="DtfDeterminismAnalyzer" PrivateAssets="all" />or
dotnet add package DtfDeterminismAnalyzerThe 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();
}Press Ctrl+. (Windows) or Cmd+. (macOS) to apply automatic fixes for common violations.
| 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 |
| 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 | β |
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)
}- Visual Studio 2019+ (16.3+) and 2022
- VS Code with C# extension
- JetBrains Rider 2020.3+
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 = warningExplore working examples in the repository:
- Azure Functions Sample - Complete Azure Functions project with 40+ violations for learning
- DTF Sample - Pure Durable Task Framework implementation
We welcome contributions! See our Contributing Guidelines for details.
Development Setup:
git clone https://github.com/kokosda/dtf-determinism-analyzer.git
cd dtf-determinism-analyzerQuick start with automated script (cross-platform):
.\scripts\test-codefixes.ps1Manual setup:
dotnet build
dotnet testFor comprehensive development workflows, code fix testing, and cross-platform setup instructions, see the Local Development Guide.
- β 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
- Durable Functions Code Constraints - Microsoft Documentation
- Understanding Replay Behavior - Why determinism matters
This project is licensed under the MIT License.
Made with β€οΈ for the DTF community