Covariant THub-Parameter for IHubContext
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
Right now, the THub-Paramter of [IHubContext](https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/server/Core/src/IHubContext%60T.cs) isn't covariant what makes the following cast invalid:
```
IHubContext? concrete = null;
IHubContext, IHubClient>? loose = null;
loose = concrete;
```
I need this because I'd like to redirect the HubContext to my concrete's hub context without needing to know the concrete type for consumers:
`serviceCollection.AddSingleton, IHubClient>>(sp => sp.GetRequiredService>());`
This also maybe is a bit related to https://github.com/dotnet/aspnetcore/issues/41538? Is there a reason for not making it covariant? A soon fix would be awesome.
### Describe the solution you'd like
Quite easy: `public interface IHubContext`
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.