Browse Source

Update the entire codebase to use is null/is not null

pull/1089/head
Kévin Chalet 5 years ago
parent
commit
3841f32f17
  1. 20
      samples/Mvc.Server/Controllers/AccountController.cs
  2. 12
      samples/Mvc.Server/Controllers/AuthorizationController.cs
  3. 2
      samples/Mvc.Server/Controllers/ErrorController.cs
  4. 24
      samples/Mvc.Server/Controllers/ManageController.cs
  5. 2
      samples/Mvc.Server/Controllers/ResourceController.cs
  6. 2
      samples/Mvc.Server/Controllers/UserinfoController.cs
  7. 2
      samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs
  8. 6
      samples/Mvc.Server/Worker.cs
  9. 6
      shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs
  10. 6
      src/OpenIddict.Abstractions/OpenIddictExtensions.cs
  11. 10
      src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs
  12. 127
      src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs
  13. 12
      src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs
  14. 2
      src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs
  15. 20
      src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs
  16. 18
      src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs
  17. 20
      src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs
  18. 20
      src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs
  19. 82
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  20. 62
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  21. 70
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  22. 78
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  23. 50
      src/OpenIddict.Core/OpenIddictCoreBuilder.cs
  24. 14
      src/OpenIddict.Core/OpenIddictCoreExtensions.cs
  25. 4
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs
  26. 6
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs
  27. 4
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs
  28. 6
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs
  29. 6
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs
  30. 6
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs
  31. 6
      src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs
  32. 62
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  33. 66
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  34. 48
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  35. 89
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs
  36. 2
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs
  37. 2
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs
  38. 2
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs
  39. 2
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs
  40. 4
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs
  41. 4
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreCustomizer.cs
  42. 6
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs
  43. 6
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs
  44. 6
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs
  45. 6
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs
  46. 6
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs
  47. 6
      src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs
  48. 62
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  49. 54
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  50. 48
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  51. 74
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs
  52. 4
      src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs
  53. 4
      src/OpenIddict.MongoDb/OpenIddictMongoDbContext.cs
  54. 6
      src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs
  55. 4
      src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs
  56. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs
  57. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs
  58. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs
  59. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs
  60. 72
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs
  61. 50
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs
  62. 52
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs
  63. 60
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs
  64. 6
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs
  65. 8
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs
  66. 6
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs
  67. 8
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs
  68. 24
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs
  69. 32
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs
  70. 20
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs
  71. 102
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs
  72. 8
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs
  73. 6
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs
  74. 4
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionConfiguration.cs
  75. 6
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs
  76. 14
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
  77. 10
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs
  78. 26
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs
  79. 6
      src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs
  80. 4
      src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs
  81. 6
      src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs
  82. 14
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandler.cs
  83. 22
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs
  84. 32
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
  85. 20
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
  86. 88
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
  87. 10
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs
  88. 4
      src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs
  89. 2
      src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs
  90. 6
      src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs
  91. 8
      src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs
  92. 98
      src/OpenIddict.Server/OpenIddictServerBuilder.cs
  93. 26
      src/OpenIddict.Server/OpenIddictServerConfiguration.cs
  94. 6
      src/OpenIddict.Server/OpenIddictServerDispatcher.cs
  95. 6
      src/OpenIddict.Server/OpenIddictServerExtensions.cs
  96. 8
      src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
  97. 60
      src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs
  98. 76
      src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs
  99. 52
      src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs
  100. 74
      src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs

20
samples/Mvc.Server/Controllers/AccountController.cs

@ -154,7 +154,7 @@ namespace Mvc.Server.Controllers
public async Task<IActionResult> 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<IActionResult> 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<ActionResult> 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");
}

12
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,

2
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());
}

24
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<IActionResult> 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<IActionResult> 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<IActionResult> 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<ActionResult> 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 });
}

2
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,

2
samples/Mvc.Server/Controllers/UserinfoController.cs

@ -26,7 +26,7 @@ namespace Mvc.Server.Controllers
public async Task<IActionResult> Userinfo()
{
var user = await _userManager.GetUserAsync(User);
if (user == null)
if (user is null)
{
return Challenge(
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,

2
samples/Mvc.Server/Helpers/AsyncEnumerableExtensions.cs

@ -8,7 +8,7 @@ namespace Mvc.Server.Helpers
{
public static Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source)
{
if (source == null)
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}

6
samples/Mvc.Server/Worker.cs

@ -30,7 +30,7 @@ namespace Mvc.Server
{
var manager = provider.GetRequiredService<IOpenIddictApplicationManager>();
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<IOpenIddictScopeManager>();
if (await manager.FindByNameAsync("demo_api") == null)
if (await manager.FindByNameAsync("demo_api") is null)
{
await manager.CreateAsync(new OpenIddictScopeDescriptor
{

6
shared/OpenIddict.Extensions/Helpers/OpenIddictHelpers.cs

@ -27,12 +27,12 @@ namespace OpenIddict.Extensions
/// <returns>A <see cref="Type"/> instance if the base type was found, <c>null</c> otherwise.</returns>
public static IEnumerable<Type> 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)
{

6
src/OpenIddict.Abstractions/OpenIddictExtensions.cs

@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
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
/// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddOpenIddict(this IServiceCollection services, Action<OpenIddictBuilder> 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));
}

10
src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs

@ -23,7 +23,7 @@ namespace OpenIddict.Abstractions
/// <returns><c>true</c> if the type is supported, <c>false</c> otherwise.</returns>
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
/// <returns>The deserialized <see cref="OpenIddictMessage"/> instance.</returns>
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
/// <param name="options">The JSON serializer options.</param>
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));
}

127
src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs

@ -31,7 +31,7 @@ namespace OpenIddict.Abstractions
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetAcrValues(this OpenIddictRequest request)
{
if (request == null)
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
@ -45,7 +45,7 @@ namespace OpenIddict.Abstractions
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetPrompts(this OpenIddictRequest request)
{
if (request == null)
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
@ -59,7 +59,7 @@ namespace OpenIddict.Abstractions
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetResponseTypes(this OpenIddictRequest request)
{
if (request == null)
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
@ -73,7 +73,7 @@ namespace OpenIddict.Abstractions
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetScopes(this OpenIddictRequest request)
{
if (request == null)
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
@ -88,7 +88,7 @@ namespace OpenIddict.Abstractions
/// <param name="value">The component to look for in the parameter.</param>
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
/// <param name="prompt">The component to look for in the parameter.</param>
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
/// <param name="type">The component to look for in the parameter.</param>
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
/// <param name="scope">The component to look for in the parameter.</param>
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
/// <returns><c>true</c> if the request is a response_type=none request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is a code flow request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is an implicit flow request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is an hybrid flow request, <c>false</c> otherwise.</returns>
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
/// </returns>
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
/// </returns>
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
/// </returns>
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
/// <returns><c>true</c> if the request is a code grant request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is a client credentials grant request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is a device code grant request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is a password grant request, <c>false</c> otherwise.</returns>
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
/// <returns><c>true</c> if the request is a refresh token grant request, <c>false</c> otherwise.</returns>
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
/// <returns>The destinations associated with the claim.</returns>
public static ImmutableArray<string> GetDestinations(this Claim claim)
{
if (claim == null)
if (claim is null)
{
throw new ArgumentNullException(nameof(claim));
}
@ -529,7 +529,7 @@ namespace OpenIddict.Abstractions
/// <param name="destination">The required destination.</param>
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
/// <param name="destinations">The destinations.</param>
public static Claim SetDestinations(this Claim claim, ImmutableArray<string> destinations)
{
if (claim == null)
if (claim is null)
{
throw new ArgumentNullException(nameof(claim));
}
@ -607,7 +607,7 @@ namespace OpenIddict.Abstractions
/// <returns>The destinations, returned as a flattened dictionary.</returns>
public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsPrincipal principal)
{
if (principal == null)
if (principal is null)
{
throw new ArgumentNullException(nameof(principal));
}
@ -645,12 +645,12 @@ namespace OpenIddict.Abstractions
/// <returns>The principal.</returns>
public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary<string, string[]> 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
/// </param>
public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func<Claim, bool> 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
/// </param>
public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func<Claim, bool> 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
/// <param name="value">The value associated with the claim.</param>
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
/// <param name="destinations">The destinations associated with the claim.</param>
public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, ImmutableArray<string> 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
/// <returns>The claim value.</returns>
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
/// <returns>The claim value.</returns>
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
/// <returns>The claim values.</returns>
public static ImmutableArray<string> 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
/// <returns><c>true</c> if the identity contains at least one claim of the specified type.</returns>
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
/// <returns>The claim values.</returns>
public static ImmutableArray<string> 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
/// <returns><c>true</c> if the principal contains at least one claim of the specified type.</returns>
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
/// <returns>The claims identity.</returns>
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
/// <returns>The claims identity.</returns>
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
/// <returns>The claims identity.</returns>
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
/// <returns>The claims identity.</returns>
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
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values)
{
if (identity == null)
if (identity is null)
{
throw new ArgumentNullException(nameof(identity));
}
@ -1083,7 +1078,7 @@ namespace OpenIddict.Abstractions
/// <returns>The claims identity.</returns>
public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values)
{
if (principal == null)
if (principal is null)
{
throw new ArgumentNullException(nameof(principal));
}
@ -1110,13 +1105,13 @@ namespace OpenIddict.Abstractions
/// <returns>The creation date or <c>null</c> if the claim cannot be found.</returns>
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
/// <returns>The expiration date or <c>null</c> if the claim cannot be found.</returns>
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
/// <returns><c>true</c> if the principal contains the given audience.</returns>
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
/// <returns><c>true</c> if the principal contains the given presenter.</returns>
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
/// <returns><c>true</c> if the principal contains the given resource.</returns>
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
/// <returns><c>true</c> if the principal contains the given scope.</returns>
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
/// <returns><c>true</c> if the token type matches the specified type.</returns>
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<string> 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));
}

12
src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs

@ -68,7 +68,7 @@ namespace OpenIddict.Abstractions
/// <param name="parameters">The message parameters.</param>
public OpenIddictMessage(IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters)
{
if (parameters == null)
if (parameters is null)
{
throw new ArgumentNullException(nameof(parameters));
}
@ -85,7 +85,7 @@ namespace OpenIddict.Abstractions
/// <param name="parameters">The message parameters.</param>
public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?>> parameters)
{
if (parameters == null)
if (parameters is null)
{
throw new ArgumentNullException(nameof(parameters));
}
@ -113,7 +113,7 @@ namespace OpenIddict.Abstractions
/// <param name="parameters">The message parameters.</param>
public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?[]?>> parameters)
{
if (parameters == null)
if (parameters is null)
{
throw new ArgumentNullException(nameof(parameters));
}
@ -140,7 +140,7 @@ namespace OpenIddict.Abstractions
/// <param name="parameters">The message parameters.</param>
public OpenIddictMessage(IEnumerable<KeyValuePair<string, StringValues>> 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
/// <param name="writer">The UTF-8 JSON writer.</param>
public void WriteTo(Utf8JsonWriter writer)
{
if (writer == null)
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

2
src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs

@ -505,7 +505,7 @@ namespace OpenIddict.Abstractions
/// <param name="writer">The UTF-8 JSON writer.</param>
public void WriteTo(Utf8JsonWriter writer)
{
if (writer == null)
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

20
src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs

@ -45,7 +45,7 @@ namespace OpenIddict.Core
/// <inheritdoc/>
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<TApplication?> 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<TApplication?> 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
/// <inheritdoc/>
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
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
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<TApplication> 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<IChangeToken> CreateExpirationSignalAsync(
TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}

18
src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs

@ -45,7 +45,7 @@ namespace OpenIddict.Core
/// <inheritdoc/>
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<TAuthorization?> 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
/// <inheritdoc/>
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
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
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<TAuthorization> 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<IChangeToken> CreateExpirationSignalAsync(
TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}

20
src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs

@ -46,7 +46,7 @@ namespace OpenIddict.Core
/// <inheritdoc/>
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<TScope?> 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<TScope?> 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
/// <inheritdoc/>
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
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
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<TScope> 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
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}

20
src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs

@ -45,7 +45,7 @@ namespace OpenIddict.Core
/// <inheritdoc/>
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<TToken?> 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<TToken?> 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
/// <inheritdoc/>
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
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
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<TToken> 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
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}

82
src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs

@ -111,7 +111,7 @@ namespace OpenIddict.Core
public virtual ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -143,7 +143,7 @@ namespace OpenIddict.Core
/// </returns>
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<TApplication> 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
/// </returns>
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<TResult> GetAsync<TResult>(
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -464,7 +464,7 @@ namespace OpenIddict.Core
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> 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<string?> 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<string?> 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<string?> 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<string?> 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<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>();
}
@ -595,7 +595,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual ValueTask<string?> 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<string?> 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<ImmutableArray<string>> 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<ImmutableArray<string>> 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<ImmutableArray<string>> 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<ImmutableArray<string>> 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<bool> 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<bool> 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<bool> 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<bool> 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<TResult> ListAsync<TResult>(
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -878,7 +878,7 @@ namespace OpenIddict.Core
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> 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
/// </returns>
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
/// </returns>
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<ValidationResult> 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<bool> 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<bool> ValidateRedirectUriAsync(
TApplication application, string address, CancellationToken cancellationToken = default)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}

62
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -98,7 +98,7 @@ namespace OpenIddict.Core
public virtual ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -116,7 +116,7 @@ namespace OpenIddict.Core
/// </returns>
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<TAuthorization> 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<string> scopes, CancellationToken cancellationToken = default)
{
if (principal == null)
if (principal is null)
{
throw new ArgumentNullException(nameof(principal));
}
@ -251,7 +251,7 @@ namespace OpenIddict.Core
/// </returns>
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<string?> 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<TResult> GetAsync<TResult>(
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -675,7 +675,7 @@ namespace OpenIddict.Core
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> 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<DateTimeOffset?> 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
/// </returns>
public virtual ValueTask<string?> 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<ImmutableArray<string>> 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<string?> 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<string?> 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<string?> 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<bool> HasScopesAsync(TAuthorization authorization,
ImmutableArray<string> 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<bool> 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<bool> 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<TResult> ListAsync<TResult>(
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -909,7 +909,7 @@ namespace OpenIddict.Core
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> 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
/// <returns><c>true</c> if the authorization was successfully revoked, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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
/// </returns>
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<ValidationResult> ValidateAsync(
TAuthorization authorization, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}

70
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -97,7 +97,7 @@ namespace OpenIddict.Core
public virtual ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -115,7 +115,7 @@ namespace OpenIddict.Core
/// </returns>
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<TScope> 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
/// </returns>
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<TResult> GetAsync<TResult>(
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -402,7 +402,7 @@ namespace OpenIddict.Core
Func<IQueryable<TScope>, TState, IQueryable<TResult>> 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
/// </returns>
public virtual ValueTask<string?> 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<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>();
}
@ -466,7 +466,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual ValueTask<string?> 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<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>();
}
@ -511,7 +511,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual ValueTask<string?> 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<string?> 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<string?> 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
/// </returns>
public virtual ValueTask<string?> 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<ImmutableArray<string>> 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<TResult> ListAsync<TResult>(
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -720,7 +720,7 @@ namespace OpenIddict.Core
Func<IQueryable<TScope>, TState, IQueryable<TResult>> 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
/// </returns>
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<ValidationResult> 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))
{

78
src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs

@ -98,7 +98,7 @@ namespace OpenIddict.Core
public virtual ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -116,7 +116,7 @@ namespace OpenIddict.Core
/// </returns>
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<TToken> 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
/// </returns>
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
/// </returns>
public virtual ValueTask<string?> 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<TResult> GetAsync<TResult>(
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -641,7 +641,7 @@ namespace OpenIddict.Core
Func<IQueryable<TToken>, TState, IQueryable<TResult>> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<DateTimeOffset?> 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
/// </returns>
public virtual ValueTask<DateTimeOffset?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// </returns>
public virtual ValueTask<string?> 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
/// <returns><c>true</c> if the token has the specified status, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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
/// <returns><c>true</c> if the token has the specified type, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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<TResult> ListAsync<TResult>(
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -908,7 +908,7 @@ namespace OpenIddict.Core
Func<IQueryable<TToken>, TState, IQueryable<TResult>> 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<bool> 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
/// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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
/// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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
/// <returns><c>true</c> if the token was successfully revoked, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> 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
/// </returns>
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<ValidationResult> 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))
{

50
src/OpenIddict.Core/OpenIddictCoreBuilder.cs

@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder Configure(Action<OpenIddictCoreOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -74,13 +74,13 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder SetDefaultTokenEntity(Type type)
{
if (type == null)
if (type is null)
{
throw new ArgumentNullException(nameof(type));
}

14
src/OpenIddict.Core/OpenIddictCoreExtensions.cs

@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
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<IOptionsMonitor<OpenIddictCoreOptions>>().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<IOptionsMonitor<OpenIddictCoreOptions>>().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<IOptionsMonitor<OpenIddictCoreOptions>>().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<IOptionsMonitor<OpenIddictCoreOptions>>().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
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
public static OpenIddictBuilder AddCore(this OpenIddictBuilder builder, Action<OpenIddictCoreBuilder> 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));
}

4
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs

@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkBuilder"/>.</returns>
public OpenIddictEntityFrameworkBuilder Configure(Action<OpenIddictEntityFrameworkOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -99,7 +99,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkBuilder"/>.</returns>
public OpenIddictEntityFrameworkBuilder UseDbContext(Type type)
{
if (type == null)
if (type is null)
{
throw new ArgumentNullException(nameof(type));
}

6
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkExtensions.cs

@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkBuilder"/>.</returns>
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<OpenIddictEntityFrameworkBuilder> 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));
}

4
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs

@ -48,7 +48,7 @@ namespace System.Data.Entity
where TToken : OpenIddictEntityFrameworkToken<TKey, TApplication, TAuthorization>
where TKey : IEquatable<TKey>
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
@ -71,7 +71,7 @@ namespace System.Data.Entity
/// <returns>The non-streamed async enumeration containing the results.</returns>
internal static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IQueryable<T> source, CancellationToken cancellationToken)
{
if (source == null)
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}

6
src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkApplicationStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework
public IOpenIddictApplicationStore<TApplication> Get<TApplication>() where TApplication : class
{
var store = _provider.GetService<IOpenIddictApplicationStore<TApplication>>();
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));
}

6
src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkAuthorizationStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework
public IOpenIddictAuthorizationStore<TAuthorization> Get<TAuthorization>() where TAuthorization : class
{
var store = _provider.GetService<IOpenIddictAuthorizationStore<TAuthorization>>();
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));
}

6
src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkScopeStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework
public IOpenIddictScopeStore<TScope> Get<TScope>() where TScope : class
{
var store = _provider.GetService<IOpenIddictScopeStore<TScope>>();
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));
}

6
src/OpenIddict.EntityFramework/Resolvers/OpenIddictEntityFrameworkTokenStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFramework
public IOpenIddictTokenStore<TToken> Get<TToken>() where TToken : class
{
var store = _provider.GetService<IOpenIddictTokenStore<TToken>>();
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));
}

62
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs

@ -109,7 +109,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -120,7 +120,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -326,7 +326,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientIdAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -337,7 +337,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientSecretAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -348,7 +348,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -359,7 +359,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -370,7 +370,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -381,7 +381,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -409,7 +409,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -420,7 +420,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -447,7 +447,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -474,7 +474,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -501,7 +501,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -528,7 +528,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -602,7 +602,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray<string> 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<string> 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<string, JsonElement> 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<string> addresses, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -805,7 +805,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray<string> requirements, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -829,7 +829,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}

66
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs

@ -106,7 +106,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -117,7 +117,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -416,7 +412,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -427,7 +423,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -438,7 +434,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -465,7 +461,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -492,7 +488,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -503,7 +499,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -514,7 +510,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> 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<string, JsonElement> 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<string> scopes, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -748,7 +744,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}

48
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs

@ -92,7 +92,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -103,7 +103,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -231,7 +231,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetDescriptionAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -242,7 +242,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -270,7 +270,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -281,7 +281,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -309,7 +309,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -320,7 +320,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -331,7 +331,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -358,7 +358,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -431,7 +431,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray<string> resources, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -597,7 +597,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}

89
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs

@ -106,7 +106,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -117,7 +117,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -359,13 +354,13 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual async ValueTask<string?> 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
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -398,7 +393,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -409,7 +404,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -420,7 +415,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -431,7 +426,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -458,7 +453,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -469,7 +464,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -480,7 +475,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -491,7 +486,7 @@ namespace OpenIddict.EntityFramework
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}

2
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreApplicationConfiguration.cs

@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore
{
public void Configure(EntityTypeBuilder<TApplication> builder)
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}

2
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreAuthorizationConfiguration.cs

@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore
{
public void Configure(EntityTypeBuilder<TAuthorization> builder)
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}

2
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreScopeConfiguration.cs

@ -24,7 +24,7 @@ namespace OpenIddict.EntityFrameworkCore
{
public void Configure(EntityTypeBuilder<TScope> builder)
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}

2
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictEntityFrameworkCoreTokenConfiguration.cs

@ -28,7 +28,7 @@ namespace OpenIddict.EntityFrameworkCore
{
public void Configure(EntityTypeBuilder<TToken> builder)
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}

4
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs

@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkCoreBuilder"/>.</returns>
public OpenIddictEntityFrameworkCoreBuilder Configure(Action<OpenIddictEntityFrameworkCoreOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -101,7 +101,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkCoreBuilder"/>.</returns>
public OpenIddictEntityFrameworkCoreBuilder UseDbContext(Type type)
{
if (type == null)
if (type is null)
{
throw new ArgumentNullException(nameof(type));
}

4
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));
}

6
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreExtensions.cs

@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictEntityFrameworkCoreBuilder"/>.</returns>
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<OpenIddictEntityFrameworkCoreBuilder> 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));
}

6
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs

@ -68,7 +68,7 @@ namespace Microsoft.EntityFrameworkCore
where TToken : OpenIddictEntityFrameworkCoreToken<TKey, TApplication, TAuthorization>
where TKey : IEquatable<TKey>
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
@ -122,7 +122,7 @@ namespace Microsoft.EntityFrameworkCore
where TToken : OpenIddictEntityFrameworkCoreToken<TKey, TApplication, TAuthorization>
where TKey : IEquatable<TKey>
{
if (builder == null)
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
@ -145,7 +145,7 @@ namespace Microsoft.EntityFrameworkCore
internal static IAsyncEnumerable<T> AsAsyncEnumerable<T>(
this IQueryable<T> source, CancellationToken cancellationToken = default)
{
if (source == null)
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}

6
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreApplicationStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore
public IOpenIddictApplicationStore<TApplication> Get<TApplication>() where TApplication : class
{
var store = _provider.GetService<IOpenIddictApplicationStore<TApplication>>();
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));
}

6
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreAuthorizationStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore
public IOpenIddictAuthorizationStore<TAuthorization> Get<TAuthorization>() where TAuthorization : class
{
var store = _provider.GetService<IOpenIddictAuthorizationStore<TAuthorization>>();
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));
}

6
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreScopeStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore
public IOpenIddictScopeStore<TScope> Get<TScope>() where TScope : class
{
var store = _provider.GetService<IOpenIddictScopeStore<TScope>>();
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));
}

6
src/OpenIddict.EntityFrameworkCore/Resolvers/OpenIddictEntityFrameworkCoreTokenStoreResolver.cs

@ -43,7 +43,7 @@ namespace OpenIddict.EntityFrameworkCore
public IOpenIddictTokenStore<TToken> Get<TToken>() where TToken : class
{
var store = _provider.GetService<IOpenIddictTokenStore<TToken>>();
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));
}

62
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs

@ -138,7 +138,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -149,7 +149,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -377,7 +377,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientIdAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -388,7 +388,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientSecretAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -399,7 +399,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -410,7 +410,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -421,7 +421,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -432,7 +432,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -460,7 +460,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -471,7 +471,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -498,7 +498,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -525,7 +525,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -552,7 +552,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -579,7 +579,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -652,7 +652,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray<string> 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<string> 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<string, JsonElement> 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<string> addresses, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -855,7 +855,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask SetRequirementsAsync(TApplication application, ImmutableArray<string> requirements, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -879,7 +879,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}

54
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs

@ -128,7 +128,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -139,7 +139,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -480,7 +480,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -491,7 +491,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -502,7 +502,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -529,7 +529,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -556,7 +556,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -567,7 +567,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -578,7 +578,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> 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<string, JsonElement> 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<string> 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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}

48
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -108,7 +108,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -119,7 +119,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -247,7 +247,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetDescriptionAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -258,7 +258,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -286,7 +286,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -297,7 +297,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -325,7 +325,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -336,7 +336,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -347,7 +347,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -374,7 +374,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -447,7 +447,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
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<CultureInfo, string> 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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray<string> resources, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -613,7 +613,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}

74
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs

@ -128,7 +128,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -139,7 +139,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -406,13 +406,13 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual async ValueTask<string?> 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
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -445,7 +445,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -456,7 +456,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -467,7 +467,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -478,7 +478,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -505,7 +505,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -516,7 +516,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -527,7 +527,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -538,7 +538,7 @@ namespace OpenIddict.EntityFrameworkCore
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}

4
src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs

@ -40,7 +40,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictMongoDbBuilder"/>.</returns>
public OpenIddictMongoDbBuilder Configure(Action<OpenIddictMongoDbOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -166,7 +166,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictMongoDbBuilder"/>.</returns>
public OpenIddictMongoDbBuilder UseDatabase(IMongoDatabase database)
{
if (database == null)
if (database is null)
{
throw new ArgumentNullException(nameof(database));
}

4
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<IMongoDatabase>();
}
if (database == null)
if (database is null)
{
return new ValueTask<IMongoDatabase>(Task.FromException<IMongoDatabase>(
new InvalidOperationException(SR.GetResourceString(SR.ID1261))));

6
src/OpenIddict.MongoDb/OpenIddictMongoDbExtensions.cs

@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictMongoDbBuilder"/>.</returns>
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<OpenIddictMongoDbBuilder> 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));
}

4
src/OpenIddict.MongoDb/OpenIddictMongoDbHelpers.cs

@ -26,7 +26,7 @@ namespace MongoDB.Driver
/// <returns>The streamed async enumeration containing the results.</returns>
internal static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IAsyncCursorSource<T> source, CancellationToken cancellationToken)
{
if (source == null)
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
@ -56,7 +56,7 @@ namespace MongoDB.Driver
/// <returns>The streamed async enumeration containing the results.</returns>
internal static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IQueryable<T> source, CancellationToken cancellationToken)
{
if (source == null)
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs

@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb
public IOpenIddictApplicationStore<TApplication> Get<TApplication>() where TApplication : class
{
var store = _provider.GetService<IOpenIddictApplicationStore<TApplication>>();
if (store != null)
if (store is not null)
{
return store;
}

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs

@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb
public IOpenIddictAuthorizationStore<TAuthorization> Get<TAuthorization>() where TAuthorization : class
{
var store = _provider.GetService<IOpenIddictAuthorizationStore<TAuthorization>>();
if (store != null)
if (store is not null)
{
return store;
}

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs

@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb
public IOpenIddictScopeStore<TScope> Get<TScope>() where TScope : class
{
var store = _provider.GetService<IOpenIddictScopeStore<TScope>>();
if (store != null)
if (store is not null)
{
return store;
}

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs

@ -33,7 +33,7 @@ namespace OpenIddict.MongoDb
public IOpenIddictTokenStore<TToken> Get<TToken>() where TToken : class
{
var store = _provider.GetService<IOpenIddictTokenStore<TToken>>();
if (store != null)
if (store is not null)
{
return store;
}

72
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs

@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -210,7 +210,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientIdAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -221,7 +221,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientSecretAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -232,7 +232,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetClientTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -243,7 +243,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -254,7 +254,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -265,12 +265,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>>(ImmutableDictionary.Create<CultureInfo, string>());
}
@ -281,7 +281,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> 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<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -310,12 +310,12 @@ namespace OpenIddict.MongoDb
public virtual ValueTask<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -326,12 +326,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> 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<string, JsonElement>>(ImmutableDictionary.Create<string, JsonElement>());
}
@ -344,12 +344,12 @@ namespace OpenIddict.MongoDb
public virtual ValueTask<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -360,12 +360,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -418,7 +418,7 @@ namespace OpenIddict.MongoDb
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> 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<CultureInfo, string> names, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -524,7 +524,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask SetPermissionsAsync(TApplication application, ImmutableArray<string> 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<string> 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<string, JsonElement> 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<string> 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<string> requirements, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}
@ -632,7 +632,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
if (application is null)
{
throw new ArgumentNullException(nameof(application));
}

50
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs

@ -61,7 +61,7 @@ namespace OpenIddict.MongoDb
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -75,7 +75,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -364,7 +364,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -375,7 +375,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -386,12 +386,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> 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<string, JsonElement>>(ImmutableDictionary.Create<string, JsonElement>());
}
@ -403,12 +403,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -419,7 +419,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -430,7 +430,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -441,7 +441,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TAuthorization>, TState, IQueryable<TResult>> 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<string, JsonElement> 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<string> scopes, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}
@ -648,7 +648,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
if (authorization is null)
{
throw new ArgumentNullException(nameof(authorization));
}

52
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs

@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -199,7 +199,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetDescriptionAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -210,12 +210,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>>(ImmutableDictionary.Create<CultureInfo, string>());
}
@ -226,7 +226,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -237,12 +237,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<CultureInfo, string>> 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<CultureInfo, string>>(ImmutableDictionary.Create<CultureInfo, string>());
}
@ -253,7 +253,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -264,7 +264,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetNameAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -275,12 +275,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> 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<string, JsonElement>>(ImmutableDictionary.Create<string, JsonElement>());
}
@ -292,12 +292,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableArray<string>> 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<string>>(ImmutableArray.Create<string>());
}
@ -350,7 +350,7 @@ namespace OpenIddict.MongoDb
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -372,7 +372,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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<CultureInfo, string> 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<CultureInfo, string> names, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -413,7 +413,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
public virtual ValueTask SetResourcesAsync(TScope scope, ImmutableArray<string> resources, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}
@ -484,7 +484,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
if (scope is null)
{
throw new ArgumentNullException(nameof(scope));
}

60
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs

@ -62,7 +62,7 @@ namespace OpenIddict.MongoDb
public virtual async ValueTask<long> CountAsync<TResult>(
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -76,7 +76,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken)
{
if (query == null)
if (query is null)
{
throw new ArgumentNullException(nameof(query));
}
@ -347,7 +347,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -363,7 +363,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -374,7 +374,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -385,7 +385,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -396,7 +396,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -407,12 +407,12 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> 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<string, JsonElement>>(ImmutableDictionary.Create<string, JsonElement>());
}
@ -424,7 +424,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -435,7 +435,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -446,7 +446,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}
@ -457,7 +457,7 @@ namespace OpenIddict.MongoDb
/// <inheritdoc/>
public virtual ValueTask<string?> 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<IQueryable<TToken>, TState, IQueryable<TResult>> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<string, JsonElement> 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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
if (token is null)
{
throw new ArgumentNullException(nameof(token));
}

6
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs

@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerAspNetCoreBuilder"/>.</returns>
public OpenIddictServerAspNetCoreBuilder Configure(Action<OpenIddictServerAspNetCoreOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -172,7 +172,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerAspNetCoreBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerAspNetCoreBuilder"/>.</returns>
public OpenIddictServerAspNetCoreBuilder SetLogoutEndpointCachingPolicy(DistributedCacheEntryOptions policy)
{
if (policy == null)
if (policy is null)
{
throw new ArgumentNullException(nameof(policy));
}

8
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreConfiguration.cs

@ -26,7 +26,7 @@ namespace OpenIddict.Server.AspNetCore
/// <param name="options">The options instance to initialize.</param>
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
/// <param name="options">The options instance to initialize.</param>
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
/// <param name="options">The options instance to initialize.</param>
public void PostConfigure(string name, OpenIddictServerAspNetCoreOptions options)
{
if (options == null)
if (options is null)
{
throw new ArgumentNullException(nameof(options));
}

6
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreExtensions.cs

@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerAspNetCoreBuilder"/>.</returns>
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<OpenIddictServerAspNetCoreBuilder> 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));
}

8
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<OpenIddictServerAspNetCoreFeature>()?.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<ProcessAuthenticationContext>(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
/// <inheritdoc/>
public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties? properties)
{
if (user == null)
if (user is null)
{
throw new ArgumentNullException(nameof(user));
}

24
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlerFilters.cs

@ -31,7 +31,7 @@ namespace OpenIddict.Server.AspNetCore
public ValueTask<bool> 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<bool> 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<bool> 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<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
return new ValueTask<bool>(context.Transaction.GetHttpRequest() != null);
return new ValueTask<bool>(context.Transaction.GetHttpRequest() is not null);
}
}
@ -111,7 +111,7 @@ namespace OpenIddict.Server.AspNetCore
public ValueTask<bool> 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<bool> 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<bool> 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<bool> 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<bool> 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<bool> 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<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

32
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs

@ -90,12 +90,12 @@ namespace OpenIddict.Server.AspNetCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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))

20
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs

@ -87,12 +87,12 @@ namespace OpenIddict.Server.AspNetCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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))

102
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs

@ -87,7 +87,7 @@ namespace OpenIddict.Server.AspNetCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(ProcessChallengeContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
var properties = context.Transaction.GetProperty<AuthenticationProperties>(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
/// <inheritdoc/>
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<AuthenticationProperties>(typeof(AuthenticationProperties).FullName!);
if (properties == null)
if (properties is null)
{
return default;
}
@ -400,7 +400,7 @@ namespace OpenIddict.Server.AspNetCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<IStatusCodePagesFeature>();
if (feature == null || !feature.Enabled)
if (feature is null || !feature.Enabled)
{
return default;
}
@ -1221,7 +1221,7 @@ namespace OpenIddict.Server.AspNetCore
/// <inheritdoc/>
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
/// <inheritdoc/>
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<AuthenticationProperties>(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
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

8
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHelpers.cs

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore
/// <returns>The <see cref="HttpRequest"/> instance or <c>null</c> if it couldn't be found.</returns>
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
/// <returns>The <see cref="OpenIddictServerEndpointType"/>.</returns>
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
/// <returns>The <see cref="OpenIddictRequest"/> instance or <c>null</c> if it couldn't be found.</returns>
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
/// <returns>The <see cref="OpenIddictResponse"/> instance or <c>null</c> if it couldn't be found.</returns>
public static OpenIddictResponse? GetOpenIddictServerResponse(this HttpContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

6
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs

@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerDataProtectionBuilder"/>.</returns>
public OpenIddictServerDataProtectionBuilder Configure(Action<OpenIddictServerDataProtectionOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -56,7 +56,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerDataProtectionBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerDataProtectionBuilder"/>.</returns>
public OpenIddictServerDataProtectionBuilder UseFormatter(IOpenIddictServerDataProtectionFormatter formatter)
{
if (formatter == null)
if (formatter is null)
{
throw new ArgumentNullException(nameof(formatter));
}

4
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
/// <param name="options">The options instance to initialize.</param>
public void PostConfigure(string name, OpenIddictServerDataProtectionOptions options)
{
if (options == null)
if (options is null)
{
throw new ArgumentNullException(nameof(options));
}

6
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionExtensions.cs

@ -29,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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<OpenIddictServerDataProtectionBuilder> 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));
}

14
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));
}

10
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlerFilters.cs

@ -31,7 +31,7 @@ namespace OpenIddict.Server.DataProtection
public ValueTask<bool> 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<bool> 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<bool> 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<bool> 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<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

26
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs

@ -68,13 +68,13 @@ namespace OpenIddict.Server.DataProtection
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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));
}

6
src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs

@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerOwinBuilder"/>.</returns>
public OpenIddictServerOwinBuilder Configure(Action<OpenIddictServerOwinOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -161,7 +161,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerOwinBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerOwinBuilder"/>.</returns>
public OpenIddictServerOwinBuilder SetLogoutEndpointCachingPolicy(DistributedCacheEntryOptions policy)
{
if (policy == null)
if (policy is null)
{
throw new ArgumentNullException(nameof(policy));
}

4
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));
}

6
src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs

@ -28,7 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerOwinBuilder"/>.</returns>
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<OpenIddictServerOwinBuilder> 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));
}

14
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<OpenIddictServerTransaction>(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<AuthenticationTicket?> AuthenticateCoreAsync()
{
var transaction = Context.Get<OpenIddictServerTransaction>(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<ProcessAuthenticationContext>(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<OpenIddictServerTransaction>(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<OpenIddictServerTransaction>(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<OpenIddictServerTransaction>(typeof(OpenIddictServerTransaction).FullName) ??
throw new InvalidOperationException(SR.GetResourceString(SR.ID1111));

22
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs

@ -29,7 +29,7 @@ namespace OpenIddict.Server.Owin
public ValueTask<bool> 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<bool> 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<bool> 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<bool> 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<bool> 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<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
return new ValueTask<bool>(context.Transaction.GetOwinRequest() != null);
return new ValueTask<bool>(context.Transaction.GetOwinRequest() is not null);
}
}
@ -152,7 +152,7 @@ namespace OpenIddict.Server.Owin
public ValueTask<bool> 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<bool> 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<bool> 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<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

32
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs

@ -89,12 +89,12 @@ namespace OpenIddict.Server.Owin
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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))

20
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs

@ -86,12 +86,12 @@ namespace OpenIddict.Server.Owin
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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))

88
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs

@ -75,7 +75,7 @@ namespace OpenIddict.Server.Owin
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(ProcessChallengeContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
var properties = context.Transaction.GetProperty<AuthenticationProperties>(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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<AuthenticationProperties>(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
/// <inheritdoc/>
public ValueTask HandleAsync(TContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

10
src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs

@ -27,7 +27,7 @@ namespace Owin
/// <returns>The <see cref="IAppBuilder"/>.</returns>
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
/// <returns>The <see cref="IOwinRequest"/> instance or <c>null</c> if it couldn't be found.</returns>
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
/// <returns>The <see cref="OpenIddictServerEndpointType"/>.</returns>
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
/// <returns>The <see cref="OpenIddictRequest"/> instance or <c>null</c> if it couldn't be found.</returns>
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
/// <returns>The <see cref="OpenIddictResponse"/> instance or <c>null</c> if it couldn't be found.</returns>
public static OpenIddictResponse? GetOpenIddictServerResponse(this IOwinContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

4
src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs

@ -39,13 +39,13 @@ namespace OpenIddict.Server.Owin
/// </returns>
public override Task Invoke(IOwinContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
var provider = context.Get<IServiceProvider>(typeof(IServiceProvider).FullName);
if (provider == null)
if (provider is null)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID1120));
}

2
src/OpenIddict.Server.Quartz/OpenIddictServerQuartzBuilder.cs

@ -38,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerQuartzBuilder"/>.</returns>
public OpenIddictServerQuartzBuilder Configure(Action<OpenIddictServerQuartzOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}

6
src/OpenIddict.Server.Quartz/OpenIddictServerQuartzExtensions.cs

@ -26,7 +26,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerQuartzBuilder"/>.</returns>
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<OpenIddictServerQuartzBuilder> 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));
}

8
src/OpenIddict.Server.Quartz/OpenIddictServerQuartzJob.cs

@ -50,7 +50,7 @@ namespace OpenIddict.Server.Quartz
/// <inheritdoc/>
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<IOpenIddictTokenManager>();
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<IOpenIddictAuthorizationManager>();
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))
{

98
src/OpenIddict.Server/OpenIddictServerBuilder.cs

@ -50,7 +50,7 @@ namespace Microsoft.Extensions.DependencyInjection
Action<OpenIddictServerHandlerDescriptor.Builder<TContext>> 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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
public OpenIddictServerBuilder Configure(Action<OpenIddictServerOptions> configuration)
{
if (configuration == null)
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}
@ -146,7 +146,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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<X509Certificate2>()
.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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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<X509Certificate2>()
.SingleOrDefault();
if (certificate == null)
if (certificate is null)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID1065));
}
@ -560,7 +560,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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<X509Certificate2>()
.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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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<X509Certificate2>()
.SingleOrDefault();
if (certificate == null)
if (certificate is null)
{
throw new InvalidOperationException(SR.GetResourceString(SR.ID1065));
}
@ -1085,7 +1085,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
public OpenIddictServerBuilder SetIssuer(Uri address)
{
if (address == null)
if (address is null)
{
throw new ArgumentNullException(nameof(address));
}

26
src/OpenIddict.Server/OpenIddictServerConfiguration.cs

@ -29,7 +29,7 @@ namespace OpenIddict.Server
/// <param name="options">The options instance to initialize.</param>
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);

6
src/OpenIddict.Server/OpenIddictServerDispatcher.cs

@ -35,7 +35,7 @@ namespace OpenIddict.Server
public async ValueTask DispatchAsync<TContext>(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<TContext> :
_provider.GetService(descriptor.ServiceDescriptor.ServiceType) as IOpenIddictServerHandler<TContext>;
if (handler == null)
if (handler is null)
{
throw new InvalidOperationException(SR.FormatID1097(descriptor.ServiceDescriptor.ServiceType));
}

6
src/OpenIddict.Server/OpenIddictServerExtensions.cs

@ -31,7 +31,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <returns>The <see cref="OpenIddictServerBuilder"/>.</returns>
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
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
public static OpenIddictBuilder AddServer(this OpenIddictBuilder builder, Action<OpenIddictServerBuilder> 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));
}

8
src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs

@ -79,7 +79,7 @@ namespace OpenIddict.Server
/// <returns>The builder instance, so that calls can be easily chained.</returns>
public Builder<TContext> AddFilter(Type type)
{
if (type == null)
if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
@ -110,7 +110,7 @@ namespace OpenIddict.Server
/// <returns>The builder instance, so that calls can be easily chained.</returns>
public Builder<TContext> SetServiceDescriptor(ServiceDescriptor descriptor)
{
if (descriptor == null)
if (descriptor is null)
{
throw new ArgumentNullException(nameof(descriptor));
}
@ -162,7 +162,7 @@ namespace OpenIddict.Server
/// <returns>The builder instance, so that calls can be easily chained.</returns>
public Builder<TContext> UseInlineHandler(Func<TContext, ValueTask> handler)
{
if (handler == null)
if (handler is null)
{
throw new ArgumentNullException(nameof(handler));
}
@ -199,7 +199,7 @@ namespace OpenIddict.Server
public Builder<TContext> UseSingletonHandler<THandler>(THandler handler)
where THandler : IOpenIddictServerHandler<TContext>
{
if (handler == null)
if (handler is null)
{
throw new ArgumentNullException(nameof(handler));
}

60
src/OpenIddict.Server/OpenIddictServerHandlerFilters.cs

@ -21,7 +21,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -37,7 +37,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -53,7 +53,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -69,7 +69,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -85,7 +85,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -101,7 +101,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -117,7 +117,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -133,7 +133,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -149,7 +149,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -165,7 +165,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -181,7 +181,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -197,7 +197,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -213,7 +213,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -229,7 +229,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -245,7 +245,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -261,7 +261,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -277,7 +277,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -293,7 +293,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -309,7 +309,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -325,7 +325,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -341,7 +341,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -357,7 +357,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -373,7 +373,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -389,7 +389,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -405,7 +405,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -421,7 +421,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -437,7 +437,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -453,7 +453,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(ProcessSignInContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -469,7 +469,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -485,7 +485,7 @@ namespace OpenIddict.Server
{
public ValueTask<bool> IsActiveAsync(BaseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

76
src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs

@ -88,7 +88,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -386,7 +386,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -425,7 +425,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -465,7 +465,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -546,7 +546,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -599,7 +599,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -679,7 +679,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -728,7 +728,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -776,7 +776,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -817,7 +817,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateAuthorizationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -923,7 +923,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(ApplyAuthorizationResponseContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

52
src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs

@ -86,7 +86,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(ValidateDeviceRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -391,7 +391,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public async ValueTask HandleAsync(HandleVerificationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}

74
src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs

@ -90,7 +90,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -457,7 +457,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -486,7 +486,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -516,24 +516,24 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -591,7 +591,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -620,7 +620,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -649,7 +649,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -678,7 +678,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -744,7 +744,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
public ValueTask HandleAsync(HandleConfigurationRequestContext context)
{
if (context == null)
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
@ -783,7 +783,7 @@ namespace OpenIddict.Server
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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));
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save