Best Practices
Building with confidence
The Dapr .NET SDK offers a rich set of capabilities for building distributed applications. This section provides practical guidance for using the SDK effectively in production scenarios—focusing on reliability, maintainability, and developer experience.
Topics covered include:
- Error handling strategies across Dapr building blocks
- Managing experimental features and suppressing related warnings
- Leveraging source analyzers and generators to reduce boilerplate and catch issues early
- Running integration tests with Dapr.Testcontainers
- General .NET development practices in Dapr-based applications
Error model guidance
Dapr operations can fail for many reasons—network issues, misconfigured components, or transient faults. The SDK provides structured error types to help you distinguish between retryable and fatal errors.
Learn how to use DaprException and its derived types effectively here.
Experimental attributes
Some SDK features are marked as experimental and may change in future releases. These are annotated with
[Experimental] and generate build-time warnings by default. You can:
- Suppress warnings selectively using
#pragma warning disable - Use
SuppressMessageattributes for finer control - Track experimental usage across your codebase
Learn more about our use of the [Experimenta] attribute here.
Source tooling
The SDK includes Roslyn-based analyzers and source generators to help you write better code with less effort. These tools:
- Warn about common misuses of the SDK
- Generate boilerplate for actor registration and invocation
- Support IDE integration for faster feedback
Read more about how to install and use these analyzers here.
Additional guidance
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.
Learn how to run integration tests with Dapr.Testcontainers here.
[Experimental] attribute
Learn more →
Testcontainers
Use Dapr.Testcontainers to run Dapr integration tests with real infrastructure
Learn more →
Roslyn Analyzers/Generators
Code analyzers and fixes for common Dapr issues
Learn more →