Skip to content

Commit 241a646

Browse files
authored
Best practice and local dev documentation updates (#1608)
* Refactored error model documentation into developer guidance section * Minor changes to developer index page * Fixed header on experimental attributes doc * Grammar tweak * Migrated into development section, fixed table to add missing version added numbers * Added missing space * Changed dev integrations title to more general dev guidance * Rearranged guidance/development docs, added new landing page for "best practices" section * Added best practices to main page --------- Signed-off-by: Whit Waldo <[email protected]>
1 parent 5afb5a2 commit 241a646

File tree

11 files changed

+143
-81
lines changed

11 files changed

+143
-81
lines changed

daprdocs/content/en/dotnet-sdk-docs/_index.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,27 @@ Put the Dapr .NET SDK to the test. Walk through the .NET quickstarts and tutoria
8686

8787
## More information
8888

89-
Learn more about local development options, or browse NuGet packages to add to your existing .NET applications.
89+
Learn more about local development options, best practices, or browse NuGet packages to add to your existing .NET
90+
applications.
9091

9192
<div class="card-deck">
9293
<div class="card">
9394
<div class="card-body">
9495
<h5 class="card-title"><b>Development</b></h5>
95-
<p class="card-text">Learn about local development options for .NET Dapr applications</p>
96-
<a href="{{% ref dotnet-development %}}" class="stretched-link"></a>
96+
<p class="card-text">Learn about local development integration options</p>
97+
<a href="{{% ref dotnet-integrations %}}" class="stretched-link"></a>
98+
</div>
99+
<div class="card">
100+
<div class="card-body">
101+
<h5 class="card-title"><b>Best Practices</b></h5>
102+
<p class="card-text">Learn about best practices for developing .NET Dapr applications</p>
103+
<a href="{{% ref dotnet-guidance %}}" class="stretched-link"></a>
97104
</div>
98105
</div>
99106
<div class="card">
100107
<div class="card-body">
101108
<h5 class="card-title"><b>NuGet packages</b></h5>
102-
<p class="card-text">Dapr packages for adding the .NET SDKs to your .NET applications.</p>
109+
<p class="card-text">NuGet packages for adding the Dapr to your .NET applications.</p>
103110
<a href="https://www.nuget.org/profiles/dapr.io" class="stretched-link"></a>
104111
</div>
105112
</div>

daprdocs/content/en/dotnet-sdk-docs/dotnet-development/_index.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

daprdocs/content/en/dotnet-sdk-docs/dotnet-error-handling/_index.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
type: docs
3+
title: "Best Practices for the Dapr .NET SDK"
4+
linkTitle: "Best Practices"
5+
weight: 85000
6+
description: Using Dapr .NET SDK effectively
7+
---
8+
9+
## Building with confidence
10+
11+
The Dapr .NET SDK offers a rich set of capabilities for building distributed applications. This section provides
12+
practical guidance for using the SDK effectively in production scenarios—focusing on reliability, maintainability, and
13+
developer experience.
14+
15+
Topics covered include:
16+
17+
- Error handling strategies across Dapr building blocks
18+
- Managing experimental features and suppressing related warnings
19+
- Leveraging source analyzers and generators to reduce boilerplate and catch issues early
20+
- General .NET development practices in Dapr-based applications
21+
22+
## Error model guidance
23+
24+
Dapr operations can fail for many reasons—network issues, misconfigured components, or transient faults. The SDK
25+
provides structured error types to help you distinguish between retryable and fatal errors.
26+
27+
Learn how to use `DaprException` and its derived types effectively [here]({{% ref dotnet-guidance-error-model.md %}}).
28+
29+
## Experimental attributes
30+
31+
Some SDK features are marked as experimental and may change in future releases. These are annotated with
32+
`[Experimental]` and generate build-time warnings by default. You can:
33+
34+
- Suppress warnings selectively using `#pragma warning disable`
35+
- Use `SuppressMessage` attributes for finer control
36+
- Track experimental usage across your codebase
37+
38+
Learn more about our use of the `[Experimenta]` attribute [here]({{% ref dotnet-guidance-experimental-attributes.md %}}).
39+
40+
## Source tooling
41+
42+
The SDK includes Roslyn-based analyzers and source generators to help you write better code with less effort. These tools:
43+
44+
- Warn about common misuses of the SDK
45+
- Generate boilerplate for actor registration and invocation
46+
- Support IDE integration for faster feedback
47+
48+
Read more about how to install and use these analyzers [here]({{% ref dotnet-guidance-source-generators.md %}}).
49+
50+
## Additional guidance
51+
52+
This section is designed to support a wide range of development scenarios. As your applications grow in complexity, you'll find increasingly relevant practices and patterns for working with Dapr in .NET—from actor lifecycle management to configuration strategies and performance tuning.
53+

daprdocs/content/en/dotnet-sdk-docs/dotnet-error-handling/dotnet-richer-error-model.md renamed to daprdocs/content/en/dotnet-sdk-docs/dotnet-guidance/dotnet-guidance-error-model.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
22
type: docs
3-
title: "Richer Error Model in the Dapr .NET SDK"
4-
linkTitle: "Richer error model"
5-
weight: 59000
3+
title: "Error Model in the Dapr .NET SDK"
4+
linkTitle: "Error Model"
5+
weight: 85100
66
description: Learn how to use the richer error model in the .NET SDK.
77
---
88

99
The Dapr .NET SDK supports the richer error model, implemented by the Dapr runtime. This model provides a way for applications to enrich their errors with added context,
10-
allowing consumers of the application to better understand the issue and resolve faster. You can read more about the richer error model [here](https://google.aip.dev/193), and you
10+
allowing consumers of the application to better understand the issue and resolve it faster. You can read more about the richer error model [here](https://google.aip.dev/193), and you
1111
can find the Dapr proto file implementing these errors [here](https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto").
1212

1313
The Dapr .NET SDK implements all details supported by the Dapr runtime, implemented in the `Dapr.Common.Exceptions` namespace, and is accessible through
14-
the `DaprException` extension method `TryGetExtendedErrorInfo`. Currently this detail extraction is only supported for
15-
`RpcException`'s where the details are present.
14+
the `DaprException` extension method `TryGetExtendedErrorInfo`. Currently, this detail extraction is only supported for
15+
`RpcException`s where the details are present.
1616

1717
```csharp
1818
// Example usage of ExtendedErrorInfo
@@ -75,7 +75,7 @@ All details implement the abstract `DaprExtendedErrorDetail` and have an associa
7575

7676
## RetryInfo
7777

78-
Information telling the client how long to wait before they should retry. Provides a `DaprRetryDelay` with the properties
78+
Information notifying the client how long to wait before they should retry. Provides a `DaprRetryDelay` with the properties
7979
`Second` (offset in seconds) and `Nano` (offset in nanoseconds).
8080

8181
## DebugInfo
@@ -91,11 +91,12 @@ a collection of `DaprQuotaFailureViolation`, which each contain a `Subject` (the
9191
## PreconditionFailure
9292

9393
Information informing the client that some required precondition was not met. Has one property `Violations`, a collection of
94-
`DaprPreconditionFailureViolation`, which each has `Subject` (subject where the precondition failure occured e.g. "Azure"), `Type` (representation of the precondition type e.g. "TermsOfService"), and `Description` (further description e.g. "ToS must be accepted.").
94+
`DaprPreconditionFailureViolation`, which each has `Subject` (subject where the precondition failure occured, e.g. "Azure"),
95+
`Type` (representation of the precondition type, e.g. "TermsOfService"), and `Description` (further description e.g. "ToS must be accepted.").
9596

9697
## RequestInfo
9798

98-
Information returned by the server that can be used by the server to identify the clients request. Contains
99+
Information returned by the server that can be used by the server to identify the client's request. Contains
99100
`RequestId` and `ServingData` properties, `RequestId` being some string (such as a UID) the server can interpret,
100101
and `ServingData` being some arbitrary data that made up part of the request.
101102

@@ -105,13 +106,13 @@ Contains a localized message, along with the locale of the message. Contains `Lo
105106

106107
## BadRequest
107108

108-
Describes a bad request field. Contains collection of `DaprBadRequestDetailFieldViolation`, which each has `Field` (the offending field in request e.g. 'first_name') and
109-
`Description` (further information detailing the reason e.g. "first_name cannot contain special characters").
109+
Describes a bad request field. Contains collection of `DaprBadRequestDetailFieldViolation`, which each has `Field` (the offending field in request, e.g. 'first_name') and
110+
`Description` (further information detailing the reason, e.g. "first_name cannot contain special characters").
110111

111112
## ErrorInfo
112113

113-
Details the cause of an error. Contains three properties, `Reason` (the reason for the error, which should take the form of UPPER_SNAKE_CASE e.g. DAPR_INVALID_KEY),
114-
`Domain` (domain the error belongs to e.g. 'dapr.io'), and `Metadata`, a key value based collection of futher information.
114+
Details the cause of an error. Contains three properties, `Reason` (the reason for the error, which should take the form of UPPER_SNAKE_CASE, e.g. DAPR_INVALID_KEY),
115+
`Domain` (domain the error belongs to, e.g. 'dapr.io'), and `Metadata`, a key/value-based collection with further information.
115116

116117
## Help
117118

@@ -121,13 +122,13 @@ which provides `Url` (a url to help or documentation), and `Description` (a desc
121122
## ResourceInfo
122123

123124
Provides information relating to an accessed resource. Provides three properties `ResourceType` (type of the resource being access e.g. "Azure service bus"),
124-
`ResourceName` (The name of the resource e.g. "my-configured-service-bus"), `Owner` (the owner of the resource e.g. "[email protected]"),
125-
and `Description` (further information on the resource relating to the error e.g. "missing permissions to use this resource").
125+
`ResourceName` (the name of the resource e.g. "my-configured-service-bus"), `Owner` (the owner of the resource e.g. "[email protected]"),
126+
and `Description` (further information on the resource relating to the error, e.g. "missing permissions to use this resource").
126127

127128
## Unknown
128129

129130
Returned when the detail type url cannot be mapped to the correct `DaprExtendedErrorDetail` implementation.
130-
Provides one property `TypeUrl` (the type url that could not be parsed e.g. "type.googleapis.com/Google.rpc.UnrecognizedType").
131+
Provides one property `TypeUrl` (the type url that could not be parsed, e.g. "type.googleapis.com/Google.rpc.UnrecognizedType").
131132

132133

133134

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
type: docs
3-
title: "Dapr .NET SDK Development with Dapr CLI"
3+
title: "Experimental Attributes"
44
linkTitle: "Experimental Attributes"
5-
weight: 61000
6-
description: Learn about local development with the Dapr CLI
5+
weight: 85200
6+
description: Learn about why we mark some methods with the `[Experimental]` attribute
77
---
88

99
## Experimental Attributes

daprdocs/content/en/dotnet-sdk-docs/dotnet-code-analysis/_index.md renamed to daprdocs/content/en/dotnet-sdk-docs/dotnet-guidance/dotnet-guidance-source-generators.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
type: docs
3-
title: "Overview of Dapr source code analysis"
4-
linkTitle: "Code Analysis"
5-
weight: 70000
3+
title: "Dapr source code analyzers and generators"
4+
linkTitle: "Roslyn Analyzers/Generators"
5+
weight: 85300
66
description: Code analyzers and fixes for common Dapr issues
77
no_list: true
88
---
@@ -13,7 +13,7 @@ from NuGet alongside each of the standard capability packages to enable these an
1313

1414
{{% alert title="Note" color="primary" %}}
1515

16-
A future release of the Dapr .NET SDK will include these analyzers by default without necessitating a separate package
16+
A future release of the Dapr .NET SDK will include these analyzers by default without requiring a separate package
1717
install.
1818

1919
{{% /alert %}}
@@ -57,19 +57,19 @@ the `EnableNETAnalyzers` property to `false` in your csproj file.
5757

5858
## Available Analyzers
5959

60-
| Diagnostic ID | Dapr Package | Category | Severity | Version Added | Description | Code Fix Available |
61-
| -- | -- |------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------| -- |
62-
| DAPR1301 | Dapr.Workflow | Usage | Warning | 1.16 | The workflow type is not registered with the dependency injection provider | Yes |
63-
| DAPR1302 | Dapr.Workflow | Usage | Warning | 1.16 | The workflow activity type is not registered with the dependency injection provider | Yes |
64-
| DAPR1401 | Dapr.Actors | Usage | Warning | 1.16 | Actor timer method invocations require the named callback method to exist on type | No |
65-
| DAPR1402 | Dapr.Actors | Usage | Warning | The actor type is not registered with dependency injection | Yes |
66-
| DAPR1403 | Dapr.Actors | Interoperability | Info | Set options.UseJsonSerialization to true to support interoperability with non-.NET actors | Yes |
67-
| DAPR1404 | Dapr.Actors | Usage | Warning | Call app.MapActorsHandlers to map endpoints for Dapr actors | Yes |
68-
| DAPR1501 | Dapr.Jobs | Usage | Warning | Job invocations require the MapDaprScheduledJobHandler to be set and configured for each anticipated job on IEndpointRouteBuilder | No |
60+
| Diagnostic ID | Dapr Package | Category | Severity | Version Added | Description | Code Fix Available |
61+
| -- | -- |------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| -- |
62+
| DAPR1301 | Dapr.Workflow | Usage | Warning | 1.16 | The workflow type is not registered with the dependency injection provider | Yes |
63+
| DAPR1302 | Dapr.Workflow | Usage | Warning | 1.16 | The workflow activity type is not registered with the dependency injection provider | Yes |
64+
| DAPR1401 | Dapr.Actors | Usage | Warning | 1.16 | Actor timer method invocations require the named callback method to exist on type | No |
65+
| DAPR1402 | Dapr.Actors | Usage | Warning | 1.16 | The actor type is not registered with dependency injection | Yes |
66+
| DAPR1403 | Dapr.Actors | Interoperability | Info | 1.16 | Set options.UseJsonSerialization to true to support interoperability with non-.NET actors | Yes |
67+
| DAPR1404 | Dapr.Actors | Usage | Warning | 1.16 | Call app.MapActorsHandlers to map endpoints for Dapr actors | Yes |
68+
| DAPR1501 | Dapr.Jobs | Usage | Warning | 1.16 | Job invocations require the MapDaprScheduledJobHandler to be set and configured for each anticipated job on IEndpointRouteBuilder | No |
6969

7070
## Analyzer Categories
7171
The following are each of the eligible categories that an analyzer can be assigned to and are modeled after the
72-
standard categories used by the.NET analyzers:
72+
standard categories used by the .NET analyzers:
7373
- Design
7474
- Documentation
7575
- Globalization

0 commit comments

Comments
 (0)