File tree Expand file tree Collapse file tree 6 files changed +11
-5
lines changed
Umbraco.Cms.Api.Common/DependencyInjection
Umbraco.Cms.Api.Management/DependencyInjection
tests/Umbraco.Tests.Integration
Umbraco.Infrastructure/Persistence
Umbraco.Persistence.EFCore/Scoping Expand file tree Collapse file tree 6 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public static class UmbracoBuilderApiExtensions
1111{
1212 public static IUmbracoBuilder AddUmbracoApiOpenApiUI ( this IUmbracoBuilder builder )
1313 {
14- if ( builder . Services . Any ( x => x . ImplementationType == typeof ( OperationIdSelector ) ) )
14+ if ( builder . Services . Any ( x => ! x . IsKeyedService && x . ImplementationType == typeof ( OperationIdSelector ) ) )
1515 {
1616 return builder ;
1717 }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public static class UmbracoBuilderAuthExtensions
1717{
1818 public static IUmbracoBuilder AddUmbracoOpenIddict ( this IUmbracoBuilder builder )
1919 {
20- if ( builder . Services . Any ( x=> x . ImplementationType == typeof ( OpenIddictCleanupJob ) ) is false )
20+ if ( builder . Services . Any ( x => ! x . IsKeyedService && x . ImplementationType == typeof ( OpenIddictCleanupJob ) ) is false )
2121 {
2222 ConfigureOpenIddict ( builder ) ;
2323 }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public static IUmbracoBuilder AddUmbracoManagementApi(this IUmbracoBuilder build
2424 builder . Services . AddUnique < IConflictingRouteService , ConflictingRouteService > ( ) ;
2525 builder . AddUmbracoApiOpenApiUI ( ) ;
2626
27- if ( ! services . Any ( x => x . ImplementationType == typeof ( JsonPatchService ) ) )
27+ if ( ! services . Any ( x => ! x . IsKeyedService && x . ImplementationType == typeof ( JsonPatchService ) ) )
2828 {
2929 ModelsBuilderBuilderExtensions . AddModelsBuilder ( builder )
3030 . AddJson ( )
Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ protected void ConfigureServices(IServiceCollection services)
136136
137137 services . AddLogger ( webHostEnvironment , Configuration ) ;
138138
139+ // Register a keyed service to verify that all calls to ServiceDescriptor.ImplementationType
140+ // are guarded by checking IsKeyedService first.
141+ // Failure to check this when accessing a keyed service descriptor's ImplementationType property
142+ // throws a InvalidOperationException.
143+ services . AddKeyedSingleton < object > ( "key" ) ;
144+
139145 // Add it!
140146 var hostingEnvironment = TestHelper . GetHostingEnvironment ( ) ;
141147 var typeLoader = services . AddTypeLoader (
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ protected void SetUp()
3636
3737 protected override void ConfigureTestServices ( IServiceCollection services ) =>
3838 // SQLite + retry policy makes tests fail, we retry before throwing distributed locking timeout.
39- services . RemoveAll ( x => x . ImplementationType == typeof ( SqliteAddRetryPolicyInterceptor ) ) ;
39+ services . RemoveAll ( x => ! x . IsKeyedService && x . ImplementationType == typeof ( SqliteAddRetryPolicyInterceptor ) ) ;
4040
4141 [ Test ]
4242 public void SingleReadLockTest ( )
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public class EFCoreLockTests : UmbracoIntegrationTest
2323 protected override void ConfigureTestServices ( IServiceCollection services )
2424 {
2525 // SQLite + retry policy makes tests fail, we retry before throwing distributed locking timeout.
26- services . RemoveAll ( x => x . ImplementationType == typeof ( SqliteAddRetryPolicyInterceptor ) ) ;
26+ services . RemoveAll ( x => ! x . IsKeyedService && x . ImplementationType == typeof ( SqliteAddRetryPolicyInterceptor ) ) ;
2727
2828 // Remove all locking implementations to ensure we only use EFCoreDistributedLockingMechanisms
2929 services . RemoveAll ( x => x . ServiceType == typeof ( IDistributedLockingMechanism ) ) ;
You can’t perform that action at this time.
0 commit comments