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
I've got Microsoft.Extensions.DependencyInjection as a dependency.
When I call ServiceProvider.GetRequiredService<T>() then I get an IDE error about ambiguous extensions.
There's the standard DI:
publicstatic T GetRequiredService<T>(thisIServiceProviderprovider)whereT:notnull{
ThrowHelper.ThrowIfNull(provider);return(T)provider.GetRequiredService(typeof(T));}
And a Testing Platform one:
publicstatic TService GetRequiredService<TService>(thisIServiceProviderprovider)whereTService:notnull{
Guard.NotNull(provider);object?service=((ServiceProvider)provider).GetService(typeof(TService));
ApplicationStateGuard.Ensure(service is not null,string.Format(CultureInfo.InvariantCulture, PlatformResources.ServiceProviderCannotFindServiceErrorMessage,typeof(TService)));return(TService)service;}
Do your testing platform ones need to be public? As a quick fix would be to make them internal.
Because even if I tried to use it, it crashes with the exception:
Unhandled exception. System.InvalidCastException: Unable to cast object of type 'Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope' to type 'Microsoft.Testing.Platform.Services.ServiceProvider'.
at Microsoft.Testing.Platform.Services.ServiceProviderExtensions.GetRequiredService[TService](IServiceProvider provider) in /_/src/Platform/Microsoft.Testing.Platform/Services/ServiceProviderExtensions.cs:line 40
The text was updated successfully, but these errors were encountered:
Would it be possible to have a look at the code where this happens? Our extension class does need to be public as it is the way to access the platform service provider system but our extension class is under Microsoft.Testing.Platform.Services so there should be no confusion if you are not mixing up the 2 worlds together.
I've got Microsoft.Extensions.DependencyInjection as a dependency.
When I call
ServiceProvider.GetRequiredService<T>()
then I get an IDE error about ambiguous extensions.There's the standard DI:
And a Testing Platform one:
Do your testing platform ones need to be public? As a quick fix would be to make them internal.
Because even if I tried to use it, it crashes with the exception:
The text was updated successfully, but these errors were encountered: