DtfDeterminismAnalyzer 1.0.1

dotnet add package DtfDeterminismAnalyzer --version 1.0.1
                    
NuGet\Install-Package DtfDeterminismAnalyzer -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DtfDeterminismAnalyzer" Version="1.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DtfDeterminismAnalyzer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DtfDeterminismAnalyzer">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DtfDeterminismAnalyzer --version 1.0.1
                    
#r "nuget: DtfDeterminismAnalyzer, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DtfDeterminismAnalyzer@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DtfDeterminismAnalyzer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DtfDeterminismAnalyzer&version=1.0.1
                    
Install as a Cake Tool

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.

NuGet Version NuGet Downloads Build Status License

🚀 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:

🤝 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

📄 License

This project is licensed under the MIT License.


Made with ❤️ for the DTF community

There are no supported framework assets in this package.

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.

Version Downloads Last Updated
1.0.1 156 10/25/2025
1.0.0 224 9/30/2025

Initial release with 10 determinism rules and automatic code fixes for DateTime, GUID, and Thread.Sleep violations.