diff --git a/src/Antiforgery/test/DefaultAntiforgeryTokenStoreTest.cs b/src/Antiforgery/test/DefaultAntiforgeryTokenStoreTest.cs index d205f8efc2d9..e4af2032f52f 100644 --- a/src/Antiforgery/test/DefaultAntiforgeryTokenStoreTest.cs +++ b/src/Antiforgery/test/DefaultAntiforgeryTokenStoreTest.cs @@ -164,7 +164,7 @@ public async Task GetRequestTokens_NonFormContentType_UsesHeaderToken() httpContext.Request.Headers.Add("header-name", "header-value"); // Will not be accessed - httpContext.Request.Form = null; + httpContext.Request.Form = null!; var options = new AntiforgeryOptions { @@ -191,7 +191,7 @@ public async Task GetRequestTokens_NoHeaderToken_NonFormContentType_ReturnsNullT httpContext.Request.ContentType = "application/json"; // Will not be accessed - httpContext.Request.Form = null; + httpContext.Request.Form = null!; var options = new AntiforgeryOptions { diff --git a/src/HealthChecks/HealthChecks/test/DependencyInjection/ServiceCollectionExtensionsTest.cs b/src/HealthChecks/HealthChecks/test/DependencyInjection/ServiceCollectionExtensionsTest.cs index 4a191a365f6c..c715ce88338a 100644 --- a/src/HealthChecks/HealthChecks/test/DependencyInjection/ServiceCollectionExtensionsTest.cs +++ b/src/HealthChecks/HealthChecks/test/DependencyInjection/ServiceCollectionExtensionsTest.cs @@ -53,7 +53,7 @@ public void AddHealthChecks_RegistersPublisherService_WhenOtherHostedServicesReg services.AddHealthChecks(); // Assert - Assert.Collection(services.OrderBy(s => s.ServiceType.FullName).ThenBy(s => s.ImplementationType.FullName), + Assert.Collection(services.OrderBy(s => s.ServiceType.FullName).ThenBy(s => s.ImplementationType!.FullName), actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); diff --git a/src/Http/Http.Abstractions/test/MapPathMiddlewareTests.cs b/src/Http/Http.Abstractions/test/MapPathMiddlewareTests.cs index 7131f28bc265..6e907814d957 100644 --- a/src/Http/Http.Abstractions/test/MapPathMiddlewareTests.cs +++ b/src/Http/Http.Abstractions/test/MapPathMiddlewareTests.cs @@ -39,8 +39,8 @@ private static void UseNotImplemented(IApplicationBuilder app) [Fact] public void NullArguments_ArgumentNullException() { - var builder = new ApplicationBuilder(serviceProvider: null); - var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build(); + var builder = new ApplicationBuilder(serviceProvider: null!); + var noMiddleware = new ApplicationBuilder(serviceProvider: null!).Build(); var noOptions = new MapOptions(); Assert.Throws(() => builder.Map("/foo", configuration: null!)); Assert.Throws(() => new MapMiddleware(noMiddleware, null!)); @@ -57,7 +57,7 @@ public void NullArguments_ArgumentNullException() public async Task PathMatchFunc_BranchTaken(string matchPath, string basePath, string requestPath) { HttpContext context = CreateRequest(basePath, requestPath); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map(matchPath, UseSuccess); var app = builder.Build(); await app.Invoke(context); @@ -85,7 +85,7 @@ public async Task PathMatchFunc_BranchTaken(string matchPath, string basePath, s public async Task PathMatchAction_BranchTaken(string matchPath, string basePath, string requestPath) { HttpContext context = CreateRequest(basePath, requestPath); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map(matchPath, subBuilder => subBuilder.Run(Success)); var app = builder.Build(); await app.Invoke(context); @@ -113,7 +113,7 @@ public async Task PathMatchAction_BranchTaken(string matchPath, string basePath, public async Task PathMatchAction_BranchTaken_WithPreserveMatchedPathSegment(string matchPath, string basePath, string requestPath) { HttpContext context = CreateRequest(basePath, requestPath); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map(matchPath, true, subBuilder => subBuilder.Run(Success)); var app = builder.Build(); await app.Invoke(context); @@ -129,7 +129,7 @@ public async Task PathMatchAction_BranchTaken_WithPreserveMatchedPathSegment(str [InlineData("/foo/cho/")] public void MatchPathWithTrailingSlashThrowsException(string matchPath) { - Assert.Throws(() => new ApplicationBuilder(serviceProvider: null).Map(matchPath, map => { }).Build()); + Assert.Throws(() => new ApplicationBuilder(serviceProvider: null!).Map(matchPath, map => { }).Build()); } [Theory] @@ -143,7 +143,7 @@ public void MatchPathWithTrailingSlashThrowsException(string matchPath) public async Task PathMismatchFunc_PassedThrough(string matchPath, string basePath, string requestPath) { HttpContext context = CreateRequest(basePath, requestPath); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map(matchPath, UseNotImplemented); builder.Run(Success); var app = builder.Build(); @@ -165,7 +165,7 @@ public async Task PathMismatchFunc_PassedThrough(string matchPath, string basePa public async Task PathMismatchAction_PassedThrough(string matchPath, string basePath, string requestPath) { HttpContext context = CreateRequest(basePath, requestPath); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map(matchPath, UseNotImplemented); builder.Run(Success); var app = builder.Build(); @@ -179,7 +179,7 @@ public async Task PathMismatchAction_PassedThrough(string matchPath, string base [Fact] public async Task ChainedRoutes_Success() { - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.Map("/route1", map => { map.Map("/subroute1", UseSuccess); diff --git a/src/Http/Http.Abstractions/test/MapPredicateMiddlewareTests.cs b/src/Http/Http.Abstractions/test/MapPredicateMiddlewareTests.cs index 1765859e02b3..c83bb47bcc1d 100644 --- a/src/Http/Http.Abstractions/test/MapPredicateMiddlewareTests.cs +++ b/src/Http/Http.Abstractions/test/MapPredicateMiddlewareTests.cs @@ -48,8 +48,8 @@ private bool FalsePredicate(HttpContext context) [Fact] public void NullArguments_ArgumentNullException() { - var builder = new ApplicationBuilder(serviceProvider: null); - var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build(); + var builder = new ApplicationBuilder(serviceProvider: null!); + var noMiddleware = new ApplicationBuilder(serviceProvider: null!).Build(); var noOptions = new MapWhenOptions(); Assert.Throws(() => builder.MapWhen(null!, UseNotImplemented)); Assert.Throws(() => builder.MapWhen(NotImplementedPredicate, configuration: null!)); @@ -63,7 +63,7 @@ public void NullArguments_ArgumentNullException() public async Task PredicateTrue_BranchTaken() { HttpContext context = CreateRequest(); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.MapWhen(TruePredicate, UseSuccess); var app = builder.Build(); await app.Invoke(context); @@ -75,7 +75,7 @@ public async Task PredicateTrue_BranchTaken() public async Task PredicateTrueAction_BranchTaken() { HttpContext context = CreateRequest(); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.MapWhen(TruePredicate, UseSuccess); var app = builder.Build(); await app.Invoke(context); @@ -87,7 +87,7 @@ public async Task PredicateTrueAction_BranchTaken() public async Task PredicateFalseAction_PassThrough() { HttpContext context = CreateRequest(); - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.MapWhen(FalsePredicate, UseNotImplemented); builder.Run(Success); var app = builder.Build(); @@ -99,7 +99,7 @@ public async Task PredicateFalseAction_PassThrough() [Fact] public async Task ChainedPredicates_Success() { - var builder = new ApplicationBuilder(serviceProvider: null); + var builder = new ApplicationBuilder(serviceProvider: null!); builder.MapWhen(TruePredicate, map1 => { map1.MapWhen((Predicate)FalsePredicate, UseNotImplemented); diff --git a/src/Http/Http.Abstractions/test/UsePathBaseExtensionsTests.cs b/src/Http/Http.Abstractions/test/UsePathBaseExtensionsTests.cs index f67d23487ff7..f5724d28bc22 100644 --- a/src/Http/Http.Abstractions/test/UsePathBaseExtensionsTests.cs +++ b/src/Http/Http.Abstractions/test/UsePathBaseExtensionsTests.cs @@ -54,7 +54,7 @@ public IServiceProvider ApplicationServices set { _wrappedBuilder.ApplicationServices = value; } } - public IDictionary Properties => _wrappedBuilder.Properties; + public IDictionary Properties => _wrappedBuilder.Properties; public IFeatureCollection ServerFeatures => _wrappedBuilder.ServerFeatures; public RequestDelegate Build() => _wrappedBuilder.Build(); public IApplicationBuilder New() => _wrappedBuilder.New(); @@ -163,7 +163,7 @@ private static HttpContext CreateRequest(string pathBase, string requestPath) private static ApplicationBuilder CreateBuilder() { - return new ApplicationBuilder(serviceProvider: null); + return new ApplicationBuilder(serviceProvider: null!); } } } diff --git a/src/Http/Http.Abstractions/test/UseWhenExtensionsTests.cs b/src/Http/Http.Abstractions/test/UseWhenExtensionsTests.cs index 2173df91384f..478e592b7f85 100644 --- a/src/Http/Http.Abstractions/test/UseWhenExtensionsTests.cs +++ b/src/Http/Http.Abstractions/test/UseWhenExtensionsTests.cs @@ -111,7 +111,7 @@ private static HttpContext CreateContext() private static ApplicationBuilder CreateBuilder() { - return new ApplicationBuilder(serviceProvider: null); + return new ApplicationBuilder(serviceProvider: null!); } private static bool TruePredicate(HttpContext context)