-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
FakeNavigationManager registration changed from Singleton to Scoped #1408
Comments
If there are no reasons to keep it at scoped. But didn't we change it to scoped due to a dotnet 8 change? |
as far as I remember we did this as "mitigation" for the endless recursive loop - at least all of our tests are green (including the new NavMan test) |
Weren't there someone that raise an issue wanting this to be scoped. My brain is fried, so it could very well be it was a first attempt that was not roled back. Let's revert and push a preview and see if somebody comes calling. |
Well - our code indicates that funny bit: services.AddSingleton<FakeNavigationManager>();
services.AddScoped<NavigationManager>(s => s.GetRequiredService<FakeNavigationManager>()); So we can safely assume, that it doesn't matter and we can revert back :D Will make a PR. |
* fix: Make NavigationManager singleton fixes #1408 * chore: Bump Packages
@vedion There will be a |
That fixes our issue. Thank you for the fast feedback. |
Hi,
In this PR the registration of the FakeNavigationManager registration was changed from Singleton to Scoped:
8f99afa#diff-bf76c0726692846a886af9a9923c58a1d5e5828342c75002435ce77d764b902f
On the client the scope for the NavigationManager is Singleton:
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-8.0#default-services
We have Singleton services in the client where the NavigationManager is injected but now we get this error in the bUnit tests:
"System.InvalidOperationException - Cannot consume scoped service 'Microsoft.AspNetCore.Components.NavigationManager' from singleton"
Why was this changed?
Best Regards,
Anders Havn
The text was updated successfully, but these errors were encountered: