Skip to content

Commit 0843752

Browse files
Run formatter over .NET (#87)
1 parent 44eba4e commit 0843752

9 files changed

Lines changed: 24 additions & 1 deletion

File tree

references/core/determinism.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Each Temporal SDK language provides a different level of protection against non-
8888
- TypeScript: The TypeScript SDK runs workflows in an isolated V8 sandbox, intercepting many common sources of non-determinism and replacing them automatically with deterministic variants.
8989
- Java: The Java SDK has no sandbox. Determinism is enforced by developer conventions — the SDK provides `Workflow.*` APIs as safe alternatives (e.g., `Workflow.sleep()` instead of `Thread.sleep()`), and non-determinism is only detected at replay time via `NonDeterministicException`. A static analysis tool (`temporal-workflowcheck`, beta) can catch violations at build time. Cooperative threading under a global lock eliminates the need for synchronization.
9090
- Go: The Go SDK has no runtime sandbox. Therefore, non-determinism bugs will never be immediately appararent, and are usually only observable during replay. The optional `workflowcheck` static analysis tool can be used to check for many sources of non-determinism at compile time.
91-
- .NET: The .NET SDK has no sandbox. It uses a custom TaskScheduler and a runtime EventListener to detect invalid task scheduling. Developers must use Workflow.* safe alternatives (e.g., Workflow.DelayAsync instead of Task.Delay) and avoid non-deterministic .NET Task APIs.
91+
- .NET: The .NET SDK has no sandbox. It uses a custom TaskScheduler and a runtime EventListener to detect invalid task scheduling. Developers must use `Workflow.*` safe alternatives (e.g., Workflow.DelayAsync instead of Task.Delay) and avoid non-deterministic .NET Task APIs.
9292

9393
Regardless of which SDK you are using, it is your responsibility to ensure that workflow code does not contain sources of non-determinism. Use SDK-specific tools as well as replay tests for doing so.
9494

references/dotnet/data-handling.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The .NET SDK uses data converters to serialize/deserialize workflow inputs, outp
77
## Default Data Converter
88

99
The default converter handles:
10+
1011
- `null`
1112
- `byte[]` (as binary)
1213
- `Google.Protobuf.IMessage` instances

references/dotnet/determinism-protection.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class BadWorkflow
2727
Many .NET `Task` APIs implicitly use `TaskScheduler.Default`, which breaks determinism. Here are the key rules:
2828

2929
**Do NOT use:**
30+
3031
- `Task.Run` — uses default scheduler. Use `Workflow.RunTaskAsync`.
3132
- `Task.ConfigureAwait(false)` — leaves current context. Use `ConfigureAwait(true)` or omit.
3233
- `Task.Delay` / `Task.Wait` / timeout-based `CancellationTokenSource` — uses system timers. Use `Workflow.DelayAsync` / `Workflow.WaitConditionAsync`.
@@ -36,6 +37,7 @@ Many .NET `Task` APIs implicitly use `TaskScheduler.Default`, which breaks deter
3637
- `System.Threading.Semaphore` / `SemaphoreSlim` / `Mutex` — use `Temporalio.Workflows.Semaphore` / `Mutex`.
3738

3839
**Be wary of:**
40+
3941
- Third-party libraries that implicitly use `TaskScheduler.Default`
4042
- `Dataflow` blocks and similar concurrency libraries with hidden default scheduler usage
4143

references/dotnet/dotnet.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ Temporal workflows are durable through history replay. For details on how this w
1313
## Quick Start
1414

1515
**Add Dependency:** Install the Temporal SDK NuGet package:
16+
1617
```bash
1718
dotnet add package Temporalio
1819
```
1920

2021
**Activities.cs** - Activity definitions (separate file for clarity):
22+
2123
```csharp
2224
using Temporalio.Activities;
2325

@@ -32,6 +34,7 @@ public class MyActivities
3234
```
3335

3436
**GreetingWorkflow.workflow.cs** - Workflow definition:
37+
3538
```csharp
3639
using Temporalio.Workflows;
3740

@@ -49,6 +52,7 @@ public class GreetingWorkflow
4952
```
5053

5154
**Worker (Program.cs)** - Worker setup:
55+
5256
```csharp
5357
using Temporalio.Client;
5458
using Temporalio.Worker;
@@ -69,6 +73,7 @@ await worker.ExecuteAsync();
6973
**Start the worker:** Run `dotnet run` in the worker project.
7074

7175
**Starter (Program.cs)** - Start a workflow execution:
76+
7277
```csharp
7378
using Temporalio.Client;
7479

@@ -86,19 +91,22 @@ Console.WriteLine($"Result: {result}");
8691
## Key Concepts
8792

8893
### Workflow Definition
94+
8995
- Use `[Workflow]` attribute on class
9096
- Put any state initialization logic in the constructor of your workflow class to guarantee that it happens before signals/updates arrive. If your state initialization logic requires the workflow parameters, then add the `[WorkflowInit]` attribute and parameters to your constructor.
9197
- Use `[WorkflowRun]` on the async entry point method
9298
- Must return `Task` or `Task<T>`
9399
- Use `[WorkflowSignal]`, `[WorkflowQuery]`, `[WorkflowUpdate]` for handlers
94100

95101
### Activity Definition
102+
96103
- Use `[Activity]` attribute on methods
97104
- Can be sync or async
98105
- Instance methods support dependency injection
99106
- Static methods are also supported
100107

101108
### Worker Setup
109+
102110
- Connect client, create `TemporalWorker` with workflows and activities
103111
- Use `AddWorkflow<T>()` and `AddAllActivities(instance)` or `AddActivity(method)`
104112

@@ -181,6 +189,7 @@ See `references/dotnet/testing.md` for info on writing tests.
181189
## Additional Resources
182190

183191
### Reference Files
192+
184193
- **`references/dotnet/patterns.md`** — Signals, queries, child workflows, saga pattern, etc.
185194
- **`references/dotnet/determinism.md`** — Essentials of determinism in .NET
186195
- **`references/dotnet/gotchas.md`** — .NET-specific mistakes and anti-patterns

references/dotnet/gotchas.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public class GoodWorkflow
174174
### Not Handling Activity Cancellation
175175

176176
Activities must **opt in** to receive cancellation. This requires:
177+
177178
1. **Heartbeating**Cancellation is delivered via heartbeat
178179
2. **Checking the cancellation token** — Token is triggered when heartbeat detects cancellation
179180

references/dotnet/observability.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class MyWorkflow
3030
```
3131

3232
The workflow logger automatically:
33+
3334
- Suppresses duplicate logs during replay
3435
- Includes workflow context (workflow ID, run ID, etc.)
3536

references/dotnet/patterns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,12 @@ public class HandlerAwareWorkflow
425425
## Activity Heartbeat Details
426426

427427
### WHY:
428+
428429
- **Support activity cancellation** — Cancellations are delivered via heartbeat; activities that don't heartbeat won't know they've been cancelled
429430
- **Resume progress after worker failure** — Heartbeat details persist across retries
430431

431432
### WHEN:
433+
432434
- **Cancellable activities** — Any activity that should respond to cancellation
433435
- **Long-running activities** — Track progress for resumability
434436
- **Checkpointing** — Save progress periodically

references/dotnet/testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public async Task TestActivity()
161161
```
162162

163163
The `ActivityEnvironment` provides:
164+
164165
- `Info` — Activity info, defaulted to basic values
165166
- `CancellationTokenSource` — Token source for issuing cancellation
166167
- `Heartbeater` — Callback invoked each heartbeat

references/dotnet/versioning.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ShippingWorkflow
3434
```
3535

3636
**How it works:**
37+
3738
- For new executions: `Patched()` returns `true` and records a marker in the Workflow history
3839
- For replay with the marker: `Patched()` returns `true` (history includes this patch)
3940
- For replay without the marker: `Patched()` returns `false` (history predates this patch)
@@ -207,6 +208,7 @@ var worker = new TemporalWorker(
207208
```
208209

209210
**Configuration parameters:**
211+
210212
- `UseWorkerVersioning`: Enables Worker Versioning
211213
- `DeploymentOptions`: Identifies the Worker Deployment Version (deployment name + build ID)
212214
- Build ID: Typically a git commit hash, version number, or timestamp
@@ -223,6 +225,7 @@ public class StableWorkflow { /* ... */ }
223225
```
224226

225227
**When to use PINNED:**
228+
226229
- Short-running workflows (minutes to hours)
227230
- Consistency is critical (e.g., financial transactions)
228231
- You want to eliminate version compatibility complexity
@@ -238,6 +241,7 @@ public class UpgradableWorkflow { /* ... */ }
238241
```
239242

240243
**When to use AUTO_UPGRADE:**
244+
241245
- Long-running workflows (weeks or months)
242246
- Workflows need to benefit from bug fixes during execution
243247
- Migrating from traditional rolling deployments
@@ -269,6 +273,7 @@ var worker = new TemporalWorker(
269273
**Blue-Green Deployments**
270274

271275
Maintain two environments and switch traffic between them:
276+
272277
1. Deploy new code to idle environment
273278
2. Run tests and validation
274279
3. Switch traffic to new environment
@@ -277,6 +282,7 @@ Maintain two environments and switch traffic between them:
277282
**Rainbow Deployments**
278283

279284
Multiple versions run simultaneously:
285+
280286
- New workflows use latest version
281287
- Existing workflows complete on their original version
282288
- Add new versions alongside existing ones

0 commit comments

Comments
 (0)