dapr / dapr/dotnet-sdk

`services.AddDaprClient()` should allow fluent registration

Open
#817 1 comment 1 reaction 0 assignees View on GitHub
breaking-change
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
1d 22h
Merged PRs (30d)
5

Description

## Describe the proposal

The Dapr.AspNetCore package has an extension for registering the Dapr client using `services.AddDaprClient()` [here](https://github.com/dapr/dotnet-sdk/blob/764b4d7674296b3e1c3864de80e9fe6dd2d16b0d/src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L31). Traditionally extensions like this will return the `IServiceCollection` provided so registrations can be chained:

```c#
services
.AddSingleton()
.AddTransient();
```

Unfortunately, the current method returns `void` so it cuts off the fluent registration support.

I'd like to propose changing that to return `IServiceCollection` to follow the registration conventions and allow fluent registration.

This would be a breaking API change from a binary perspective but not a source perspective - folks upgrading without recompiling would break, but if you recompile it wouldn't require any code changes. Potentially it could be scheduled for the next major release?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.