Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5243c4a
Add .NET reference files for temporal-developer skill
donald-pinckney Mar 16, 2026
6f5e7dc
Fix .NET alignment issues from self-review
donald-pinckney Mar 16, 2026
d338213
Fix .NET correctness issues from verification pass
donald-pinckney Mar 16, 2026
d80bd35
Update supported language references to include .NET
donald-pinckney Mar 16, 2026
0114238
Edits to advanced features
donald-pinckney Apr 1, 2026
2ee9c02
edits to determinism protection, and move the .editorconfig section
donald-pinckney Apr 1, 2026
3709a85
missed one
donald-pinckney Apr 1, 2026
b41ecc6
edit determinism.md
donald-pinckney Apr 1, 2026
7ae7afb
edit error-handling.md
donald-pinckney Apr 1, 2026
4f19f25
edit gotchas.md
donald-pinckney Apr 1, 2026
c51d32b
edit patterns.md
donald-pinckney Apr 1, 2026
3aa4ce7
edit versioning.md
donald-pinckney Apr 1, 2026
2a38c83
edit observability.md
donald-pinckney Apr 1, 2026
93388e5
fix metrics
donald-pinckney Apr 1, 2026
54ce199
self-review round 1
donald-pinckney Apr 1, 2026
b4c958e
minor correctness fixed
donald-pinckney Apr 2, 2026
9be5c85
Merge branch 'main' into add-dotnet
donald-pinckney Apr 17, 2026
476f53b
Update references/dotnet/patterns.md
donald-pinckney Apr 17, 2026
58bbf52
address comments, clarify reference to earlier code snippet
donald-pinckney Apr 17, 2026
467fd27
clarify that operations are forbidden IN WORKFLOWS
donald-pinckney Apr 17, 2026
014eb91
cleanup workflow cancellation handling example
donald-pinckney Apr 17, 2026
76aa90a
add task token retrieval comment
donald-pinckney Apr 17, 2026
744cf8d
update .net requirements
donald-pinckney Apr 17, 2026
58f8972
Fix propagation of workflow cancellation
donald-pinckney Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
edit determinism.md
  • Loading branch information
donald-pinckney committed Apr 1, 2026
commit b41ecc6c3cb7fc335cc1fafa1f00629700396bbb
27 changes: 9 additions & 18 deletions references/dotnet/determinism.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

## Overview

The .NET SDK has **no sandbox** for workflow code. Determinism is enforced through developer discipline, runtime task detection via an `EventListener`, and safe API alternatives provided by the SDK.
The .NET SDK has NO runtime sandbox (unlike Python/TypeScript). Workflows must be deterministic for replay, and determinism is enforced by developer convention and runtime task detection via an `EventListener` (see `references/dotnet/determinism-protection.md`).

## Why Determinism Matters: History Replay

Temporal provides durable execution through **History Replay**. When a Worker needs to restore workflow state (after a crash, cache eviction, or to continue after a long timer), it re-executes the workflow code from the beginning, which requires the workflow code to be **deterministic**.

## SDK Protection

The .NET SDK uses a custom `TaskScheduler` to order workflow tasks deterministically. It also enables a runtime `EventListener` that detects when workflow code accidentally uses the default scheduler. When detected, an `InvalidWorkflowOperationException` is thrown, which "pauses" the workflow (fails the workflow task) until the code is fixed.

This is a **runtime-only** check — there is no compile-time sandbox. See `references/dotnet/determinism-protection.md` for details.
Temporal provides durable execution through **History Replay**. When a Worker restores workflow state, it re-executes workflow code from the beginning. This requires the code to be **deterministic**. See `references/core/determinism.md` for a deep explanation.

## Forbidden Operations
Comment thread
donald-pinckney marked this conversation as resolved.
Outdated

Expand Down Expand Up @@ -51,13 +45,10 @@ Use `WorkflowReplayer` to verify your code changes are compatible with existing

## Best Practices

1. Use `Workflow.UtcNow` for all time operations
2. Use `Workflow.Random` for random values
3. Use `Workflow.NewGuid()` for unique identifiers
4. Use `Workflow.DelayAsync` instead of `Task.Delay`
5. Use `Workflow.WhenAllAsync` / `Workflow.WhenAnyAsync` for task combinators
6. Never use `ConfigureAwait(false)` in workflows
7. Use `SortedDictionary` or sort before iterating collections
8. Test with replay to catch non-determinism
9. Keep workflows focused on orchestration, delegate I/O to activities
10. Use `Workflow.Logger` for replay-safe logging
1. Always use `Workflow.*` APIs instead of standard .NET equivalents (see table above)
2. Never use `ConfigureAwait(false)` in workflows
3. Use `SortedDictionary` or sort before iterating collections
4. Move all I/O operations (network, filesystem, database) into activities
5. Use `Workflow.Logger` instead of `Console.WriteLine` for replay-safe logging
6. Keep workflow code focused on orchestration; delegate non-deterministic work to activities
7. Test with replay after making changes to workflow definitions