-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Covariant THub-Parameter for IHubContext #50705
Comments
More related to #30167 (comment). We added support for |
Oh wow, that actually already is a bit older. Any issues with just making it covariant? Guess that'd be the easiest solution? |
Sorry for pinging, but been a while. Any news on this? |
You're welcome to try it out and open a pull request if it works. We'd likely want a similar test to:
|
I've created this pretty simple PR right now. Seems right to me, since the not generic version has a covariant parameter, too. But actually no idea what kind of test to implement for it? And ... tbh ... Guess I (or even my machine) won't make this super huge project build within a day. |
Basically copy the test in
MethodHub , use HubT .
You could try using CodeSpaces on GitHub which would build in the cloud. |
Don't get me wrong, I really appreciate your effort helping me running this project. And maybe one day I'll become a great ASP.Net contributor ;) But Codespace won't let me choose a machine and I guess you have all that projects up and running? If you could add that requested test, I'd be super thankful :) |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
Right now, the THub-Paramter of IHubContext<THub, T> isn't covariant what makes the following cast invalid:
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<IHubContext<Hub<IHubClient>, IHubClient>>(sp => sp.GetRequiredService<IHubContext<ConcreteHub, IHubClient>>());
This also maybe is a bit related to #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<out THub, T>
Additional context
No response
The text was updated successfully, but these errors were encountered: