You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By leveraging source generators, we can create a strongly-typed, fluent builder interface that encapsulates the component metadata.
For example, rather than working with untyped dictionaries, the source generator would produce metadata classes (like RedisStateMetadata) with defined properties:
Catch Errors Early: Identify misconfigurations before the application even runs.
Enforce Consistency: Ensure that every component adheres to its expected schema.
Improve Developer Experience: Provide immediate feedback through compile-time warnings or errors, reducing runtime surprises.
The goal is to offer a robust, type-safe mechanism that validates the Dapr component specifications, thereby increasing reliability and reducing debugging time.
Usage example
1. Fluent Chaining
This approach uses individual fluent methods to configure each property:
Here, AddDaprRedisStateStore("myDaprRedisStateStore") initializes the configuration for a Redis state store with the provided name. The subsequent fluent methods (WithHost, WithPort, and WithPassword) configure the strongly typed RedisStateMetadata.
2. Lambda Configuration in the Method
This variant offers an overload that accepts an Action<RedisStateMetadata> for inline configuration:
In this scenario, AddDaprRedisStateStore first creates the state store resource, and then WithMetadata allows you to configure the associated metadata using a lambda expression. This approach maintains the separation of concerns while still providing a fluent and strongly typed configuration experience.
Breaking change?
Yes
Alternatives
Each of the apis would support the future generation of a WithReference API that can be used to provide a rich experience for configuring dapr components based on aspire managed resources
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
The text was updated successfully, but these errors were encountered:
We have noticed this issue has not been updated within 21 days. If there is no action on this issue in the next 14 days, we will automatically close it. You can use /stale-extend to extend the window.
Related to an existing integration?
Yes
Existing integration
Hosting.Dapr
Overview
By leveraging source generators, we can create a strongly-typed, fluent builder interface that encapsulates the component metadata.
For example, rather than working with untyped dictionaries, the source generator would produce metadata classes (like RedisStateMetadata) with defined properties:
Usage example
1. Fluent Chaining
This approach uses individual fluent methods to configure each property:
Here,
AddDaprRedisStateStore("myDaprRedisStateStore")
initializes the configuration for a Redis state store with the provided name. The subsequent fluent methods (WithHost
,WithPort
, andWithPassword
) configure the strongly typedRedisStateMetadata
.2. Lambda Configuration in the Method
This variant offers an overload that accepts an
Action<RedisStateMetadata>
for inline configuration:This API variant bundles the configuration into a single call, offering a compact way to set up the metadata.
3. WithMetadata Extension
The third approach separates the initial resource creation from metadata configuration using a dedicated
WithMetadata
method:In this scenario,
AddDaprRedisStateStore
first creates the state store resource, and thenWithMetadata
allows you to configure the associated metadata using a lambda expression. This approach maintains the separation of concerns while still providing a fluent and strongly typed configuration experience.Breaking change?
Yes
Alternatives
Each of the apis would support the future generation of a WithReference API that can be used to provide a rich experience for configuring dapr components based on aspire managed resources
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
The text was updated successfully, but these errors were encountered: