From 3841f32f17014af4cd635af71aafc1423abf0c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 9 Sep 2020 02:41:08 +0200 Subject: [PATCH] Update the entire codebase to use is null/is not null --- .../Controllers/AccountController.cs | 20 +- .../Controllers/AuthorizationController.cs | 12 +- .../Mvc.Server/Controllers/ErrorController.cs | 2 +- .../Controllers/ManageController.cs | 24 +- .../Controllers/ResourceController.cs | 2 +- .../Controllers/UserinfoController.cs | 2 +- .../Helpers/AsyncEnumerableExtensions.cs | 2 +- samples/Mvc.Server/Worker.cs | 6 +- .../Helpers/OpenIddictHelpers.cs | 6 +- .../OpenIddictExtensions.cs | 6 +- .../Primitives/OpenIddictConverter.cs | 10 +- .../Primitives/OpenIddictExtensions.cs | 127 ++++---- .../Primitives/OpenIddictMessage.cs | 12 +- .../Primitives/OpenIddictParameter.cs | 2 +- .../Caches/OpenIddictApplicationCache.cs | 20 +- .../Caches/OpenIddictAuthorizationCache.cs | 18 +- .../Caches/OpenIddictScopeCache.cs | 20 +- .../Caches/OpenIddictTokenCache.cs | 20 +- .../Managers/OpenIddictApplicationManager.cs | 82 ++--- .../OpenIddictAuthorizationManager.cs | 62 ++-- .../Managers/OpenIddictScopeManager.cs | 70 ++-- .../Managers/OpenIddictTokenManager.cs | 78 ++--- src/OpenIddict.Core/OpenIddictCoreBuilder.cs | 50 +-- .../OpenIddictCoreExtensions.cs | 14 +- .../OpenIddictEntityFrameworkBuilder.cs | 4 +- .../OpenIddictEntityFrameworkExtensions.cs | 6 +- .../OpenIddictEntityFrameworkHelpers.cs | 4 +- ...EntityFrameworkApplicationStoreResolver.cs | 6 +- ...tityFrameworkAuthorizationStoreResolver.cs | 6 +- ...IddictEntityFrameworkScopeStoreResolver.cs | 6 +- ...IddictEntityFrameworkTokenStoreResolver.cs | 6 +- ...enIddictEntityFrameworkApplicationStore.cs | 62 ++-- ...IddictEntityFrameworkAuthorizationStore.cs | 66 ++-- .../OpenIddictEntityFrameworkScopeStore.cs | 48 +-- .../OpenIddictEntityFrameworkTokenStore.cs | 89 +++-- ...tyFrameworkCoreApplicationConfiguration.cs | 2 +- ...FrameworkCoreAuthorizationConfiguration.cs | 2 +- ...ctEntityFrameworkCoreScopeConfiguration.cs | 2 +- ...ctEntityFrameworkCoreTokenConfiguration.cs | 2 +- .../OpenIddictEntityFrameworkCoreBuilder.cs | 4 +- ...OpenIddictEntityFrameworkCoreCustomizer.cs | 4 +- ...OpenIddictEntityFrameworkCoreExtensions.cs | 6 +- .../OpenIddictEntityFrameworkCoreHelpers.cs | 6 +- ...tyFrameworkCoreApplicationStoreResolver.cs | 6 +- ...FrameworkCoreAuthorizationStoreResolver.cs | 6 +- ...ctEntityFrameworkCoreScopeStoreResolver.cs | 6 +- ...ctEntityFrameworkCoreTokenStoreResolver.cs | 6 +- ...dictEntityFrameworkCoreApplicationStore.cs | 62 ++-- ...ctEntityFrameworkCoreAuthorizationStore.cs | 54 +-- ...OpenIddictEntityFrameworkCoreScopeStore.cs | 48 +-- ...OpenIddictEntityFrameworkCoreTokenStore.cs | 74 ++--- .../OpenIddictMongoDbBuilder.cs | 4 +- .../OpenIddictMongoDbContext.cs | 4 +- .../OpenIddictMongoDbExtensions.cs | 6 +- .../OpenIddictMongoDbHelpers.cs | 4 +- ...enIddictMongoDbApplicationStoreResolver.cs | 2 +- ...IddictMongoDbAuthorizationStoreResolver.cs | 2 +- .../OpenIddictMongoDbScopeStoreResolver.cs | 2 +- .../OpenIddictMongoDbTokenStoreResolver.cs | 2 +- .../OpenIddictMongoDbApplicationStore.cs | 72 ++-- .../OpenIddictMongoDbAuthorizationStore.cs | 50 +-- .../Stores/OpenIddictMongoDbScopeStore.cs | 52 +-- .../Stores/OpenIddictMongoDbTokenStore.cs | 60 ++-- .../OpenIddictServerAspNetCoreBuilder.cs | 6 +- ...OpenIddictServerAspNetCoreConfiguration.cs | 8 +- .../OpenIddictServerAspNetCoreExtensions.cs | 6 +- .../OpenIddictServerAspNetCoreHandler.cs | 8 +- ...penIddictServerAspNetCoreHandlerFilters.cs | 24 +- ...ServerAspNetCoreHandlers.Authentication.cs | 32 +- ...nIddictServerAspNetCoreHandlers.Session.cs | 20 +- .../OpenIddictServerAspNetCoreHandlers.cs | 102 +++--- .../OpenIddictServerAspNetCoreHelpers.cs | 8 +- .../OpenIddictServerDataProtectionBuilder.cs | 6 +- ...IddictServerDataProtectionConfiguration.cs | 4 +- ...penIddictServerDataProtectionExtensions.cs | 6 +- ...OpenIddictServerDataProtectionFormatter.cs | 14 +- ...ddictServerDataProtectionHandlerFilters.cs | 10 +- .../OpenIddictServerDataProtectionHandlers.cs | 26 +- .../OpenIddictServerOwinBuilder.cs | 6 +- .../OpenIddictServerOwinConfiguration.cs | 4 +- .../OpenIddictServerOwinExtensions.cs | 6 +- .../OpenIddictServerOwinHandler.cs | 14 +- .../OpenIddictServerOwinHandlerFilters.cs | 22 +- ...IddictServerOwinHandlers.Authentication.cs | 32 +- .../OpenIddictServerOwinHandlers.Session.cs | 20 +- .../OpenIddictServerOwinHandlers.cs | 88 ++--- .../OpenIddictServerOwinHelpers.cs | 10 +- .../OpenIddictServerOwinMiddlewareFactory.cs | 4 +- .../OpenIddictServerQuartzBuilder.cs | 2 +- .../OpenIddictServerQuartzExtensions.cs | 6 +- .../OpenIddictServerQuartzJob.cs | 8 +- .../OpenIddictServerBuilder.cs | 98 +++--- .../OpenIddictServerConfiguration.cs | 26 +- .../OpenIddictServerDispatcher.cs | 6 +- .../OpenIddictServerExtensions.cs | 6 +- .../OpenIddictServerHandlerDescriptor.cs | 8 +- .../OpenIddictServerHandlerFilters.cs | 60 ++-- ...OpenIddictServerHandlers.Authentication.cs | 76 ++--- .../OpenIddictServerHandlers.Device.cs | 52 +-- .../OpenIddictServerHandlers.Discovery.cs | 74 ++--- .../OpenIddictServerHandlers.Exchange.cs | 78 ++--- .../OpenIddictServerHandlers.Introspection.cs | 60 ++-- .../OpenIddictServerHandlers.Revocation.cs | 50 +-- .../OpenIddictServerHandlers.Session.cs | 22 +- .../OpenIddictServerHandlers.Userinfo.cs | 24 +- .../OpenIddictServerHandlers.cs | 308 +++++++++--------- .../OpenIddictServerHelpers.cs | 6 +- .../OpenIddictServerOptions.cs | 2 +- .../OpenIddictValidationAspNetCoreBuilder.cs | 2 +- ...IddictValidationAspNetCoreConfiguration.cs | 6 +- ...penIddictValidationAspNetCoreExtensions.cs | 6 +- .../OpenIddictValidationAspNetCoreHandler.cs | 6 +- ...ddictValidationAspNetCoreHandlerFilters.cs | 4 +- .../OpenIddictValidationAspNetCoreHandlers.cs | 46 +-- .../OpenIddictValidationAspNetCoreHelpers.cs | 8 +- ...enIddictValidationDataProtectionBuilder.cs | 6 +- ...ctValidationDataProtectionConfiguration.cs | 4 +- ...ddictValidationDataProtectionExtensions.cs | 6 +- ...IddictValidationDataProtectionFormatter.cs | 4 +- ...nIddictValidationDataProtectionHandlers.cs | 6 +- .../OpenIddictValidationOwinBuilder.cs | 2 +- .../OpenIddictValidationOwinConfiguration.cs | 2 +- .../OpenIddictValidationOwinExtensions.cs | 6 +- .../OpenIddictValidationOwinHandler.cs | 8 +- .../OpenIddictValidationOwinHandlerFilters.cs | 4 +- .../OpenIddictValidationOwinHandlers.cs | 46 +-- .../OpenIddictValidationOwinHelpers.cs | 10 +- ...enIddictValidationOwinMiddlewareFactory.cs | 4 +- ...ddictValidationServerIntegrationBuilder.cs | 2 +- ...alidationServerIntegrationConfiguration.cs | 4 +- ...ctValidationServerIntegrationExtensions.cs | 6 +- ...penIddictValidationSystemNetHttpBuilder.cs | 2 +- ...ictValidationSystemNetHttpConfiguration.cs | 6 +- ...IddictValidationSystemNetHttpExtensions.cs | 6 +- ...ctValidationSystemNetHttpHandlerFilters.cs | 2 +- ...tionSystemNetHttpHandlers.Introspection.cs | 6 +- ...enIddictValidationSystemNetHttpHandlers.cs | 32 +- .../OpenIddictValidationBuilder.cs | 30 +- .../OpenIddictValidationConfiguration.cs | 18 +- .../OpenIddictValidationDispatcher.cs | 6 +- .../OpenIddictValidationExtensions.cs | 6 +- .../OpenIddictValidationHandlerDescriptor.cs | 8 +- .../OpenIddictValidationHandlerFilters.cs | 8 +- .../OpenIddictValidationHandlers.Discovery.cs | 14 +- ...nIddictValidationHandlers.Introspection.cs | 16 +- .../OpenIddictValidationHandlers.cs | 64 ++-- .../OpenIddictValidationHelpers.cs | 6 +- .../OpenIddictValidationOptions.cs | 2 +- .../OpenIddictValidationService.cs | 22 +- .../Primitives/OpenIddictExtensionsTests.cs | 2 +- .../OpenIddictCoreBuilderTests.cs | 8 +- .../OpenIddictCoreExtensionsTests.cs | 2 +- ...nIddictServerAspNetCoreIntegrationTests.cs | 4 +- .../OpenIddictServerIntegrationTestClient.cs | 28 +- .../OpenIddictServerOwinIntegrationTests.cs | 4 +- 155 files changed, 1732 insertions(+), 1746 deletions(-) diff --git a/samples/Mvc.Server/Controllers/AccountController.cs b/samples/Mvc.Server/Controllers/AccountController.cs index d140ad68..6b79b210 100644 --- a/samples/Mvc.Server/Controllers/AccountController.cs +++ b/samples/Mvc.Server/Controllers/AccountController.cs @@ -154,7 +154,7 @@ namespace Mvc.Server.Controllers public async Task ExternalLoginCallback(string returnUrl = null) { var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) + if (info is null) { return RedirectToAction(nameof(Login)); } @@ -194,7 +194,7 @@ namespace Mvc.Server.Controllers { // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) + if (info is null) { return View("ExternalLoginFailure"); } @@ -221,12 +221,12 @@ namespace Mvc.Server.Controllers [AllowAnonymous] public async Task ConfirmEmail(string userId, string code) { - if (userId == null || code == null) + if (userId is null || code is null) { return View("Error"); } var user = await _userManager.FindByIdAsync(userId); - if (user == null) + if (user is null) { return View("Error"); } @@ -253,7 +253,7 @@ namespace Mvc.Server.Controllers if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.Email); - if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) + if (user is null || !(await _userManager.IsEmailConfirmedAsync(user))) { // Don't reveal that the user does not exist or is not confirmed return View("ForgotPasswordConfirmation"); @@ -287,7 +287,7 @@ namespace Mvc.Server.Controllers [AllowAnonymous] public IActionResult ResetPassword(string code = null) { - return code == null ? View("Error") : View(); + return code is null ? View("Error") : View(); } // @@ -302,7 +302,7 @@ namespace Mvc.Server.Controllers return View(model); } var user = await _userManager.FindByNameAsync(model.Email); - if (user == null) + if (user is null) { // Don't reveal that the user does not exist return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account"); @@ -332,7 +332,7 @@ namespace Mvc.Server.Controllers public async Task SendCode(string returnUrl = null, bool rememberMe = false) { var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) + if (user is null) { return View("Error"); } @@ -354,7 +354,7 @@ namespace Mvc.Server.Controllers } var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) + if (user is null) { return View("Error"); } @@ -387,7 +387,7 @@ namespace Mvc.Server.Controllers { // Require that the user has already logged in via username/password or external login var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) + if (user is null) { return View("Error"); } diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index 2dda9912..591b2592 100644 --- a/samples/Mvc.Server/Controllers/AuthorizationController.cs +++ b/samples/Mvc.Server/Controllers/AuthorizationController.cs @@ -62,7 +62,7 @@ namespace Mvc.Server // Retrieve the user principal stored in the authentication cookie. // If it can't be extracted, redirect the user to the login page. var result = await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme); - if (result == null || !result.Succeeded) + if (result is null || !result.Succeeded) { // If the client application requested promptless authentication, // return an error indicating that the user is not logged in. @@ -110,7 +110,7 @@ namespace Mvc.Server // If a max_age parameter was provided, ensure that the cookie is not too old. // If it's too old, automatically redirect the user agent to the login page. - if (request.MaxAge != null && result.Properties?.IssuedUtc != null && + if (request.MaxAge is not null && result.Properties?.IssuedUtc is not null && DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value)) { if (request.HasPrompt(Prompts.None)) @@ -179,7 +179,7 @@ namespace Mvc.Server // Automatically create a permanent authorization to avoid requiring explicit consent // for future authorization or token requests containing the same scopes. var authorization = authorizations.LastOrDefault(); - if (authorization == null) + if (authorization is null) { authorization = await _authorizationManager.CreateAsync( principal: principal, @@ -269,7 +269,7 @@ namespace Mvc.Server // Automatically create a permanent authorization to avoid requiring explicit consent // for future authorization or token requests containing the same scopes. var authorization = authorizations.LastOrDefault(); - if (authorization == null) + if (authorization is null) { authorization = await _authorizationManager.CreateAsync( principal: principal, @@ -433,7 +433,7 @@ namespace Mvc.Server if (request.IsPasswordGrantType()) { var user = await _userManager.FindByNameAsync(request.Username); - if (user == null) + if (user is null) { return Forbid( authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, @@ -484,7 +484,7 @@ namespace Mvc.Server // when the user password/roles change, use the following line instead: // var user = _signInManager.ValidateSecurityStampAsync(info.Principal); var user = await _userManager.GetUserAsync(principal); - if (user == null) + if (user is null) { return Forbid( authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, diff --git a/samples/Mvc.Server/Controllers/ErrorController.cs b/samples/Mvc.Server/Controllers/ErrorController.cs index 18e20424..fd5ca6e3 100644 --- a/samples/Mvc.Server/Controllers/ErrorController.cs +++ b/samples/Mvc.Server/Controllers/ErrorController.cs @@ -18,7 +18,7 @@ namespace Mvc.Server // If the error was not caused by an invalid // OIDC request, display a generic error page. var response = HttpContext.GetOpenIddictServerResponse(); - if (response == null) + if (response is null) { return View(new ErrorViewModel()); } diff --git a/samples/Mvc.Server/Controllers/ManageController.cs b/samples/Mvc.Server/Controllers/ManageController.cs index 99b742e1..ffb34014 100644 --- a/samples/Mvc.Server/Controllers/ManageController.cs +++ b/samples/Mvc.Server/Controllers/ManageController.cs @@ -67,7 +67,7 @@ namespace Mvc.Server.Controllers { ManageMessageId? message = ManageMessageId.Error; var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { var result = await _userManager.RemoveLoginAsync(user, account.LoginProvider, account.ProviderKey); if (result.Succeeded) @@ -110,7 +110,7 @@ namespace Mvc.Server.Controllers public async Task EnableTwoFactorAuthentication() { var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { await _userManager.SetTwoFactorEnabledAsync(user, true); await _signInManager.SignInAsync(user, isPersistent: false); @@ -126,7 +126,7 @@ namespace Mvc.Server.Controllers public async Task DisableTwoFactorAuthentication() { var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { await _userManager.SetTwoFactorEnabledAsync(user, false); await _signInManager.SignInAsync(user, isPersistent: false); @@ -142,7 +142,7 @@ namespace Mvc.Server.Controllers { var code = await _userManager.GenerateChangePhoneNumberTokenAsync(await GetCurrentUserAsync(), phoneNumber); // Send an SMS to verify the phone number - return phoneNumber == null ? View("Error") : View(new VerifyPhoneNumberViewModel { PhoneNumber = phoneNumber }); + return phoneNumber is null ? View("Error") : View(new VerifyPhoneNumberViewModel { PhoneNumber = phoneNumber }); } // @@ -156,7 +156,7 @@ namespace Mvc.Server.Controllers return View(model); } var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { var result = await _userManager.ChangePhoneNumberAsync(user, model.PhoneNumber, model.Code); if (result.Succeeded) @@ -177,7 +177,7 @@ namespace Mvc.Server.Controllers public async Task RemovePhoneNumber() { var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { var result = await _userManager.SetPhoneNumberAsync(user, null); if (result.Succeeded) @@ -208,7 +208,7 @@ namespace Mvc.Server.Controllers return View(model); } var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { var result = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (result.Succeeded) @@ -243,7 +243,7 @@ namespace Mvc.Server.Controllers } var user = await GetCurrentUserAsync(); - if (user != null) + if (user is not null) { var result = await _userManager.AddPasswordAsync(user, model.NewPassword); if (result.Succeeded) @@ -267,13 +267,13 @@ namespace Mvc.Server.Controllers : message == ManageMessageId.Error ? "An error has occurred." : ""; var user = await GetCurrentUserAsync(); - if (user == null) + if (user is null) { return View("Error"); } var userLogins = await _userManager.GetLoginsAsync(user); var otherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).Where(auth => userLogins.All(ul => auth.Name != ul.LoginProvider)).ToList(); - ViewData["ShowRemoveButton"] = user.PasswordHash != null || userLogins.Count > 1; + ViewData["ShowRemoveButton"] = user.PasswordHash is not null || userLogins.Count > 1; return View(new ManageLoginsViewModel { CurrentLogins = userLogins, @@ -299,12 +299,12 @@ namespace Mvc.Server.Controllers public async Task LinkLoginCallback() { var user = await GetCurrentUserAsync(); - if (user == null) + if (user is null) { return View("Error"); } var info = await _signInManager.GetExternalLoginInfoAsync(await _userManager.GetUserIdAsync(user)); - if (info == null) + if (info is null) { return RedirectToAction(nameof(ManageLogins), new { Message = ManageMessageId.Error }); } diff --git a/samples/Mvc.Server/Controllers/ResourceController.cs b/samples/Mvc.Server/Controllers/ResourceController.cs index b0733c76..0348032f 100644 --- a/samples/Mvc.Server/Controllers/ResourceController.cs +++ b/samples/Mvc.Server/Controllers/ResourceController.cs @@ -40,7 +40,7 @@ namespace Mvc.Server.Controllers } var user = await _userManager.GetUserAsync(User); - if (user == null) + if (user is null) { return Challenge( authenticationSchemes: OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme, diff --git a/samples/Mvc.Server/Controllers/UserinfoController.cs b/samples/Mvc.Server/Controllers/UserinfoController.cs index 8675eb80..1035c38b 100644 --- a/samples/Mvc.Server/Controllers/UserinfoController.cs +++ b/samples/Mvc.Server/Controllers/UserinfoController.cs @@ -26,7 +26,7 @@ namespace Mvc.Server.Controllers public async Task Userinfo() { var user = await _userManager.GetUserAsync(User); - if (user == null) + if (user is null) { return Challenge( authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, diff --git a/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs b/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs index f4c85f06..4a69b1d3 100644 --- a/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs +++ b/samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs @@ -8,7 +8,7 @@ namespace Mvc.Server.Helpers { public static Task> ToListAsync(this IAsyncEnumerable source) { - if (source == null) + if (source is null) { throw new ArgumentNullException(nameof(source)); } diff --git a/samples/Mvc.Server/Worker.cs b/samples/Mvc.Server/Worker.cs index 5a72bf8d..ed7d7739 100644 --- a/samples/Mvc.Server/Worker.cs +++ b/samples/Mvc.Server/Worker.cs @@ -30,7 +30,7 @@ namespace Mvc.Server { var manager = provider.GetRequiredService(); - if (await manager.FindByClientIdAsync("mvc") == null) + if (await manager.FindByClientIdAsync("mvc") is null) { await manager.CreateAsync(new OpenIddictApplicationDescriptor { @@ -74,7 +74,7 @@ namespace Mvc.Server // * Scope: openid email profile roles // * Grant type: authorization code // * Request access token locally: yes - if (await manager.FindByClientIdAsync("postman") == null) + if (await manager.FindByClientIdAsync("postman") is null) { await manager.CreateAsync(new OpenIddictApplicationDescriptor { @@ -106,7 +106,7 @@ namespace Mvc.Server { var manager = provider.GetRequiredService(); - if (await manager.FindByNameAsync("demo_api") == null) + if (await manager.FindByNameAsync("demo_api") is null) { await manager.CreateAsync(new OpenIddictScopeDescriptor { diff --git a/shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs b/shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs index b56019f3..32c9d30f 100644 --- a/shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs +++ b/shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs @@ -27,12 +27,12 @@ namespace OpenIddict.Extensions /// A instance if the base type was found, null otherwise. public static IEnumerable FindGenericBaseTypes(Type type, Type definition) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } - if (definition == null) + if (definition is null) { throw new ArgumentNullException(nameof(definition)); } @@ -60,7 +60,7 @@ namespace OpenIddict.Extensions else { - for (var candidate = type; candidate != null; candidate = candidate.BaseType) + for (var candidate = type; candidate is not null; candidate = candidate.BaseType) { if (!candidate.IsGenericType && !candidate.IsConstructedGenericType) { diff --git a/src/OpenIddict.Abstractions/OpenIddictExtensions.cs b/src/OpenIddict.Abstractions/OpenIddictExtensions.cs index 4baf3d55..bad57860 100644 --- a/src/OpenIddict.Abstractions/OpenIddictExtensions.cs +++ b/src/OpenIddict.Abstractions/OpenIddictExtensions.cs @@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictBuilder AddOpenIddict(this IServiceCollection services) { - if (services == null) + if (services is null) { throw new ArgumentNullException(nameof(services)); } @@ -38,12 +38,12 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static IServiceCollection AddOpenIddict(this IServiceCollection services, Action configuration) { - if (services == null) + if (services is null) { throw new ArgumentNullException(nameof(services)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs index 461fe14f..5932cfad 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs @@ -23,7 +23,7 @@ namespace OpenIddict.Abstractions /// true if the type is supported, false otherwise. public override bool CanConvert(Type typeToConvert) { - if (typeToConvert == null) + if (typeToConvert is null) { throw new ArgumentNullException(nameof(typeToConvert)); } @@ -42,7 +42,7 @@ namespace OpenIddict.Abstractions /// The deserialized instance. public override OpenIddictMessage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (typeToConvert == null) + if (typeToConvert is null) { throw new ArgumentNullException(nameof(typeToConvert)); } @@ -51,7 +51,7 @@ namespace OpenIddict.Abstractions return typeToConvert == typeof(OpenIddictMessage) ? new OpenIddictMessage(document.RootElement.Clone()) : typeToConvert == typeof(OpenIddictRequest) ? new OpenIddictRequest(document.RootElement.Clone()) : - typeToConvert == typeof(OpenIddictResponse) ? (OpenIddictMessage) new OpenIddictResponse(document.RootElement.Clone()) : + typeToConvert == typeof(OpenIddictResponse) ? new OpenIddictResponse(document.RootElement.Clone()) : throw new ArgumentException(SR.GetResourceString(SR.ID1175), nameof(typeToConvert)); } @@ -63,12 +63,12 @@ namespace OpenIddict.Abstractions /// The JSON serializer options. public override void Write(Utf8JsonWriter writer, OpenIddictMessage value, JsonSerializerOptions options) { - if (writer == null) + if (writer is null) { throw new ArgumentNullException(nameof(writer)); } - if (value == null) + if (value is null) { throw new ArgumentNullException(nameof(value)); } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs index 783ea397..f48fb945 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs @@ -31,7 +31,7 @@ namespace OpenIddict.Abstractions /// The instance. public static ImmutableArray GetAcrValues(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -45,7 +45,7 @@ namespace OpenIddict.Abstractions /// The instance. public static ImmutableArray GetPrompts(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -59,7 +59,7 @@ namespace OpenIddict.Abstractions /// The instance. public static ImmutableArray GetResponseTypes(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -73,7 +73,7 @@ namespace OpenIddict.Abstractions /// The instance. public static ImmutableArray GetScopes(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -88,7 +88,7 @@ namespace OpenIddict.Abstractions /// The component to look for in the parameter. public static bool HasAcrValue(this OpenIddictRequest request, string value) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -108,7 +108,7 @@ namespace OpenIddict.Abstractions /// The component to look for in the parameter. public static bool HasPrompt(this OpenIddictRequest request, string prompt) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -128,7 +128,7 @@ namespace OpenIddict.Abstractions /// The component to look for in the parameter. public static bool HasResponseType(this OpenIddictRequest request, string type) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -148,7 +148,7 @@ namespace OpenIddict.Abstractions /// The component to look for in the parameter. public static bool HasScope(this OpenIddictRequest request, string scope) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -169,7 +169,7 @@ namespace OpenIddict.Abstractions /// true if the request is a response_type=none request, false otherwise. public static bool IsNoneFlow(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -196,7 +196,7 @@ namespace OpenIddict.Abstractions /// true if the request is a code flow request, false otherwise. public static bool IsAuthorizationCodeFlow(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -224,7 +224,7 @@ namespace OpenIddict.Abstractions /// true if the request is an implicit flow request, false otherwise. public static bool IsImplicitFlow(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -278,7 +278,7 @@ namespace OpenIddict.Abstractions /// true if the request is an hybrid flow request, false otherwise. public static bool IsHybridFlow(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -345,7 +345,7 @@ namespace OpenIddict.Abstractions /// public static bool IsFragmentResponseMode(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -378,7 +378,7 @@ namespace OpenIddict.Abstractions /// public static bool IsQueryResponseMode(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -410,7 +410,7 @@ namespace OpenIddict.Abstractions /// public static bool IsFormPostResponseMode(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -426,7 +426,7 @@ namespace OpenIddict.Abstractions /// true if the request is a code grant request, false otherwise. public static bool IsAuthorizationCodeGrantType(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -442,7 +442,7 @@ namespace OpenIddict.Abstractions /// true if the request is a client credentials grant request, false otherwise. public static bool IsClientCredentialsGrantType(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -458,7 +458,7 @@ namespace OpenIddict.Abstractions /// true if the request is a device code grant request, false otherwise. public static bool IsDeviceCodeGrantType(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -474,7 +474,7 @@ namespace OpenIddict.Abstractions /// true if the request is a password grant request, false otherwise. public static bool IsPasswordGrantType(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -490,7 +490,7 @@ namespace OpenIddict.Abstractions /// true if the request is a refresh token grant request, false otherwise. public static bool IsRefreshTokenGrantType(this OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -505,7 +505,7 @@ namespace OpenIddict.Abstractions /// The destinations associated with the claim. public static ImmutableArray GetDestinations(this Claim claim) { - if (claim == null) + if (claim is null) { throw new ArgumentNullException(nameof(claim)); } @@ -529,7 +529,7 @@ namespace OpenIddict.Abstractions /// The required destination. public static bool HasDestination(this Claim claim, string destination) { - if (claim == null) + if (claim is null) { throw new ArgumentNullException(nameof(claim)); } @@ -557,7 +557,7 @@ namespace OpenIddict.Abstractions /// The destinations. public static Claim SetDestinations(this Claim claim, ImmutableArray destinations) { - if (claim == null) + if (claim is null) { throw new ArgumentNullException(nameof(claim)); } @@ -607,7 +607,7 @@ namespace OpenIddict.Abstractions /// The destinations, returned as a flattened dictionary. public static ImmutableDictionary GetDestinations(this ClaimsPrincipal principal) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -645,12 +645,12 @@ namespace OpenIddict.Abstractions /// The principal. public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary destinations) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } - if (destinations == null) + if (destinations is null) { throw new ArgumentNullException(nameof(destinations)); } @@ -676,12 +676,12 @@ namespace OpenIddict.Abstractions /// public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func filter) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } - if (filter == null) + if (filter is null) { throw new ArgumentNullException(nameof(filter)); } @@ -698,7 +698,7 @@ namespace OpenIddict.Abstractions } } - if (clone.Actor != null) + if (clone.Actor is not null) { clone.Actor = clone.Actor.Clone(filter); } @@ -716,12 +716,12 @@ namespace OpenIddict.Abstractions /// public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func filter) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } - if (filter == null) + if (filter is null) { throw new ArgumentNullException(nameof(filter)); } @@ -744,7 +744,7 @@ namespace OpenIddict.Abstractions /// The value associated with the claim. public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -772,7 +772,7 @@ namespace OpenIddict.Abstractions /// The destinations associated with the claim. public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, ImmutableArray destinations) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -787,11 +787,6 @@ namespace OpenIddict.Abstractions throw new ArgumentException(SR.GetResourceString(SR.ID1184), nameof(value)); } - if (destinations == null) - { - throw new ArgumentNullException(nameof(destinations)); - } - identity.AddClaim(new Claim(type, value).SetDestinations(destinations)); return identity; } @@ -814,7 +809,7 @@ namespace OpenIddict.Abstractions /// The claim value. public static string? GetClaim(this ClaimsIdentity identity, string type) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -835,7 +830,7 @@ namespace OpenIddict.Abstractions /// The claim value. public static string? GetClaim(this ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -856,7 +851,7 @@ namespace OpenIddict.Abstractions /// The claim values. public static ImmutableArray GetClaims(this ClaimsIdentity identity, string type) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -877,7 +872,7 @@ namespace OpenIddict.Abstractions /// true if the identity contains at least one claim of the specified type. public static bool HasClaim(this ClaimsIdentity identity, string type) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -898,7 +893,7 @@ namespace OpenIddict.Abstractions /// The claim values. public static ImmutableArray GetClaims(this ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -919,7 +914,7 @@ namespace OpenIddict.Abstractions /// true if the principal contains at least one claim of the specified type. public static bool HasClaim(this ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -940,7 +935,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsIdentity RemoveClaims(this ClaimsIdentity identity, string type) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -966,7 +961,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsPrincipal RemoveClaims(this ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -996,7 +991,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, string? value) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -1025,7 +1020,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string? value) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1054,7 +1049,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray values) { - if (identity == null) + if (identity is null) { throw new ArgumentNullException(nameof(identity)); } @@ -1083,7 +1078,7 @@ namespace OpenIddict.Abstractions /// The claims identity. public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray values) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1110,13 +1105,13 @@ namespace OpenIddict.Abstractions /// The creation date or null if the claim cannot be found. public static DateTimeOffset? GetCreationDate(this ClaimsPrincipal principal) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } var claim = principal.FindFirst(Claims.Private.CreationDate); - if (claim == null) + if (claim is null) { return null; } @@ -1136,13 +1131,13 @@ namespace OpenIddict.Abstractions /// The expiration date or null if the claim cannot be found. public static DateTimeOffset? GetExpirationDate(this ClaimsPrincipal principal) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } var claim = principal.FindFirst(Claims.Private.ExpirationDate); - if (claim == null) + if (claim is null) { return null; } @@ -1275,7 +1270,7 @@ namespace OpenIddict.Abstractions /// true if the principal contains the given audience. public static bool HasAudience(this ClaimsPrincipal principal, string audience) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1304,7 +1299,7 @@ namespace OpenIddict.Abstractions /// true if the principal contains the given presenter. public static bool HasPresenter(this ClaimsPrincipal principal, string presenter) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1333,7 +1328,7 @@ namespace OpenIddict.Abstractions /// true if the principal contains the given resource. public static bool HasResource(this ClaimsPrincipal principal, string resource) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1362,7 +1357,7 @@ namespace OpenIddict.Abstractions /// true if the principal contains the given scope. public static bool HasScope(this ClaimsPrincipal principal, string scope) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1383,7 +1378,7 @@ namespace OpenIddict.Abstractions /// true if the token type matches the specified type. public static bool HasTokenType(this ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -1617,7 +1612,7 @@ namespace OpenIddict.Abstractions private static ImmutableArray GetValues(string? source, char[] separators) { - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); if (string.IsNullOrEmpty(source)) { @@ -1648,7 +1643,7 @@ namespace OpenIddict.Abstractions private static bool HasValue(string? source, string value, char[] separators) { Debug.Assert(!string.IsNullOrEmpty(value), SR.GetResourceString(SR.ID5002)); - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); if (string.IsNullOrEmpty(source)) { @@ -1674,7 +1669,7 @@ namespace OpenIddict.Abstractions private static StringSegment TrimStart(StringSegment segment, char[] separators) { - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); var index = segment.Offset; @@ -1693,7 +1688,7 @@ namespace OpenIddict.Abstractions private static StringSegment TrimEnd(StringSegment segment, char[] separators) { - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); var index = segment.Offset + segment.Length - 1; @@ -1712,14 +1707,14 @@ namespace OpenIddict.Abstractions private static StringSegment Trim(StringSegment segment, char[] separators) { - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); return TrimEnd(TrimStart(segment, separators), separators); } private static bool IsSeparator(char character, char[] separators) { - Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators is not null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); for (var index = 0; index < separators!.Length; index++) { @@ -1734,7 +1729,7 @@ namespace OpenIddict.Abstractions private static TimeSpan? GetLifetime(ClaimsPrincipal principal, string type) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs index 31924dc1..12a259d7 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs @@ -68,7 +68,7 @@ namespace OpenIddict.Abstractions /// The message parameters. public OpenIddictMessage(IEnumerable> parameters) { - if (parameters == null) + if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } @@ -85,7 +85,7 @@ namespace OpenIddict.Abstractions /// The message parameters. public OpenIddictMessage(IEnumerable> parameters) { - if (parameters == null) + if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } @@ -113,7 +113,7 @@ namespace OpenIddict.Abstractions /// The message parameters. public OpenIddictMessage(IEnumerable> parameters) { - if (parameters == null) + if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } @@ -140,7 +140,7 @@ namespace OpenIddict.Abstractions /// The message parameters. public OpenIddictMessage(IEnumerable> parameters) { - if (parameters == null) + if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } @@ -279,7 +279,7 @@ namespace OpenIddict.Abstractions } // If the parameter value is null or empty, remove the corresponding entry from the collection. - if (value == null || OpenIddictParameter.IsNullOrEmpty(value.GetValueOrDefault())) + if (value is null || OpenIddictParameter.IsNullOrEmpty(value.GetValueOrDefault())) { Parameters.Remove(name); } @@ -360,7 +360,7 @@ namespace OpenIddict.Abstractions /// The UTF-8 JSON writer. public void WriteTo(Utf8JsonWriter writer) { - if (writer == null) + if (writer is null) { throw new ArgumentNullException(nameof(writer)); } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs index 93adf1bc..6268b6d4 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs @@ -505,7 +505,7 @@ namespace OpenIddict.Abstractions /// The UTF-8 JSON writer. public void WriteTo(Utf8JsonWriter writer) { - if (writer == null) + if (writer is null) { throw new ArgumentNullException(nameof(writer)); } diff --git a/src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs b/src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs index 7e48f32d..07488040 100644 --- a/src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs +++ b/src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs @@ -45,7 +45,7 @@ namespace OpenIddict.Core /// public async ValueTask AddAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -127,7 +127,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((application = await _store.FindByClientIdAsync(identifier, cancellationToken)) != null) + if ((application = await _store.FindByClientIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(application, cancellationToken); } @@ -161,7 +161,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((application = await _store.FindByIdAsync(identifier, cancellationToken)) != null) + if ((application = await _store.FindByIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(application, cancellationToken); } @@ -257,7 +257,7 @@ namespace OpenIddict.Core /// public async ValueTask RemoveAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -284,17 +284,17 @@ namespace OpenIddict.Core /// A that can be used to monitor the asynchronous operation. protected virtual async ValueTask CreateEntryAsync(object key, TApplication? application, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } using var entry = _cache.CreateEntry(key); - if (application != null) + if (application is not null) { var signal = await CreateExpirationSignalAsync(application, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -316,7 +316,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateEntryAsync( object key, ImmutableArray applications, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -326,7 +326,7 @@ namespace OpenIddict.Core foreach (var application in applications) { var signal = await CreateExpirationSignalAsync(application, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -351,7 +351,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateExpirationSignalAsync( TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } diff --git a/src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs b/src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs index 0ba2d90d..8b2113ab 100644 --- a/src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs +++ b/src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs @@ -45,7 +45,7 @@ namespace OpenIddict.Core /// public async ValueTask AddAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -378,7 +378,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((authorization = await _store.FindByIdAsync(identifier, cancellationToken)) != null) + if ((authorization = await _store.FindByIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(authorization, cancellationToken); } @@ -433,7 +433,7 @@ namespace OpenIddict.Core /// public async ValueTask RemoveAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -460,17 +460,17 @@ namespace OpenIddict.Core /// A that can be used to monitor the asynchronous operation. protected virtual async ValueTask CreateEntryAsync(object key, TAuthorization? authorization, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } using var entry = _cache.CreateEntry(key); - if (authorization != null) + if (authorization is not null) { var signal = await CreateExpirationSignalAsync(authorization, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -492,7 +492,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateEntryAsync( object key, ImmutableArray authorizations, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -502,7 +502,7 @@ namespace OpenIddict.Core foreach (var authorization in authorizations) { var signal = await CreateExpirationSignalAsync(authorization, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -527,7 +527,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateExpirationSignalAsync( TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } diff --git a/src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs b/src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs index 0d254488..b583a162 100644 --- a/src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs +++ b/src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs @@ -46,7 +46,7 @@ namespace OpenIddict.Core /// public async ValueTask AddAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -119,7 +119,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((scope = await _store.FindByIdAsync(identifier, cancellationToken)) != null) + if ((scope = await _store.FindByIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(scope, cancellationToken); } @@ -151,7 +151,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((scope = await _store.FindByNameAsync(name, cancellationToken)) != null) + if ((scope = await _store.FindByNameAsync(name, cancellationToken)) is not null) { await AddAsync(scope, cancellationToken); } @@ -231,7 +231,7 @@ namespace OpenIddict.Core /// public async ValueTask RemoveAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -258,17 +258,17 @@ namespace OpenIddict.Core /// A that can be used to monitor the asynchronous operation. protected virtual async ValueTask CreateEntryAsync(object key, TScope? scope, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } using var entry = _cache.CreateEntry(key); - if (scope != null) + if (scope is not null) { var signal = await CreateExpirationSignalAsync(scope, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -290,7 +290,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateEntryAsync( object key, ImmutableArray scopes, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -300,7 +300,7 @@ namespace OpenIddict.Core foreach (var scope in scopes) { var signal = await CreateExpirationSignalAsync(scope, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -324,7 +324,7 @@ namespace OpenIddict.Core /// protected virtual async ValueTask CreateExpirationSignalAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } diff --git a/src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs b/src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs index bc31f9c1..349bba43 100644 --- a/src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs +++ b/src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs @@ -45,7 +45,7 @@ namespace OpenIddict.Core /// public async ValueTask AddAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -396,7 +396,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((token = await _store.FindByIdAsync(identifier, cancellationToken)) != null) + if ((token = await _store.FindByIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(token, cancellationToken); } @@ -430,7 +430,7 @@ namespace OpenIddict.Core async Task ExecuteAsync() { - if ((token = await _store.FindByReferenceIdAsync(identifier, cancellationToken)) != null) + if ((token = await _store.FindByReferenceIdAsync(identifier, cancellationToken)) is not null) { await AddAsync(token, cancellationToken); } @@ -485,7 +485,7 @@ namespace OpenIddict.Core /// public async ValueTask RemoveAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -512,17 +512,17 @@ namespace OpenIddict.Core /// A that can be used to monitor the asynchronous operation. protected virtual async ValueTask CreateEntryAsync(object key, TToken? token, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } using var entry = _cache.CreateEntry(key); - if (token != null) + if (token is not null) { var signal = await CreateExpirationSignalAsync(token, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -544,7 +544,7 @@ namespace OpenIddict.Core protected virtual async ValueTask CreateEntryAsync( object key, ImmutableArray tokens, CancellationToken cancellationToken) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -554,7 +554,7 @@ namespace OpenIddict.Core foreach (var token in tokens) { var signal = await CreateExpirationSignalAsync(token, cancellationToken); - if (signal == null) + if (signal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1196)); } @@ -578,7 +578,7 @@ namespace OpenIddict.Core /// protected virtual async ValueTask CreateExpirationSignalAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs index 7cb91e69..6ef2ae0b 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs @@ -111,7 +111,7 @@ namespace OpenIddict.Core public virtual ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -143,7 +143,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask CreateAsync(TApplication application, string? secret, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -218,13 +218,13 @@ namespace OpenIddict.Core public virtual async ValueTask CreateAsync( OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } var application = await Store.InstantiateAsync(cancellationToken); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1207)); } @@ -255,7 +255,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -289,7 +289,7 @@ namespace OpenIddict.Core await Store.FindByClientIdAsync(identifier, cancellationToken) : await Cache.FindByClientIdAsync(identifier, cancellationToken); - if (application == null) + if (application is null) { return null; } @@ -326,7 +326,7 @@ namespace OpenIddict.Core await Store.FindByIdAsync(identifier, cancellationToken) : await Cache.FindByIdAsync(identifier, cancellationToken); - if (application == null) + if (application is null) { return null; } @@ -440,7 +440,7 @@ namespace OpenIddict.Core public virtual ValueTask GetAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -464,7 +464,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -484,7 +484,7 @@ namespace OpenIddict.Core public virtual ValueTask GetClientIdAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -504,7 +504,7 @@ namespace OpenIddict.Core public virtual ValueTask GetClientTypeAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -524,7 +524,7 @@ namespace OpenIddict.Core public virtual async ValueTask GetConsentTypeAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -550,7 +550,7 @@ namespace OpenIddict.Core public virtual ValueTask GetDisplayNameAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -570,13 +570,13 @@ namespace OpenIddict.Core public virtual async ValueTask> GetDisplayNamesAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } var names = await Store.GetDisplayNamesAsync(application, cancellationToken); - if (names == null || names.Count == 0) + if (names is null || names.Count == 0) { return ImmutableDictionary.Create(); } @@ -595,7 +595,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -633,18 +633,18 @@ namespace OpenIddict.Core public virtual async ValueTask GetLocalizedDisplayNameAsync( TApplication application, CultureInfo culture, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (culture == null) + if (culture is null) { throw new ArgumentNullException(nameof(culture)); } var names = await Store.GetDisplayNamesAsync(application, cancellationToken); - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { return await Store.GetDisplayNameAsync(application, cancellationToken); } @@ -676,7 +676,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetPermissionsAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -696,7 +696,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetPostLogoutRedirectUrisAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -716,7 +716,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetRedirectUrisAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -736,7 +736,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetRequirementsAsync( TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -754,7 +754,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasClientTypeAsync( TApplication application, string type, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -777,7 +777,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasConsentTypeAsync( TApplication application, string type, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -800,7 +800,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasPermissionAsync( TApplication application, string permission, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -823,7 +823,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasRequirementAsync( TApplication application, string requirement, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -857,7 +857,7 @@ namespace OpenIddict.Core public virtual IAsyncEnumerable ListAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -878,7 +878,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -898,12 +898,12 @@ namespace OpenIddict.Core public virtual async ValueTask PopulateAsync(TApplication application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -935,12 +935,12 @@ namespace OpenIddict.Core OpenIddictApplicationDescriptor descriptor, TApplication application, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -1008,7 +1008,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -1063,7 +1063,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask UpdateAsync(TApplication application, string? secret, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -1094,12 +1094,12 @@ namespace OpenIddict.Core public virtual async ValueTask UpdateAsync(TApplication application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -1129,7 +1129,7 @@ namespace OpenIddict.Core public virtual async IAsyncEnumerable ValidateAsync( TApplication application, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -1148,7 +1148,7 @@ namespace OpenIddict.Core // the casing is different). To avoid issues when the client identifier is part of an index // using the same collation, an error is added even if the two identifiers don't exactly match. var other = await Store.FindByClientIdAsync(identifier, cancellationToken); - if (other != null && !string.Equals( + if (other is not null && !string.Equals( await Store.GetIdAsync(other, cancellationToken), await Store.GetIdAsync(application, cancellationToken), StringComparison.Ordinal)) { @@ -1232,7 +1232,7 @@ namespace OpenIddict.Core public virtual async ValueTask ValidateClientSecretAsync( TApplication application, string secret, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -1279,7 +1279,7 @@ namespace OpenIddict.Core public virtual async ValueTask ValidateRedirectUriAsync( TApplication application, string address, CancellationToken cancellationToken = default) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs index 4803ba27..37af1ca4 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs @@ -98,7 +98,7 @@ namespace OpenIddict.Core public virtual ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -116,7 +116,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -174,13 +174,13 @@ namespace OpenIddict.Core public virtual async ValueTask CreateAsync( OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } var authorization = await Store.InstantiateAsync(cancellationToken); - if (authorization == null) + if (authorization is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1219)); } @@ -207,7 +207,7 @@ namespace OpenIddict.Core ClaimsPrincipal principal, string subject, string client, string type, ImmutableArray scopes, CancellationToken cancellationToken = default) { - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -251,7 +251,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -560,7 +560,7 @@ namespace OpenIddict.Core await Store.FindByIdAsync(identifier, cancellationToken) : await Cache.FindByIdAsync(identifier, cancellationToken); - if (authorization == null) + if (authorization is null) { return null; } @@ -630,7 +630,7 @@ namespace OpenIddict.Core public virtual ValueTask GetApplicationIdAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -651,7 +651,7 @@ namespace OpenIddict.Core public virtual ValueTask GetAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -675,7 +675,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -695,7 +695,7 @@ namespace OpenIddict.Core public virtual ValueTask GetCreationDateAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -714,7 +714,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -734,7 +734,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetScopesAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -754,7 +754,7 @@ namespace OpenIddict.Core public virtual ValueTask GetStatusAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -774,7 +774,7 @@ namespace OpenIddict.Core public virtual ValueTask GetSubjectAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -794,7 +794,7 @@ namespace OpenIddict.Core public virtual ValueTask GetTypeAsync( TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -812,7 +812,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -831,7 +831,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasStatusAsync(TAuthorization authorization, string status, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -854,7 +854,7 @@ namespace OpenIddict.Core public virtual async ValueTask HasTypeAsync( TAuthorization authorization, string type, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -888,7 +888,7 @@ namespace OpenIddict.Core public virtual IAsyncEnumerable ListAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -909,7 +909,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -929,12 +929,12 @@ namespace OpenIddict.Core public virtual async ValueTask PopulateAsync(TAuthorization authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -960,12 +960,12 @@ namespace OpenIddict.Core OpenIddictAuthorizationDescriptor descriptor, TAuthorization authorization, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -1007,7 +1007,7 @@ namespace OpenIddict.Core public virtual async ValueTask SetApplicationIdAsync( TAuthorization authorization, string? identifier, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -1024,7 +1024,7 @@ namespace OpenIddict.Core /// true if the authorization was successfully revoked, false otherwise. public virtual async ValueTask TryRevokeAsync(TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -1071,7 +1071,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -1125,12 +1125,12 @@ namespace OpenIddict.Core public virtual async ValueTask UpdateAsync(TAuthorization authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -1148,7 +1148,7 @@ namespace OpenIddict.Core public virtual async IAsyncEnumerable ValidateAsync( TAuthorization authorization, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } diff --git a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs index 144dad6f..e1ca7955 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs @@ -97,7 +97,7 @@ namespace OpenIddict.Core public virtual ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -115,7 +115,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -167,13 +167,13 @@ namespace OpenIddict.Core public virtual async ValueTask CreateAsync( OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } var scope = await Store.InstantiateAsync(cancellationToken); - if (scope == null) + if (scope is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1222)); } @@ -194,7 +194,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -227,7 +227,7 @@ namespace OpenIddict.Core await Store.FindByIdAsync(identifier, cancellationToken) : await Cache.FindByIdAsync(identifier, cancellationToken); - if (scope == null) + if (scope is null) { return null; } @@ -264,7 +264,7 @@ namespace OpenIddict.Core await Store.FindByNameAsync(name, cancellationToken) : await Cache.FindByNameAsync(name, cancellationToken); - if (scope == null) + if (scope is null) { return null; } @@ -378,7 +378,7 @@ namespace OpenIddict.Core public virtual ValueTask GetAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -402,7 +402,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -421,7 +421,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -441,13 +441,13 @@ namespace OpenIddict.Core public virtual async ValueTask> GetDescriptionsAsync( TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } var descriptions = await Store.GetDescriptionsAsync(scope, cancellationToken); - if (descriptions == null || descriptions.Count == 0) + if (descriptions is null || descriptions.Count == 0) { return ImmutableDictionary.Create(); } @@ -466,7 +466,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -486,13 +486,13 @@ namespace OpenIddict.Core public virtual async ValueTask> GetDisplayNamesAsync( TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } var names = await Store.GetDisplayNamesAsync(scope, cancellationToken); - if (names == null || names.Count == 0) + if (names is null || names.Count == 0) { return ImmutableDictionary.Create(); } @@ -511,7 +511,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -548,18 +548,18 @@ namespace OpenIddict.Core public virtual async ValueTask GetLocalizedDisplayNameAsync( TScope scope, CultureInfo culture, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (culture == null) + if (culture is null) { throw new ArgumentNullException(nameof(culture)); } var names = await Store.GetDisplayNamesAsync(scope, cancellationToken); - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { return await Store.GetDisplayNameAsync(scope, cancellationToken); } @@ -608,18 +608,18 @@ namespace OpenIddict.Core public virtual async ValueTask GetLocalizedDescriptionAsync( TScope scope, CultureInfo culture, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (culture == null) + if (culture is null) { throw new ArgumentNullException(nameof(culture)); } var descriptions = await Store.GetDescriptionsAsync(scope, cancellationToken); - if (descriptions == null || descriptions.IsEmpty) + if (descriptions is null || descriptions.IsEmpty) { return await Store.GetDescriptionAsync(scope, cancellationToken); } @@ -650,7 +650,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -670,7 +670,7 @@ namespace OpenIddict.Core public virtual ValueTask> GetResourcesAsync( TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -699,7 +699,7 @@ namespace OpenIddict.Core public virtual IAsyncEnumerable ListAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -720,7 +720,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -762,12 +762,12 @@ namespace OpenIddict.Core public virtual async ValueTask PopulateAsync(TScope scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -793,12 +793,12 @@ namespace OpenIddict.Core OpenIddictScopeDescriptor descriptor, TScope scope, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -832,7 +832,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -886,12 +886,12 @@ namespace OpenIddict.Core public virtual async ValueTask UpdateAsync(TScope scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -909,7 +909,7 @@ namespace OpenIddict.Core public virtual async IAsyncEnumerable ValidateAsync( TScope scope, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -934,7 +934,7 @@ namespace OpenIddict.Core // the casing is different). To avoid issues when the scope name is part of an index // using the same collation, an error is added even if the two names don't exactly match. var other = await Store.FindByNameAsync(name, cancellationToken); - if (other != null && !string.Equals( + if (other is not null && !string.Equals( await Store.GetIdAsync(other, cancellationToken), await Store.GetIdAsync(scope, cancellationToken), StringComparison.Ordinal)) { diff --git a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs index dadf5a42..eaa513f4 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs @@ -98,7 +98,7 @@ namespace OpenIddict.Core public virtual ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -116,7 +116,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -182,13 +182,13 @@ namespace OpenIddict.Core public virtual async ValueTask CreateAsync( OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } var token = await Store.InstantiateAsync(cancellationToken); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1225)); } @@ -209,7 +209,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -486,7 +486,7 @@ namespace OpenIddict.Core await Store.FindByIdAsync(identifier, cancellationToken) : await Cache.FindByIdAsync(identifier, cancellationToken); - if (token == null) + if (token is null) { return null; } @@ -526,7 +526,7 @@ namespace OpenIddict.Core await Store.FindByReferenceIdAsync(identifier, cancellationToken) : await Cache.FindByReferenceIdAsync(identifier, cancellationToken); - if (token == null) + if (token is null) { return null; } @@ -596,7 +596,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -617,7 +617,7 @@ namespace OpenIddict.Core public virtual ValueTask GetAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -641,7 +641,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -660,7 +660,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -679,7 +679,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -698,7 +698,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -717,7 +717,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -736,7 +736,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -757,7 +757,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -776,7 +776,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -795,7 +795,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -814,7 +814,7 @@ namespace OpenIddict.Core /// public virtual ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -831,7 +831,7 @@ namespace OpenIddict.Core /// true if the token has the specified status, false otherwise. public virtual async ValueTask HasStatusAsync(TToken token, string status, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -853,7 +853,7 @@ namespace OpenIddict.Core /// true if the token has the specified type, false otherwise. public virtual async ValueTask HasTypeAsync(TToken token, string type, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -887,7 +887,7 @@ namespace OpenIddict.Core public virtual IAsyncEnumerable ListAsync( Func, IQueryable> query, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -908,7 +908,7 @@ namespace OpenIddict.Core Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken = default) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -928,12 +928,12 @@ namespace OpenIddict.Core public virtual async ValueTask PopulateAsync(TToken token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -962,12 +962,12 @@ namespace OpenIddict.Core OpenIddictTokenDescriptor descriptor, TToken token, CancellationToken cancellationToken = default) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1007,7 +1007,7 @@ namespace OpenIddict.Core public virtual async ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1028,7 +1028,7 @@ namespace OpenIddict.Core public virtual async ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1047,7 +1047,7 @@ namespace OpenIddict.Core public virtual async ValueTask TryExtendAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1063,7 +1063,7 @@ namespace OpenIddict.Core { await UpdateAsync(token, cancellationToken); - if (date != null) + if (date is not null) { Logger.LogInformation(SR.GetResourceString(SR.ID7167), await Store.GetIdAsync(token, cancellationToken), date); } @@ -1099,7 +1099,7 @@ namespace OpenIddict.Core /// true if the token was successfully redemeed, false otherwise. public virtual async ValueTask TryRedeemAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1144,7 +1144,7 @@ namespace OpenIddict.Core /// true if the token was successfully redemeed, false otherwise. public virtual async ValueTask TryRejectAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1189,7 +1189,7 @@ namespace OpenIddict.Core /// true if the token was successfully revoked, false otherwise. public virtual async ValueTask TryRevokeAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1236,7 +1236,7 @@ namespace OpenIddict.Core /// public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1290,12 +1290,12 @@ namespace OpenIddict.Core public virtual async ValueTask UpdateAsync(TToken token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -1324,7 +1324,7 @@ namespace OpenIddict.Core public virtual async IAsyncEnumerable ValidateAsync( TToken token, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -1339,7 +1339,7 @@ namespace OpenIddict.Core // the casing is different). To avoid issues when the reference identifier is part of an index // using the same collation, an error is added even if the two identifiers don't exactly match. var other = await Store.FindByReferenceIdAsync(identifier, cancellationToken); - if (other != null && !string.Equals( + if (other is not null && !string.Equals( await Store.GetIdAsync(other, cancellationToken), await Store.GetIdAsync(token, cancellationToken), StringComparison.Ordinal)) { diff --git a/src/OpenIddict.Core/OpenIddictCoreBuilder.cs b/src/OpenIddict.Core/OpenIddictCoreBuilder.cs index bd0c6d73..f4b24f86 100644 --- a/src/OpenIddict.Core/OpenIddictCoreBuilder.cs +++ b/src/OpenIddict.Core/OpenIddictCoreBuilder.cs @@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -74,13 +74,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder AddApplicationStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(IOpenIddictApplicationStore<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -130,13 +130,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder AddAuthorizationStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(IOpenIddictAuthorizationStore<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -186,13 +186,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder AddScopeStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(IOpenIddictScopeStore<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -242,13 +242,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder AddTokenStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(IOpenIddictTokenStore<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -296,13 +296,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder ReplaceApplicationManager(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(OpenIddictApplicationManager<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -353,7 +353,7 @@ namespace Microsoft.Extensions.DependencyInjection public OpenIddictCoreBuilder ReplaceApplicationStoreResolver( Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -390,13 +390,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder ReplaceAuthorizationManager(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(OpenIddictAuthorizationManager<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -447,7 +447,7 @@ namespace Microsoft.Extensions.DependencyInjection public OpenIddictCoreBuilder ReplaceAuthorizationStoreResolver( Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -484,13 +484,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder ReplaceScopeManager(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(OpenIddictScopeManager<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -541,7 +541,7 @@ namespace Microsoft.Extensions.DependencyInjection public OpenIddictCoreBuilder ReplaceScopeStoreResolver( Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -578,13 +578,13 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder ReplaceTokenManager(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } var root = OpenIddictHelpers.FindGenericBaseType(type, typeof(OpenIddictTokenManager<>)); - if (root == null) + if (root is null) { throw new ArgumentException(SR.GetResourceString(SR.ID1231), nameof(type)); } @@ -635,7 +635,7 @@ namespace Microsoft.Extensions.DependencyInjection public OpenIddictCoreBuilder ReplaceTokenStoreResolver( Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -684,7 +684,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder SetDefaultApplicationEntity(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -711,7 +711,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder SetDefaultAuthorizationEntity(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -738,7 +738,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder SetDefaultScopeEntity(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -765,7 +765,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictCoreBuilder SetDefaultTokenEntity(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } diff --git a/src/OpenIddict.Core/OpenIddictCoreExtensions.cs b/src/OpenIddict.Core/OpenIddictCoreExtensions.cs index 3c976165..1e8e217d 100644 --- a/src/OpenIddict.Core/OpenIddictCoreExtensions.cs +++ b/src/OpenIddict.Core/OpenIddictCoreExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictCoreBuilder AddCore(this OpenIddictBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -57,7 +57,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>().CurrentValue; - if (options.DefaultApplicationType == null) + if (options.DefaultApplicationType is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1272)); } @@ -69,7 +69,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>().CurrentValue; - if (options.DefaultAuthorizationType == null) + if (options.DefaultAuthorizationType is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1273)); } @@ -81,7 +81,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>().CurrentValue; - if (options.DefaultScopeType == null) + if (options.DefaultScopeType is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1274)); } @@ -93,7 +93,7 @@ namespace Microsoft.Extensions.DependencyInjection builder.Services.TryAddScoped(provider => { var options = provider.GetRequiredService>().CurrentValue; - if (options.DefaultTokenType == null) + if (options.DefaultTokenType is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1275)); } @@ -126,12 +126,12 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictBuilder AddCore(this OpenIddictBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs index 48b486b7..1a542ff3 100644 --- a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs +++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs @@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictEntityFrameworkBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -99,7 +99,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictEntityFrameworkBuilder UseDbContext(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs index a8198172..ec7854e0 100644 --- a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs +++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs @@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictEntityFrameworkBuilder UseEntityFramework(this OpenIddictCoreBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -69,12 +69,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictCoreBuilder UseEntityFramework( this OpenIddictCoreBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs index 4dac9167..6d59ef8b 100644 --- a/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs +++ b/src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs @@ -48,7 +48,7 @@ namespace System.Data.Entity where TToken : OpenIddictEntityFrameworkToken where TKey : IEquatable { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -71,7 +71,7 @@ namespace System.Data.Entity /// The non-streamed async enumeration containing the results. internal static IAsyncEnumerable AsAsyncEnumerable(this IQueryable source, CancellationToken cancellationToken) { - if (source == null) + if (source is null) { throw new ArgumentNullException(nameof(source)); } diff --git a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs index d8f73aeb..5e9d43ae 100644 --- a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs +++ b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework public IOpenIddictApplicationStore Get() where TApplication : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFramework var type = _cache.GetOrAdd(typeof(TApplication), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkApplication<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1233)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1234)); } diff --git a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs index 993c9e56..707f24ac 100644 --- a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs +++ b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework public IOpenIddictAuthorizationStore Get() where TAuthorization : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFramework var type = _cache.GetOrAdd(typeof(TAuthorization), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkAuthorization<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1235)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1234)); } diff --git a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs index 587e6726..e142c52d 100644 --- a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs +++ b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework public IOpenIddictScopeStore Get() where TScope : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFramework var type = _cache.GetOrAdd(typeof(TScope), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkScope<>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1236)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1234)); } diff --git a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs index 32e7d507..3fd72865 100644 --- a/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs +++ b/src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework public IOpenIddictTokenStore Get() where TToken : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFramework var type = _cache.GetOrAdd(typeof(TToken), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkToken<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1237)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1234)); } diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs index 7d848d7e..00d17fc8 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs @@ -109,7 +109,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -120,7 +120,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -133,7 +133,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -315,7 +315,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -326,7 +326,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetClientIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -337,7 +337,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetClientSecretAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -348,7 +348,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetClientTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -359,7 +359,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -370,7 +370,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -381,7 +381,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -409,7 +409,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -420,7 +420,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -447,7 +447,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -474,7 +474,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -501,7 +501,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -528,7 +528,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -591,7 +591,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -602,7 +602,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetClientIdAsync(TApplication application, string? identifier, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -615,7 +615,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetClientSecretAsync(TApplication application, string? secret, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -628,7 +628,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetClientTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -641,7 +641,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetConsentTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -654,7 +654,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetDisplayNameAsync(TApplication application, string? name, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -668,12 +668,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetDisplayNamesAsync(TApplication application, ImmutableDictionary names, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { application.DisplayNames = null; @@ -706,7 +706,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray permissions, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -731,7 +731,7 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetPostLogoutRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -756,12 +756,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetPropertiesAsync(TApplication application, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { application.Properties = null; @@ -781,7 +781,7 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -805,7 +805,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray requirements, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -829,7 +829,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs index 4e1bcddd..cbaaa811 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs @@ -106,7 +106,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -117,7 +117,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -130,7 +130,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -204,8 +204,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from authorization in Authorizations.Include(authorization => authorization.Application) - where authorization.Application != null && - authorization.Application.Id!.Equals(key) && + where authorization.Application!.Id!.Equals(key) && authorization.Subject == subject select authorization).AsAsyncEnumerable(cancellationToken); } @@ -233,8 +232,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from authorization in Authorizations.Include(authorization => authorization.Application) - where authorization.Application != null && - authorization.Application.Id!.Equals(key) && + where authorization.Application!.Id!.Equals(key) && authorization.Subject == subject && authorization.Status == status select authorization).AsAsyncEnumerable(cancellationToken); @@ -268,8 +266,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from authorization in Authorizations.Include(authorization => authorization.Application) - where authorization.Application != null && - authorization.Application.Id!.Equals(key) && + where authorization.Application!.Id!.Equals(key) && authorization.Subject == subject && authorization.Status == status && authorization.Type == type @@ -309,8 +306,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); var authorizations = (from authorization in Authorizations.Include(authorization => authorization.Application) - where authorization.Application != null && - authorization.Application.Id!.Equals(key) && + where authorization.Application!.Id!.Equals(key) && authorization.Subject == subject && authorization.Status == status && authorization.Type == type @@ -374,13 +370,13 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } // If the application is not attached to the authorization, try to load it manually. - if (authorization.Application == null) + if (authorization.Application is null) { var reference = Context.Entry(authorization).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -391,7 +387,7 @@ namespace OpenIddict.EntityFramework await reference.LoadAsync(cancellationToken); } - if (authorization.Application == null) + if (authorization.Application is null) { return null; } @@ -404,7 +400,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -416,7 +412,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -427,7 +423,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -438,7 +434,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -465,7 +461,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -492,7 +488,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -503,7 +499,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -514,7 +510,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -562,7 +558,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -637,7 +633,7 @@ namespace OpenIddict.EntityFramework } } - if (exceptions != null) + if (exceptions is not null) { throw new AggregateException(SR.GetResourceString(SR.ID1242), exceptions); } @@ -647,7 +643,7 @@ namespace OpenIddict.EntityFramework public virtual async ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -655,7 +651,7 @@ namespace OpenIddict.EntityFramework if (!string.IsNullOrEmpty(identifier)) { var application = await Applications.FindAsync(cancellationToken, ConvertIdentifierFromString(identifier)); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1243)); } @@ -666,7 +662,7 @@ namespace OpenIddict.EntityFramework else { // If the application is not attached to the authorization, try to load it manually. - if (authorization.Application == null) + if (authorization.Application is null) { var reference = Context.Entry(authorization).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -685,7 +681,7 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetCreationDateAsync(TAuthorization authorization, DateTimeOffset? date, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -699,12 +695,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetPropertiesAsync(TAuthorization authorization, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { authorization.Properties = null; @@ -724,7 +720,7 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -748,7 +744,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -761,7 +757,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -774,7 +770,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -787,7 +783,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs index feee3183..5d7144bc 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs @@ -92,7 +92,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -103,7 +103,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -116,7 +116,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -220,7 +220,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -231,7 +231,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -242,7 +242,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -270,7 +270,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -281,7 +281,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -309,7 +309,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -320,7 +320,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -331,7 +331,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -358,7 +358,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetResourcesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -420,7 +420,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -431,7 +431,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -445,12 +445,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetDescriptionsAsync(TScope scope, ImmutableDictionary descriptions, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (descriptions == null || descriptions.IsEmpty) + if (descriptions is null || descriptions.IsEmpty) { scope.Descriptions = null; @@ -483,7 +483,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -497,12 +497,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetDisplayNamesAsync(TScope scope, ImmutableDictionary names, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { scope.DisplayNames = null; @@ -535,7 +535,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -549,12 +549,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetPropertiesAsync(TScope scope, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { scope.Properties = null; @@ -573,7 +573,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray resources, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -597,7 +597,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs index bcf47cda..aa4b6350 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs @@ -106,7 +106,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -117,7 +117,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -130,7 +130,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -168,8 +168,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) - where token.Application != null && - token.Application.Id!.Equals(key) && + where token.Application!.Id!.Equals(key) && token.Subject == subject select token).AsAsyncEnumerable(cancellationToken); } @@ -197,8 +196,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) - where token.Application != null && - token.Application.Id!.Equals(key) && + where token.Application!.Id!.Equals(key) && token.Subject == subject && token.Status == status select token).AsAsyncEnumerable(cancellationToken); @@ -232,8 +230,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(client); return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) - where token.Application != null && - token.Application.Id!.Equals(key) && + where token.Application!.Id!.Equals(key) && token.Subject == subject && token.Status == status && token.Type == type @@ -251,8 +248,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(identifier); return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) - where token.Application != null && - token.Application.Id!.Equals(key) + where token.Application!.Id!.Equals(key) select token).AsAsyncEnumerable(cancellationToken); } @@ -267,8 +263,7 @@ namespace OpenIddict.EntityFramework var key = ConvertIdentifierFromString(identifier); return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) - where token.Authorization != null && - token.Authorization.Id!.Equals(key) + where token.Authorization!.Id!.Equals(key) select token).AsAsyncEnumerable(cancellationToken); } @@ -316,13 +311,13 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } // If the application is not attached to the token, try to load it manually. - if (token.Application == null) + if (token.Application is null) { var reference = Context.Entry(token).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -333,7 +328,7 @@ namespace OpenIddict.EntityFramework await reference.LoadAsync(cancellationToken); } - if (token.Application == null) + if (token.Application is null) { return null; } @@ -346,7 +341,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -359,13 +354,13 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } // If the authorization is not attached to the token, try to load it manually. - if (token.Authorization == null) + if (token.Authorization is null) { var reference = Context.Entry(token).Reference(entry => entry.Authorization); if (reference.EntityEntry.State == EntityState.Detached) @@ -376,7 +371,7 @@ namespace OpenIddict.EntityFramework await reference.LoadAsync(cancellationToken); } - if (token.Authorization == null) + if (token.Authorization is null) { return null; } @@ -387,7 +382,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -398,7 +393,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -409,7 +404,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -420,7 +415,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -431,7 +426,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask> GetPropertiesAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -458,7 +453,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -469,7 +464,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -480,7 +475,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -491,7 +486,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -540,7 +535,7 @@ namespace OpenIddict.EntityFramework Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -616,7 +611,7 @@ namespace OpenIddict.EntityFramework } } - if (exceptions != null) + if (exceptions is not null) { throw new AggregateException(SR.GetResourceString(SR.ID1248), exceptions); } @@ -625,7 +620,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -633,7 +628,7 @@ namespace OpenIddict.EntityFramework if (!string.IsNullOrEmpty(identifier)) { var application = await Applications.FindAsync(cancellationToken, ConvertIdentifierFromString(identifier)); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1249)); } @@ -644,7 +639,7 @@ namespace OpenIddict.EntityFramework else { // If the application is not attached to the token, try to load it manually. - if (token.Application == null) + if (token.Application is null) { var reference = Context.Entry(token).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -662,7 +657,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -670,7 +665,7 @@ namespace OpenIddict.EntityFramework if (!string.IsNullOrEmpty(identifier)) { var authorization = await Authorizations.FindAsync(cancellationToken, ConvertIdentifierFromString(identifier)); - if (authorization == null) + if (authorization is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1250)); } @@ -681,7 +676,7 @@ namespace OpenIddict.EntityFramework else { // If the authorization is not attached to the token, try to load it manually. - if (token.Authorization == null) + if (token.Authorization is null) { var reference = Context.Entry(token).Reference(entry => entry.Authorization); if (reference.EntityEntry.State == EntityState.Detached) @@ -699,7 +694,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -712,7 +707,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -725,7 +720,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -739,12 +734,12 @@ namespace OpenIddict.EntityFramework public virtual ValueTask SetPropertiesAsync(TToken token, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { token.Properties = null; @@ -763,7 +758,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -776,7 +771,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -789,7 +784,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -802,7 +797,7 @@ namespace OpenIddict.EntityFramework /// public virtual ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -815,7 +810,7 @@ namespace OpenIddict.EntityFramework /// public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs index 6c7c6c60..aef7b342 100644 --- a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs +++ b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs @@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore { public void Configure(EntityTypeBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs index 627e97e0..eba33bd8 100644 --- a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs +++ b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs @@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore { public void Configure(EntityTypeBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs index 5d77bbd6..0634fce5 100644 --- a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs +++ b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs @@ -24,7 +24,7 @@ namespace OpenIddict.EntityFrameworkCore { public void Configure(EntityTypeBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs index 9cfbe99b..8a3ea041 100644 --- a/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs +++ b/src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs @@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore { public void Configure(EntityTypeBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs index 443e7a4d..c1b3b648 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs @@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictEntityFrameworkCoreBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -101,7 +101,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictEntityFrameworkCoreBuilder UseDbContext(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs index 02ae4a24..76bde03a 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs @@ -29,12 +29,12 @@ namespace OpenIddict.EntityFrameworkCore public override void Customize(ModelBuilder modelBuilder, DbContext context) { - if (modelBuilder == null) + if (modelBuilder is null) { throw new ArgumentNullException(nameof(modelBuilder)); } - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs index dd6d50e0..397b61ba 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs @@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictEntityFrameworkCoreBuilder UseEntityFrameworkCore(this OpenIddictCoreBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -69,12 +69,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictCoreBuilder UseEntityFrameworkCore( this OpenIddictCoreBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs index aeffafde..2d99d45c 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs @@ -68,7 +68,7 @@ namespace Microsoft.EntityFrameworkCore where TToken : OpenIddictEntityFrameworkCoreToken where TKey : IEquatable { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -122,7 +122,7 @@ namespace Microsoft.EntityFrameworkCore where TToken : OpenIddictEntityFrameworkCoreToken where TKey : IEquatable { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -145,7 +145,7 @@ namespace Microsoft.EntityFrameworkCore internal static IAsyncEnumerable AsAsyncEnumerable( this IQueryable source, CancellationToken cancellationToken = default) { - if (source == null) + if (source is null) { throw new ArgumentNullException(nameof(source)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs index e27e221e..ef8b7918 100644 --- a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs +++ b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore public IOpenIddictApplicationStore Get() where TApplication : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFrameworkCore var type = _cache.GetOrAdd(typeof(TApplication), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkCoreApplication<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1251)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1252)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs index 4cf4c005..28cfd55d 100644 --- a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs +++ b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore public IOpenIddictAuthorizationStore Get() where TAuthorization : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFrameworkCore var type = _cache.GetOrAdd(typeof(TAuthorization), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkCoreAuthorization<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1253)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1252)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs index cad7250e..66fdedc5 100644 --- a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs +++ b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore public IOpenIddictScopeStore Get() where TScope : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFrameworkCore var type = _cache.GetOrAdd(typeof(TScope), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkCoreScope<>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1254)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1252)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs index 1941b2fa..95190193 100644 --- a/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs +++ b/src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs @@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore public IOpenIddictTokenStore Get() where TToken : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } @@ -51,13 +51,13 @@ namespace OpenIddict.EntityFrameworkCore var type = _cache.GetOrAdd(typeof(TToken), key => { var root = OpenIddictHelpers.FindGenericBaseType(key, typeof(OpenIddictEntityFrameworkCoreToken<,,>)); - if (root == null) + if (root is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1255)); } var context = _options.CurrentValue.DbContextType; - if (context == null) + if (context is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1252)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs index f60186dc..f3441323 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs @@ -138,7 +138,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -149,7 +149,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -162,7 +162,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -366,7 +366,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -377,7 +377,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetClientIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -388,7 +388,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetClientSecretAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -399,7 +399,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetClientTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -410,7 +410,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -421,7 +421,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -432,7 +432,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -460,7 +460,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -471,7 +471,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -498,7 +498,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -525,7 +525,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -552,7 +552,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -579,7 +579,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -641,7 +641,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -652,7 +652,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetClientIdAsync(TApplication application, string? identifier, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -665,7 +665,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetClientSecretAsync(TApplication application, string? secret, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -678,7 +678,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetClientTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -691,7 +691,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetConsentTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -704,7 +704,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetDisplayNameAsync(TApplication application, string? name, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -718,12 +718,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetDisplayNamesAsync(TApplication application, ImmutableDictionary names, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { application.DisplayNames = null; @@ -756,7 +756,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray permissions, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -781,7 +781,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetPostLogoutRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -806,12 +806,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetPropertiesAsync(TApplication application, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { application.Properties = null; @@ -831,7 +831,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -855,7 +855,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray requirements, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -879,7 +879,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs index 6e319ac8..dceabfce 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs @@ -128,7 +128,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -139,7 +139,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -152,7 +152,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -437,13 +437,13 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } // If the application is not attached to the authorization, try to load it manually. - if (authorization.Application == null) + if (authorization.Application is null) { var reference = Context.Entry(authorization).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -454,7 +454,7 @@ namespace OpenIddict.EntityFrameworkCore await reference.LoadAsync(cancellationToken); } - if (authorization.Application == null) + if (authorization.Application is null) { return null; } @@ -467,7 +467,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -480,7 +480,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -491,7 +491,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -502,7 +502,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -529,7 +529,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -556,7 +556,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -567,7 +567,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -578,7 +578,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -626,7 +626,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -713,7 +713,7 @@ namespace OpenIddict.EntityFrameworkCore } } - if (exceptions != null) + if (exceptions is not null) { throw new AggregateException(SR.GetResourceString(SR.ID1242), exceptions); } @@ -723,7 +723,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual async ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -737,7 +737,7 @@ namespace OpenIddict.EntityFrameworkCore var application = await Applications.AsQueryable() .FirstOrDefaultAsync(application => application.Id!.Equals(key), cancellationToken); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1243)); } @@ -748,7 +748,7 @@ namespace OpenIddict.EntityFrameworkCore else { // If the application is not attached to the authorization, try to load it manually. - if (authorization.Application == null) + if (authorization.Application is null) { var reference = Context.Entry(authorization).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -767,7 +767,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetCreationDateAsync(TAuthorization authorization, DateTimeOffset? date, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -781,12 +781,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetPropertiesAsync(TAuthorization authorization, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { authorization.Properties = null; @@ -806,7 +806,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -831,7 +831,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -845,7 +845,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -859,7 +859,7 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -872,7 +872,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs index a2fa0282..c2796ed3 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs @@ -108,7 +108,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -119,7 +119,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -132,7 +132,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -236,7 +236,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -247,7 +247,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -258,7 +258,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -286,7 +286,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -297,7 +297,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -325,7 +325,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -336,7 +336,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -347,7 +347,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -374,7 +374,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetResourcesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -436,7 +436,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -447,7 +447,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -461,12 +461,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetDescriptionsAsync(TScope scope, ImmutableDictionary descriptions, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (descriptions == null || descriptions.IsEmpty) + if (descriptions is null || descriptions.IsEmpty) { scope.Descriptions = null; @@ -499,7 +499,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -513,12 +513,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetDisplayNamesAsync(TScope scope, ImmutableDictionary names, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (names == null || names.IsEmpty) + if (names is null || names.IsEmpty) { scope.DisplayNames = null; @@ -551,7 +551,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -565,12 +565,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetPropertiesAsync(TScope scope, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { scope.Properties = null; @@ -589,7 +589,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray resources, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -613,7 +613,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs index 4dd14382..dc8a7f40 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs @@ -128,7 +128,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -139,7 +139,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -152,7 +152,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -362,13 +362,13 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } // If the application is not attached to the token, try to load it manually. - if (token.Application == null) + if (token.Application is null) { var reference = Context.Entry(token).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -379,7 +379,7 @@ namespace OpenIddict.EntityFrameworkCore await reference.LoadAsync(cancellationToken); } - if (token.Application == null) + if (token.Application is null) { return null; } @@ -392,7 +392,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -406,13 +406,13 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } // If the authorization is not attached to the token, try to load it manually. - if (token.Authorization == null) + if (token.Authorization is null) { var reference = Context.Entry(token).Reference(entry => entry.Authorization); if (reference.EntityEntry.State == EntityState.Detached) @@ -423,7 +423,7 @@ namespace OpenIddict.EntityFrameworkCore await reference.LoadAsync(cancellationToken); } - if (token.Authorization == null) + if (token.Authorization is null) { return null; } @@ -434,7 +434,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -445,7 +445,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -456,7 +456,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -467,7 +467,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -478,7 +478,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask> GetPropertiesAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -505,7 +505,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -516,7 +516,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -527,7 +527,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -538,7 +538,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -587,7 +587,7 @@ namespace OpenIddict.EntityFrameworkCore Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -674,7 +674,7 @@ namespace OpenIddict.EntityFrameworkCore } } - if (exceptions != null) + if (exceptions is not null) { throw new AggregateException(SR.GetResourceString(SR.ID1248), exceptions); } @@ -683,7 +683,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -697,7 +697,7 @@ namespace OpenIddict.EntityFrameworkCore var application = await Applications.AsQueryable() .FirstOrDefaultAsync(application => application.Id!.Equals(key), cancellationToken); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1249)); } @@ -708,7 +708,7 @@ namespace OpenIddict.EntityFrameworkCore else { // If the application is not attached to the token, try to load it manually. - if (token.Application == null) + if (token.Application is null) { var reference = Context.Entry(token).Reference(entry => entry.Application); if (reference.EntityEntry.State == EntityState.Detached) @@ -726,7 +726,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -740,7 +740,7 @@ namespace OpenIddict.EntityFrameworkCore var authorization = await Authorizations.AsQueryable() .FirstOrDefaultAsync(authorization => authorization.Id!.Equals(key), cancellationToken); - if (authorization == null) + if (authorization is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1250)); } @@ -751,7 +751,7 @@ namespace OpenIddict.EntityFrameworkCore else { // If the authorization is not attached to the token, try to load it manually. - if (token.Authorization == null) + if (token.Authorization is null) { var reference = Context.Entry(token).Reference(entry => entry.Authorization); if (reference.EntityEntry.State == EntityState.Detached) @@ -769,7 +769,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -782,7 +782,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -795,7 +795,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -809,12 +809,12 @@ namespace OpenIddict.EntityFrameworkCore public virtual ValueTask SetPropertiesAsync(TToken token, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { token.Properties = null; @@ -833,7 +833,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -846,7 +846,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -859,7 +859,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -872,7 +872,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -885,7 +885,7 @@ namespace OpenIddict.EntityFrameworkCore /// public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs index e2ec1599..445c3652 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs @@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictMongoDbBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -166,7 +166,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictMongoDbBuilder UseDatabase(IMongoDatabase database) { - if (database == null) + if (database is null) { throw new ArgumentNullException(nameof(database)); } diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs index a28167fc..ceec6a7b 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs @@ -37,12 +37,12 @@ namespace OpenIddict.MongoDb } var database = _options.CurrentValue.Database; - if (database == null) + if (database is null) { database = _provider.GetService(); } - if (database == null) + if (database is null) { return new ValueTask(Task.FromException( new InvalidOperationException(SR.GetResourceString(SR.ID1261)))); diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs index 21594a3a..c6bd8ced 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs @@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictMongoDbBuilder UseMongoDb(this OpenIddictCoreBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -67,12 +67,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictCoreBuilder UseMongoDb( this OpenIddictCoreBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs b/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs index e3b29207..108c3652 100644 --- a/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs +++ b/src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs @@ -26,7 +26,7 @@ namespace MongoDB.Driver /// The streamed async enumeration containing the results. internal static IAsyncEnumerable ToAsyncEnumerable(this IAsyncCursorSource source, CancellationToken cancellationToken) { - if (source == null) + if (source is null) { throw new ArgumentNullException(nameof(source)); } @@ -56,7 +56,7 @@ namespace MongoDB.Driver /// The streamed async enumeration containing the results. internal static IAsyncEnumerable ToAsyncEnumerable(this IQueryable source, CancellationToken cancellationToken) { - if (source == null) + if (source is null) { throw new ArgumentNullException(nameof(source)); } diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs index 1a8e93a9..5ad11b1c 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs @@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb public IOpenIddictApplicationStore Get() where TApplication : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs index a4296f20..6095ae5c 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs @@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb public IOpenIddictAuthorizationStore Get() where TAuthorization : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs index da5143d8..37e926d1 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs @@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb public IOpenIddictScopeStore Get() where TScope : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs index 22ba1c5f..8fd8bbf8 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs @@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb public IOpenIddictTokenStore Get() where TToken : class { var store = _provider.GetService>(); - if (store != null) + if (store is not null) { return store; } diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs index d8edb8fb..b547228e 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs @@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb public virtual async ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -90,7 +90,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -196,7 +196,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -210,7 +210,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetClientIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -221,7 +221,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetClientSecretAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -232,7 +232,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetClientTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -243,7 +243,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -254,7 +254,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -265,12 +265,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.DisplayNames == null || application.DisplayNames.Count == 0) + if (application.DisplayNames is null || application.DisplayNames.Count == 0) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -281,7 +281,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -293,12 +293,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask> GetPermissionsAsync( TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.Permissions == null || application.Permissions.Count == 0) + if (application.Permissions is null || application.Permissions.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -310,12 +310,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask> GetPostLogoutRedirectUrisAsync( TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.PostLogoutRedirectUris == null || application.PostLogoutRedirectUris.Count == 0) + if (application.PostLogoutRedirectUris is null || application.PostLogoutRedirectUris.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -326,12 +326,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.Properties == null) + if (application.Properties is null) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -344,12 +344,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask> GetRedirectUrisAsync( TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.RedirectUris == null || application.RedirectUris.Count == 0) + if (application.RedirectUris is null || application.RedirectUris.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -360,12 +360,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (application.Requirements == null || application.Requirements.Count == 0) + if (application.Requirements is null || application.Requirements.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -418,7 +418,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -441,7 +441,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetClientIdAsync(TApplication application, string? identifier, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -455,7 +455,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetClientSecretAsync(TApplication application, string? secret, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -469,7 +469,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetClientTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -483,7 +483,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetConsentTypeAsync(TApplication application, string? type, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -497,7 +497,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetDisplayNameAsync(TApplication application, string? name, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -511,7 +511,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetDisplayNamesAsync(TApplication application, ImmutableDictionary names, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -524,7 +524,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray permissions, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -545,7 +545,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetPostLogoutRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -566,12 +566,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetPropertiesAsync(TApplication application, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { application.Properties = null; @@ -591,7 +591,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -612,7 +612,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray requirements, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } @@ -632,7 +632,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken) { - if (application == null) + if (application is null) { throw new ArgumentNullException(nameof(application)); } diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs index b2fbd743..0b605e10 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs @@ -61,7 +61,7 @@ namespace OpenIddict.MongoDb public virtual async ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -75,7 +75,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -89,7 +89,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -332,7 +332,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -350,7 +350,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -364,7 +364,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -375,7 +375,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -386,12 +386,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (authorization.Properties == null) + if (authorization.Properties is null) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -403,12 +403,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (authorization.Scopes == null || authorization.Scopes.Count == 0) + if (authorization.Scopes is null || authorization.Scopes.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -419,7 +419,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -430,7 +430,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -441,7 +441,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -494,7 +494,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -556,7 +556,7 @@ namespace OpenIddict.MongoDb } } - if (buffer != null) + if (buffer is not null) { yield return buffer; } @@ -567,7 +567,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -589,7 +589,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetCreationDateAsync(TAuthorization authorization, DateTimeOffset? date, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -603,12 +603,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetPropertiesAsync(TAuthorization authorization, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { authorization.Properties = null; @@ -628,7 +628,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -648,7 +648,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -661,7 +661,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -674,7 +674,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } @@ -687,7 +687,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken) { - if (authorization == null) + if (authorization is null) { throw new ArgumentNullException(nameof(authorization)); } diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs index 762a9fa0..2edb4795 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs @@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb public virtual async ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -90,7 +90,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -185,7 +185,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -199,7 +199,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -210,12 +210,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (scope.Descriptions == null || scope.Descriptions.Count == 0) + if (scope.Descriptions is null || scope.Descriptions.Count == 0) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -226,7 +226,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -237,12 +237,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (scope.DisplayNames == null || scope.DisplayNames.Count == 0) + if (scope.DisplayNames is null || scope.DisplayNames.Count == 0) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -253,7 +253,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -264,7 +264,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -275,12 +275,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (scope.Properties == null) + if (scope.Properties is null) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -292,12 +292,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetResourcesAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (scope.Resources == null || scope.Resources.Count == 0) + if (scope.Resources is null || scope.Resources.Count == 0) { return new ValueTask>(ImmutableArray.Create()); } @@ -350,7 +350,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -372,7 +372,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -386,7 +386,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetDescriptionsAsync(TScope scope, ImmutableDictionary descriptions, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -400,7 +400,7 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetDisplayNamesAsync(TScope scope, ImmutableDictionary names, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -413,7 +413,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -426,7 +426,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -440,12 +440,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetPropertiesAsync(TScope scope, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { scope.Properties = null; @@ -464,7 +464,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray resources, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } @@ -484,7 +484,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken) { - if (scope == null) + if (scope is null) { throw new ArgumentNullException(nameof(scope)); } diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs index 6dac66b6..070a8921 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs @@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb public virtual async ValueTask CountAsync( Func, IQueryable> query, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -90,7 +90,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -315,7 +315,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -333,7 +333,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -347,7 +347,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -363,7 +363,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -374,7 +374,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -385,7 +385,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -396,7 +396,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -407,12 +407,12 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask> GetPropertiesAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (token.Properties == null) + if (token.Properties is null) { return new ValueTask>(ImmutableDictionary.Create()); } @@ -424,7 +424,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -435,7 +435,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -446,7 +446,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -457,7 +457,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -510,7 +510,7 @@ namespace OpenIddict.MongoDb Func, TState, IQueryable> query, TState state, CancellationToken cancellationToken) { - if (query == null) + if (query is null) { throw new ArgumentNullException(nameof(query)); } @@ -573,7 +573,7 @@ namespace OpenIddict.MongoDb } } - if (buffer != null) + if (buffer is not null) { yield return buffer; } @@ -583,7 +583,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -604,7 +604,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -625,7 +625,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -638,7 +638,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -651,7 +651,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -665,12 +665,12 @@ namespace OpenIddict.MongoDb public virtual ValueTask SetPropertiesAsync(TToken token, ImmutableDictionary properties, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } - if (properties == null || properties.IsEmpty) + if (properties is null || properties.IsEmpty) { token.Properties = null; @@ -689,7 +689,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -702,7 +702,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -715,7 +715,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -728,7 +728,7 @@ namespace OpenIddict.MongoDb /// public virtual ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } @@ -741,7 +741,7 @@ namespace OpenIddict.MongoDb /// public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken) { - if (token == null) + if (token is null) { throw new ArgumentNullException(nameof(token)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs index 60cb703f..f823a0a5 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs @@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerAspNetCoreBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -172,7 +172,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerAspNetCoreBuilder SetAuthorizationEndpointCachingPolicy(DistributedCacheEntryOptions policy) { - if (policy == null) + if (policy is null) { throw new ArgumentNullException(nameof(policy)); } @@ -188,7 +188,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerAspNetCoreBuilder SetLogoutEndpointCachingPolicy(DistributedCacheEntryOptions policy) { - if (policy == null) + if (policy is null) { throw new ArgumentNullException(nameof(policy)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs index a1d65e9c..8edf836d 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs @@ -26,7 +26,7 @@ namespace OpenIddict.Server.AspNetCore /// The options instance to initialize. public void Configure(AuthenticationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -44,7 +44,7 @@ namespace OpenIddict.Server.AspNetCore public void Configure(OpenIddictServerOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -60,7 +60,7 @@ namespace OpenIddict.Server.AspNetCore /// The options instance to initialize. public void PostConfigure(string name, AuthenticationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -95,7 +95,7 @@ namespace OpenIddict.Server.AspNetCore /// The options instance to initialize. public void PostConfigure(string name, OpenIddictServerAspNetCoreOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs index 43c3b391..a7cb2bba 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictServerAspNetCoreBuilder UseAspNetCore(this OpenIddictServerBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -80,12 +80,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictServerBuilder UseAspNetCore( this OpenIddictServerBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs index b835fa67..7cc7cd33 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs @@ -54,7 +54,7 @@ namespace OpenIddict.Server.AspNetCore // Note: the transaction may be already attached when replaying an ASP.NET Core request // (e.g when using the built-in status code pages middleware with the re-execute mode). var transaction = Context.Features.Get()?.Transaction; - if (transaction == null) + if (transaction is null) { // Create a new transaction and attach the HTTP request to make it available to the ASP.NET Core handlers. transaction = await _factory.CreateTransactionAsync(); @@ -118,7 +118,7 @@ namespace OpenIddict.Server.AspNetCore // (generally later in the pipeline, when using the pass-through mode). To avoid having to re-validate it, // the authentication context is resolved from the transaction. If it's not available, a new one is created. var context = transaction.GetProperty(typeof(ProcessAuthenticationContext).FullName!); - if (context == null) + if (context is null) { context = new ProcessAuthenticationContext(transaction); await _dispatcher.DispatchAsync(context); @@ -155,7 +155,7 @@ namespace OpenIddict.Server.AspNetCore else { - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); Debug.Assert(!string.IsNullOrEmpty(context.Principal.GetTokenType()), SR.GetResourceString(SR.ID5009)); Debug.Assert(!string.IsNullOrEmpty(context.Token), SR.GetResourceString(SR.ID5010)); @@ -227,7 +227,7 @@ namespace OpenIddict.Server.AspNetCore /// public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties? properties) { - if (user == null) + if (user is null) { throw new ArgumentNullException(nameof(user)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs index fe51275e..98dfdff1 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs @@ -31,7 +31,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -53,7 +53,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -74,7 +74,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -90,12 +90,12 @@ namespace OpenIddict.Server.AspNetCore { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - return new ValueTask(context.Transaction.GetHttpRequest() != null); + return new ValueTask(context.Transaction.GetHttpRequest() is not null); } } @@ -111,7 +111,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -133,7 +133,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -154,7 +154,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -175,7 +175,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -197,7 +197,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -219,7 +219,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -241,7 +241,7 @@ namespace OpenIddict.Server.AspNetCore public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs index 4469c778..bad76c91 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs @@ -90,12 +90,12 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(ExtractAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // If a request_id parameter can be found in the authorization request, // restore the complete authorization request from the distributed cache. @@ -108,7 +108,7 @@ namespace OpenIddict.Server.AspNetCore // Note: the cache key is always prefixed with a specific marker // to avoid collisions with the other types of cached payloads. var token = await _cache.GetStringAsync(Cache.AuthorizationRequest + context.Request.RequestId); - if (token == null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) + if (token is null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) { context.Logger.LogError(SR.GetResourceString(SR.ID7146), Parameters.RequestId); @@ -191,17 +191,17 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(ExtractAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -295,7 +295,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -340,7 +340,7 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -348,7 +348,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -379,7 +379,7 @@ namespace OpenIddict.Server.AspNetCore foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) @@ -430,7 +430,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -438,7 +438,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -459,7 +459,7 @@ namespace OpenIddict.Server.AspNetCore foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) @@ -494,7 +494,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -502,7 +502,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -523,7 +523,7 @@ namespace OpenIddict.Server.AspNetCore foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs index d06cba65..38fdcd02 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs @@ -87,12 +87,12 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(ExtractLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // If a request_id parameter can be found in the logout request, // restore the complete logout request from the distributed cache. @@ -105,7 +105,7 @@ namespace OpenIddict.Server.AspNetCore // Note: the cache key is always prefixed with a specific marker // to avoid collisions with the other types of cached payloads. var token = await _cache.GetStringAsync(Cache.LogoutRequest + context.Request.RequestId); - if (token == null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) + if (token is null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) { context.Logger.LogError(SR.GetResourceString(SR.ID7150), Parameters.RequestId); @@ -188,17 +188,17 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(ExtractLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -292,7 +292,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -332,7 +332,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -340,7 +340,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -360,7 +360,7 @@ namespace OpenIddict.Server.AspNetCore foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs index 3710cac5..06edc14e 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs @@ -87,7 +87,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -95,7 +95,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -189,7 +189,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -197,14 +197,14 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } // Don't require that the request host be present if the request is not handled // by an OpenIddict endpoint or if an explicit issuer URL was already set. - if (context.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown) + if (context.Issuer is not null || context.EndpointType == OpenIddictServerEndpointType.Unknown) { return default; } @@ -255,7 +255,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -263,7 +263,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -308,13 +308,13 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null) + if (properties is not null) { context.Response.Error = properties.GetString(Properties.Error); context.Response.ErrorDescription = properties.GetString(Properties.ErrorDescription); @@ -346,15 +346,15 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties == null) + if (properties is null) { return default; } @@ -400,7 +400,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -408,7 +408,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -453,7 +453,7 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -461,7 +461,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -533,7 +533,7 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -541,7 +541,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -609,17 +609,17 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -708,7 +708,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -716,12 +716,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); string header = request.Headers[HeaderNames.Authorization]; if (string.IsNullOrEmpty(header) || !header.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) @@ -759,7 +759,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -790,7 +790,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -798,12 +798,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // When client authentication is made using basic authentication, the authorization server MUST return // a 401 response with a valid WWW-Authenticate header containing the Basic scheme and a non-empty realm. @@ -850,7 +850,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -858,7 +858,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -897,7 +897,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -905,12 +905,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // When client authentication is made using basic authentication, the authorization server MUST return // a 401 response with a valid WWW-Authenticate header containing the HTTP Basic authentication scheme. @@ -1011,7 +1011,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1019,7 +1019,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -1057,7 +1057,7 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1065,7 +1065,7 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -1114,7 +1114,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1122,12 +1122,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); if (string.IsNullOrEmpty(context.Transaction.Response.Error)) { @@ -1162,7 +1162,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1170,12 +1170,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); if (string.IsNullOrEmpty(context.Transaction.Response.Error)) { @@ -1186,7 +1186,7 @@ namespace OpenIddict.Server.AspNetCore // If it was not registered or enabled, let the default OpenIddict server handlers render // a default error page instead of delegating the rendering to the status code middleware. var feature = response.HttpContext.Features.Get(); - if (feature == null || !feature.Enabled) + if (feature is null || !feature.Enabled) { return default; } @@ -1221,7 +1221,7 @@ namespace OpenIddict.Server.AspNetCore /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1229,12 +1229,12 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); if (string.IsNullOrEmpty(context.Transaction.Response.Error)) { @@ -1298,7 +1298,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1306,13 +1306,13 @@ namespace OpenIddict.Server.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null && !string.IsNullOrEmpty(properties.RedirectUri)) + if (properties is not null && !string.IsNullOrEmpty(properties.RedirectUri)) { response.Redirect(properties.RedirectUri); @@ -1345,7 +1345,7 @@ namespace OpenIddict.Server.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs index 559b307a..02bb2e40 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static HttpRequest? GetHttpRequest(this OpenIddictServerTransaction transaction) { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore /// The . public static OpenIddictServerEndpointType GetOpenIddictServerEndpointType(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static OpenIddictRequest? GetOpenIddictServerRequest(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static OpenIddictResponse? GetOpenIddictServerResponse(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs index 99456e91..b51fbd6f 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerDataProtectionBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -56,7 +56,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerDataProtectionBuilder UseDataProtectionProvider(IDataProtectionProvider provider) { - if (provider == null) + if (provider is null) { throw new ArgumentNullException(nameof(provider)); } @@ -71,7 +71,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerDataProtectionBuilder UseFormatter(IOpenIddictServerDataProtectionFormatter formatter) { - if (formatter == null) + if (formatter is null) { throw new ArgumentNullException(nameof(formatter)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionConfiguration.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionConfiguration.cs index e58b4c50..8f364a8e 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionConfiguration.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionConfiguration.cs @@ -27,7 +27,7 @@ namespace OpenIddict.Server.DataProtection public void Configure(OpenIddictServerOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -44,7 +44,7 @@ namespace OpenIddict.Server.DataProtection /// The options instance to initialize. public void PostConfigure(string name, OpenIddictServerDataProtectionOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs index 3c93854d..1c4cbd88 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictServerDataProtectionBuilder UseDataProtection(this OpenIddictServerBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -68,12 +68,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictServerBuilder UseDataProtection( this OpenIddictServerBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs index c5ea4efd..b16072b0 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs @@ -22,13 +22,13 @@ namespace OpenIddict.Server.DataProtection { public ClaimsPrincipal? ReadToken(BinaryReader reader) { - if (reader == null) + if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var (principal, properties) = Read(reader); - if (principal == null) + if (principal is null) { return null; } @@ -186,12 +186,12 @@ namespace OpenIddict.Server.DataProtection public void WriteToken(BinaryWriter writer, ClaimsPrincipal principal) { - if (writer == null) + if (writer is null) { throw new ArgumentNullException(nameof(writer)); } - if (principal == null) + if (principal is null) { throw new ArgumentNullException(nameof(principal)); } @@ -303,7 +303,7 @@ namespace OpenIddict.Server.DataProtection writer.Write(false); } - if (identity.Actor != null) + if (identity.Actor is not null) { writer.Write(true); WriteIdentity(writer, identity.Actor); @@ -317,12 +317,12 @@ namespace OpenIddict.Server.DataProtection static void WriteClaim(BinaryWriter writer, Claim claim) { - if (writer == null) + if (writer is null) { throw new ArgumentNullException(nameof(writer)); } - if (claim == null) + if (claim is null) { throw new ArgumentNullException(nameof(claim)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs index d34dd7fd..44b918b0 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs @@ -31,7 +31,7 @@ namespace OpenIddict.Server.DataProtection public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -53,7 +53,7 @@ namespace OpenIddict.Server.DataProtection public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -75,7 +75,7 @@ namespace OpenIddict.Server.DataProtection public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -97,7 +97,7 @@ namespace OpenIddict.Server.DataProtection public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -119,7 +119,7 @@ namespace OpenIddict.Server.DataProtection public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs index 043dca36..2f469a10 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs @@ -68,13 +68,13 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } // If a principal was already attached, don't overwrite it. - if (context.Principal != null) + if (context.Principal is not null) { return default; } @@ -94,7 +94,7 @@ namespace OpenIddict.Server.DataProtection ValidateToken(context.Token, TokenTypeHints.DeviceCode) ?? ValidateToken(context.Token, TokenTypeHints.UserCode); - if (principal == null) + if (principal is null) { context.Reject( error: context.EndpointType switch @@ -187,7 +187,7 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -198,7 +198,7 @@ namespace OpenIddict.Server.DataProtection return default; } - if (context.AccessTokenPrincipal == null) + if (context.AccessTokenPrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -250,7 +250,7 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -261,7 +261,7 @@ namespace OpenIddict.Server.DataProtection return default; } - if (context.AuthorizationCodePrincipal == null) + if (context.AuthorizationCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -313,7 +313,7 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -324,7 +324,7 @@ namespace OpenIddict.Server.DataProtection return default; } - if (context.DeviceCodePrincipal == null) + if (context.DeviceCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -376,7 +376,7 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -387,7 +387,7 @@ namespace OpenIddict.Server.DataProtection return default; } - if (context.RefreshTokenPrincipal == null) + if (context.RefreshTokenPrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -439,7 +439,7 @@ namespace OpenIddict.Server.DataProtection /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -450,7 +450,7 @@ namespace OpenIddict.Server.DataProtection return default; } - if (context.UserCodePrincipal == null) + if (context.UserCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs index 310fa59e..8b803c99 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs @@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerOwinBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -161,7 +161,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerOwinBuilder SetAuthorizationEndpointCachingPolicy(DistributedCacheEntryOptions policy) { - if (policy == null) + if (policy is null) { throw new ArgumentNullException(nameof(policy)); } @@ -177,7 +177,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerOwinBuilder SetLogoutEndpointCachingPolicy(DistributedCacheEntryOptions policy) { - if (policy == null) + if (policy is null) { throw new ArgumentNullException(nameof(policy)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs index 1fb0c008..9f5492e1 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs @@ -19,7 +19,7 @@ namespace OpenIddict.Server.Owin { public void Configure(OpenIddictServerOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -30,7 +30,7 @@ namespace OpenIddict.Server.Owin public void PostConfigure(string name, OpenIddictServerOwinOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs index 84e383c2..4b6a8515 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs @@ -28,7 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictServerOwinBuilder UseOwin(this OpenIddictServerBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -77,12 +77,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictServerBuilder UseOwin( this OpenIddictServerBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandler.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandler.cs index 32e40756..051597c3 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandler.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandler.cs @@ -46,7 +46,7 @@ namespace OpenIddict.Server.Owin // Note: the transaction may be already attached when replaying an OWIN request // (e.g when using a status code pages middleware re-invoking the OWIN pipeline). var transaction = Context.Get(typeof(OpenIddictServerTransaction).FullName); - if (transaction == null) + if (transaction is null) { // Create a new transaction and attach the OWIN request to make it available to the OWIN handlers. transaction = await _factory.CreateTransactionAsync(); @@ -121,7 +121,7 @@ namespace OpenIddict.Server.Owin protected override async Task AuthenticateCoreAsync() { var transaction = Context.Get(typeof(OpenIddictServerTransaction).FullName); - if (transaction == null) + if (transaction is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1111)); } @@ -130,7 +130,7 @@ namespace OpenIddict.Server.Owin // (generally later in the pipeline, when using the pass-through mode). To avoid having to re-validate it, // the authentication context is resolved from the transaction. If it's not available, a new one is created. var context = transaction.GetProperty(typeof(ProcessAuthenticationContext).FullName!); - if (context == null) + if (context is null) { context = new ProcessAuthenticationContext(transaction); await _dispatcher.DispatchAsync(context); @@ -167,7 +167,7 @@ namespace OpenIddict.Server.Owin else { - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); Debug.Assert(!string.IsNullOrEmpty(context.Principal.GetTokenType()), SR.GetResourceString(SR.ID5009)); Debug.Assert(!string.IsNullOrEmpty(context.Token), SR.GetResourceString(SR.ID5010)); @@ -201,7 +201,7 @@ namespace OpenIddict.Server.Owin // corresponds to a challenge response, as LookupChallenge() will always return a non-null // value when active authentication is used, even if no challenge was actually triggered. var challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode); - if (challenge != null && (Response.StatusCode == 401 || Response.StatusCode == 403)) + if (challenge is not null && (Response.StatusCode == 401 || Response.StatusCode == 403)) { var transaction = Context.Get(typeof(OpenIddictServerTransaction).FullName) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1111)); @@ -244,7 +244,7 @@ namespace OpenIddict.Server.Owin } var signin = Helper.LookupSignIn(Options.AuthenticationType); - if (signin != null) + if (signin is not null) { var transaction = Context.Get(typeof(OpenIddictServerTransaction).FullName) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1111)); @@ -288,7 +288,7 @@ namespace OpenIddict.Server.Owin } var signout = Helper.LookupSignOut(Options.AuthenticationType, Options.AuthenticationMode); - if (signout != null) + if (signout is not null) { var transaction = Context.Get(typeof(OpenIddictServerTransaction).FullName) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1111)); diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs index 122e33d9..88abb625 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs @@ -29,7 +29,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -51,7 +51,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -72,7 +72,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -93,7 +93,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -115,7 +115,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -131,12 +131,12 @@ namespace OpenIddict.Server.Owin { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - return new ValueTask(context.Transaction.GetOwinRequest() != null); + return new ValueTask(context.Transaction.GetOwinRequest() is not null); } } @@ -152,7 +152,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -174,7 +174,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -196,7 +196,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -218,7 +218,7 @@ namespace OpenIddict.Server.Owin public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs index 88589988..0e84ac99 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs @@ -89,12 +89,12 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(ExtractAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // If a request_id parameter can be found in the authorization request, // restore the complete authorization request from the distributed cache. @@ -107,7 +107,7 @@ namespace OpenIddict.Server.Owin // Note: the cache key is always prefixed with a specific marker // to avoid collisions with the other types of cached payloads. var token = await _cache.GetStringAsync(Cache.AuthorizationRequest + context.Request.RequestId); - if (token == null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) + if (token is null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) { context.Logger.LogError(SR.GetResourceString(SR.ID7146), Parameters.RequestId); @@ -190,17 +190,17 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(ExtractAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -289,7 +289,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -334,7 +334,7 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -342,7 +342,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -374,7 +374,7 @@ namespace OpenIddict.Server.Owin foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) @@ -425,7 +425,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -433,7 +433,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -454,7 +454,7 @@ namespace OpenIddict.Server.Owin foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) @@ -489,7 +489,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -497,7 +497,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -518,7 +518,7 @@ namespace OpenIddict.Server.Owin foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs index 2453ca33..752aed6c 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs @@ -86,12 +86,12 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(ExtractLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // If a request_id parameter can be found in the logout request, // restore the complete logout request from the distributed cache. @@ -104,7 +104,7 @@ namespace OpenIddict.Server.Owin // Note: the cache key is always prefixed with a specific marker // to avoid collisions with the other types of cached payloads. var token = await _cache.GetStringAsync(Cache.LogoutRequest + context.Request.RequestId); - if (token == null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) + if (token is null || !context.Options.JsonWebTokenHandler.CanReadToken(token)) { context.Logger.LogError(SR.GetResourceString(SR.ID7150), Parameters.RequestId); @@ -187,17 +187,17 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(ExtractLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -286,7 +286,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -326,7 +326,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -334,7 +334,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -354,7 +354,7 @@ namespace OpenIddict.Server.Owin foreach (var (key, value) in from parameter in context.Response.GetParameters() let values = (string?[]?) parameter.Value - where values != null + where values is not null from value in values where !string.IsNullOrEmpty(value) select (parameter.Key, Value: value)) diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs index fbaf73d4..6fe0e0cc 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs @@ -75,7 +75,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -83,7 +83,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -177,7 +177,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -185,14 +185,14 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } // Don't require that the request host be present if the request is not handled // by an OpenIddict endpoint or if an explicit issuer URL was already set. - if (context.Issuer != null || context.EndpointType == OpenIddictServerEndpointType.Unknown) + if (context.Issuer is not null || context.EndpointType == OpenIddictServerEndpointType.Unknown) { return default; } @@ -243,7 +243,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -251,7 +251,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -296,13 +296,13 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null) + if (properties is not null) { context.Response.Error = GetProperty(properties, Properties.Error); context.Response.ErrorDescription = GetProperty(properties, Properties.ErrorDescription); @@ -337,7 +337,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -345,7 +345,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -390,7 +390,7 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -398,7 +398,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -470,7 +470,7 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -478,7 +478,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -546,17 +546,17 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -645,17 +645,17 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -696,7 +696,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -727,17 +727,17 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -787,7 +787,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -795,7 +795,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -834,17 +834,17 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -948,7 +948,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -956,7 +956,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -994,7 +994,7 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1002,7 +1002,7 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -1051,17 +1051,17 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -1101,17 +1101,17 @@ namespace OpenIddict.Server.Owin /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -1178,7 +1178,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1186,13 +1186,13 @@ namespace OpenIddict.Server.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null && !string.IsNullOrEmpty(properties.RedirectUri)) + if (properties is not null && !string.IsNullOrEmpty(properties.RedirectUri)) { response.Redirect(properties.RedirectUri); @@ -1225,7 +1225,7 @@ namespace OpenIddict.Server.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs index 1f787465..18fb31ad 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs @@ -27,7 +27,7 @@ namespace Owin /// The . public static IAppBuilder UseOpenIddictServer(this IAppBuilder app) { - if (app == null) + if (app is null) { throw new ArgumentNullException(nameof(app)); } @@ -42,7 +42,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static IOwinRequest? GetOwinRequest(this OpenIddictServerTransaction transaction) { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -67,7 +67,7 @@ namespace Owin /// The . public static OpenIddictServerEndpointType GetOpenIddictServerEndpointType(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -82,7 +82,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static OpenIddictRequest? GetOpenIddictServerRequest(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -97,7 +97,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static OpenIddictResponse? GetOpenIddictServerResponse(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs index 2b589ae2..88155bef 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs @@ -39,13 +39,13 @@ namespace OpenIddict.Server.Owin /// public override Task Invoke(IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var provider = context.Get(typeof(IServiceProvider).FullName); - if (provider == null) + if (provider is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1120)); } diff --git a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs index f07d1f72..07cfb04d 100644 --- a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs +++ b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerQuartzBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs index 15a3c562..0bc8b67f 100644 --- a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs +++ b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictServerQuartzBuilder UseQuartz(this OpenIddictServerBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -83,12 +83,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictServerBuilder UseQuartz( this OpenIddictServerBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs index c582db19..e610c03b 100644 --- a/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs +++ b/src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs @@ -50,7 +50,7 @@ namespace OpenIddict.Server.Quartz /// public async Task Execute(IJobExecutionContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -71,7 +71,7 @@ namespace OpenIddict.Server.Quartz if (!_options.CurrentValue.DisableTokenPruning) { var manager = scope.ServiceProvider.GetService(); - if (manager == null) + if (manager is null) { // Inform Quartz.NET that the triggers associated with this job should be removed, // as the future invocations will always fail until the application is correctly @@ -128,7 +128,7 @@ namespace OpenIddict.Server.Quartz if (!_options.CurrentValue.DisableAuthorizationPruning) { var manager = scope.ServiceProvider.GetService(); - if (manager == null) + if (manager is null) { // Inform Quartz.NET that the triggers associated with this job should be removed, // as the future invocations will always fail until the application is correctly @@ -182,7 +182,7 @@ namespace OpenIddict.Server.Quartz } } - if (exceptions != null) + if (exceptions is not null) { throw new JobExecutionException(new AggregateException(exceptions)) { diff --git a/src/OpenIddict.Server/OpenIddictServerBuilder.cs b/src/OpenIddict.Server/OpenIddictServerBuilder.cs index fba838b4..fbf8cddb 100644 --- a/src/OpenIddict.Server/OpenIddictServerBuilder.cs +++ b/src/OpenIddict.Server/OpenIddictServerBuilder.cs @@ -50,7 +50,7 @@ namespace Microsoft.Extensions.DependencyInjection Action> configuration) where TContext : OpenIddictServerEvents.BaseContext { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -72,7 +72,7 @@ namespace Microsoft.Extensions.DependencyInjection [EditorBrowsable(EditorBrowsableState.Advanced)] public OpenIddictServerBuilder AddEventHandler(OpenIddictServerHandlerDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -91,7 +91,7 @@ namespace Microsoft.Extensions.DependencyInjection [EditorBrowsable(EditorBrowsableState.Advanced)] public OpenIddictServerBuilder RemoveEventHandler(OpenIddictServerHandlerDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -120,7 +120,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -146,7 +146,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddEncryptionCredentials(EncryptingCredentials credentials) { - if (credentials == null) + if (credentials is null) { throw new ArgumentNullException(nameof(credentials)); } @@ -161,7 +161,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddEncryptionKey(SecurityKey key) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -204,7 +204,7 @@ namespace Microsoft.Extensions.DependencyInjection Justification = "The X.509 certificate is attached to the server options.")] public OpenIddictServerBuilder AddDevelopmentEncryptionCertificate(X500DistinguishedName subject) { - if (subject == null) + if (subject is null) { throw new ArgumentNullException(nameof(subject)); } @@ -219,7 +219,7 @@ namespace Microsoft.Extensions.DependencyInjection .OfType() .SingleOrDefault(); - if (certificate != null && (certificate.NotBefore > DateTime.Now || certificate.NotAfter < DateTime.Now)) + if (certificate is not null && (certificate.NotBefore > DateTime.Now || certificate.NotAfter < DateTime.Now)) { store.Remove(certificate); certificate = null; @@ -227,7 +227,7 @@ namespace Microsoft.Extensions.DependencyInjection #if SUPPORTS_CERTIFICATE_GENERATION // If no appropriate certificate can be found, generate and persist a new certificate in the specified store. - if (certificate == null) + if (certificate is null) { using var algorithm = RSA.Create(keySizeInBits: 2048); @@ -370,7 +370,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddEncryptionCertificate(X509Certificate2 certificate) { - if (certificate == null) + if (certificate is null) { throw new ArgumentNullException(nameof(certificate)); } @@ -423,7 +423,7 @@ namespace Microsoft.Extensions.DependencyInjection Assembly assembly, string resource, string password, X509KeyStorageFlags flags) { - if (assembly == null) + if (assembly is null) { throw new ArgumentNullException(nameof(assembly)); } @@ -439,7 +439,7 @@ namespace Microsoft.Extensions.DependencyInjection } using var stream = assembly.GetManifestResourceStream(resource); - if (stream == null) + if (stream is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1063)); } @@ -477,7 +477,7 @@ namespace Microsoft.Extensions.DependencyInjection Justification = "The X.509 certificate is attached to the server options.")] public OpenIddictServerBuilder AddEncryptionCertificate(Stream stream, string password, X509KeyStorageFlags flags) { - if (stream == null) + if (stream is null) { throw new ArgumentNullException(nameof(stream)); } @@ -506,7 +506,7 @@ namespace Microsoft.Extensions.DependencyInjection } var certificate = GetCertificate(StoreLocation.CurrentUser, thumbprint) ?? GetCertificate(StoreLocation.LocalMachine, thumbprint); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -545,7 +545,7 @@ namespace Microsoft.Extensions.DependencyInjection .OfType() .SingleOrDefault(); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -560,7 +560,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddSigningCredentials(SigningCredentials credentials) { - if (credentials == null) + if (credentials is null) { throw new ArgumentNullException(nameof(credentials)); } @@ -575,7 +575,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddSigningKey(SecurityKey key) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -641,7 +641,7 @@ namespace Microsoft.Extensions.DependencyInjection Justification = "The X.509 certificate is attached to the server options.")] public OpenIddictServerBuilder AddDevelopmentSigningCertificate(X500DistinguishedName subject) { - if (subject == null) + if (subject is null) { throw new ArgumentNullException(nameof(subject)); } @@ -656,7 +656,7 @@ namespace Microsoft.Extensions.DependencyInjection .OfType() .SingleOrDefault(); - if (certificate != null && (certificate.NotBefore > DateTime.Now || certificate.NotAfter < DateTime.Now)) + if (certificate is not null && (certificate.NotBefore > DateTime.Now || certificate.NotAfter < DateTime.Now)) { store.Remove(certificate); certificate = null; @@ -664,7 +664,7 @@ namespace Microsoft.Extensions.DependencyInjection #if SUPPORTS_CERTIFICATE_GENERATION // If no appropriate certificate can be found, generate and persist a new certificate in the specified store. - if (certificate == null) + if (certificate is null) { using var algorithm = RSA.Create(keySizeInBits: 2048); @@ -826,7 +826,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder AddSigningCertificate(X509Certificate2 certificate) { - if (certificate == null) + if (certificate is null) { throw new ArgumentNullException(nameof(certificate)); } @@ -879,7 +879,7 @@ namespace Microsoft.Extensions.DependencyInjection Assembly assembly, string resource, string password, X509KeyStorageFlags flags) { - if (assembly == null) + if (assembly is null) { throw new ArgumentNullException(nameof(assembly)); } @@ -895,7 +895,7 @@ namespace Microsoft.Extensions.DependencyInjection } using var stream = assembly.GetManifestResourceStream(resource); - if (stream == null) + if (stream is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1063)); } @@ -933,7 +933,7 @@ namespace Microsoft.Extensions.DependencyInjection Justification = "The X.509 certificate is attached to the server options.")] public OpenIddictServerBuilder AddSigningCertificate(Stream stream, string password, X509KeyStorageFlags flags) { - if (stream == null) + if (stream is null) { throw new ArgumentNullException(nameof(stream)); } @@ -962,7 +962,7 @@ namespace Microsoft.Extensions.DependencyInjection } var certificate = GetCertificate(StoreLocation.CurrentUser, thumbprint) ?? GetCertificate(StoreLocation.LocalMachine, thumbprint); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -1001,7 +1001,7 @@ namespace Microsoft.Extensions.DependencyInjection .OfType() .SingleOrDefault(); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -1085,7 +1085,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetAuthorizationEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1102,7 +1102,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetAuthorizationEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1133,7 +1133,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetConfigurationEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1150,7 +1150,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetConfigurationEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1181,7 +1181,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetCryptographyEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1198,7 +1198,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetCryptographyEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1229,7 +1229,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetDeviceEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1246,7 +1246,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetDeviceEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1277,7 +1277,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetIntrospectionEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1294,7 +1294,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetIntrospectionEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1325,7 +1325,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetLogoutEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1342,7 +1342,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetLogoutEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1373,7 +1373,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetRevocationEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1390,7 +1390,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetRevocationEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1421,7 +1421,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetTokenEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1438,7 +1438,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetTokenEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1469,7 +1469,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetUserinfoEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1486,7 +1486,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetUserinfoEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1517,7 +1517,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetVerificationEndpointUris(params string[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1534,7 +1534,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetVerificationEndpointUris(params Uri[] addresses) { - if (addresses == null) + if (addresses is null) { throw new ArgumentNullException(nameof(addresses)); } @@ -1646,7 +1646,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder RegisterClaims(params string[] claims) { - if (claims == null) + if (claims is null) { throw new ArgumentNullException(nameof(claims)); } @@ -1667,7 +1667,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder RegisterScopes(params string[] scopes) { - if (scopes == null) + if (scopes is null) { throw new ArgumentNullException(nameof(scopes)); } @@ -1754,7 +1754,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictServerBuilder SetIssuer(Uri address) { - if (address == null) + if (address is null) { throw new ArgumentNullException(nameof(address)); } diff --git a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs index 3425a983..b49d526d 100644 --- a/src/OpenIddict.Server/OpenIddictServerConfiguration.cs +++ b/src/OpenIddict.Server/OpenIddictServerConfiguration.cs @@ -29,7 +29,7 @@ namespace OpenIddict.Server /// The options instance to initialize. public void PostConfigure(string name, OpenIddictServerOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -48,7 +48,7 @@ namespace OpenIddict.Server options.UseRollingRefreshTokens |= !options.UseRollingRefreshTokens && !options.DisableSlidingRefreshTokenExpiration; } - if (options.JsonWebTokenHandler == null) + if (options.JsonWebTokenHandler is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1074)); } @@ -284,23 +284,23 @@ namespace OpenIddict.Server (SecurityKey first, SecurityKey second) when ReferenceEquals(first, second) => 0, // If one of the keys is a symmetric key, prefer it to the other one. - (SymmetricSecurityKey _, SymmetricSecurityKey _) => 0, - (SymmetricSecurityKey _, SecurityKey _) => -1, - (SecurityKey _, SymmetricSecurityKey _) => 1, + (SymmetricSecurityKey, SymmetricSecurityKey) => 0, + (SymmetricSecurityKey, SecurityKey) => -1, + (SecurityKey, SymmetricSecurityKey) => 1, // If one of the keys is backed by a X.509 certificate, don't prefer it if it's not valid yet. - (X509SecurityKey first, SecurityKey _) when first.Certificate.NotBefore > DateTime.Now => 1, - (SecurityKey _, X509SecurityKey second) when second.Certificate.NotBefore > DateTime.Now => 1, + (X509SecurityKey first, SecurityKey) when first.Certificate.NotBefore > DateTime.Now => 1, + (SecurityKey, X509SecurityKey second) when second.Certificate.NotBefore > DateTime.Now => 1, // If the two keys are backed by a X.509 certificate, prefer the one with the furthest expiration date. (X509SecurityKey first, X509SecurityKey second) => -first.Certificate.NotAfter.CompareTo(second.Certificate.NotAfter), // If one of the keys is backed by a X.509 certificate, prefer the X.509 security key. - (X509SecurityKey _, SecurityKey _) => -1, - (SecurityKey _, X509SecurityKey _) => 1, + (X509SecurityKey, SecurityKey) => -1, + (SecurityKey, X509SecurityKey) => 1, // If the two keys are not backed by a X.509 certificate, none should be preferred to the other. - (SecurityKey _, SecurityKey _) => 0 + (SecurityKey, SecurityKey) => 0 }; static string? GetKeyIdentifier(SecurityKey key) @@ -319,11 +319,11 @@ namespace OpenIddict.Server // Note: if the RSA parameters are not attached to the signing key, // extract them by calling ExportParameters on the RSA instance. var parameters = rsaSecurityKey.Parameters; - if (parameters.Modulus == null) + if (parameters.Modulus is null) { parameters = rsaSecurityKey.Rsa.ExportParameters(includePrivateParameters: false); - Debug.Assert(parameters.Modulus != null, SR.GetResourceString(SR.ID5003)); + Debug.Assert(parameters.Modulus is not null, SR.GetResourceString(SR.ID5003)); } // Only use the 40 first chars of the base64url-encoded modulus. @@ -337,7 +337,7 @@ namespace OpenIddict.Server // Extract the ECDSA parameters from the signing credentials. var parameters = ecsdaSecurityKey.ECDsa.ExportParameters(includePrivateParameters: false); - Debug.Assert(parameters.Q.X != null, SR.GetResourceString(SR.ID5004)); + Debug.Assert(parameters.Q.X is not null, SR.GetResourceString(SR.ID5004)); // Only use the 40 first chars of the base64url-encoded X coordinate. var identifier = Base64UrlEncoder.Encode(parameters.Q.X); diff --git a/src/OpenIddict.Server/OpenIddictServerDispatcher.cs b/src/OpenIddict.Server/OpenIddictServerDispatcher.cs index 2f060a8d..51dc2df4 100644 --- a/src/OpenIddict.Server/OpenIddictServerDispatcher.cs +++ b/src/OpenIddict.Server/OpenIddictServerDispatcher.cs @@ -35,7 +35,7 @@ namespace OpenIddict.Server public async ValueTask DispatchAsync(TContext context) where TContext : BaseContext { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -103,11 +103,11 @@ namespace OpenIddict.Server continue; } - var handler = descriptor.ServiceDescriptor.ImplementationInstance != null ? + var handler = descriptor.ServiceDescriptor.ImplementationInstance is not null ? descriptor.ServiceDescriptor.ImplementationInstance as IOpenIddictServerHandler : _provider.GetService(descriptor.ServiceDescriptor.ServiceType) as IOpenIddictServerHandler; - if (handler == null) + if (handler is null) { throw new InvalidOperationException(SR.FormatID1097(descriptor.ServiceDescriptor.ServiceType)); } diff --git a/src/OpenIddict.Server/OpenIddictServerExtensions.cs b/src/OpenIddict.Server/OpenIddictServerExtensions.cs index bc5123e6..6ae522c6 100644 --- a/src/OpenIddict.Server/OpenIddictServerExtensions.cs +++ b/src/OpenIddict.Server/OpenIddictServerExtensions.cs @@ -31,7 +31,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictServerBuilder AddServer(this OpenIddictBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -107,12 +107,12 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictBuilder AddServer(this OpenIddictBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs index 03bbc086..b5c143ea 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs @@ -79,7 +79,7 @@ namespace OpenIddict.Server /// The builder instance, so that calls can be easily chained. public Builder AddFilter(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -110,7 +110,7 @@ namespace OpenIddict.Server /// The builder instance, so that calls can be easily chained. public Builder SetServiceDescriptor(ServiceDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -162,7 +162,7 @@ namespace OpenIddict.Server /// The builder instance, so that calls can be easily chained. public Builder UseInlineHandler(Func handler) { - if (handler == null) + if (handler is null) { throw new ArgumentNullException(nameof(handler)); } @@ -199,7 +199,7 @@ namespace OpenIddict.Server public Builder UseSingletonHandler(THandler handler) where THandler : IOpenIddictServerHandler { - if (handler == null) + if (handler is null) { throw new ArgumentNullException(nameof(handler)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs b/src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs index dfd13f96..caffae2a 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs @@ -21,7 +21,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -37,7 +37,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -53,7 +53,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -69,7 +69,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -85,7 +85,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -101,7 +101,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -117,7 +117,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -133,7 +133,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -149,7 +149,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -165,7 +165,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -181,7 +181,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -197,7 +197,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -213,7 +213,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -229,7 +229,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -245,7 +245,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -261,7 +261,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -277,7 +277,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -293,7 +293,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -309,7 +309,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -325,7 +325,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -341,7 +341,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -357,7 +357,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -373,7 +373,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -389,7 +389,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -405,7 +405,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -421,7 +421,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -437,7 +437,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -453,7 +453,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -469,7 +469,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -485,7 +485,7 @@ namespace OpenIddict.Server { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs index e01c61c5..a283a161 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs @@ -88,7 +88,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -117,7 +117,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1026)); } @@ -150,7 +150,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -216,7 +216,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -245,7 +245,7 @@ namespace OpenIddict.Server return; } - if (notification.Principal != null) + if (notification.Principal is not null) { var @event = new ProcessSignInContext(context.Transaction) { @@ -305,7 +305,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -347,7 +347,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -386,7 +386,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -425,7 +425,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -465,7 +465,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -546,7 +546,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -599,7 +599,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -679,7 +679,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -728,7 +728,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -776,7 +776,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -817,7 +817,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -923,7 +923,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -931,7 +931,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { context.Logger.LogError(SR.GetResourceString(SR.ID7044), context.ClientId); @@ -972,7 +972,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -980,7 +980,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1030,7 +1030,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1038,7 +1038,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1107,7 +1107,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1121,7 +1121,7 @@ namespace OpenIddict.Server // even if the service was registered and resolved from the dependency injection container. if (scopes.Count != 0 && !context.Options.EnableDegradedMode) { - Debug.Assert(_scopeManager != null, SR.GetResourceString(SR.ID5011)); + Debug.Assert(_scopeManager is not null, SR.GetResourceString(SR.ID5011)); await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) { @@ -1175,7 +1175,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1183,7 +1183,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1230,7 +1230,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1238,7 +1238,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1327,7 +1327,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1335,7 +1335,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1392,7 +1392,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateAuthorizationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1407,7 +1407,7 @@ namespace OpenIddict.Server } var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1444,12 +1444,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Request == null) + if (context.Request is null) { return default; } @@ -1459,7 +1459,7 @@ namespace OpenIddict.Server // Note: at this stage, the validated redirect URI property may be null (e.g if an error // is returned from the ExtractAuthorizationRequest/ValidateAuthorizationRequest events). - if (notification != null && !notification.IsRejected) + if (notification is not null && !notification.IsRejected) { context.RedirectUri = notification.RedirectUri; } @@ -1487,12 +1487,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Request == null) + if (context.Request is null) { return default; } @@ -1529,7 +1529,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyAuthorizationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs index 9904622c..93ba9d91 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs @@ -86,7 +86,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -115,7 +115,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1030)); } @@ -148,7 +148,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -205,7 +205,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -234,7 +234,7 @@ namespace OpenIddict.Server return; } - if (notification.Principal == null) + if (notification.Principal is null) { // Note: no authentication type is deliberately specified to represent an unauthenticated identity. var principal = new ClaimsPrincipal(new ClaimsIdentity()); @@ -298,7 +298,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -340,7 +340,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -391,7 +391,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -405,7 +405,7 @@ namespace OpenIddict.Server // even if the service was registered and resolved from the dependency injection container. if (scopes.Count != 0 && !context.Options.EnableDegradedMode) { - Debug.Assert(_scopeManager != null, SR.GetResourceString(SR.ID5011)); + Debug.Assert(_scopeManager is not null, SR.GetResourceString(SR.ID5011)); await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) { @@ -459,7 +459,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -469,7 +469,7 @@ namespace OpenIddict.Server // Retrieve the application details corresponding to the requested client_id. // If no entity can be found, this likely indicates that the client_id is invalid. var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { context.Logger.LogError(SR.GetResourceString(SR.ID7058), context.ClientId); @@ -511,7 +511,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -519,7 +519,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -583,7 +583,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -591,7 +591,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -647,7 +647,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -655,7 +655,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -704,7 +704,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateDeviceRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -712,7 +712,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -765,7 +765,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -794,7 +794,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1033)); } @@ -827,7 +827,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -884,7 +884,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -913,7 +913,7 @@ namespace OpenIddict.Server return; } - if (notification.Principal != null) + if (notification.Principal is not null) { var @event = new ProcessSignInContext(context.Transaction) { @@ -973,7 +973,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1020,7 +1020,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(HandleVerificationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs index 6a418f96..c3cc5a85 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs @@ -90,7 +90,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -119,7 +119,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1036)); } @@ -152,7 +152,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -209,7 +209,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -295,7 +295,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -337,7 +337,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -374,7 +374,7 @@ namespace OpenIddict.Server static Uri? GetEndpointAbsoluteUri(Uri? issuer, Uri endpoint) { // If the endpoint is disabled (i.e a null address is specified), return null. - if (endpoint == null) + if (endpoint is null) { return null; } @@ -386,7 +386,7 @@ namespace OpenIddict.Server } // At this stage, throw an exception if the issuer cannot be retrieved. - if (issuer == null || !issuer.IsAbsoluteUri) + if (issuer is null || !issuer.IsAbsoluteUri) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1022)); } @@ -428,7 +428,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -457,7 +457,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -486,7 +486,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -516,24 +516,24 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.IntrospectionEndpoint != null) + if (context.IntrospectionEndpoint is not null) { context.IntrospectionEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretBasic); context.IntrospectionEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretPost); } - if (context.RevocationEndpoint != null) + if (context.RevocationEndpoint is not null) { context.RevocationEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretBasic); context.RevocationEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretPost); } - if (context.TokenEndpoint != null) + if (context.TokenEndpoint is not null) { context.TokenEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretBasic); context.TokenEndpointAuthenticationMethods.Add(ClientAuthenticationMethods.ClientSecretPost); @@ -562,7 +562,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -591,7 +591,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -620,7 +620,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -649,7 +649,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -678,7 +678,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -744,7 +744,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleConfigurationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -783,7 +783,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -812,7 +812,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1037)); } @@ -845,7 +845,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -902,7 +902,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1030,7 +1030,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1072,7 +1072,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleCryptographyRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1149,7 +1149,7 @@ namespace OpenIddict.Server X509SecurityKey x509SecurityKey when x509SecurityKey.PublicKey is RSA algorithm => algorithm.ExportParameters(includePrivateParameters: false), - RsaSecurityKey rsaSecurityKey when rsaSecurityKey.Rsa != null => + RsaSecurityKey rsaSecurityKey when rsaSecurityKey.Rsa is not null => rsaSecurityKey.Rsa.ExportParameters(includePrivateParameters: false), RsaSecurityKey rsaSecurityKey => rsaSecurityKey.Parameters, @@ -1157,15 +1157,15 @@ namespace OpenIddict.Server _ => (RSAParameters?) null }; - if (parameters == null) + if (parameters is null) { context.Logger.LogWarning(SR.GetResourceString(SR.ID7073), credentials.Key.GetType().Name); continue; } - Debug.Assert(parameters.Value.Exponent != null && - parameters.Value.Modulus != null, SR.GetResourceString(SR.ID5003)); + Debug.Assert(parameters.Value.Exponent is not null && + parameters.Value.Modulus is not null, SR.GetResourceString(SR.ID5003)); key.Kty = JsonWebAlgorithmsKeyTypes.RSA; @@ -1185,21 +1185,21 @@ namespace OpenIddict.Server X509SecurityKey x509SecurityKey when x509SecurityKey.PublicKey is ECDsa algorithm => algorithm.ExportParameters(includePrivateParameters: false), - ECDsaSecurityKey ecdsaSecurityKey when ecdsaSecurityKey.ECDsa != null => + ECDsaSecurityKey ecdsaSecurityKey when ecdsaSecurityKey.ECDsa is not null => ecdsaSecurityKey.ECDsa.ExportParameters(includePrivateParameters: false), _ => (ECParameters?) null }; - if (parameters == null) + if (parameters is null) { context.Logger.LogWarning(SR.GetResourceString(SR.ID7074), credentials.Key.GetType().Name); continue; } - Debug.Assert(parameters.Value.Q.X != null && - parameters.Value.Q.Y != null, SR.GetResourceString(SR.ID5004)); + Debug.Assert(parameters.Value.Q.X is not null && + parameters.Value.Q.Y is not null, SR.GetResourceString(SR.ID5004)); Debug.Assert(parameters.Value.Curve.IsNamed, SR.GetResourceString(SR.ID5005)); @@ -1218,7 +1218,7 @@ namespace OpenIddict.Server // If the signing key is embedded in a X.509 certificate, set // the x5t and x5c parameters using the certificate details. var certificate = (credentials.Key as X509SecurityKey)?.Certificate; - if (certificate != null) + if (certificate is not null) { // x5t must be base64url-encoded. // See https://tools.ietf.org/html/rfc7517#section-4.8 @@ -1250,7 +1250,7 @@ namespace OpenIddict.Server return certificate.GetCertHash(algorithm); #else using var hash = CryptoConfig.CreateFromName(algorithm.Name) as HashAlgorithm; - if (hash == null || hash is KeyedHashAlgorithm) + if (hash is null || hash is KeyedHashAlgorithm) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1216)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs index 10777c2e..aaf22562 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs @@ -94,7 +94,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -123,7 +123,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1039)); } @@ -156,7 +156,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -217,7 +217,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -246,7 +246,7 @@ namespace OpenIddict.Server return; } - if (notification.Principal != null) + if (notification.Principal is not null) { var @event = new ProcessSignInContext(context.Transaction) { @@ -306,7 +306,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -348,7 +348,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -410,7 +410,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -459,7 +459,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -500,7 +500,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -540,7 +540,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -579,7 +579,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -620,7 +620,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -672,7 +672,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -686,7 +686,7 @@ namespace OpenIddict.Server // even if the service was registered and resolved from the dependency injection container. if (scopes.Count != 0 && !context.Options.EnableDegradedMode) { - Debug.Assert(_scopeManager != null, SR.GetResourceString(SR.ID5011)); + Debug.Assert(_scopeManager is not null, SR.GetResourceString(SR.ID5011)); await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) { @@ -740,7 +740,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -750,7 +750,7 @@ namespace OpenIddict.Server // Retrieve the application details corresponding to the requested client_id. // If no entity can be found, this likely indicates that the client_id is invalid. var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { context.Logger.LogError(SR.GetResourceString(SR.ID7081), context.ClientId); @@ -792,7 +792,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -800,7 +800,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -876,7 +876,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -884,7 +884,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -940,7 +940,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -948,7 +948,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -997,7 +997,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1005,7 +1005,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1068,7 +1068,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1076,7 +1076,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1134,7 +1134,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1154,7 +1154,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1196,7 +1196,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1260,7 +1260,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1272,7 +1272,7 @@ namespace OpenIddict.Server return default; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var presenters = context.Principal.GetPresenters(); if (presenters.IsDefaultOrEmpty) @@ -1346,7 +1346,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1356,7 +1356,7 @@ namespace OpenIddict.Server return default; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Validate the redirect_uri sent by the client application as part of this token request. // Note: for pure OAuth 2.0 requests, redirect_uri is only mandatory if the authorization request @@ -1415,7 +1415,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1425,7 +1425,7 @@ namespace OpenIddict.Server return default; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Note: the ValidateProofKeyForCodeExchangeRequirement handler (invoked earlier) ensures // a code_verifier is specified if the proof key for code exchange requirement was enforced @@ -1531,7 +1531,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1546,7 +1546,7 @@ namespace OpenIddict.Server return default; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // When an explicit scope parameter has been included in the token request // but was missing from the initial request, the request MUST be rejected. @@ -1601,7 +1601,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleTokenRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs index e57c08b9..cbc366b3 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs @@ -87,7 +87,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -116,7 +116,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1045)); } @@ -149,7 +149,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -210,7 +210,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -252,17 +252,17 @@ namespace OpenIddict.Server [Claims.ClientId] = notification.ClientId }; - if (notification.IssuedAt != null) + if (notification.IssuedAt is not null) { response[Claims.IssuedAt] = EpochTime.GetIntDate(notification.IssuedAt.Value.UtcDateTime); } - if (notification.NotBefore != null) + if (notification.NotBefore is not null) { response[Claims.NotBefore] = EpochTime.GetIntDate(notification.NotBefore.Value.UtcDateTime); } - if (notification.ExpiresAt != null) + if (notification.ExpiresAt is not null) { response[Claims.ExpiresAt] = EpochTime.GetIntDate(notification.ExpiresAt.Value.UtcDateTime); } @@ -313,7 +313,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -355,7 +355,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -394,7 +394,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -443,7 +443,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -453,7 +453,7 @@ namespace OpenIddict.Server // Retrieve the application details corresponding to the requested client_id. // If no entity can be found, this likely indicates that the client_id is invalid. var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { context.Logger.LogError(SR.GetResourceString(SR.ID7099), context.ClientId); @@ -495,7 +495,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -503,7 +503,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -567,7 +567,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -575,7 +575,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -631,7 +631,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -639,7 +639,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -681,7 +681,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -733,12 +733,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); if (!context.Principal.HasTokenType(TokenTypeHints.AccessToken) && !context.Principal.HasTokenType(TokenTypeHints.RefreshToken)) @@ -779,13 +779,13 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // When the introspected token is an access token, the caller must be listed either as a presenter // (i.e the party the token was issued to) or as an audience (i.e a resource server/API). @@ -843,7 +843,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -876,12 +876,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); context.TokenId = context.Principal.GetClaim(Claims.JwtId); context.TokenUsage = context.Principal.GetTokenType(); @@ -936,13 +936,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(HandleIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } Debug.Assert(!string.IsNullOrEmpty(context.Request.ClientId), SR.FormatID5000(Parameters.ClientId)); - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Don't return application-specific claims if the token is not an access token. if (!context.Principal.HasTokenType(TokenTypeHints.AccessToken)) @@ -959,7 +959,7 @@ namespace OpenIddict.Server } var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -1056,7 +1056,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs index ac50598e..66f12fe7 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs @@ -79,7 +79,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -108,7 +108,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1047)); } @@ -141,7 +141,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -202,7 +202,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -259,7 +259,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -301,7 +301,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -340,7 +340,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -389,7 +389,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -399,7 +399,7 @@ namespace OpenIddict.Server // Retrieve the application details corresponding to the requested client_id. // If no entity can be found, this likely indicates that the client_id is invalid. var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { context.Logger.LogError(SR.GetResourceString(SR.ID7112), context.ClientId); @@ -441,7 +441,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -449,7 +449,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -513,7 +513,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -521,7 +521,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -577,7 +577,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -585,7 +585,7 @@ namespace OpenIddict.Server Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); var application = await _applicationManager.FindByClientIdAsync(context.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1031)); } @@ -627,7 +627,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -679,12 +679,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); if (!context.Principal.HasTokenType(TokenTypeHints.AccessToken) && !context.Principal.HasTokenType(TokenTypeHints.RefreshToken)) @@ -725,13 +725,13 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } Debug.Assert(!string.IsNullOrEmpty(context.ClientId), SR.FormatID5000(Parameters.ClientId)); - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // When the revoked token is an access token, the caller must be listed either as a presenter // (i.e the party the token was issued to) or as an audience (i.e a resource server/API). @@ -789,7 +789,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -831,12 +831,12 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(HandleRevocationRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the token identifier from the authentication principal. var identifier = context.Principal.GetTokenId(); @@ -852,7 +852,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { context.Logger.LogInformation(SR.GetResourceString(SR.ID7123), identifier); @@ -893,7 +893,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyRevocationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs index 185cb139..df5c2bad 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs @@ -68,7 +68,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -97,7 +97,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1049)); } @@ -130,7 +130,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -191,7 +191,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -279,7 +279,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -321,7 +321,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -386,7 +386,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateLogoutRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -442,12 +442,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Request == null) + if (context.Request is null) { return default; } @@ -457,7 +457,7 @@ namespace OpenIddict.Server // Note: at this stage, the validated redirect URI property may be null (e.g if // an error is returned from the ExtractLogoutRequest/ValidateLogoutRequest events). - if (notification != null && !notification.IsRejected) + if (notification is not null && !notification.IsRejected) { context.PostLogoutRedirectUri = notification.PostLogoutRedirectUri; } @@ -484,7 +484,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ApplyLogoutResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs index 3915385b..a0136a76 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs @@ -70,7 +70,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -99,7 +99,7 @@ namespace OpenIddict.Server return; } - if (notification.Request == null) + if (notification.Request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1052)); } @@ -132,7 +132,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -193,7 +193,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -285,7 +285,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -327,7 +327,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ValidateUserinfoRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -370,7 +370,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ValidateUserinfoRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -423,7 +423,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleUserinfoRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -456,12 +456,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleUserinfoRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Note: when receiving an access token, its audiences list cannot be used for the "aud" claim // as the client application is not the intented audience but only an authorized presenter. @@ -490,12 +490,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(HandleUserinfoRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); context.Subject = context.Principal.GetClaim(Claims.Subject); diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.cs index 550683b0..e3849418 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.cs @@ -139,7 +139,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -183,7 +183,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -251,7 +251,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -309,7 +309,7 @@ namespace OpenIddict.Server public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -324,7 +324,7 @@ namespace OpenIddict.Server // If the reference token cannot be found, don't return an error to allow another handler to validate it. var token = await _tokenManager.FindByReferenceIdAsync(context.Token); - if (token == null) + if (token is null) { return; } @@ -386,13 +386,13 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } // If a principal was already attached, don't overwrite it. - if (context.Principal != null) + if (context.Principal is not null) { return default; } @@ -454,16 +454,16 @@ namespace OpenIddict.Server }, description: (result.Exception, context.EndpointType) switch { - (SecurityTokenInvalidTypeException _, OpenIddictServerEndpointType.Token) + (SecurityTokenInvalidTypeException, OpenIddictServerEndpointType.Token) when context.Request.IsAuthorizationCodeGrantType() => context.Localizer[SR.ID3005], - (SecurityTokenInvalidTypeException _, OpenIddictServerEndpointType.Token) + (SecurityTokenInvalidTypeException, OpenIddictServerEndpointType.Token) when context.Request.IsDeviceCodeGrantType() => context.Localizer[SR.ID3006], - (SecurityTokenInvalidTypeException _, OpenIddictServerEndpointType.Token) + (SecurityTokenInvalidTypeException, OpenIddictServerEndpointType.Token) when context.Request.IsRefreshTokenGrantType() => context.Localizer[SR.ID3007], - (SecurityTokenInvalidTypeException _, OpenIddictServerEndpointType.Userinfo) => context.Localizer[SR.ID3008], + (SecurityTokenInvalidTypeException, OpenIddictServerEndpointType.Userinfo) => context.Localizer[SR.ID3008], _ => context.Localizer[SR.ID3004] }); @@ -473,7 +473,7 @@ namespace OpenIddict.Server // Get the JWT token. If the token is encrypted using JWE, retrieve the inner token. var token = (JsonWebToken) result.SecurityToken; - if (token.InnerToken != null) + if (token.InnerToken is not null) { token = token.InnerToken; } @@ -530,12 +530,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return default; } @@ -575,12 +575,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return default; } @@ -687,12 +687,12 @@ namespace OpenIddict.Server public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return; } @@ -704,7 +704,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -737,12 +737,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { context.Reject( error: context.EndpointType switch @@ -819,12 +819,12 @@ namespace OpenIddict.Server public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the token identifier from the authentication principal. // If no token identifier can be found, this indicates that the token @@ -837,7 +837,7 @@ namespace OpenIddict.Server // If the token entry cannot be found, return a generic error. var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { context.Reject( error: context.EndpointType switch @@ -1010,12 +1010,12 @@ namespace OpenIddict.Server public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var identifier = context.Principal.GetAuthorizationId(); if (string.IsNullOrEmpty(identifier)) @@ -1024,7 +1024,7 @@ namespace OpenIddict.Server } var authorization = await _authorizationManager.FindByIdAsync(identifier); - if (authorization == null || !await _authorizationManager.HasStatusAsync(authorization, Statuses.Valid)) + if (authorization is null || !await _authorizationManager.HasStatusAsync(authorization, Statuses.Valid)) { context.Logger.LogError(SR.GetResourceString(SR.ID7006), identifier); @@ -1069,12 +1069,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Don't validate the lifetime of id_tokens used as id_token_hints. switch (context.EndpointType) @@ -1134,7 +1134,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1170,7 +1170,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1227,7 +1227,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1241,7 +1241,7 @@ namespace OpenIddict.Server typeof(ProcessAuthenticationContext).FullName!) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1006)); - Debug.Assert(notification.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(notification.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the device code identifier from the user code principal. var identifier = notification.Principal.GetClaim(Claims.Private.DeviceCodeId); @@ -1251,7 +1251,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token != null) + if (token is not null) { await _tokenManager.TryRejectAsync(token); } @@ -1286,7 +1286,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -1300,7 +1300,7 @@ namespace OpenIddict.Server typeof(ProcessAuthenticationContext).FullName!) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1006)); - Debug.Assert(notification.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(notification.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the device code identifier from the authentication principal. var identifier = notification.Principal.GetTokenId(); @@ -1310,7 +1310,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token != null) + if (token is not null) { await _tokenManager.TryRejectAsync(token); } @@ -1336,12 +1336,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); switch (context.EndpointType) { @@ -1354,7 +1354,7 @@ namespace OpenIddict.Server default: throw new InvalidOperationException(SR.GetResourceString(SR.ID1009)); } - if (context.Principal.Identity == null) + if (context.Principal.Identity is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1010)); } @@ -1409,12 +1409,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); switch (context.EndpointType) { @@ -1433,7 +1433,7 @@ namespace OpenIddict.Server typeof(ProcessAuthenticationContext).FullName!) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1006)); - if (notification.Principal == null) + if (notification.Principal is null) { return default; } @@ -1481,12 +1481,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Always include the "openid" scope when the developer doesn't explicitly call SetScopes. // Note: the application is allowed to specify a different "scopes": in this case, @@ -1518,12 +1518,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Add the validated client_id to the list of authorized presenters, // unless the presenters were explicitly set by the developer. @@ -1554,12 +1554,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // When a "resources" property cannot be found in the ticket, infer it from the "audiences" property. if (context.Principal.HasAudience() && !context.Principal.HasResource()) @@ -1592,12 +1592,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); context.IncludeAccessToken = context.EndpointType switch { @@ -1706,12 +1706,12 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // If no authorization code, device code or refresh token is returned, don't create an authorization. if (!context.IncludeAuthorizationCode && !context.IncludeDeviceCode && !context.IncludeRefreshToken) @@ -1740,7 +1740,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -1749,7 +1749,7 @@ namespace OpenIddict.Server } var authorization = await _authorizationManager.CreateAsync(descriptor); - if (authorization == null) + if (authorization is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1017)); } @@ -1792,12 +1792,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Create a new principal containing only the filtered claims. // Actors identities are also filtered (delegation scenarios). @@ -1911,12 +1911,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Create a new principal containing only the filtered claims. // Actors identities are also filtered (delegation scenarios). @@ -1997,12 +1997,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Note: a device code principal is produced when a device code is included in the response or when a // device code entry is replaced when processing a sign-in response sent to the verification endpoint. @@ -2078,12 +2078,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Create a new principal containing only the filtered claims. // Actors identities are also filtered (delegation scenarios). @@ -2122,7 +2122,7 @@ namespace OpenIddict.Server typeof(ProcessAuthenticationContext).FullName!) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1006)); - Debug.Assert(notification.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(notification.Principal is not null, SR.GetResourceString(SR.ID5006)); principal.SetExpirationDate(notification.Principal.GetExpirationDate()); } @@ -2162,12 +2162,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Replace the principal by a new one containing only the filtered claims. // Actors identities are also filtered (delegation scenarios). @@ -2276,12 +2276,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Create a new principal containing only the filtered claims. // Actors identities are also filtered (delegation scenarios). @@ -2355,7 +2355,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2381,7 +2381,7 @@ namespace OpenIddict.Server } } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the token identifier from the authentication principal. // If no token identifier can be found, this indicates that the token has no backing database entry. @@ -2396,7 +2396,7 @@ namespace OpenIddict.Server // If the operation fails, return an error indicating the code/token is no longer valid. // See https://tools.ietf.org/html/rfc6749#section-6 for more information. var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null || !await _tokenManager.TryRedeemAsync(token)) + if (token is null || !await _tokenManager.TryRedeemAsync(token)) { context.Reject( error: Errors.InvalidGrant, @@ -2449,7 +2449,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2459,7 +2459,7 @@ namespace OpenIddict.Server return; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // When rolling tokens are enabled, try to revoke all the previously issued tokens // associated with the authorization if the request is a refresh_token request. @@ -2516,7 +2516,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2526,7 +2526,7 @@ namespace OpenIddict.Server return; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // Extract the token identifier from the authentication principal. // If no token identifier can be found, this indicates that the token has no backing database entry. @@ -2537,7 +2537,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1264)); } @@ -2591,13 +2591,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.AccessTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -2617,7 +2617,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -2626,7 +2626,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -2659,7 +2659,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2670,7 +2670,7 @@ namespace OpenIddict.Server return default; } - if (context.AccessTokenPrincipal == null) + if (context.AccessTokenPrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -2687,7 +2687,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -2777,7 +2777,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2788,7 +2788,7 @@ namespace OpenIddict.Server } var principal = context.AccessTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -2800,7 +2800,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -2865,13 +2865,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.AuthorizationCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -2891,7 +2891,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -2900,7 +2900,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -2933,7 +2933,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -2944,7 +2944,7 @@ namespace OpenIddict.Server return default; } - if (context.AuthorizationCodePrincipal == null) + if (context.AuthorizationCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -2959,7 +2959,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3031,7 +3031,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3042,7 +3042,7 @@ namespace OpenIddict.Server } var principal = context.AuthorizationCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3054,7 +3054,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -3119,7 +3119,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3130,7 +3130,7 @@ namespace OpenIddict.Server } var principal = context.DeviceCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3150,7 +3150,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -3159,7 +3159,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -3192,7 +3192,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3203,7 +3203,7 @@ namespace OpenIddict.Server return default; } - if (context.DeviceCodePrincipal == null) + if (context.DeviceCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3218,7 +3218,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3291,7 +3291,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3307,7 +3307,7 @@ namespace OpenIddict.Server } var principal = context.DeviceCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3319,7 +3319,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -3378,7 +3378,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3393,10 +3393,10 @@ namespace OpenIddict.Server return; } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var principal = context.DeviceCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3409,7 +3409,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1264)); } @@ -3470,13 +3470,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.RefreshTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3496,7 +3496,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -3505,7 +3505,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -3538,7 +3538,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3549,7 +3549,7 @@ namespace OpenIddict.Server return default; } - if (context.RefreshTokenPrincipal == null) + if (context.RefreshTokenPrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3564,7 +3564,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3637,7 +3637,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3648,7 +3648,7 @@ namespace OpenIddict.Server } var principal = context.RefreshTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3660,7 +3660,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -3710,13 +3710,13 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.UserCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3766,13 +3766,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.UserCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3792,7 +3792,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -3801,7 +3801,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -3834,7 +3834,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3845,7 +3845,7 @@ namespace OpenIddict.Server return default; } - if (context.UserCodePrincipal == null) + if (context.UserCodePrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3860,7 +3860,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -3923,7 +3923,7 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -3934,7 +3934,7 @@ namespace OpenIddict.Server } var principal = context.UserCodePrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -3946,7 +3946,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -3997,7 +3997,7 @@ namespace OpenIddict.Server // User codes are relatively short. To help reduce the risks of collisions with // existing entries, a database check is performed here before updating the entry. - while (await manager.FindByReferenceIdAsync(token) != null); + while (await manager.FindByReferenceIdAsync(token) is not null); return token; } @@ -4024,13 +4024,13 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.IdentityTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -4043,13 +4043,13 @@ namespace OpenIddict.Server var credentials = context.Options.SigningCredentials.FirstOrDefault( credentials => credentials.Key is AsymmetricSecurityKey); - if (credentials == null) + if (credentials is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1265)); } using var hash = GetHashAlgorithm(credentials); - if (hash == null || hash is KeyedHashAlgorithm) + if (hash is null || hash is KeyedHashAlgorithm) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1266)); } @@ -4083,7 +4083,7 @@ namespace OpenIddict.Server hash = CryptoConfig.CreateFromName(credentials.Digest) as HashAlgorithm; } - if (hash == null) + if (hash is null) { var algorithm = credentials.Digest switch { @@ -4172,13 +4172,13 @@ namespace OpenIddict.Server /// public async ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var principal = context.IdentityTokenPrincipal; - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1019)); } @@ -4198,7 +4198,7 @@ namespace OpenIddict.Server if (!string.IsNullOrEmpty(context.Request.ClientId)) { var application = await _applicationManager.FindByClientIdAsync(context.Request.ClientId); - if (application == null) + if (application is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1016)); } @@ -4207,7 +4207,7 @@ namespace OpenIddict.Server } var token = await _tokenManager.CreateAsync(descriptor); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1018)); } @@ -4240,7 +4240,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -4251,7 +4251,7 @@ namespace OpenIddict.Server return default; } - if (context.IdentityTokenPrincipal == null) + if (context.IdentityTokenPrincipal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -4267,7 +4267,7 @@ namespace OpenIddict.Server _ => true }); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1021)); } @@ -4338,7 +4338,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -4386,12 +4386,12 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.AccessTokenPrincipal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.AccessTokenPrincipal is not null, SR.GetResourceString(SR.ID5006)); context.Response.TokenType = TokenTypes.Bearer; @@ -4434,15 +4434,15 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignInContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.DeviceCodePrincipal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.DeviceCodePrincipal is not null, SR.GetResourceString(SR.ID5006)); var address = GetEndpointAbsoluteUri(context.Issuer, context.Options.VerificationEndpointUris.FirstOrDefault()); - if (address != null) + if (address is not null) { var builder = new UriBuilder(address) { @@ -4465,7 +4465,7 @@ namespace OpenIddict.Server static Uri? GetEndpointAbsoluteUri(Uri? issuer, Uri endpoint) { // If the endpoint is disabled (i.e a null address is specified), return null. - if (endpoint == null) + if (endpoint is null) { return null; } @@ -4477,7 +4477,7 @@ namespace OpenIddict.Server } // At this stage, throw an exception if the issuer cannot be retrieved. - if (issuer == null || !issuer.IsAbsoluteUri) + if (issuer is null || !issuer.IsAbsoluteUri) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1022)); } @@ -4520,7 +4520,7 @@ namespace OpenIddict.Server /// public ValueTask HandleAsync(ProcessSignOutContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Server/OpenIddictServerHelpers.cs b/src/OpenIddict.Server/OpenIddictServerHelpers.cs index 1c49664a..53120fb5 100644 --- a/src/OpenIddict.Server/OpenIddictServerHelpers.cs +++ b/src/OpenIddict.Server/OpenIddictServerHelpers.cs @@ -24,7 +24,7 @@ namespace OpenIddict.Server public static TProperty? GetProperty( this OpenIddictServerTransaction transaction, string name) where TProperty : class { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -54,7 +54,7 @@ namespace OpenIddict.Server this OpenIddictServerTransaction transaction, string name, TProperty? value) where TProperty : class { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -64,7 +64,7 @@ namespace OpenIddict.Server throw new ArgumentException(SR.GetResourceString(SR.ID1105), nameof(name)); } - if (value == null) + if (value is null) { transaction.Properties.Remove(name); } diff --git a/src/OpenIddict.Server/OpenIddictServerOptions.cs b/src/OpenIddict.Server/OpenIddictServerOptions.cs index 33143da3..90f6746c 100644 --- a/src/OpenIddict.Server/OpenIddictServerOptions.cs +++ b/src/OpenIddict.Server/OpenIddictServerOptions.cs @@ -163,7 +163,7 @@ namespace OpenIddict.Server } // Note: unlike IdentityModel, this custom validator deliberately uses case-insensitive comparisons. - if (parameters.ValidTypes != null && parameters.ValidTypes.Any() && + if (parameters.ValidTypes is not null && parameters.ValidTypes.Any() && !parameters.ValidTypes.Contains(type, StringComparer.OrdinalIgnoreCase)) { throw new SecurityTokenInvalidTypeException(SR.GetResourceString(SR.ID1270)) diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs index 58eaa123..af14547a 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationAspNetCoreBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs index f854067e..566f0565 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreConfiguration.cs @@ -25,7 +25,7 @@ namespace OpenIddict.Validation.AspNetCore /// The options instance to initialize. public void Configure(AuthenticationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -43,7 +43,7 @@ namespace OpenIddict.Validation.AspNetCore public void Configure(OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -59,7 +59,7 @@ namespace OpenIddict.Validation.AspNetCore /// The options instance to initialize. public void PostConfigure(string name, AuthenticationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreExtensions.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreExtensions.cs index 78ebd55c..bfd3ee93 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreExtensions.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationAspNetCoreBuilder UseAspNetCore(this OpenIddictValidationBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -68,12 +68,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictValidationBuilder UseAspNetCore( this OpenIddictValidationBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs index cbd4e3c0..473da91b 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandler.cs @@ -51,7 +51,7 @@ namespace OpenIddict.Validation.AspNetCore // Note: the transaction may be already attached when replaying an ASP.NET Core request // (e.g when using the built-in status code pages middleware with the re-execute mode). var transaction = Context.Features.Get()?.Transaction; - if (transaction == null) + if (transaction is null) { // Create a new transaction and attach the HTTP request to make it available to the ASP.NET Core handlers. transaction = await _factory.CreateTransactionAsync(); @@ -115,7 +115,7 @@ namespace OpenIddict.Validation.AspNetCore // (generally later in the pipeline, when using the pass-through mode). To avoid having to re-validate it, // the authentication context is resolved from the transaction. If it's not available, a new one is created. var context = transaction.GetProperty(typeof(ProcessAuthenticationContext).FullName!); - if (context == null) + if (context is null) { context = new ProcessAuthenticationContext(transaction); await _dispatcher.DispatchAsync(context); @@ -152,7 +152,7 @@ namespace OpenIddict.Validation.AspNetCore else { - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); Debug.Assert(!string.IsNullOrEmpty(context.Principal.GetTokenType()), SR.GetResourceString(SR.ID5009)); Debug.Assert(!string.IsNullOrEmpty(context.Token), SR.GetResourceString(SR.ID5010)); diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlerFilters.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlerFilters.cs index fb899d11..a8045918 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlerFilters.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlerFilters.cs @@ -25,12 +25,12 @@ namespace OpenIddict.Validation.AspNetCore { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - return new ValueTask(context.Transaction.GetHttpRequest() != null); + return new ValueTask(context.Transaction.GetHttpRequest() is not null); } } } diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs index afd1b7f9..cfe5f213 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs @@ -85,7 +85,7 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -93,14 +93,14 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } // Only use the current host as the issuer if the // issuer was not explicitly set in the options. - if (context.Issuer != null) + if (context.Issuer is not null) { return default; } @@ -150,7 +150,7 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -164,7 +164,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -204,7 +204,7 @@ namespace OpenIddict.Validation.AspNetCore /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -218,7 +218,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -262,7 +262,7 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -276,7 +276,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetHttpRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -315,13 +315,13 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null) + if (properties is not null) { context.Response.Error = properties.GetString(Properties.Error); context.Response.ErrorDescription = properties.GetString(Properties.ErrorDescription); @@ -353,17 +353,17 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -405,7 +405,7 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -413,7 +413,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -452,17 +452,17 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -557,7 +557,7 @@ namespace OpenIddict.Validation.AspNetCore /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -565,7 +565,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } @@ -603,7 +603,7 @@ namespace OpenIddict.Validation.AspNetCore /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -611,7 +611,7 @@ namespace OpenIddict.Validation.AspNetCore // This handler only applies to ASP.NET Core requests. If the HTTP context cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetHttpRequest()?.HttpContext.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1113)); } diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHelpers.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHelpers.cs index a0365ae2..d4f3f341 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHelpers.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHelpers.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static HttpRequest? GetHttpRequest(this OpenIddictValidationTransaction transaction) { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore /// The . public static OpenIddictValidationEndpointType GetOpenIddictValidationEndpointType(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static OpenIddictRequest? GetOpenIddictValidationRequest(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore /// The instance or null if it couldn't be found. public static OpenIddictResponse? GetOpenIddictValidationResponse(this HttpContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs index 011209ea..70b5fe79 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationDataProtectionBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -56,7 +56,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationDataProtectionBuilder UseDataProtectionProvider(IDataProtectionProvider provider) { - if (provider == null) + if (provider is null) { throw new ArgumentNullException(nameof(provider)); } @@ -71,7 +71,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationDataProtectionBuilder UseFormatter(IOpenIddictValidationDataProtectionFormatter formatter) { - if (formatter == null) + if (formatter is null) { throw new ArgumentNullException(nameof(formatter)); } diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionConfiguration.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionConfiguration.cs index 09fab289..f9e99721 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionConfiguration.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionConfiguration.cs @@ -27,7 +27,7 @@ namespace OpenIddict.Validation.DataProtection public void Configure(OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -44,7 +44,7 @@ namespace OpenIddict.Validation.DataProtection /// The options instance to initialize. public void PostConfigure(string name, OpenIddictValidationDataProtectionOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionExtensions.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionExtensions.cs index a981126b..532551fc 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionExtensions.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionExtensions.cs @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationDataProtectionBuilder UseDataProtection(this OpenIddictValidationBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -58,12 +58,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictValidationBuilder UseDataProtection( this OpenIddictValidationBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs index e3191c78..af4fb29d 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs @@ -20,13 +20,13 @@ namespace OpenIddict.Validation.DataProtection { public ClaimsPrincipal? ReadToken(BinaryReader reader) { - if (reader == null) + if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var (principal, properties) = Read(reader); - if (principal == null) + if (principal is null) { return null; } diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs index 58d29e28..9ddcc94c 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs @@ -56,13 +56,13 @@ namespace OpenIddict.Validation.DataProtection /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } // If a principal was already attached, don't overwrite it. - if (context.Principal != null) + if (context.Principal is not null) { return default; } @@ -102,7 +102,7 @@ namespace OpenIddict.Validation.DataProtection context.Logger.LogTrace(exception, SR.GetResourceString(SR.ID7153), context.Token); } - if (context.Principal == null) + if (context.Principal is null) { context.Reject( error: Errors.InvalidToken, diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs index f3ce787f..62c55571 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs @@ -39,7 +39,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationOwinBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs index d68e2244..c6035e3b 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs @@ -16,7 +16,7 @@ namespace OpenIddict.Validation.Owin { public void Configure(OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs index c5553f73..0c6246fe 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs @@ -28,7 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationOwinBuilder UseOwin(this OpenIddictValidationBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -65,12 +65,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictValidationBuilder UseOwin( this OpenIddictValidationBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandler.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandler.cs index 50a06828..a2552860 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandler.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandler.cs @@ -46,7 +46,7 @@ namespace OpenIddict.Validation.Owin // Note: the transaction may be already attached when replaying an OWIN request // (e.g when using a status code pages middleware re-invoking the OWIN pipeline). var transaction = Context.Get(typeof(OpenIddictValidationTransaction).FullName); - if (transaction == null) + if (transaction is null) { // Create a new transaction and attach the OWIN request to make it available to the OWIN handlers. transaction = await _factory.CreateTransactionAsync(); @@ -127,7 +127,7 @@ namespace OpenIddict.Validation.Owin // (generally later in the pipeline, when using the pass-through mode). To avoid having to re-validate it, // the authentication context is resolved from the transaction. If it's not available, a new one is created. var context = transaction.GetProperty(typeof(ProcessAuthenticationContext).FullName!); - if (context == null) + if (context is null) { context = new ProcessAuthenticationContext(transaction); await _dispatcher.DispatchAsync(context); @@ -164,7 +164,7 @@ namespace OpenIddict.Validation.Owin else { - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); Debug.Assert(!string.IsNullOrEmpty(context.Principal.GetTokenType()), SR.GetResourceString(SR.ID5009)); Debug.Assert(!string.IsNullOrEmpty(context.Token), SR.GetResourceString(SR.ID5010)); @@ -198,7 +198,7 @@ namespace OpenIddict.Validation.Owin // corresponds to a challenge response, as LookupChallenge() will always return a non-null // value when active authentication is used, even if no challenge was actually triggered. var challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode); - if (challenge != null && (Response.StatusCode == 401 || Response.StatusCode == 403)) + if (challenge is not null && (Response.StatusCode == 401 || Response.StatusCode == 403)) { var transaction = Context.Get(typeof(OpenIddictValidationTransaction).FullName) ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID1165)); diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs index 935f8d4e..0c569299 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs @@ -23,12 +23,12 @@ namespace OpenIddict.Validation.Owin { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - return new ValueTask(context.Transaction.GetOwinRequest() != null); + return new ValueTask(context.Transaction.GetOwinRequest() is not null); } } } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs index e2572b16..02640b97 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs @@ -82,7 +82,7 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(ProcessRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -90,14 +90,14 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } // Only use the current host as the issuer if the // issuer was not explicitly set in the options. - if (context.Issuer != null) + if (context.Issuer is not null) { return default; } @@ -147,7 +147,7 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -161,7 +161,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -201,7 +201,7 @@ namespace OpenIddict.Validation.Owin /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -215,7 +215,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -260,7 +260,7 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -274,7 +274,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var request = context.Transaction.GetOwinRequest(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -314,13 +314,13 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!); - if (properties != null) + if (properties is not null) { context.Response.Error = GetProperty(properties, Properties.Error); context.Response.ErrorDescription = GetProperty(properties, Properties.ErrorDescription); @@ -355,17 +355,17 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -407,7 +407,7 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -415,7 +415,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -454,17 +454,17 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID5007)); // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -564,7 +564,7 @@ namespace OpenIddict.Validation.Owin /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -572,7 +572,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } @@ -610,7 +610,7 @@ namespace OpenIddict.Validation.Owin /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -618,7 +618,7 @@ namespace OpenIddict.Validation.Owin // This handler only applies to OWIN requests. If The OWIN request cannot be resolved, // this may indicate that the request was incorrectly processed by another server stack. var response = context.Transaction.GetOwinRequest()?.Context.Response; - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1119)); } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs index cb5274e4..c7199128 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs @@ -27,7 +27,7 @@ namespace Owin /// The . public static IAppBuilder UseOpenIddictValidation(this IAppBuilder app) { - if (app == null) + if (app is null) { throw new ArgumentNullException(nameof(app)); } @@ -42,7 +42,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static IOwinRequest? GetOwinRequest(this OpenIddictValidationTransaction transaction) { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -67,7 +67,7 @@ namespace Owin /// The . public static OpenIddictValidationEndpointType GetOpenIddictValidationEndpointType(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -82,7 +82,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static OpenIddictRequest? GetOpenIddictValidationRequest(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -97,7 +97,7 @@ namespace Owin /// The instance or null if it couldn't be found. public static OpenIddictResponse? GetOpenIddictValidationResponse(this IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs index ef530e53..ab7ad0c6 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs @@ -39,13 +39,13 @@ namespace OpenIddict.Validation.Owin /// public override Task Invoke(IOwinContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var provider = context.Get(typeof(IServiceProvider).FullName); - if (provider == null) + if (provider is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1167)); } diff --git a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs index 48a2f127..ca39e5e8 100644 --- a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs +++ b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs @@ -36,7 +36,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationServerIntegrationBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationConfiguration.cs b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationConfiguration.cs index 770c35c7..e6aa0177 100644 --- a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationConfiguration.cs +++ b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationConfiguration.cs @@ -34,7 +34,7 @@ namespace OpenIddict.Validation.ServerIntegration /// The options instance to initialize. public void Configure(OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -67,7 +67,7 @@ namespace OpenIddict.Validation.ServerIntegration /// The options instance to initialize. public void PostConfigure(string name, OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } diff --git a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationExtensions.cs b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationExtensions.cs index 11e3278d..d21887b4 100644 --- a/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationExtensions.cs +++ b/src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationExtensions.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationServerIntegrationBuilder UseLocalServer(this OpenIddictValidationBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -52,12 +52,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictValidationBuilder UseLocalServer( this OpenIddictValidationBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs index 1fd436f8..83db863a 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs @@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationSystemNetHttpBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs index 25fff06e..234f370b 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpConfiguration.cs @@ -28,7 +28,7 @@ namespace OpenIddict.Validation.SystemNetHttp public void Configure(OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -42,7 +42,7 @@ namespace OpenIddict.Validation.SystemNetHttp public void Configure(string name, HttpClientFactoryOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } @@ -69,7 +69,7 @@ namespace OpenIddict.Validation.SystemNetHttp var options = _provider.GetRequiredService>(); #endif var policy = options.CurrentValue.HttpErrorPolicy; - if (policy != null) + if (policy is not null) { builder.AdditionalHandlers.Add(new PolicyHttpMessageHandler(policy)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpExtensions.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpExtensions.cs index be5599ab..2d23038d 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpExtensions.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpExtensions.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationSystemNetHttpBuilder UseSystemNetHttp(this OpenIddictValidationBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -63,12 +63,12 @@ namespace Microsoft.Extensions.DependencyInjection public static OpenIddictValidationBuilder UseSystemNetHttp( this OpenIddictValidationBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlerFilters.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlerFilters.cs index f0dd5735..1a8bcf6d 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlerFilters.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlerFilters.cs @@ -21,7 +21,7 @@ namespace OpenIddict.Validation.SystemNetHttp { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs index f2369b44..29aca2e4 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs @@ -55,17 +55,17 @@ namespace OpenIddict.Validation.SystemNetHttp /// public async ValueTask HandleAsync(PrepareIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to System.Net.Http requests. If the HTTP request cannot be resolved, // this may indicate that the request was incorrectly processed by another client stack. var request = context.Transaction.GetHttpRequestMessage(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1172)); } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs index 840ec67f..50b71ab6 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs @@ -48,7 +48,7 @@ namespace OpenIddict.Validation.SystemNetHttp /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -83,7 +83,7 @@ namespace OpenIddict.Validation.SystemNetHttp /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -118,17 +118,17 @@ namespace OpenIddict.Validation.SystemNetHttp /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to System.Net.Http requests. If the HTTP request cannot be resolved, // this may indicate that the request was incorrectly processed by another client stack. var request = context.Transaction.GetHttpRequestMessage(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1172)); } @@ -139,7 +139,7 @@ namespace OpenIddict.Validation.SystemNetHttp using var content = new FormUrlEncodedContent( from parameter in context.Transaction.Request.GetParameters() let values = (string[]?) parameter.Value - where values != null + where values is not null from value in values select new KeyValuePair(parameter.Key, value)); @@ -171,17 +171,17 @@ namespace OpenIddict.Validation.SystemNetHttp /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Transaction.Request != null, SR.GetResourceString(SR.ID5008)); + Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID5008)); // This handler only applies to System.Net.Http requests. If the HTTP request cannot be resolved, // this may indicate that the request was incorrectly processed by another client stack. var request = context.Transaction.GetHttpRequestMessage(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1172)); } @@ -189,7 +189,7 @@ namespace OpenIddict.Validation.SystemNetHttp request.Content = new FormUrlEncodedContent( from parameter in context.Transaction.Request.GetParameters() let values = (string[]?) parameter.Value - where values != null + where values is not null from value in values select new KeyValuePair(parameter.Key, value)); @@ -221,7 +221,7 @@ namespace OpenIddict.Validation.SystemNetHttp /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -229,20 +229,20 @@ namespace OpenIddict.Validation.SystemNetHttp // This handler only applies to System.Net.Http requests. If the HTTP request cannot be resolved, // this may indicate that the request was incorrectly processed by another client stack. var request = context.Transaction.GetHttpRequestMessage(); - if (request == null) + if (request is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1172)); } var assembly = typeof(OpenIddictValidationSystemNetHttpOptions).Assembly.GetName(); using var client = _factory.CreateClient(assembly.Name); - if (client == null) + if (client is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1173)); } var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead); - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1174)); } @@ -271,7 +271,7 @@ namespace OpenIddict.Validation.SystemNetHttp /// public async ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -279,7 +279,7 @@ namespace OpenIddict.Validation.SystemNetHttp // This handler only applies to System.Net.Http requests. If the HTTP response cannot be resolved, // this may indicate that the request was incorrectly processed by another client stack. var response = context.Transaction.GetHttpResponseMessage(); - if (response == null) + if (response is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1172)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs index fe7aeab9..23c85149 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs @@ -49,7 +49,7 @@ namespace Microsoft.Extensions.DependencyInjection Action> configuration) where TContext : OpenIddictValidationEvents.BaseContext { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -71,7 +71,7 @@ namespace Microsoft.Extensions.DependencyInjection [EditorBrowsable(EditorBrowsableState.Advanced)] public OpenIddictValidationBuilder AddEventHandler(OpenIddictValidationHandlerDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -90,7 +90,7 @@ namespace Microsoft.Extensions.DependencyInjection [EditorBrowsable(EditorBrowsableState.Advanced)] public OpenIddictValidationBuilder RemoveEventHandler(OpenIddictValidationHandlerDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -119,7 +119,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder Configure(Action configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -136,7 +136,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder AddEncryptionCredentials(EncryptingCredentials credentials) { - if (credentials == null) + if (credentials is null) { throw new ArgumentNullException(nameof(credentials)); } @@ -151,7 +151,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder AddEncryptionKey(SecurityKey key) { - if (key == null) + if (key is null) { throw new ArgumentNullException(nameof(key)); } @@ -185,7 +185,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder AddEncryptionCertificate(X509Certificate2 certificate) { - if (certificate == null) + if (certificate is null) { throw new ArgumentNullException(nameof(certificate)); } @@ -239,7 +239,7 @@ namespace Microsoft.Extensions.DependencyInjection Assembly assembly, string resource, string password, X509KeyStorageFlags flags) { - if (assembly == null) + if (assembly is null) { throw new ArgumentNullException(nameof(assembly)); } @@ -255,7 +255,7 @@ namespace Microsoft.Extensions.DependencyInjection } using var stream = assembly.GetManifestResourceStream(resource); - if (stream == null) + if (stream is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1063)); } @@ -294,7 +294,7 @@ namespace Microsoft.Extensions.DependencyInjection public OpenIddictValidationBuilder AddEncryptionCertificate( Stream stream, string password, X509KeyStorageFlags flags) { - if (stream == null) + if (stream is null) { throw new ArgumentNullException(nameof(stream)); } @@ -323,7 +323,7 @@ namespace Microsoft.Extensions.DependencyInjection } var certificate = GetCertificate(StoreLocation.CurrentUser, thumbprint) ?? GetCertificate(StoreLocation.LocalMachine, thumbprint); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -363,7 +363,7 @@ namespace Microsoft.Extensions.DependencyInjection .OfType() .SingleOrDefault(); - if (certificate == null) + if (certificate is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1065)); } @@ -379,7 +379,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder AddAudiences(params string[] audiences) { - if (audiences == null) + if (audiences is null) { throw new ArgumentNullException(nameof(audiences)); } @@ -420,7 +420,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder SetConfiguration(OpenIdConnectConfiguration configuration) { - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } @@ -468,7 +468,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public OpenIddictValidationBuilder SetIssuer(Uri address) { - if (address == null) + if (address is null) { throw new ArgumentNullException(nameof(address)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationConfiguration.cs b/src/OpenIddict.Validation/OpenIddictValidationConfiguration.cs index 97d4d53b..a77ef839 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationConfiguration.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationConfiguration.cs @@ -33,18 +33,18 @@ namespace OpenIddict.Validation /// The options instance to initialize. public void PostConfigure(string name, OpenIddictValidationOptions options) { - if (options == null) + if (options is null) { throw new ArgumentNullException(nameof(options)); } - if (options.JsonWebTokenHandler == null) + if (options.JsonWebTokenHandler is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1074)); } - if (options.Configuration == null && options.ConfigurationManager == null && - options.Issuer == null && options.MetadataAddress == null) + if (options.Configuration is null && options.ConfigurationManager is null && + options.Issuer is null && options.MetadataAddress is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1127)); } @@ -56,7 +56,7 @@ namespace OpenIddict.Validation throw new InvalidOperationException(SR.GetResourceString(SR.ID1128)); } - if (options.Issuer == null && options.MetadataAddress == null) + if (options.Issuer is null && options.MetadataAddress is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1129)); } @@ -90,9 +90,9 @@ namespace OpenIddict.Validation throw new InvalidOperationException(SR.GetResourceString(SR.ID1086)); } - if (options.ConfigurationManager == null) + if (options.ConfigurationManager is null) { - if (options.Configuration != null) + if (options.Configuration is not null) { options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); } @@ -105,14 +105,14 @@ namespace OpenIddict.Validation throw new InvalidOperationException(SR.GetResourceString(SR.ID1134)); } - if (options.MetadataAddress == null) + if (options.MetadataAddress is null) { options.MetadataAddress = new Uri(".well-known/openid-configuration", UriKind.Relative); } if (!options.MetadataAddress.IsAbsoluteUri) { - if (options.Issuer == null || !options.Issuer.IsAbsoluteUri) + if (options.Issuer is null || !options.Issuer.IsAbsoluteUri) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1135)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs b/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs index d5c2ec3e..45a8da62 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs @@ -35,7 +35,7 @@ namespace OpenIddict.Validation public async ValueTask DispatchAsync(TContext context) where TContext : BaseContext { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -103,11 +103,11 @@ namespace OpenIddict.Validation continue; } - var handler = descriptor.ServiceDescriptor.ImplementationInstance != null ? + var handler = descriptor.ServiceDescriptor.ImplementationInstance is not null ? descriptor.ServiceDescriptor.ImplementationInstance as IOpenIddictValidationHandler : _provider.GetService(descriptor.ServiceDescriptor.ServiceType) as IOpenIddictValidationHandler; - if (handler == null) + if (handler is null) { throw new InvalidOperationException(SR.FormatID1137(descriptor.ServiceDescriptor.ServiceType)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs index 3fb8cf4e..c0ef6436 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationExtensions.cs @@ -31,7 +31,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The . public static OpenIddictValidationBuilder AddValidation(this OpenIddictBuilder builder) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } @@ -83,12 +83,12 @@ namespace Microsoft.Extensions.DependencyInjection this OpenIddictBuilder builder, Action configuration) { - if (builder == null) + if (builder is null) { throw new ArgumentNullException(nameof(builder)); } - if (configuration == null) + if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs index 2a538d2e..d1d2ee1c 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs @@ -79,7 +79,7 @@ namespace OpenIddict.Validation /// The builder instance, so that calls can be easily chained. public Builder AddFilter(Type type) { - if (type == null) + if (type is null) { throw new ArgumentNullException(nameof(type)); } @@ -110,7 +110,7 @@ namespace OpenIddict.Validation /// The builder instance, so that calls can be easily chained. public Builder SetServiceDescriptor(ServiceDescriptor descriptor) { - if (descriptor == null) + if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } @@ -162,7 +162,7 @@ namespace OpenIddict.Validation /// The builder instance, so that calls can be easily chained. public Builder UseInlineHandler(Func handler) { - if (handler == null) + if (handler is null) { throw new ArgumentNullException(nameof(handler)); } @@ -199,7 +199,7 @@ namespace OpenIddict.Validation public Builder UseSingletonHandler(THandler handler) where THandler : IOpenIddictValidationHandler { - if (handler == null) + if (handler is null) { throw new ArgumentNullException(nameof(handler)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlerFilters.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlerFilters.cs index 3b645916..65bb369d 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlerFilters.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlerFilters.cs @@ -21,7 +21,7 @@ namespace OpenIddict.Validation { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -37,7 +37,7 @@ namespace OpenIddict.Validation { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -53,7 +53,7 @@ namespace OpenIddict.Validation { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -69,7 +69,7 @@ namespace OpenIddict.Validation { public ValueTask IsActiveAsync(BaseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs index a202ae7c..5a8c2b9d 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs @@ -51,7 +51,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleConfigurationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -77,7 +77,7 @@ namespace OpenIddict.Validation return default; } - if (context.Issuer != null && context.Issuer != address) + if (context.Issuer is not null && context.Issuer != address) { context.Reject( error: Errors.ServerError, @@ -110,7 +110,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleConfigurationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -160,7 +160,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleConfigurationResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -214,13 +214,13 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleCryptographyResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } var keys = context.Response[JsonWebKeySetParameterNames.Keys]?.GetUnnamedParameters(); - if (keys == null || keys.Count == 0) + if (keys is null || keys.Count == 0) { context.Reject( error: Errors.ServerError, @@ -266,7 +266,7 @@ namespace OpenIddict.Validation _ => null }; - if (key == null) + if (key is null) { context.Reject( error: Errors.ServerError, diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs index 4ec8b9cc..04d20cc9 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs @@ -57,7 +57,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(PrepareIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -87,7 +87,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(PrepareIntrospectionRequestContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -117,7 +117,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -169,7 +169,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -284,7 +284,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -303,7 +303,7 @@ namespace OpenIddict.Validation return default; } - if (context.Issuer != null && context.Issuer != uri) + if (context.Issuer is not null && context.Issuer != uri) { context.Reject( error: Errors.ServerError, @@ -335,7 +335,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -379,7 +379,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(HandleIntrospectionResponseContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs index 9036dbc8..bc0457f2 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs @@ -69,7 +69,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -122,7 +122,7 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -136,7 +136,7 @@ namespace OpenIddict.Validation // If the reference token cannot be found, don't return an error to allow another handler to validate it. var token = await _tokenManager.FindByReferenceIdAsync(context.Token); - if (token == null) + if (token is null) { return; } @@ -185,13 +185,13 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } // If a principal was already attached, don't overwrite it. - if (context.Principal != null) + if (context.Principal is not null) { return; } @@ -248,10 +248,10 @@ namespace OpenIddict.Validation error: Errors.InvalidToken, description: result.Exception switch { - SecurityTokenInvalidIssuerException _ => context.Localizer[SR.ID3088], - SecurityTokenInvalidTypeException _ => context.Localizer[SR.ID3089], - SecurityTokenSignatureKeyNotFoundException _ => context.Localizer[SR.ID3090], - SecurityTokenInvalidSignatureException _ => context.Localizer[SR.ID3091], + SecurityTokenInvalidIssuerException => context.Localizer[SR.ID3088], + SecurityTokenInvalidTypeException => context.Localizer[SR.ID3089], + SecurityTokenSignatureKeyNotFoundException => context.Localizer[SR.ID3090], + SecurityTokenInvalidSignatureException => context.Localizer[SR.ID3091], _ => context.Localizer[SR.ID3004] }); @@ -301,13 +301,13 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } // If a principal was already attached, don't overwrite it. - if (context.Principal != null) + if (context.Principal is not null) { return; } @@ -373,12 +373,12 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return default; } @@ -418,12 +418,12 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return default; } @@ -531,12 +531,12 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { return; } @@ -548,7 +548,7 @@ namespace OpenIddict.Validation } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null) + if (token is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1020)); } @@ -581,12 +581,12 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - if (context.Principal == null) + if (context.Principal is null) { context.Reject( error: Errors.InvalidToken, @@ -635,12 +635,12 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var date = context.Principal.GetExpirationDate(); if (date.HasValue && date.Value < DateTimeOffset.UtcNow) @@ -677,12 +677,12 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); // If no explicit audience has been configured, // skip the default audience validation. @@ -749,12 +749,12 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var identifier = context.Principal.GetTokenId(); if (string.IsNullOrEmpty(identifier)) @@ -763,7 +763,7 @@ namespace OpenIddict.Validation } var token = await _tokenManager.FindByIdAsync(identifier); - if (token == null || !await _tokenManager.HasStatusAsync(token, Statuses.Valid)) + if (token is null || !await _tokenManager.HasStatusAsync(token, Statuses.Valid)) { context.Logger.LogError(SR.GetResourceString(SR.ID7005), identifier); @@ -812,12 +812,12 @@ namespace OpenIddict.Validation /// public async ValueTask HandleAsync(ProcessAuthenticationContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); var identifier = context.Principal.GetAuthorizationId(); if (string.IsNullOrEmpty(identifier)) @@ -826,7 +826,7 @@ namespace OpenIddict.Validation } var authorization = await _authorizationManager.FindByIdAsync(identifier); - if (authorization == null || !await _authorizationManager.HasStatusAsync(authorization, Statuses.Valid)) + if (authorization is null || !await _authorizationManager.HasStatusAsync(authorization, Statuses.Valid)) { context.Logger.LogError(SR.GetResourceString(SR.ID7006), identifier); @@ -857,7 +857,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(ProcessChallengeContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } @@ -915,7 +915,7 @@ namespace OpenIddict.Validation /// public ValueTask HandleAsync(TContext context) { - if (context == null) + if (context is null) { throw new ArgumentNullException(nameof(context)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationHelpers.cs b/src/OpenIddict.Validation/OpenIddictValidationHelpers.cs index d658b75b..787ba051 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHelpers.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHelpers.cs @@ -24,7 +24,7 @@ namespace OpenIddict.Validation public static TProperty? GetProperty( this OpenIddictValidationTransaction transaction, string name) where TProperty : class { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -54,7 +54,7 @@ namespace OpenIddict.Validation this OpenIddictValidationTransaction transaction, string name, TProperty? value) where TProperty : class { - if (transaction == null) + if (transaction is null) { throw new ArgumentNullException(nameof(transaction)); } @@ -64,7 +64,7 @@ namespace OpenIddict.Validation throw new ArgumentException(SR.GetResourceString(SR.ID1105), nameof(name)); } - if (value == null) + if (value is null) { transaction.Properties.Remove(name); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationOptions.cs b/src/OpenIddict.Validation/OpenIddictValidationOptions.cs index dc862013..695e5331 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationOptions.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationOptions.cs @@ -149,7 +149,7 @@ namespace OpenIddict.Validation } // Note: unlike IdentityModel, this custom validator deliberately uses case-insensitive comparisons. - if (parameters.ValidTypes != null && parameters.ValidTypes.Any() && + if (parameters.ValidTypes is not null && parameters.ValidTypes.Any() && !parameters.ValidTypes.Contains(type, StringComparer.OrdinalIgnoreCase)) { throw new SecurityTokenInvalidTypeException(SR.GetResourceString(SR.ID1270)) diff --git a/src/OpenIddict.Validation/OpenIddictValidationService.cs b/src/OpenIddict.Validation/OpenIddictValidationService.cs index a0567719..7935d882 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationService.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationService.cs @@ -38,7 +38,7 @@ namespace OpenIddict.Validation /// The OpenID Connect server configuration retrieved from the remote server. public async ValueTask GetConfigurationAsync(Uri address, CancellationToken cancellationToken = default) { - if (address == null) + if (address is null) { throw new ArgumentNullException(nameof(address)); } @@ -69,7 +69,7 @@ namespace OpenIddict.Validation var response = await ExtractConfigurationResponseAsync(); var configuration = await HandleConfigurationResponseAsync(); - if (configuration == null) + if (configuration is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1144)); } @@ -131,7 +131,7 @@ namespace OpenIddict.Validation context.Error, context.ErrorDescription, context.ErrorUri); } - Debug.Assert(context.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID5007)); return context.Response; } @@ -179,7 +179,7 @@ namespace OpenIddict.Validation /// The security keys retrieved from the remote server. public async ValueTask GetSecurityKeysAsync(Uri address, CancellationToken cancellationToken = default) { - if (address == null) + if (address is null) { throw new ArgumentNullException(nameof(address)); } @@ -211,7 +211,7 @@ namespace OpenIddict.Validation var response = await ExtractCryptographyResponseAsync(); var keys = await HandleCryptographyResponseAsync(); - if (keys == null) + if (keys is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1146)); } @@ -273,7 +273,7 @@ namespace OpenIddict.Validation context.Error, context.ErrorDescription, context.ErrorUri); } - Debug.Assert(context.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID5007)); return context.Response; } @@ -334,7 +334,7 @@ namespace OpenIddict.Validation public async ValueTask IntrospectTokenAsync( Uri address, string token, string? type, CancellationToken cancellationToken = default) { - if (address == null) + if (address is null) { throw new ArgumentNullException(nameof(address)); } @@ -370,7 +370,7 @@ namespace OpenIddict.Validation var response = await ExtractIntrospectionResponseAsync(); var principal = await HandleIntrospectionResponseAsync(); - if (principal == null) + if (principal is null) { throw new InvalidOperationException(SR.GetResourceString(SR.ID1156)); } @@ -434,7 +434,7 @@ namespace OpenIddict.Validation context.Error, context.ErrorDescription, context.ErrorUri); } - Debug.Assert(context.Response != null, SR.GetResourceString(SR.ID5007)); + Debug.Assert(context.Response is not null, SR.GetResourceString(SR.ID5007)); return context.Response; } @@ -458,7 +458,7 @@ namespace OpenIddict.Validation context.Error, context.ErrorDescription, context.ErrorUri); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); return context.Principal; } @@ -521,7 +521,7 @@ namespace OpenIddict.Validation context.Error, context.ErrorDescription, context.ErrorUri); } - Debug.Assert(context.Principal != null, SR.GetResourceString(SR.ID5006)); + Debug.Assert(context.Principal is not null, SR.GetResourceString(SR.ID5006)); return context.Principal; } diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs index 737124b2..8f0c0911 100644 --- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs +++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs @@ -2953,7 +2953,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives private TimeSpan? ParseLifeTime(string lifetime) { - var lifeT = lifetime != null + var lifeT = lifetime is not null ? (TimeSpan?) TimeSpan.FromSeconds(double.Parse(lifetime, NumberStyles.Number, CultureInfo.InvariantCulture)) : null; diff --git a/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs b/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs index ba466a4d..ab369f2a 100644 --- a/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs +++ b/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs @@ -79,7 +79,7 @@ namespace OpenIddict.Core.Tests // Assert Assert.Contains(services, service => service.ServiceType == typeof(ClosedGenericApplicationManager) && - service.ImplementationFactory != null); + service.ImplementationFactory is not null); Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictApplicationManager) && service.ImplementationType == typeof(ClosedGenericApplicationManager)); @@ -170,7 +170,7 @@ namespace OpenIddict.Core.Tests // Assert Assert.Contains(services, service => service.ServiceType == typeof(ClosedGenericAuthorizationManager) && - service.ImplementationFactory != null); + service.ImplementationFactory is not null); Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictAuthorizationManager) && service.ImplementationType == typeof(ClosedGenericAuthorizationManager)); @@ -260,7 +260,7 @@ namespace OpenIddict.Core.Tests // Assert Assert.Contains(services, service => service.ServiceType == typeof(ClosedGenericScopeManager) && - service.ImplementationFactory != null); + service.ImplementationFactory is not null); Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictScopeManager) && service.ImplementationType == typeof(ClosedGenericScopeManager)); @@ -351,7 +351,7 @@ namespace OpenIddict.Core.Tests // Assert Assert.Contains(services, service => service.ServiceType == typeof(ClosedGenericTokenManager) && - service.ImplementationFactory != null); + service.ImplementationFactory is not null); Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictTokenManager) && service.ImplementationType == typeof(ClosedGenericTokenManager)); diff --git a/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs b/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs index c28e4159..8e5bde6c 100644 --- a/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs +++ b/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs @@ -122,7 +122,7 @@ namespace OpenIddict.Core.Tests builder.AddCore(); // Assert - Assert.Contains(services, service => service.ServiceType == type && service.ImplementationFactory != null); + Assert.Contains(services, service => service.ServiceType == type && service.ImplementationFactory is not null); } [Fact] diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs index 4ba722f1..03c80382 100644 --- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs +++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs @@ -499,7 +499,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests var feature = context.Features.Get(); var response = feature?.Transaction.GetProperty("custom_response"); - if (response != null) + if (response is not null) { context.Response.ContentType = "application/json"; await context.Response.WriteAsync(JsonSerializer.Serialize(response)); @@ -595,7 +595,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests else if (context.Request.Path == "/authenticate") { var result = await context.AuthenticateAsync(OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); - if (result?.Principal == null) + if (result?.Principal is null) { return; } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs index 265a7ab6..cf7ff5e6 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs @@ -49,12 +49,12 @@ namespace OpenIddict.Server.IntegrationTests /// The HTML parser used to parse the responses returned by the OpenID Connect server. public OpenIddictServerIntegrationTestClient(HttpClient client, HtmlParser parser) { - if (client == null) + if (client is null) { throw new ArgumentNullException(nameof(client)); } - if (parser == null) + if (parser is null) { throw new ArgumentNullException(nameof(parser)); } @@ -102,7 +102,7 @@ namespace OpenIddict.Server.IntegrationTests /// The OpenID Connect response returned by the server. public Task GetAsync(string uri, OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -134,7 +134,7 @@ namespace OpenIddict.Server.IntegrationTests /// The OpenID Connect response returned by the server. public Task PostAsync(string uri, OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -167,7 +167,7 @@ namespace OpenIddict.Server.IntegrationTests /// The OpenID Connect response returned by the server. public Task SendAsync(string method, string uri, OpenIddictRequest request) { - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -195,12 +195,12 @@ namespace OpenIddict.Server.IntegrationTests /// The OpenID Connect response returned by the server. public Task SendAsync(HttpMethod method, string uri, OpenIddictRequest request) { - if (method == null) + if (method is null) { throw new ArgumentNullException(nameof(method)); } - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } @@ -223,22 +223,22 @@ namespace OpenIddict.Server.IntegrationTests /// The OpenID Connect response returned by the server. public virtual async Task SendAsync(HttpMethod method, Uri uri, OpenIddictRequest request) { - if (method == null) + if (method is null) { throw new ArgumentNullException(nameof(method)); } - if (uri == null) + if (uri is null) { throw new ArgumentNullException(nameof(uri)); } - if (request == null) + if (request is null) { throw new ArgumentNullException(nameof(request)); } - if (HttpClient.BaseAddress == null && !uri.IsAbsoluteUri) + if (HttpClient.BaseAddress is null && !uri.IsAbsoluteUri) { throw new ArgumentException("The address cannot be a relative URI when no base address " + "is associated with the HTTP client.", nameof(uri)); @@ -268,7 +268,7 @@ namespace OpenIddict.Server.IntegrationTests } var values = (string[]) parameter.Value; - if (values == null || values.Length == 0) + if (values is null || values.Length == 0) { continue; } @@ -353,7 +353,7 @@ namespace OpenIddict.Server.IntegrationTests return response; } - else if (message.Headers.Location != null) + else if (message.Headers.Location is not null) { var payload = message.Headers.Location.Fragment; if (string.IsNullOrEmpty(payload)) @@ -475,7 +475,7 @@ namespace OpenIddict.Server.IntegrationTests // this is required for derived drafts like the OAuth2 token exchange specification. var parameters = new List>(); - for (var line = await reader.ReadLineAsync(); line != null; line = await reader.ReadLineAsync()) + for (var line = await reader.ReadLineAsync(); line is not null; line = await reader.ReadLineAsync()) { var index = line.IndexOf(':'); if (index == -1) diff --git a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs index 73252823..1888e5c6 100644 --- a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs +++ b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs @@ -369,7 +369,7 @@ namespace OpenIddict.Server.Owin.IntegrationTests var transaction = context.Get(typeof(OpenIddictServerTransaction).FullName); var response = transaction?.GetProperty("custom_response"); - if (response != null) + if (response is not null) { context.Response.ContentType = "application/json"; await context.Response.WriteAsync(JsonSerializer.Serialize(response)); @@ -417,7 +417,7 @@ namespace OpenIddict.Server.Owin.IntegrationTests else if (context.Request.Path == new PathString("/authenticate")) { var result = await context.Authentication.AuthenticateAsync(OpenIddictServerOwinDefaults.AuthenticationType); - if (result?.Identity == null) + if (result?.Identity is null) { return; }