1 write to ServiceType
Microsoft.Extensions.DependencyInjection.Abstractions (1)
ServiceDescriptor.cs (1)
132ServiceType = serviceType;
267 references to ServiceType
Aspire.Hosting.Testing (1)
DistributedApplicationFactory.cs (1)
393var hostDescriptor = applicationBuilder.Services.Single(s => s.ServiceType == typeof(IHost) && s.ServiceKey is null);
Aspire.Hosting.Testing.Tests (1)
ResourceLoggerForwarderServiceTests.cs (1)
24sd.ServiceType == typeof(IHostedService)
Aspire.Hosting.Tests (1)
DistributedApplicationTests.cs (1)
140var lifecycleHookDescriptors = testProgram.AppBuilder.Services.Where(sd => sd.ServiceType == typeof(IDistributedApplicationLifecycleHook));
Aspire.Microsoft.EntityFrameworkCore.Cosmos (3)
src\Components\Common\EntityFrameworkUtils.cs (3)
41var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 67oldDbContextOptionsDescriptor.ServiceType, 97var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (1)
EnrichCosmosDbTests.cs (1)
113var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Microsoft.EntityFrameworkCore.SqlServer (3)
src\Components\Common\EntityFrameworkUtils.cs (3)
41var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 67oldDbContextOptionsDescriptor.ServiceType, 97var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (5)
EnrichSqlServerTests.cs (5)
123var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 161var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 167var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 204var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 254var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL (3)
src\Components\Common\EntityFrameworkUtils.cs (3)
41var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 67oldDbContextOptionsDescriptor.ServiceType, 97var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (5)
EnrichNpgsqlTests.cs (5)
127var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 166var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 172var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 210var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 263var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Oracle.EntityFrameworkCore (3)
src\Components\Common\EntityFrameworkUtils.cs (3)
41var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 67oldDbContextOptionsDescriptor.ServiceType, 97var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Oracle.EntityFrameworkCore.Tests (5)
EnrichOracleDatabaseTests.cs (5)
124var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 162var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 168var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 205var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 255var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Aspire.Pomelo.EntityFrameworkCore.MySql (3)
src\Components\Common\EntityFrameworkUtils.cs (3)
41var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>)); 67oldDbContextOptionsDescriptor.ServiceType, 97var oldDbContextOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TContext>));
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (5)
EnrichMySqlTests.cs (5)
137var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 175var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 181var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 218var oldOptionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>)); 268var optionsDescriptor = builder.Services.FirstOrDefault(sd => sd.ServiceType == typeof(DbContextOptions<TestDbContext>));
Microsoft.AspNetCore (2)
BootstrapHostBuilder.cs (2)
26if (descriptor.ServiceType == typeof(HostBuilderContext)) 109if (descriptor.ServiceType == typeof(IHostedService))
Microsoft.AspNetCore.AsyncState.Tests (2)
AsyncStateHttpContextExtensionsTests.cs (2)
28var serviceDescriptor = services.First(x => x.ServiceType == typeof(IHttpContextAccessor)); 31serviceDescriptor = services.First(x => x.ServiceType == typeof(IAsyncContext<>));
Microsoft.AspNetCore.Authentication.Test (1)
BearerTokenTests.cs (1)
18return services.Select(d => d.ServiceType).Single(typeof(AuthenticationHandler<BearerTokenOptions>).IsAssignableFrom);
Microsoft.AspNetCore.Components.Endpoints.Tests (10)
RazorComponentsServiceCollectionExtensionsTest.cs (10)
29if (singleRegistrationServiceTypes.Contains(service.ServiceType)) 32AssertServiceCountEquals(services, service.ServiceType, 1); 37AssertAllImplementationTypesAreDistinct(services, service.ServiceType); 58if (singleRegistrationServiceTypes.Contains(service.ServiceType)) 61AssertServiceCountEquals(services, service.ServiceType, 1); 66AssertAllImplementationTypesAreDistinct(services, service.ServiceType); 80.Where(sd => !multiRegistrationServiceTypes.ContainsKey(sd.ServiceType)) 81.Select(sd => sd.ServiceType); 105var serviceDescriptors = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == serviceType); 120.Where(sd => sd.ServiceType == serviceType)
Microsoft.AspNetCore.Components.WebAssembly.Tests (1)
Hosting\WebAssemblyHostBuilderTest.cs (1)
230Assert.Single(builder.Services, d => d.ServiceType == type);
Microsoft.AspNetCore.DataProtection.Tests (2)
ServiceCollectionTests.cs (2)
61if (descriptor.ServiceType.Assembly.GetName().Name == "Microsoft.Extensions.Options") 67Assert.NotNull(services.GetService(descriptor.ServiceType));
Microsoft.AspNetCore.HeaderParsing (1)
HeaderParsingServiceCollectionExtensions.cs (1)
26if (!Throw.IfNull(services).Any(x => x.ServiceType == typeof(HeaderParsingFeature.PoolHelper)))
Microsoft.AspNetCore.Hosting.Tests (3)
WebHostBuilderTests.cs (3)
1653ServiceADescriptor = services.FirstOrDefault(s => s.ServiceType == typeof(ServiceA)); 1684var heDescriptor = services.SingleOrDefault(s => s.ServiceType == typeof(IHostingEnvironment)); 1688var wheDescriptor = services.SingleOrDefault(s => s.ServiceType == typeof(IWebHostEnvironment));
Microsoft.AspNetCore.Http.Extensions.Tests (8)
ProblemDetailsServiceCollectionExtensionsTest.cs (8)
28Assert.Single(collection, (sd) => sd.ServiceType == typeof(IProblemDetailsService) && sd.ImplementationType == typeof(ProblemDetailsService)); 29Assert.Single(collection, (sd) => sd.ServiceType == typeof(IProblemDetailsWriter) && sd.ImplementationType == typeof(DefaultProblemDetailsWriter)); 30Assert.Single(collection, (sd) => sd.ServiceType == typeof(IConfigureOptions<JsonOptions>) && sd.ImplementationType == typeof(ProblemDetailsJsonOptionsSetup)); 44Assert.Single(collection, (sd) => sd.ServiceType == typeof(IProblemDetailsService) && sd.ImplementationType == typeof(ProblemDetailsService)); 45Assert.Single(collection, (sd) => sd.ServiceType == typeof(IProblemDetailsWriter) && sd.ImplementationType == typeof(DefaultProblemDetailsWriter)); 46Assert.Single(collection, (sd) => sd.ServiceType == typeof(IConfigureOptions<JsonOptions>) && sd.ImplementationType == typeof(ProblemDetailsJsonOptionsSetup)); 62var serviceDescriptors = collection.Where(serviceDescriptor => serviceDescriptor.ServiceType == typeof(IProblemDetailsWriter)); 81var service = Assert.Single(collection, (sd) => sd.ServiceType == typeof(IProblemDetailsService));
Microsoft.AspNetCore.Identity.UI (1)
IdentityBuilderUIExtensions.cs (1)
71var environment = builder.Services.Where(d => d.ServiceType == typeof(IWebHostEnvironment)).ToArray();
Microsoft.AspNetCore.Mvc.Core (1)
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (1)
94.LastOrDefault(d => d.ServiceType == typeof(T))
Microsoft.AspNetCore.Mvc.Core.Test (12)
DependencyInjection\MvcBuilderExtensionsTest.cs (5)
98Assert.Equal(typeof(ControllerTypeA), services[0].ServiceType); 102Assert.Equal(typeof(TypeBController), services[1].ServiceType); 106Assert.Equal(typeof(IControllerActivator), services[2].ServiceType); 129Assert.Single(collection, d => d.ServiceType.Equals(typeof(ControllerOne))); 130Assert.Single(collection, d => d.ServiceType.Equals(typeof(ControllerTwo)));
DependencyInjection\MvcCoreServiceCollectionExtensionsTest.cs (7)
95if (singleRegistrationServiceTypes.Contains(service.ServiceType)) 98AssertServiceCountEquals(services, service.ServiceType, 1); 103AssertContainsSingle(services, service.ServiceType, service.ImplementationType); 223.Where(sd => !multiRegistrationServiceTypes.ContainsKey(sd.ServiceType)) 224.Select(sd => sd.ServiceType); 343var serviceDescriptors = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == serviceType); 359sd.ServiceType == serviceType &&
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
TempDataInCookiesTest.cs (1)
37var tempDataSerializers = _serviceCollection.Where(f => f.ServiceType == typeof(TempDataSerializer)).ToList();
Microsoft.AspNetCore.Mvc.Localization.Test (17)
MvcLocalizationMvcBuilderExtensionsTest.cs (8)
47sd => sd.ServiceType == typeof(IStringLocalizerFactory)); 53sd => sd.ServiceType == typeof(IStringLocalizer<>)); 60sd => sd.ServiceType == typeof(IConfigureOptions<MvcDataAnnotationsLocalizationOptions>)); 65sd => sd.ServiceType == typeof(IConfigureOptions<RazorViewEngineOptions>)); 69service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IHtmlLocalizerFactory)); 74service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IHtmlLocalizer<>)); 79service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IViewLocalizer)); 127return services.FirstOrDefault(sd => sd.ServiceType == serviceType);
MvcLocalizationMvcCoreBuilderExtensionsTest.cs (8)
47sd => sd.ServiceType == typeof(IStringLocalizerFactory)); 53sd => sd.ServiceType == typeof(IStringLocalizer<>)); 60sd => sd.ServiceType == typeof(IConfigureOptions<MvcDataAnnotationsLocalizationOptions>)); 65sd => sd.ServiceType == typeof(IConfigureOptions<RazorViewEngineOptions>)); 69service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IHtmlLocalizerFactory)); 74service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IHtmlLocalizer<>)); 79service = services.FirstOrDefault(sd => sd.ServiceType == typeof(IViewLocalizer)); 127return services.FirstOrDefault(sd => sd.ServiceType == serviceType);
MvcLocalizationServiceCollectionExtensionsTest.cs (1)
58sd.ServiceType == serviceType &&
Microsoft.AspNetCore.Mvc.NewtonsoftJson (3)
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensions.cs (3)
65f.ServiceType == typeof(IActionResultExecutor<JsonResult>) && 76f.ServiceType == typeof(TempDataSerializer) && 90f => f.ServiceType == typeof(IJsonHelper) &&
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (5)
DependencyInjection\NewtonsoftJsonMvcBuilderExtensionsTest.cs (1)
26Assert.Single(services, d => d.ServiceType == typeof(IConfigureOptions<MvcNewtonsoftJsonOptions>));
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensionsTest.cs (4)
30Assert.Single(services, d => d.ServiceType == typeof(IConfigureOptions<MvcNewtonsoftJsonOptions>)); 44var jsonHelper = Assert.Single(services, d => d.ServiceType == typeof(IJsonHelper)); 59var tempDataSerializer = Assert.Single(services, d => d.ServiceType == typeof(TempDataSerializer)); 74var jsonResultExecutor = Assert.Single(services, d => d.ServiceType == typeof(IActionResultExecutor<JsonResult>));
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (2)
DependencyInjection\RazorRuntimeCompilationMvcCoreBuilderExtensions.cs (2)
61f.ServiceType == typeof(IViewCompilerProvider) && 74f.ServiceType == typeof(IActionDescriptorProvider) &&
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (3)
DependencyInjection\RazorRuntimeCompilationMvcCoreBuilderExtensionsTest.cs (3)
25var serviceDescriptor = Assert.Single(services, service => service.ServiceType == typeof(IViewCompilerProvider)); 40var serviceDescriptor = Assert.Single(services, service => service.ServiceType == typeof(IActionDescriptorProvider)); 43serviceDescriptor = Assert.Single(services, service => service.ServiceType == typeof(MatcherPolicy));
Microsoft.AspNetCore.Mvc.Razor.Test (8)
DependencyInjection\MvcRazorMvcBuilderExtensionsTest.cs (4)
28var activatorDescriptor = Assert.Single(services.ToList(), d => d.ServiceType == typeof(ITagHelperActivator)); 54var tagHelperOne = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperOne)); 58var tagHelperTwo = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperTwo)); 62var activator = Assert.Single(collection, t => t.ServiceType == typeof(ITagHelperActivator));
DependencyInjection\MvcRazorMvcCoreBuilderExtensionsTest.cs (4)
68var activatorDescriptor = Assert.Single(services.ToList(), d => d.ServiceType == typeof(ITagHelperActivator)); 94var tagHelperOne = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperOne)); 98var tagHelperTwo = Assert.Single(collection, t => t.ServiceType == typeof(TestTagHelperTwo)); 102var activator = Assert.Single(collection, t => t.ServiceType == typeof(ITagHelperActivator));
Microsoft.AspNetCore.Mvc.RazorPages (1)
DependencyInjection\MvcRazorPagesMvcCoreBuilderExtensions.cs (1)
95f.ServiceType == typeof(IActionDescriptorProvider) &&
Microsoft.AspNetCore.Mvc.Test (24)
MvcServiceCollectionExtensionsTest.cs (24)
240Assert.Contains(services, s => s.ServiceType == typeof(IActionInvokerProvider) && s.ImplementationType == typeof(ControllerActionInvokerProvider)); 242Assert.Contains(services, s => s.ServiceType == typeof(IApiDescriptionGroupCollectionProvider)); 244Assert.Contains(services, s => s.ServiceType == typeof(CorsAuthorizationFilter)); 246Assert.Contains(services, s => s.ServiceType == typeof(IConfigureOptions<MvcOptions>) && s.ImplementationType == typeof(MvcDataAnnotationsMvcOptionsSetup)); 248Assert.Contains(services, s => s.ServiceType == typeof(FormatFilter)); 250Assert.Contains(services, s => s.ServiceType == typeof(IHtmlHelper)); 252Assert.Contains(services, s => s.ServiceType == typeof(IRazorViewEngine)); 254Assert.Contains(services, s => s.ServiceType == typeof(CacheTagHelperMemoryCacheFactory)); 257Assert.DoesNotContain(services, s => s.ServiceType == typeof(IActionInvokerProvider) && s.ImplementationType == typeof(PageActionInvokerProvider)); 266if (singleRegistrationServiceTypes.Contains(service.ServiceType)) 269AssertServiceCountEquals(services, service.ServiceType, 1); 287AssertContainsSingle(services, service.ServiceType, service.ImplementationType); 310var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 338var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 364var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 388var descriptor = Assert.Single(services, d => d.ServiceType == typeof(ApplicationPartManager)); 418foreach (var serviceType in services.Select(d => d.ServiceType).Where(t => !t.IsGenericTypeDefinition).Distinct()) 436var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 452item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>)); 465.Where(sd => !multiRegistrationServiceTypes.ContainsKey(sd.ServiceType)) 466.Where(sd => sd.ServiceType.Assembly.FullName.Contains("Mvc")) 467.Select(sd => sd.ServiceType); 619var serviceDescriptors = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == serviceType); 636sd.ServiceType == serviceType &&
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (20)
DependencyInjection\MvcViewFeaturesMvcBuilderExtensionsTest.cs (9)
45var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 61item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>)); 74var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 90item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>)); 104var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 119var descriptor = Assert.Single(builder.Services, item => item.ServiceType == typeof(ITempDataProvider)); 145Assert.Equal(typeof(ConventionsViewComponent), collection[0].ServiceType); 149Assert.Equal(typeof(AttributeViewComponent), collection[1].ServiceType); 153Assert.Equal(typeof(IViewComponentActivator), collection[2].ServiceType);
DependencyInjection\MvcViewFeaturesMvcCoreBuilderExtensionsTest.cs (11)
23var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 38var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 55item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>)); 69var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 86item => item.ServiceType == typeof(IConfigureOptions<CookieTempDataProviderOptions>)); 101var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 117var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 133var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 149var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 165var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider)); 181var descriptor = Assert.Single(services, item => item.ServiceType == typeof(ITempDataProvider));
Microsoft.AspNetCore.OpenApi.Tests (18)
Extensions\OpenApiServiceCollectionExtensionsTests.cs (18)
38Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 39Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 40Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 72Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 73Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 74Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 105Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 106Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 107Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 138Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 139Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 140Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 160Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 161Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 162Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton); 184Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiSchemaService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 185Assert.Contains(services, sd => sd.ServiceType == typeof(OpenApiDocumentService) && sd.Lifetime == ServiceLifetime.Singleton && (string)sd.ServiceKey == documentName); 186Assert.Contains(services, sd => sd.ServiceType == typeof(IDocumentProvider) && sd.Lifetime == ServiceLifetime.Singleton);
Microsoft.AspNetCore.Tests (16)
WebApplicationTests.cs (16)
1753Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(IConfigureOptions<LoggerFactoryOptions>))); 1755Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(IWebHostEnvironment))); 1756Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(IOptionsChangeTokenSource<HostFilteringOptions>))); 1757Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(IServer))); 1758Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(EndpointDataSource))); 1773Assert.DoesNotContain(builder.Services, descriptor => descriptor.ServiceType == typeof(IConfigureOptions<LoggerFactoryOptions>)); 1774Assert.DoesNotContain(builder.Services, descriptor => descriptor.ServiceType == typeof(IOptionsChangeTokenSource<HostFilteringOptions>)); 1775Assert.DoesNotContain(builder.Services, descriptor => descriptor.ServiceType == typeof(IServer)); 1776Assert.DoesNotContain(builder.Services, descriptor => descriptor.ServiceType == typeof(EndpointDataSource)); 1779Assert.Single(builder.Services.Where(descriptor => descriptor.ServiceType == typeof(IWebHostEnvironment))); 2421Assert.Contains(builder.Services, service => service.ServiceType == typeof(HostBuilderContext)); 2422Assert.Contains(builder.Services, service => service.ServiceType == typeof(IHostApplicationLifetime)); 2423Assert.Contains(builder.Services, service => service.ServiceType == typeof(IHostLifetime)); 2424Assert.Contains(builder.Services, service => service.ServiceType == typeof(IOptions<>)); 2425Assert.Contains(builder.Services, service => service.ServiceType == typeof(ILoggerFactory)); 2426Assert.Contains(builder.Services, service => service.ServiceType == typeof(ILogger<>));
Microsoft.DotNet.Internal.DependencyInjection.Testing (2)
DependencyInjectionValidation.cs (2)
57if (IsExemptType(service.ImplementationType) || IsExemptType(service.ServiceType)) 145ServiceDescriptor parameterService = services.FirstOrDefault(s => IsMatchingServiceRegistration(s.ServiceType, p.ParameterType));
Microsoft.Extensions.AsyncState.Tests (3)
AsyncContextServiceCollectionExtensionsTests.cs (3)
29var serviceDescriptor = services.First(x => x.ServiceType == typeof(IAsyncContext<>)); 32serviceDescriptor = services.First(x => x.ServiceType == typeof(IAsyncState)); 35serviceDescriptor = services.First(x => x.ServiceType == typeof(IAsyncLocalContext<>));
Microsoft.Extensions.Caching.SqlServer.Tests (2)
SqlServerCacheServicesExtensionsTest.cs (2)
25Assert.Equal(typeof(IDistributedCache), serviceDescriptor.ServiceType); 48var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache));
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (3)
CacheServiceExtensionsTests.cs (3)
26var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache)); 45var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache)); 116var distributedCache = services.FirstOrDefault(desc => desc.ServiceType == typeof(IDistributedCache));
Microsoft.Extensions.DependencyInjection (12)
DependencyInjectionEventSource.cs (3)
209if (descriptor.ServiceType.IsGenericType) 211if (descriptor.ServiceType.IsConstructedGenericType) 242builder.Append(descriptor.ServiceType);
ServiceLookup\CallSiteFactory.cs (6)
39Type serviceType = descriptor.ServiceType; 372if (serviceIdentifier.ServiceType == descriptor.ServiceType) 384callSite = new ConstantCallSite(descriptor.ServiceType, descriptor.GetImplementationInstance()); 388callSite = new FactoryCallSite(lifetime, descriptor.ServiceType, descriptor.ImplementationFactory); 392callSite = new FactoryCallSite(lifetime, descriptor.ServiceType, serviceIdentifier.ServiceKey!, descriptor.KeyedImplementationFactory); 420serviceIdentifier.ServiceType.GetGenericTypeDefinition() == descriptor.ServiceType)
ServiceLookup\ServiceIdentifier.cs (1)
27=> new ServiceIdentifier(serviceDescriptor.ServiceKey, serviceDescriptor.ServiceType);
ServiceProvider.cs (2)
188if (descriptor.ServiceType.IsGenericType && !descriptor.ServiceType.IsConstructedGenericType)
Microsoft.Extensions.DependencyInjection.Abstractions (15)
Extensions\ServiceCollectionDescriptorExtensions.cs (11)
69if (collection[i].ServiceType == descriptor.ServiceType 437/// <see cref="ServiceDescriptor.ServiceType"/> and an implementation that does not already exist 462implementationType == descriptor.ServiceType) 467descriptor.ServiceType), 475if (service.ServiceType == descriptor.ServiceType && 489/// <see cref="ServiceDescriptor.ServiceType"/> and an implementation that does not already exist 535if (collection[i].ServiceType == descriptor.ServiceType && object.Equals(collection[i].ServiceKey, descriptor.ServiceKey)) 569if (descriptor.ServiceType == serviceType && descriptor.ServiceKey == null)
Extensions\ServiceCollectionDescriptorExtensions.Keyed.cs (1)
404if (descriptor.ServiceType == serviceType && object.Equals(descriptor.ServiceKey, serviceKey))
ServiceDescriptor.cs (3)
252string? lifetime = $"{nameof(ServiceType)}: {ServiceType} {nameof(Lifetime)}: {Lifetime} "; 1017string debugText = $@"Lifetime = {Lifetime}, ServiceType = ""{ServiceType.FullName}""";
Microsoft.Extensions.DependencyInjection.AutoActivation (10)
AutoActivationExtensions.cs (5)
317if (services.Any(d => d.ServiceType == descriptor.ServiceType && d.ServiceKey == descriptor.ServiceKey)) 328if (services.Any(d => d.ServiceType == descriptor.ServiceType && d.ServiceKey == descriptor.ServiceKey)) 334_ = services.ActivateSingleton(descriptor.ServiceType);
AutoActivationExtensions.Keyed.cs (5)
351if (services.Any(d => d.ServiceType == descriptor.ServiceType && d.ServiceKey == descriptor.ServiceKey)) 362if (services.Any(d => d.ServiceType == descriptor.ServiceType && d.ServiceKey == descriptor.ServiceKey)) 368_ = services.ActivateKeyedSingleton(descriptor.ServiceType, descriptor.ServiceKey);
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (7)
DependencyInjection\ServiceCollectionExtensionsTest.cs (7)
26Assert.Collection(services.OrderBy(s => s.ServiceType.FullName), 30Assert.Equal(typeof(HealthCheckService), actual.ServiceType); 38Assert.Equal(typeof(IHostedService), actual.ServiceType); 56Assert.Collection(services.OrderBy(s => s.ServiceType.FullName).ThenBy(s => s.ImplementationType!.FullName), 60Assert.Equal(typeof(HealthCheckService), actual.ServiceType); 68Assert.Equal(typeof(IHostedService), actual.ServiceType); 76Assert.Equal(typeof(IHostedService), actual.ServiceType);
Microsoft.Extensions.Http (3)
DependencyInjection\DefaultHttpClientBuilder.cs (1)
14var tracker = (DefaultHttpClientConfigurationTracker?)services.Single(sd => sd.ServiceType == typeof(DefaultHttpClientConfigurationTracker)).ImplementationInstance;
DependencyInjection\DefaultHttpClientBuilderServiceCollection.cs (1)
27if (item.ServiceType != typeof(IConfigureOptions<HttpClientFactoryOptions>))
DependencyInjection\HttpClientBuilderExtensions.cs (1)
788var registry = (HttpClientMappingRegistry?)services.Single(sd => sd.ServiceType == typeof(HttpClientMappingRegistry)).ImplementationInstance;
Microsoft.Extensions.Http.Polly.Tests (6)
DependencyInjection\PollyHttpClientBuilderExtensionsTest.cs (6)
518Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IPolicyRegistry<string>)); 519Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IReadOnlyPolicyRegistry<string>)); 520Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IConcurrentPolicyRegistry<string>)); 549Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IPolicyRegistry<string>)); 550Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IReadOnlyPolicyRegistry<string>)); 551Assert.Single(serviceCollection, sd => sd.ServiceType == typeof(IConcurrentPolicyRegistry<string>));
Microsoft.Extensions.Http.Resilience.Tests (1)
Resilience\HttpClientBuilderExtensionsTests.Resilience.cs (1)
54Assert.Contains(services, s => s.ServiceType == typeof(ResiliencePipelineProvider<HttpKey>));
Microsoft.Extensions.Localization.Tests (1)
LocalizationServiceCollectionExtensionsTest.cs (1)
49sd.ServiceType == serviceType &&
Microsoft.Extensions.Resilience (1)
Resilience\ResilienceServiceCollectionExtensions.cs (1)
43if (services.Any(s => s.ServiceType == typeof(ResilienceMetricsEnricher)))