Browse Source

Enable additional Meziantou.Analyzer analyzers

pull/2524/head
Kévin Chalet 2 months ago
parent
commit
9780dd2e6b
  1. 51
      .editorconfig
  2. 2
      gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
  3. 2
      sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/BundleConfig.cs
  4. 2
      sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/FilterConfig.cs
  5. 2
      sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/RouteConfig.cs
  6. 2
      sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/BundleConfig.cs
  7. 2
      sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/FilterConfig.cs
  8. 2
      sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/IdentityConfig.cs
  9. 2
      sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/RouteConfig.cs
  10. 22
      sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AccountController.cs
  11. 2
      sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs
  12. 50
      sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/ManageController.cs
  13. 30
      sandbox/OpenIddict.Sandbox.AspNet.Server/Helpers/AsyncEnumerableExtensions.cs
  14. 2
      sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs
  15. 18
      sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/ManageController.cs
  16. 2
      sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs
  17. 2
      sandbox/OpenIddict.Sandbox.Console.Client/Models/ApplicationDbContext.cs
  18. 2
      sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs
  19. 2
      sandbox/OpenIddict.Sandbox.WinForms.Client/Models/ApplicationDbContext.cs
  20. 2
      sandbox/OpenIddict.Sandbox.Wpf.Client/Models/ApplicationDbContext.cs
  21. 42
      shared/OpenIddict.Extensions/OpenIddictHelpers.cs
  22. 3
      src/OpenIddict.Abstractions/OpenIddictBuilder.cs
  23. 8
      src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs
  24. 3
      src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreBuilder.cs
  25. 3
      src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionBuilder.cs
  26. 2
      src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionFormatter.cs
  27. 3
      src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs
  28. 3
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationBuilder.cs
  29. 11
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs
  30. 11
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs
  31. 20
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs
  32. 10
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs
  33. 3
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs
  34. 3
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationBuilder.cs
  35. 2
      src/OpenIddict.Client/OpenIddictClientBuilder.cs
  36. 6
      src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs
  37. 12
      src/OpenIddict.Client/OpenIddictClientHandlers.cs
  38. 9
      src/OpenIddict.Client/OpenIddictClientService.cs
  39. 8
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  40. 10
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  41. 6
      src/OpenIddict.Core/Managers/OpenIddictResourceManager.cs
  42. 8
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  43. 14
      src/OpenIddict.Core/Managers/OpenIddictSessionManager.cs
  44. 12
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  45. 2
      src/OpenIddict.Core/OpenIddictCoreBuilder.cs
  46. 2
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs
  47. 2
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs
  48. 8
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  49. 4
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  50. 4
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkResourceStore.cs
  51. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  52. 4
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkSessionStore.cs
  53. 4
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs
  54. 2
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs
  55. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  56. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  57. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs
  58. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  59. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreSessionStore.cs
  60. 4
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs
  61. 2
      src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs
  62. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs
  63. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs
  64. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbResourceStore.cs
  65. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs
  66. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbSessionStore.cs
  67. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs
  68. 3
      src/OpenIddict.Quartz/OpenIddictQuartzBuilder.cs
  69. 3
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreBuilder.cs
  70. 3
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionBuilder.cs
  71. 2
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
  72. 3
      src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs
  73. 2
      src/OpenIddict.Server/OpenIddictServerBuilder.cs
  74. 4
      src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs
  75. 4
      src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
  76. 15
      src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
  77. 18
      src/OpenIddict.Server/OpenIddictServerHandlers.cs
  78. 3
      src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs
  79. 3
      src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs
  80. 2
      src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs
  81. 3
      src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs
  82. 3
      src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs
  83. 3
      src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs
  84. 2
      src/OpenIddict.Validation/OpenIddictValidationBuilder.cs
  85. 2
      src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs
  86. 2
      src/OpenIddict.Validation/OpenIddictValidationHandlers.cs
  87. 4
      test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs
  88. 6
      test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
  89. 6
      test/OpenIddict.Client.Tests/OpenIddictClientBuilderTests.cs
  90. 2
      test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs
  91. 60
      test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs
  92. 2
      test/OpenIddict.Core.Tests/OpenIddictCoreConfigurationTests.cs
  93. 2
      test/OpenIddict.Core.Tests/OpenIddictCoreOptionsTests.cs
  94. 14
      test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs
  95. 20
      test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs
  96. 14
      test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs
  97. 20
      test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
  98. 12
      test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs
  99. 22
      test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs
  100. 6
      test/OpenIddict.Quartz.Tests/OpenIddictQuartzExtensionsTests.cs

51
.editorconfig

@ -105,12 +105,63 @@ dotnet_diagnostic.MA0003.severity = none
dotnet_diagnostic.MA0004.severity = none dotnet_diagnostic.MA0004.severity = none
dotnet_diagnostic.MA0007.severity = none dotnet_diagnostic.MA0007.severity = none
dotnet_diagnostic.MA0016.severity = none dotnet_diagnostic.MA0016.severity = none
dotnet_diagnostic.MA0018.severity = none
dotnet_diagnostic.MA0029.severity = none dotnet_diagnostic.MA0029.severity = none
dotnet_diagnostic.MA0036.severity = warning
dotnet_diagnostic.MA0043.severity = warning
dotnet_diagnostic.MA0048.severity = none dotnet_diagnostic.MA0048.severity = none
dotnet_diagnostic.MA0050.severity = warning
dotnet_diagnostic.MA0051.severity = none dotnet_diagnostic.MA0051.severity = none
dotnet_diagnostic.MA0052.severity = warning
dotnet_diagnostic.MA0053.severity = warning
dotnet_diagnostic.MA0056.severity = none dotnet_diagnostic.MA0056.severity = none
dotnet_diagnostic.MA0057.severity = warning
dotnet_diagnostic.MA0058.severity = warning
dotnet_diagnostic.MA0059.severity = warning
dotnet_diagnostic.MA0067.severity = warning
dotnet_diagnostic.MA0071.severity = warning
dotnet_diagnostic.MA0073.severity = warning
dotnet_diagnostic.MA0075.severity = warning
dotnet_diagnostic.MA0076.severity = warning
dotnet_diagnostic.MA0079.severity = warning
dotnet_diagnostic.MA0080.severity = warning
dotnet_diagnostic.MA0084.severity = none dotnet_diagnostic.MA0084.severity = none
dotnet_diagnostic.MA0089.severity = warning
dotnet_diagnostic.MA0090.severity = warning
dotnet_diagnostic.MA0098.severity = warning
dotnet_diagnostic.MA0098.severity = warning
dotnet_diagnostic.MA0100.severity = none dotnet_diagnostic.MA0100.severity = none
dotnet_diagnostic.MA0102.severity = none
dotnet_diagnostic.MA0104.severity = warning
dotnet_diagnostic.MA0105.severity = warning
dotnet_diagnostic.MA0106.severity = warning
dotnet_diagnostic.MA0107.severity = warning
dotnet_diagnostic.MA0109.severity = none
dotnet_diagnostic.MA0111.severity = warning
dotnet_diagnostic.MA0113.severity = warning
dotnet_diagnostic.MA0114.severity = warning
dotnet_diagnostic.MA0121.severity = warning
dotnet_diagnostic.MA0128.severity = warning
dotnet_diagnostic.MA0133.severity = warning
dotnet_diagnostic.MA0140.severity = warning
dotnet_diagnostic.MA0141.severity = warning
dotnet_diagnostic.MA0142.severity = warning
dotnet_diagnostic.MA0148.severity = warning
dotnet_diagnostic.MA0149.severity = warning
dotnet_diagnostic.MA0152.severity = warning
dotnet_diagnostic.MA0156.severity = warning
dotnet_diagnostic.MA0161.severity = warning
dotnet_diagnostic.MA0162.severity = warning
dotnet_diagnostic.MA0167.severity = warning
dotnet_diagnostic.MA0168.severity = warning
dotnet_diagnostic.MA0170.severity = warning
dotnet_diagnostic.MA0171.severity = warning
dotnet_diagnostic.MA0172.severity = warning
dotnet_diagnostic.MA0174.severity = warning
dotnet_diagnostic.MA0186.severity = warning
dotnet_diagnostic.MA0187.severity = warning
dotnet_diagnostic.MA0209.severity = warning
dotnet_diagnostic.MA0210.severity = warning
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface

2
gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs

@ -741,7 +741,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/BundleConfig.cs

@ -2,7 +2,7 @@
namespace OpenIddict.Sandbox.AspNet.Client; namespace OpenIddict.Sandbox.AspNet.Client;
public class BundleConfig public static class BundleConfig
{ {
// Pour plus d'informations sur le regroupement, visitez https://go.microsoft.com/fwlink/?LinkId=301862 // Pour plus d'informations sur le regroupement, visitez https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles) public static void RegisterBundles(BundleCollection bundles)

2
sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/FilterConfig.cs

@ -2,7 +2,7 @@
namespace OpenIddict.Sandbox.AspNet.Client; namespace OpenIddict.Sandbox.AspNet.Client;
public class FilterConfig public static class FilterConfig
{ {
public static void RegisterGlobalFilters(GlobalFilterCollection filters) public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{ {

2
sandbox/OpenIddict.Sandbox.AspNet.Client/App_Start/RouteConfig.cs

@ -3,7 +3,7 @@ using System.Web.Routing;
namespace OpenIddict.Sandbox.AspNet.Client; namespace OpenIddict.Sandbox.AspNet.Client;
public class RouteConfig public static class RouteConfig
{ {
public static void RegisterRoutes(RouteCollection routes) public static void RegisterRoutes(RouteCollection routes)
{ {

2
sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/BundleConfig.cs

@ -2,7 +2,7 @@
namespace OpenIddict.Sandbox.AspNet.Server; namespace OpenIddict.Sandbox.AspNet.Server;
public class BundleConfig public static class BundleConfig
{ {
// Pour plus d'informations sur le regroupement, visitez https://go.microsoft.com/fwlink/?LinkId=301862 // Pour plus d'informations sur le regroupement, visitez https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles) public static void RegisterBundles(BundleCollection bundles)

2
sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/FilterConfig.cs

@ -2,7 +2,7 @@
namespace OpenIddict.Sandbox.AspNet.Server; namespace OpenIddict.Sandbox.AspNet.Server;
public class FilterConfig public static class FilterConfig
{ {
public static void RegisterGlobalFilters(GlobalFilterCollection filters) public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{ {

2
sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/IdentityConfig.cs

@ -66,7 +66,7 @@ public class ApplicationUserManager : UserManager<ApplicationUser>
manager.EmailService = new EmailService(); manager.EmailService = new EmailService();
manager.SmsService = new SmsService(); manager.SmsService = new SmsService();
var dataProtectionProvider = options.DataProtectionProvider; var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null) if (dataProtectionProvider is not null)
{ {
manager.UserTokenProvider = manager.UserTokenProvider =
new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity")); new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));

2
sandbox/OpenIddict.Sandbox.AspNet.Server/App_Start/RouteConfig.cs

@ -3,7 +3,7 @@ using System.Web.Routing;
namespace OpenIddict.Sandbox.AspNet.Server; namespace OpenIddict.Sandbox.AspNet.Server;
public class RouteConfig public static class RouteConfig
{ {
public static void RegisterRoutes(RouteCollection routes) public static void RegisterRoutes(RouteCollection routes)
{ {

22
sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AccountController.cs

@ -174,7 +174,7 @@ public class AccountController : Controller
[AllowAnonymous] [AllowAnonymous]
public async Task<ActionResult> ConfirmEmail(string userId, string code) public async Task<ActionResult> ConfirmEmail(string userId, string code)
{ {
if (userId == null || code == null) if (userId is null || code is null)
{ {
return View("Error"); return View("Error");
} }
@ -200,7 +200,7 @@ public class AccountController : Controller
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var user = await UserManager.FindByNameAsync(model.Email); var user = await UserManager.FindByNameAsync(model.Email);
if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) if (user is null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
{ {
// Ne révélez pas que l'utilisateur n'existe pas ou qu'il n'est pas confirmé // Ne révélez pas que l'utilisateur n'existe pas ou qu'il n'est pas confirmé
return View("ForgotPasswordConfirmation"); return View("ForgotPasswordConfirmation");
@ -231,7 +231,7 @@ public class AccountController : Controller
[AllowAnonymous] [AllowAnonymous]
public ActionResult ResetPassword(string code) public ActionResult ResetPassword(string code)
{ {
return code == null ? View("Error") : View(); return code is null ? View("Error") : View();
} }
// //
@ -246,7 +246,7 @@ public class AccountController : Controller
return View(model); return View(model);
} }
var user = await UserManager.FindByNameAsync(model.Email); var user = await UserManager.FindByNameAsync(model.Email);
if (user == null) if (user is null)
{ {
// Ne révélez pas que l'utilisateur n'existe pas // Ne révélez pas que l'utilisateur n'existe pas
return RedirectToAction("ResetPasswordConfirmation", "Account"); return RedirectToAction("ResetPasswordConfirmation", "Account");
@ -285,7 +285,7 @@ public class AccountController : Controller
public async Task<ActionResult> SendCode(string returnUrl, bool rememberMe) public async Task<ActionResult> SendCode(string returnUrl, bool rememberMe)
{ {
var userId = await SignInManager.GetVerifiedUserIdAsync(); var userId = await SignInManager.GetVerifiedUserIdAsync();
if (userId == null) if (userId is null)
{ {
return View("Error"); return View("Error");
} }
@ -320,7 +320,7 @@ public class AccountController : Controller
public async Task<ActionResult> ExternalLoginCallback(string returnUrl) public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{ {
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null) if (loginInfo is null)
{ {
return RedirectToAction("Login"); return RedirectToAction("Login");
} }
@ -360,7 +360,7 @@ public class AccountController : Controller
{ {
// Obtenir des informations sur l'utilisateur à partir du fournisseur de connexion externe // Obtenir des informations sur l'utilisateur à partir du fournisseur de connexion externe
var info = await AuthenticationManager.GetExternalLoginInfoAsync(); var info = await AuthenticationManager.GetExternalLoginInfoAsync();
if (info == null) if (info is null)
{ {
return View("ExternalLoginFailure"); return View("ExternalLoginFailure");
} }
@ -404,13 +404,13 @@ public class AccountController : Controller
{ {
if (disposing) if (disposing)
{ {
if (_userManager != null) if (_userManager is not null)
{ {
_userManager.Dispose(); _userManager.Dispose();
_userManager = null; _userManager = null;
} }
if (_signInManager != null) if (_signInManager is not null)
{ {
_signInManager.Dispose(); _signInManager.Dispose();
_signInManager = null; _signInManager = null;
@ -449,7 +449,7 @@ public class AccountController : Controller
return RedirectToAction("Index", "Home"); return RedirectToAction("Index", "Home");
} }
internal class ChallengeResult : HttpUnauthorizedResult internal sealed class ChallengeResult : HttpUnauthorizedResult
{ {
public ChallengeResult(string provider, string redirectUri) public ChallengeResult(string provider, string redirectUri)
: this(provider, redirectUri, null) : this(provider, redirectUri, null)
@ -470,7 +470,7 @@ public class AccountController : Controller
public override void ExecuteResult(ControllerContext context) public override void ExecuteResult(ControllerContext context)
{ {
var properties = new AuthenticationProperties { RedirectUri = RedirectUri }; var properties = new AuthenticationProperties { RedirectUri = RedirectUri };
if (UserId != null) if (UserId is not null)
{ {
properties.Dictionary[XsrfKey] = UserId; properties.Dictionary[XsrfKey] = UserId;
} }

2
sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs

@ -421,7 +421,7 @@ public class AuthorizationController : Controller
// Retrieve the user profile corresponding to the authorization code/refresh token. // Retrieve the user profile corresponding to the authorization code/refresh token.
var user = await context.GetUserManager<ApplicationUserManager>().FindByIdAsync(result.Identity.GetClaim(Claims.Subject)); var user = await context.GetUserManager<ApplicationUserManager>().FindByIdAsync(result.Identity.GetClaim(Claims.Subject));
if (user == null) if (user is null)
{ {
context.Authentication.Challenge( context.Authentication.Challenge(
authenticationTypes: OpenIddictServerOwinDefaults.AuthenticationType, authenticationTypes: OpenIddictServerOwinDefaults.AuthenticationType,

50
sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/ManageController.cs

@ -54,12 +54,12 @@ public class ManageController : Controller
public async Task<ActionResult> Index(ManageMessageId? message) public async Task<ActionResult> Index(ManageMessageId? message)
{ {
ViewBag.StatusMessage = ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess ? "Votre mot de passe a été changé." message is ManageMessageId.ChangePasswordSuccess ? "Votre mot de passe a été changé."
: message == ManageMessageId.SetPasswordSuccess ? "Votre mot de passe a été défini." : message is ManageMessageId.SetPasswordSuccess ? "Votre mot de passe a été défini."
: message == ManageMessageId.SetTwoFactorSuccess ? "Votre fournisseur d'authentification à 2 facteurs a été défini." : message is ManageMessageId.SetTwoFactorSuccess ? "Votre fournisseur d'authentification à 2 facteurs a été défini."
: message == ManageMessageId.Error ? "Une erreur s'est produite." : message is ManageMessageId.Error ? "Une erreur s'est produite."
: message == ManageMessageId.AddPhoneSuccess ? "Votre numéro de téléphone a été ajouté." : message is ManageMessageId.AddPhoneSuccess ? "Votre numéro de téléphone a été ajouté."
: message == ManageMessageId.RemovePhoneSuccess ? "Votre numéro de téléphone a été supprimé." : message is ManageMessageId.RemovePhoneSuccess ? "Votre numéro de téléphone a été supprimé."
: ""; : "";
var userId = User.Identity.GetUserId(); var userId = User.Identity.GetUserId();
@ -85,7 +85,7 @@ public class ManageController : Controller
if (result.Succeeded) if (result.Succeeded)
{ {
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -117,7 +117,7 @@ public class ManageController : Controller
} }
// Générer le jeton et l'envoyer // Générer le jeton et l'envoyer
var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number); var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number);
if (UserManager.SmsService != null) if (UserManager.SmsService is not null)
{ {
var message = new IdentityMessage var message = new IdentityMessage
{ {
@ -137,7 +137,7 @@ public class ManageController : Controller
{ {
await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), true); await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), true);
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -152,7 +152,7 @@ public class ManageController : Controller
{ {
await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), false); await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), false);
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -165,7 +165,7 @@ public class ManageController : Controller
{ {
var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), phoneNumber); var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), phoneNumber);
// Envoyer un SMS via le fournisseur SMS afin de vérifier le numéro de téléphone // Envoyer un SMS via le fournisseur SMS afin de vérifier le numéro de téléphone
return phoneNumber == null ? View("Error") : View(new VerifyPhoneNumberViewModel { PhoneNumber = phoneNumber }); return phoneNumber is null ? View("Error") : View(new VerifyPhoneNumberViewModel { PhoneNumber = phoneNumber });
} }
// //
@ -182,7 +182,7 @@ public class ManageController : Controller
if (result.Succeeded) if (result.Succeeded)
{ {
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -205,7 +205,7 @@ public class ManageController : Controller
return RedirectToAction("Index", new { Message = ManageMessageId.Error }); return RedirectToAction("Index", new { Message = ManageMessageId.Error });
} }
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -233,7 +233,7 @@ public class ManageController : Controller
if (result.Succeeded) if (result.Succeeded)
{ {
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -262,7 +262,7 @@ public class ManageController : Controller
if (result.Succeeded) if (result.Succeeded)
{ {
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
} }
@ -280,17 +280,17 @@ public class ManageController : Controller
public async Task<ActionResult> ManageLogins(ManageMessageId? message) public async Task<ActionResult> ManageLogins(ManageMessageId? message)
{ {
ViewBag.StatusMessage = ViewBag.StatusMessage =
message == ManageMessageId.RemoveLoginSuccess ? "La connexion externe a été supprimée." message is ManageMessageId.RemoveLoginSuccess ? "La connexion externe a été supprimée."
: message == ManageMessageId.Error ? "Une erreur s'est produite." : message is ManageMessageId.Error ? "Une erreur s'est produite."
: ""; : "";
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
if (user == null) if (user is null)
{ {
return View("Error"); return View("Error");
} }
var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()); var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId());
var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => !string.Equals(auth.AuthenticationType, ul.LoginProvider, System.StringComparison.Ordinal))).ToList(); var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => !string.Equals(auth.AuthenticationType, ul.LoginProvider, System.StringComparison.Ordinal))).ToList();
ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1; ViewBag.ShowRemoveButton = user.PasswordHash is not null || userLogins.Count > 1;
return View(new ManageLoginsViewModel return View(new ManageLoginsViewModel
{ {
CurrentLogins = userLogins, CurrentLogins = userLogins,
@ -313,7 +313,7 @@ public class ManageController : Controller
public async Task<ActionResult> LinkLoginCallback() public async Task<ActionResult> LinkLoginCallback()
{ {
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId()); var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId());
if (loginInfo == null) if (loginInfo is null)
{ {
return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error }); return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error });
} }
@ -323,7 +323,7 @@ public class ManageController : Controller
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && _userManager != null) if (disposing && _userManager is not null)
{ {
_userManager.Dispose(); _userManager.Dispose();
_userManager = null; _userManager = null;
@ -355,9 +355,9 @@ public class ManageController : Controller
private bool HasPassword() private bool HasPassword()
{ {
var user = UserManager.FindById(User.Identity.GetUserId()); var user = UserManager.FindById(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
return user.PasswordHash != null; return user.PasswordHash is not null;
} }
return false; return false;
} }
@ -365,9 +365,9 @@ public class ManageController : Controller
private bool HasPhoneNumber() private bool HasPhoneNumber()
{ {
var user = UserManager.FindById(User.Identity.GetUserId()); var user = UserManager.FindById(User.Identity.GetUserId());
if (user != null) if (user is not null)
{ {
return user.PhoneNumber != null; return user.PhoneNumber is not null;
} }
return false; return false;
} }

30
sandbox/OpenIddict.Sandbox.AspNet.Server/Helpers/AsyncEnumerableExtensions.cs

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace OpenIddict.Sandbox.AspNet.Server.Helpers;
public static class AsyncEnumerableExtensions
{
public static Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
return ExecuteAsync();
async Task<List<T>> ExecuteAsync()
{
var list = new List<T>();
await foreach (var element in source)
{
list.Add(element);
}
return list;
}
}
}

2
sandbox/OpenIddict.Sandbox.AspNetCore.Client/Program.cs

@ -13,7 +13,7 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<ApplicationDbContext>(options => builder.Services.AddDbContext<ApplicationDbContext>(options =>
{ {
options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-client.sqlite3")}"); options.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-client.sqlite3")}");
// Developers who prefer using Microsoft SQL Server instead of SQLite can remove // Developers who prefer using Microsoft SQL Server instead of SQLite can remove
// the previous line and configure OpenIddict to use the specified database: // the previous line and configure OpenIddict to use the specified database:

18
sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/ManageController.cs

@ -38,12 +38,12 @@ public class ManageController : Controller
public async Task<IActionResult> Index(ManageMessageId? message = null) public async Task<IActionResult> Index(ManageMessageId? message = null)
{ {
ViewData["StatusMessage"] = ViewData["StatusMessage"] =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." message is ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message is ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message is ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred." : message is ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message is ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : message is ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: ""; : "";
var user = await GetCurrentUserAsync(); var user = await GetCurrentUserAsync();
@ -261,9 +261,9 @@ public class ManageController : Controller
public async Task<IActionResult> ManageLogins(ManageMessageId? message = null) public async Task<IActionResult> ManageLogins(ManageMessageId? message = null)
{ {
ViewData["StatusMessage"] = ViewData["StatusMessage"] =
message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed." message is ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
: message == ManageMessageId.AddLoginSuccess ? "The external login was added." : message is ManageMessageId.AddLoginSuccess ? "The external login was added."
: message == ManageMessageId.Error ? "An error has occurred." : message is ManageMessageId.Error ? "An error has occurred."
: ""; : "";
var user = await GetCurrentUserAsync(); var user = await GetCurrentUserAsync();
if (user is null) if (user is null)

2
sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs

@ -19,7 +19,7 @@ builder.Services.AddMvc();
builder.Services.AddDbContext<ApplicationDbContext>(options => builder.Services.AddDbContext<ApplicationDbContext>(options =>
{ {
options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-server.sqlite3")}"); options.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-aspnetcore-server.sqlite3")}");
// Developers who prefer using Microsoft SQL Server instead of SQLite can remove // Developers who prefer using Microsoft SQL Server instead of SQLite can remove
// the previous line and configure OpenIddict to use the specified database: // the previous line and configure OpenIddict to use the specified database:

2
sandbox/OpenIddict.Sandbox.Console.Client/Models/ApplicationDbContext.cs

@ -24,7 +24,7 @@ public class ApplicationDbContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-console-client.sqlite3")}"); optionsBuilder.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-console-client.sqlite3")}");
} }
#else #else
public ApplicationDbContext() public ApplicationDbContext()

2
sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs

@ -19,7 +19,7 @@ public static class MauiProgram
builder.Services.AddDbContext<DbContext>(options => builder.Services.AddDbContext<DbContext>(options =>
{ {
options.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-maui-client.sqlite3")}"); options.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-maui-client.sqlite3")}");
options.UseOpenIddict(); options.UseOpenIddict();
}); });

2
sandbox/OpenIddict.Sandbox.WinForms.Client/Models/ApplicationDbContext.cs

@ -24,7 +24,7 @@ public class ApplicationDbContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-winforms-client.sqlite3")}"); optionsBuilder.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-winforms-client.sqlite3")}");
} }
#else #else
public ApplicationDbContext() public ApplicationDbContext()

2
sandbox/OpenIddict.Sandbox.Wpf.Client/Models/ApplicationDbContext.cs

@ -25,7 +25,7 @@ public class ApplicationDbContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseSqlite($"Filename={Path.Combine(Path.GetTempPath(), "openiddict-sandbox-wpf-client.sqlite3")}"); optionsBuilder.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-wpf-client.sqlite3")}");
} }
#else #else
public ApplicationDbContext() public ApplicationDbContext()

42
shared/OpenIddict.Extensions/OpenIddictHelpers.cs

@ -557,7 +557,7 @@ internal static class OpenIddictHelpers
/// <summary> /// <summary>
/// Note: this implementation was taken from ASP.NET Core. /// Note: this implementation was taken from ASP.NET Core.
/// </summary> /// </summary>
private class FormReader private sealed class FormReader
{ {
public const int DefaultValueCountLimit = 1024; public const int DefaultValueCountLimit = 1024;
public const int DefaultKeyLengthLimit = 1024 * 2; public const int DefaultKeyLengthLimit = 1024 * 2;
@ -598,7 +598,7 @@ internal static class OpenIddictHelpers
while (!_endOfStream) while (!_endOfStream)
{ {
// Empty // Empty
if (_bufferCount == 0) if (_bufferCount is 0)
{ {
Buffer(); Buffer();
} }
@ -611,7 +611,7 @@ internal static class OpenIddictHelpers
public async Task<KeyValuePair<string, string>?> ReadNextPairAsync(CancellationToken cancellationToken = new CancellationToken()) public async Task<KeyValuePair<string, string>?> ReadNextPairAsync(CancellationToken cancellationToken = new CancellationToken())
{ {
await ReadNextPairAsyncImpl(cancellationToken); await ReadNextPairAsyncImplAsync(cancellationToken);
if (ReadSucceeded()) if (ReadSucceeded())
{ {
return KeyValuePair.Create(_currentKey, _currentValue); return KeyValuePair.Create(_currentKey, _currentValue);
@ -619,12 +619,12 @@ internal static class OpenIddictHelpers
return null; return null;
} }
private async Task ReadNextPairAsyncImpl(CancellationToken cancellationToken = new CancellationToken()) private async Task ReadNextPairAsyncImplAsync(CancellationToken cancellationToken = new CancellationToken())
{ {
StartReadNextPair(); StartReadNextPair();
while (!_endOfStream) while (!_endOfStream)
{ {
if (_bufferCount == 0) if (_bufferCount is 0)
{ {
await BufferAsync(cancellationToken); await BufferAsync(cancellationToken);
} }
@ -643,20 +643,20 @@ internal static class OpenIddictHelpers
private bool TryReadNextPair() private bool TryReadNextPair()
{ {
if (_currentKey == null) if (_currentKey is null)
{ {
if (!TryReadWord('=', KeyLengthLimit, out _currentKey)) if (!TryReadWord('=', KeyLengthLimit, out _currentKey))
{ {
return false; return false;
} }
if (_bufferCount == 0) if (_bufferCount is 0)
{ {
return false; return false;
} }
} }
if (_currentValue == null) if (_currentValue is null)
{ {
if (!TryReadWord('&', ValueLengthLimit, out _currentValue)) if (!TryReadWord('&', ValueLengthLimit, out _currentValue))
{ {
@ -680,7 +680,7 @@ internal static class OpenIddictHelpers
private bool ReadChar(char separator, int limit, [NotNullWhen(true)] out string? word) private bool ReadChar(char separator, int limit, [NotNullWhen(true)] out string? word)
{ {
if (_bufferCount == 0) if (_bufferCount is 0)
{ {
word = BuildWord(); word = BuildWord();
return true; return true;
@ -696,7 +696,8 @@ internal static class OpenIddictHelpers
} }
if (_builder.Length >= limit) if (_builder.Length >= limit)
{ {
throw new InvalidDataException($"Form key or value length limit {limit} exceeded."); throw new InvalidDataException(string.Create(CultureInfo.InvariantCulture,
$"Form key or value length limit {limit} exceeded."));
} }
_builder.Append(c); _builder.Append(c);
word = null; word = null;
@ -715,7 +716,7 @@ internal static class OpenIddictHelpers
{ {
_bufferOffset = 0; _bufferOffset = 0;
_bufferCount = _reader.Read(_buffer, 0, _buffer.Length); _bufferCount = _reader.Read(_buffer, 0, _buffer.Length);
_endOfStream = _bufferCount == 0; _endOfStream = _bufferCount is 0;
} }
private async Task BufferAsync(CancellationToken cancellationToken) private async Task BufferAsync(CancellationToken cancellationToken)
@ -723,7 +724,7 @@ internal static class OpenIddictHelpers
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
_bufferOffset = 0; _bufferOffset = 0;
_bufferCount = await _reader.ReadAsync(_buffer, 0, _buffer.Length); _bufferCount = await _reader.ReadAsync(_buffer, 0, _buffer.Length);
_endOfStream = _bufferCount == 0; _endOfStream = _bufferCount is 0;
} }
public Dictionary<string, StringValues> ReadForm() public Dictionary<string, StringValues> ReadForm()
@ -742,7 +743,7 @@ internal static class OpenIddictHelpers
var accumulator = new KeyValueAccumulator(); var accumulator = new KeyValueAccumulator();
while (!_endOfStream) while (!_endOfStream)
{ {
await ReadNextPairAsyncImpl(cancellationToken); await ReadNextPairAsyncImplAsync(cancellationToken);
Append(ref accumulator); Append(ref accumulator);
} }
return accumulator.GetResults(); return accumulator.GetResults();
@ -751,7 +752,7 @@ internal static class OpenIddictHelpers
[MemberNotNullWhen(true, nameof(_currentKey), nameof(_currentValue))] [MemberNotNullWhen(true, nameof(_currentKey), nameof(_currentValue))]
private bool ReadSucceeded() private bool ReadSucceeded()
{ {
return _currentKey != null && _currentValue != null; return _currentKey is not null && _currentValue is not null;
} }
private void Append(ref KeyValueAccumulator accumulator) private void Append(ref KeyValueAccumulator accumulator)
@ -761,7 +762,8 @@ internal static class OpenIddictHelpers
accumulator.Append(_currentKey, _currentValue); accumulator.Append(_currentKey, _currentValue);
if (accumulator.ValueCount > ValueCountLimit) if (accumulator.ValueCount > ValueCountLimit)
{ {
throw new InvalidDataException($"Form value count limit {ValueCountLimit} exceeded."); throw new InvalidDataException(string.Create(CultureInfo.InvariantCulture,
$"Form value count limit {ValueCountLimit} exceeded."));
} }
} }
} }
@ -777,7 +779,7 @@ internal static class OpenIddictHelpers
public void Append(string key, string value) public void Append(string key, string value)
{ {
if (_accumulator == null) if (_accumulator is null)
{ {
_accumulator = new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase); _accumulator = new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase);
} }
@ -785,11 +787,11 @@ internal static class OpenIddictHelpers
StringValues values; StringValues values;
if (_accumulator.TryGetValue(key, out values)) if (_accumulator.TryGetValue(key, out values))
{ {
if (values.Count == 0) if (values.Count is 0)
{ {
_expandingAccumulator[key].Add(value); _expandingAccumulator[key].Add(value);
} }
else if (values.Count == 1) else if (values.Count is 1)
{ {
_accumulator[key] = new string[] { values[0]!, value }; _accumulator[key] = new string[] { values[0]!, value };
} }
@ -797,7 +799,7 @@ internal static class OpenIddictHelpers
{ {
_accumulator[key] = default(StringValues); _accumulator[key] = default(StringValues);
if (_expandingAccumulator == null) if (_expandingAccumulator is null)
{ {
_expandingAccumulator = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); _expandingAccumulator = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
} }
@ -826,7 +828,7 @@ internal static class OpenIddictHelpers
public Dictionary<string, StringValues> GetResults() public Dictionary<string, StringValues> GetResults()
{ {
if (_expandingAccumulator != null) if (_expandingAccumulator is not null)
{ {
foreach (var entry in _expandingAccumulator) foreach (var entry in _expandingAccumulator)
{ {

3
src/OpenIddict.Abstractions/OpenIddictBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -28,7 +29,7 @@ public sealed class OpenIddictBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -6,6 +6,7 @@
using System.Collections.Immutable; using System.Collections.Immutable;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -290,7 +291,8 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
/// <see langword="true"/> if the two instances have both the same representation /// <see langword="true"/> if the two instances have both the same representation
/// (e.g <see cref="string"/>) and value, <see langword="false"/> otherwise. /// (e.g <see cref="string"/>) and value, <see langword="false"/> otherwise.
/// </returns> /// </returns>
public override bool Equals(object? obj) => obj is OpenIddictParameter parameter && Equals(parameter); public override bool Equals([NotNullWhen(true)] object? obj)
=> obj is OpenIddictParameter parameter && Equals(parameter);
/// <summary> /// <summary>
/// Returns the hash code of the current <see cref="OpenIddictParameter"/> instance. /// Returns the hash code of the current <see cref="OpenIddictParameter"/> instance.
@ -615,7 +617,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
}; };
value = result.GetValueOrDefault(); value = result.GetValueOrDefault();
return result.HasValue; return result is not null;
} }
/// <summary> /// <summary>
@ -651,7 +653,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
}; };
value = result.GetValueOrDefault(); value = result.GetValueOrDefault();
return result.HasValue; return result is not null;
} }
/// <summary> /// <summary>

3
src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using OpenIddict.Client; using OpenIddict.Client;
using OpenIddict.Client.AspNetCore; using OpenIddict.Client.AspNetCore;
@ -140,7 +141,7 @@ public sealed class OpenIddictClientAspNetCoreBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using OpenIddict.Client.DataProtection; using OpenIddict.Client.DataProtection;
@ -90,7 +91,7 @@ public sealed class OpenIddictClientDataProtectionBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionFormatter.cs

@ -131,7 +131,7 @@ public sealed class OpenIddictClientDataProtectionFormatter : IOpenIddictClientD
{ {
// Read the version of the format used to serialize the properties. // Read the version of the format used to serialize the properties.
var version = reader.ReadInt32(); var version = reader.ReadInt32();
if (version != 1) if (version is not 1)
{ {
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287)); throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
} }

3
src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Client; using OpenIddict.Client;
using OpenIddict.Client.Owin; using OpenIddict.Client.Owin;
using Owin; using Owin;
@ -153,7 +154,7 @@ public sealed class OpenIddictClientOwinBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO.Pipes; using System.IO.Pipes;
using System.Net; using System.Net;
using System.Runtime.Versioning; using System.Runtime.Versioning;
@ -277,7 +278,7 @@ public sealed class OpenIddictClientSystemIntegrationBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

11
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs

@ -281,7 +281,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
} }
#if IOS || MACCATALYST || MACOS #if IOS || MACCATALYST || MACOS
class ASWebAuthenticationPresentationContext(NativeWindow window) : NSObject, sealed class ASWebAuthenticationPresentationContext(NativeWindow window) : NSObject,
IASWebAuthenticationPresentationContextProviding IASWebAuthenticationPresentationContextProviding
{ {
NativeWindow IASWebAuthenticationPresentationContextProviding.GetPresentationAnchor( NativeWindow IASWebAuthenticationPresentationContextProviding.GetPresentationAnchor(
@ -564,7 +564,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
return; return;
} }
#endif #endif
if (await TryLaunchBrowserWithShellExecuteAsync(uri)) if (await TryLaunchBrowserWithShellExecuteAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
@ -581,7 +581,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
} }
#endif #endif
#if IOS || MACCATALYST #if IOS || MACCATALYST
if ((OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst()) && await TryLaunchBrowserWithUIApplicationAsync(uri)) if ((OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst()) &&
await TryLaunchBrowserWithUIApplicationAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
@ -594,13 +595,13 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
return; return;
} }
#endif #endif
if (OperatingSystem.IsMacOS() && await TryLaunchBrowserWithOpenAsync(uri)) if (OperatingSystem.IsMacOS() && await TryLaunchBrowserWithOpenAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
} }
if (OperatingSystem.IsLinux() && await TryLaunchBrowserWithXdgOpenAsync(uri)) if (OperatingSystem.IsLinux() && await TryLaunchBrowserWithXdgOpenAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;

11
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs

@ -281,7 +281,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
} }
#if IOS || MACCATALYST || MACOS #if IOS || MACCATALYST || MACOS
class ASWebAuthenticationPresentationContext(NativeWindow window) : NSObject, sealed class ASWebAuthenticationPresentationContext(NativeWindow window) : NSObject,
IASWebAuthenticationPresentationContextProviding IASWebAuthenticationPresentationContextProviding
{ {
NativeWindow IASWebAuthenticationPresentationContextProviding.GetPresentationAnchor( NativeWindow IASWebAuthenticationPresentationContextProviding.GetPresentationAnchor(
@ -564,7 +564,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
return; return;
} }
#endif #endif
if (await TryLaunchBrowserWithShellExecuteAsync(uri)) if (await TryLaunchBrowserWithShellExecuteAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
@ -581,7 +581,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
} }
#endif #endif
#if IOS || MACCATALYST #if IOS || MACCATALYST
if ((OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst()) && await TryLaunchBrowserWithUIApplicationAsync(uri)) if ((OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst()) &&
await TryLaunchBrowserWithUIApplicationAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
@ -594,13 +595,13 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
return; return;
} }
#endif #endif
if (OperatingSystem.IsMacOS() && await TryLaunchBrowserWithOpenAsync(uri)) if (OperatingSystem.IsMacOS() && await TryLaunchBrowserWithOpenAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;
} }
if (OperatingSystem.IsLinux() && await TryLaunchBrowserWithXdgOpenAsync(uri)) if (OperatingSystem.IsLinux() && await TryLaunchBrowserWithXdgOpenAsync(uri, context.CancellationToken))
{ {
context.HandleRequest(); context.HandleRequest();
return; return;

20
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs

@ -359,9 +359,10 @@ public static class OpenIddictClientSystemIntegrationHelpers
/// Starts the system browser using the operating system shell. /// Starts the system browser using the operating system shell.
/// </summary> /// </summary>
/// <param name="uri">The <see cref="Uri"/> to use.</param> /// <param name="uri">The <see cref="Uri"/> to use.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns>
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
internal static async ValueTask<bool> TryLaunchBrowserWithShellExecuteAsync(Uri uri) internal static async ValueTask<bool> TryLaunchBrowserWithShellExecuteAsync(Uri uri, CancellationToken cancellationToken)
{ {
try try
{ {
@ -369,7 +370,7 @@ public static class OpenIddictClientSystemIntegrationHelpers
{ {
FileName = uri.AbsoluteUri, FileName = uri.AbsoluteUri,
UseShellExecute = true UseShellExecute = true
})); }), cancellationToken);
return true; return true;
} }
@ -438,11 +439,14 @@ public static class OpenIddictClientSystemIntegrationHelpers
/// Starts the system browser using <see href="UIApplication"/>. /// Starts the system browser using <see href="UIApplication"/>.
/// </summary> /// </summary>
/// <param name="uri">The <see cref="Uri"/> to use.</param> /// <param name="uri">The <see cref="Uri"/> to use.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns>
[SupportedOSPlatform("ios")] [SupportedOSPlatform("ios")]
[SupportedOSPlatform("maccatalyst")] [SupportedOSPlatform("maccatalyst")]
internal static async ValueTask<bool> TryLaunchBrowserWithUIApplicationAsync(Uri uri) internal static async ValueTask<bool> TryLaunchBrowserWithUIApplicationAsync(Uri uri, CancellationToken cancellationToken)
{ {
cancellationToken.ThrowIfCancellationRequested();
try try
{ {
return await UIApplication.SharedApplication.OpenUrlAsync(new NSUrl(uri.AbsoluteUri), new UIApplicationOpenUrlOptions()); return await UIApplication.SharedApplication.OpenUrlAsync(new NSUrl(uri.AbsoluteUri), new UIApplicationOpenUrlOptions());
@ -460,8 +464,9 @@ public static class OpenIddictClientSystemIntegrationHelpers
/// </summary> /// </summary>
/// <param name="uri">The <see cref="Uri"/> to use.</param> /// <param name="uri">The <see cref="Uri"/> to use.</param>
/// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
[SupportedOSPlatform("macos")] [SupportedOSPlatform("macos")]
internal static async ValueTask<bool> TryLaunchBrowserWithOpenAsync(Uri uri) internal static async ValueTask<bool> TryLaunchBrowserWithOpenAsync(Uri uri, CancellationToken cancellationToken)
{ {
try try
{ {
@ -477,7 +482,7 @@ public static class OpenIddictClientSystemIntegrationHelpers
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
RedirectStandardOutput = true RedirectStandardOutput = true
})); }), cancellationToken);
return true; return true;
} }
@ -492,9 +497,10 @@ public static class OpenIddictClientSystemIntegrationHelpers
/// Starts the system browser using the "xdg-open" executable. /// Starts the system browser using the "xdg-open" executable.
/// </summary> /// </summary>
/// <param name="uri">The <see cref="Uri"/> to use.</param> /// <param name="uri">The <see cref="Uri"/> to use.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if the browser could be started, <see langword="false"/> otherwise.</returns>
[SupportedOSPlatform("linux")] [SupportedOSPlatform("linux")]
internal static async ValueTask<bool> TryLaunchBrowserWithXdgOpenAsync(Uri uri) internal static async ValueTask<bool> TryLaunchBrowserWithXdgOpenAsync(Uri uri, CancellationToken cancellationToken)
{ {
try try
{ {
@ -510,7 +516,7 @@ public static class OpenIddictClientSystemIntegrationHelpers
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
RedirectStandardOutput = true RedirectStandardOutput = true
})); }), cancellationToken);
return true; return true;
} }

10
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs

@ -157,19 +157,21 @@ public sealed class OpenIddictClientSystemIntegrationHttpListener : BackgroundSe
{ {
if (Socket.OSSupportsIPv4) if (Socket.OSSupportsIPv4)
{ {
listener.Prefixes.Add($"http://{IPAddress.Loopback}:{port.ToString(CultureInfo.InvariantCulture)}/"); listener.Prefixes.Add(string.Create(CultureInfo.InvariantCulture,
$"http://{IPAddress.Loopback}:{port}/"));
} }
if (Socket.OSSupportsIPv6) if (Socket.OSSupportsIPv6)
{ {
listener.Prefixes.Add($"http://[{IPAddress.IPv6Loopback}]:{port.ToString(CultureInfo.InvariantCulture)}/"); listener.Prefixes.Add(string.Create(CultureInfo.InvariantCulture,
$"http://[{IPAddress.IPv6Loopback}]:{port}/"));
} }
} }
// On older versions, listening on 127.0.0.1 and ::1 requires administrator rights. // On older versions, listening on 127.0.0.1 and ::1 requires administrator rights.
else else
{ {
listener.Prefixes.Add($"http://localhost:{port.ToString(CultureInfo.InvariantCulture)}/"); listener.Prefixes.Add(string.Create(CultureInfo.InvariantCulture, $"http://localhost:{port}/"));
} }
} }
@ -182,7 +184,7 @@ public sealed class OpenIddictClientSystemIntegrationHttpListener : BackgroundSe
// on "localhost" on platforms that use the managed HttpListener implementation. // on "localhost" on platforms that use the managed HttpListener implementation.
// //
// See https://github.com/dotnet/runtime/issues/34399 for more information. // See https://github.com/dotnet/runtime/issues/34399 for more information.
listener.Prefixes.Add($"http://localhost:{port.ToString(CultureInfo.InvariantCulture)}/"); listener.Prefixes.Add(string.Create(CultureInfo.InvariantCulture, $"http://localhost:{port}/"));
} }
try try

3
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Mail; using System.Net.Mail;
@ -300,7 +301,7 @@ public sealed class OpenIddictClientSystemNetHttpBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Client.WebIntegration; using OpenIddict.Client.WebIntegration;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -58,7 +59,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Client/OpenIddictClientBuilder.cs

@ -1180,7 +1180,7 @@ public sealed class OpenIddictClientBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

6
src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs

@ -920,17 +920,17 @@ public static partial class OpenIddictClientHandlers
=> context.Registration.EncryptionCredentials.FirstOrDefault(), => context.Registration.EncryptionCredentials.FirstOrDefault(),
// For other types of tokens, use the global encryption credentials. // For other types of tokens, use the global encryption credentials.
_ => context.Options.EncryptionCredentials.First() _ => context.Options.EncryptionCredentials[0]
}; };
context.SigningCredentials = context.TokenType switch context.SigningCredentials = context.TokenType switch
{ {
// For client assertions, use the signing credentials configured for the client registration. // For client assertions, use the signing credentials configured for the client registration.
TokenTypeIdentifiers.Private.ClientAssertion TokenTypeIdentifiers.Private.ClientAssertion
=> context.Registration.SigningCredentials.First(), => context.Registration.SigningCredentials[0],
// For other types of tokens, use the global signing credentials. // For other types of tokens, use the global signing credentials.
_ => context.Options.SigningCredentials.First() _ => context.Options.SigningCredentials[0]
}; };
return ValueTask.CompletedTask; return ValueTask.CompletedTask;

12
src/OpenIddict.Client/OpenIddictClientHandlers.cs

@ -2828,7 +2828,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Options.ClientAssertionLifetime; var lifetime = context.Options.ClientAssertionLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -5741,7 +5741,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Principal.GetStateTokenLifetime() ?? context.Options.StateTokenLifetime; var lifetime = context.Principal.GetStateTokenLifetime() ?? context.Options.StateTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -6672,7 +6672,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Options.ClientAssertionLifetime; var lifetime = context.Options.ClientAssertionLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -7835,7 +7835,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Options.ClientAssertionLifetime; var lifetime = context.Options.ClientAssertionLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -8640,7 +8640,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Options.ClientAssertionLifetime; var lifetime = context.Options.ClientAssertionLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -9272,7 +9272,7 @@ public static partial class OpenIddictClientHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Principal.GetStateTokenLifetime() ?? context.Options.StateTokenLifetime; var lifetime = context.Principal.GetStateTokenLifetime() ?? context.Options.StateTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }

9
src/OpenIddict.Client/OpenIddictClientService.cs

@ -599,6 +599,7 @@ public class OpenIddictClientService
var dispatcher = scope.ServiceProvider.GetRequiredService<IOpenIddictClientDispatcher>(); var dispatcher = scope.ServiceProvider.GetRequiredService<IOpenIddictClientDispatcher>();
var factory = scope.ServiceProvider.GetRequiredService<IOpenIddictClientFactory>(); var factory = scope.ServiceProvider.GetRequiredService<IOpenIddictClientFactory>();
var options = scope.ServiceProvider.GetRequiredService<IOptionsMonitor<OpenIddictClientOptions>>();
var transaction = await factory.CreateTransactionAsync(request.CancellationToken); var transaction = await factory.CreateTransactionAsync(request.CancellationToken);
@ -670,7 +671,11 @@ public class OpenIddictClientService
{ {
// Default to a standard 5-second interval if no explicit value was configured. // Default to a standard 5-second interval if no explicit value was configured.
// See https://www.rfc-editor.org/rfc/rfc8628#section-3.5 for more information. // See https://www.rfc-editor.org/rfc/rfc8628#section-3.5 for more information.
#if NET
await Task.Delay(interval, TimeProvider.System, source.Token);
#else
await Task.Delay(interval, source.Token); await Task.Delay(interval, source.Token);
#endif
} }
catch (ProtocolException exception) when (exception.Error is Errors.SlowDown) catch (ProtocolException exception) when (exception.Error is Errors.SlowDown)
@ -679,7 +684,11 @@ public class OpenIddictClientService
// slow down the token redeeming process by increasing the interval. // slow down the token redeeming process by increasing the interval.
// //
// See https://www.rfc-editor.org/rfc/rfc8628#section-3.5 for more information. // See https://www.rfc-editor.org/rfc/rfc8628#section-3.5 for more information.
#if NET
await Task.Delay(interval += TimeSpan.FromSeconds(5), TimeProvider.System, source.Token);
#else
await Task.Delay(interval += TimeSpan.FromSeconds(5), source.Token); await Task.Delay(interval += TimeSpan.FromSeconds(5), source.Token);
#endif
} }
} }
} }

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

@ -195,7 +195,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
} }
var results = await GetValidationResultsAsync(application, cancellationToken); var results = await GetValidationResultsAsync(application, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -382,7 +382,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var application in applications) await foreach (var application in applications.WithCancellation(cancellationToken))
{ {
var uris = await Store.GetPostLogoutRedirectUrisAsync(application, cancellationToken); var uris = await Store.GetPostLogoutRedirectUrisAsync(application, cancellationToken);
if (uris.Contains(uri, StringComparer.Ordinal)) if (uris.Contains(uri, StringComparer.Ordinal))
@ -421,7 +421,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var application in applications) await foreach (var application in applications.WithCancellation(cancellationToken))
{ {
var uris = await Store.GetRedirectUrisAsync(application, cancellationToken); var uris = await Store.GetRedirectUrisAsync(application, cancellationToken);
if (uris.Contains(uri, StringComparer.Ordinal)) if (uris.Contains(uri, StringComparer.Ordinal))
@ -1129,7 +1129,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
ArgumentNullException.ThrowIfNull(application); ArgumentNullException.ThrowIfNull(application);
var results = await GetValidationResultsAsync(application, cancellationToken); var results = await GetValidationResultsAsync(application, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

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

@ -134,7 +134,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
} }
var results = await GetValidationResultsAsync(authorization, cancellationToken); var results = await GetValidationResultsAsync(authorization, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -238,7 +238,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var authorization in authorizations) await foreach (var authorization in authorizations.WithCancellation(cancellationToken))
{ {
if (!string.IsNullOrEmpty(query.Subject) && if (!string.IsNullOrEmpty(query.Subject) &&
!string.Equals(await Store.GetSubjectAsync(authorization, cancellationToken), query.Subject, StringComparison.Ordinal)) !string.Equals(await Store.GetSubjectAsync(authorization, cancellationToken), query.Subject, StringComparison.Ordinal))
@ -285,7 +285,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var authorization in authorizations) await foreach (var authorization in authorizations.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetApplicationIdAsync(authorization, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetApplicationIdAsync(authorization, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -357,7 +357,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var authorization in authorizations) await foreach (var authorization in authorizations.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetSubjectAsync(authorization, cancellationToken), subject, StringComparison.Ordinal)) if (string.Equals(await Store.GetSubjectAsync(authorization, cancellationToken), subject, StringComparison.Ordinal))
{ {
@ -796,7 +796,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
ArgumentNullException.ThrowIfNull(authorization); ArgumentNullException.ThrowIfNull(authorization);
var results = await GetValidationResultsAsync(authorization, cancellationToken); var results = await GetValidationResultsAsync(authorization, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

6
src/OpenIddict.Core/Managers/OpenIddictResourceManager.cs

@ -129,7 +129,7 @@ public class OpenIddictResourceManager<TResource> : IOpenIddictResourceManager w
ArgumentNullException.ThrowIfNull(resource); ArgumentNullException.ThrowIfNull(resource);
var results = await GetValidationResultsAsync(resource, cancellationToken); var results = await GetValidationResultsAsync(resource, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -306,7 +306,7 @@ public class OpenIddictResourceManager<TResource> : IOpenIddictResourceManager w
async IAsyncEnumerable<TResource> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TResource> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var resource in resources) await foreach (var resource in resources.WithCancellation(cancellationToken))
{ {
var name = await Store.GetNameAsync(resource, cancellationToken); var name = await Store.GetNameAsync(resource, cancellationToken);
if (!string.IsNullOrEmpty(name) && names.Contains(name, StringComparer.Ordinal)) if (!string.IsNullOrEmpty(name) && names.Contains(name, StringComparer.Ordinal))
@ -696,7 +696,7 @@ public class OpenIddictResourceManager<TResource> : IOpenIddictResourceManager w
ArgumentNullException.ThrowIfNull(resource); ArgumentNullException.ThrowIfNull(resource);
var results = await GetValidationResultsAsync(resource, cancellationToken); var results = await GetValidationResultsAsync(resource, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

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

@ -128,7 +128,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
ArgumentNullException.ThrowIfNull(scope); ArgumentNullException.ThrowIfNull(scope);
var results = await GetValidationResultsAsync(scope, cancellationToken); var results = await GetValidationResultsAsync(scope, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -305,7 +305,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var scope in scopes) await foreach (var scope in scopes.WithCancellation(cancellationToken))
{ {
var name = await Store.GetNameAsync(scope, cancellationToken); var name = await Store.GetNameAsync(scope, cancellationToken);
if (!string.IsNullOrEmpty(name) && names.Contains(name, StringComparer.Ordinal)) if (!string.IsNullOrEmpty(name) && names.Contains(name, StringComparer.Ordinal))
@ -344,7 +344,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var scope in scopes) await foreach (var scope in scopes.WithCancellation(cancellationToken))
{ {
var resources = await Store.GetResourcesAsync(scope, cancellationToken); var resources = await Store.GetResourcesAsync(scope, cancellationToken);
if (resources.Contains(resource, StringComparer.Ordinal)) if (resources.Contains(resource, StringComparer.Ordinal))
@ -777,7 +777,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
ArgumentNullException.ThrowIfNull(scope); ArgumentNullException.ThrowIfNull(scope);
var results = await GetValidationResultsAsync(scope, cancellationToken); var results = await GetValidationResultsAsync(scope, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

14
src/OpenIddict.Core/Managers/OpenIddictSessionManager.cs

@ -133,7 +133,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
} }
var results = await GetValidationResultsAsync(session, cancellationToken); var results = await GetValidationResultsAsync(session, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -237,7 +237,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var session in sessions) await foreach (var session in sessions.WithCancellation(cancellationToken))
{ {
if (string.IsNullOrEmpty(query.Subject) || if (string.IsNullOrEmpty(query.Subject) ||
string.Equals(await Store.GetSubjectAsync(session, cancellationToken), query.Subject, StringComparison.Ordinal)) string.Equals(await Store.GetSubjectAsync(session, cancellationToken), query.Subject, StringComparison.Ordinal))
@ -276,7 +276,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var session in sessions) await foreach (var session in sessions.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetApplicationIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetApplicationIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -314,7 +314,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var session in sessions) await foreach (var session in sessions.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetAuthorizationIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetAuthorizationIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -385,7 +385,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var session in sessions) await foreach (var session in sessions.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetLoginIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetLoginIdAsync(session, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -423,7 +423,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TSession> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var session in sessions) await foreach (var session in sessions.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetSubjectAsync(session, cancellationToken), subject, StringComparison.Ordinal)) if (string.Equals(await Store.GetSubjectAsync(session, cancellationToken), subject, StringComparison.Ordinal))
{ {
@ -712,7 +712,7 @@ public class OpenIddictSessionManager<TSession> : IOpenIddictSessionManager wher
ArgumentNullException.ThrowIfNull(session); ArgumentNullException.ThrowIfNull(session);
var results = await GetValidationResultsAsync(session, cancellationToken); var results = await GetValidationResultsAsync(session, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

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

@ -143,7 +143,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
} }
var results = await GetValidationResultsAsync(token, cancellationToken); var results = await GetValidationResultsAsync(token, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0207)); builder.AppendLine(SR.GetResourceString(SR.ID0207));
@ -247,7 +247,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var token in tokens) await foreach (var token in tokens.WithCancellation(cancellationToken))
{ {
if (string.IsNullOrEmpty(query.Subject) || if (string.IsNullOrEmpty(query.Subject) ||
string.Equals(await Store.GetSubjectAsync(token, cancellationToken), query.Subject, StringComparison.Ordinal)) string.Equals(await Store.GetSubjectAsync(token, cancellationToken), query.Subject, StringComparison.Ordinal))
@ -286,7 +286,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var token in tokens) await foreach (var token in tokens.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetApplicationIdAsync(token, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetApplicationIdAsync(token, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -324,7 +324,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var token in tokens) await foreach (var token in tokens.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetAuthorizationIdAsync(token, cancellationToken), identifier, StringComparison.Ordinal)) if (string.Equals(await Store.GetAuthorizationIdAsync(token, cancellationToken), identifier, StringComparison.Ordinal))
{ {
@ -436,7 +436,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken) async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{ {
await foreach (var token in tokens) await foreach (var token in tokens.WithCancellation(cancellationToken))
{ {
if (string.Equals(await Store.GetSubjectAsync(token, cancellationToken), subject, StringComparison.Ordinal)) if (string.Equals(await Store.GetSubjectAsync(token, cancellationToken), subject, StringComparison.Ordinal))
{ {
@ -1048,7 +1048,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
ArgumentNullException.ThrowIfNull(token); ArgumentNullException.ThrowIfNull(token);
var results = await GetValidationResultsAsync(token, cancellationToken); var results = await GetValidationResultsAsync(token, cancellationToken);
if (results.Any(result => result != ValidationResult.Success)) if (results.Any(static result => result != ValidationResult.Success))
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine(SR.GetResourceString(SR.ID0215)); builder.AppendLine(SR.GetResourceString(SR.ID0215));

2
src/OpenIddict.Core/OpenIddictCoreBuilder.cs

@ -721,7 +721,7 @@ public sealed class OpenIddictCoreBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkBuilder.cs

@ -143,7 +143,7 @@ public sealed class OpenIddictEntityFrameworkBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs

@ -78,7 +78,9 @@ public static class OpenIddictEntityFrameworkHelpers
/// <param name="source">The query source.</param> /// <param name="source">The query source.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The streamed async enumeration containing the results.</returns> /// <returns>The streamed async enumeration containing the results.</returns>
#pragma warning disable MA0156
internal static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IQueryable<T> source, CancellationToken cancellationToken) internal static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IQueryable<T> source, CancellationToken cancellationToken)
#pragma warning restore MA0156
{ {
ArgumentNullException.ThrowIfNull(source); ArgumentNullException.ThrowIfNull(source);

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

@ -241,7 +241,7 @@ public class OpenIddictEntityFrameworkApplicationStore<
where application.PostLogoutRedirectUris!.Contains(uri) where application.PostLogoutRedirectUris!.Contains(uri)
select application).AsAsyncEnumerable(cancellationToken); select application).AsAsyncEnumerable(cancellationToken);
await foreach (var application in applications) await foreach (var application in applications.WithCancellation(cancellationToken))
{ {
var uris = await GetPostLogoutRedirectUrisAsync(application, cancellationToken); var uris = await GetPostLogoutRedirectUrisAsync(application, cancellationToken);
if (uris.Contains(uri, StringComparer.Ordinal)) if (uris.Contains(uri, StringComparer.Ordinal))
@ -274,7 +274,7 @@ public class OpenIddictEntityFrameworkApplicationStore<
where application.RedirectUris!.Contains(uri) where application.RedirectUris!.Contains(uri)
select application).AsAsyncEnumerable(cancellationToken); select application).AsAsyncEnumerable(cancellationToken);
await foreach (var application in applications) await foreach (var application in applications.WithCancellation(cancellationToken))
{ {
var uris = await GetRedirectUrisAsync(application, cancellationToken); var uris = await GetRedirectUrisAsync(application, cancellationToken);
if (uris.Contains(uri, StringComparer.Ordinal)) if (uris.Contains(uri, StringComparer.Ordinal))
@ -660,12 +660,12 @@ public class OpenIddictEntityFrameworkApplicationStore<
IQueryable<TApplication> query = context.Set<TApplication>().OrderBy(application => application.Id!); IQueryable<TApplication> query = context.Set<TApplication>().OrderBy(application => application.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -432,12 +432,12 @@ public class OpenIddictEntityFrameworkAuthorizationStore<
.Include(authorization => authorization.Application) .Include(authorization => authorization.Application)
.OrderBy(authorization => authorization.Id!); .OrderBy(authorization => authorization.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkResourceStore.cs

@ -358,12 +358,12 @@ public class OpenIddictEntityFrameworkResourceStore<
IQueryable<TResource> query = context.Set<TResource>().OrderBy(resource => resource.Id!); IQueryable<TResource> query = context.Set<TResource>().OrderBy(resource => resource.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -204,7 +204,7 @@ public class OpenIddictEntityFrameworkScopeStore<
where scope.Resources!.Contains(resource) where scope.Resources!.Contains(resource)
select scope).AsAsyncEnumerable(cancellationToken); select scope).AsAsyncEnumerable(cancellationToken);
await foreach (var scope in scopes) await foreach (var scope in scopes.WithCancellation(cancellationToken))
{ {
var resources = await GetResourcesAsync(scope, cancellationToken); var resources = await GetResourcesAsync(scope, cancellationToken);
if (resources.Contains(resource, StringComparer.Ordinal)) if (resources.Contains(resource, StringComparer.Ordinal))
@ -428,12 +428,12 @@ public class OpenIddictEntityFrameworkScopeStore<
IQueryable<TScope> query = context.Set<TScope>().OrderBy(scope => scope.Id!); IQueryable<TScope> query = context.Set<TScope>().OrderBy(scope => scope.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkSessionStore.cs

@ -433,12 +433,12 @@ public class OpenIddictEntityFrameworkSessionStore<
IQueryable<TSession> query = context.Set<TSession>().OrderBy(session => session.Id!); IQueryable<TSession> query = context.Set<TSession>().OrderBy(session => session.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -467,12 +467,12 @@ public class OpenIddictEntityFrameworkTokenStore<
.Include(token => token.Authorization) .Include(token => token.Authorization)
.OrderBy(token => token.Id!); .OrderBy(token => token.Id!);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

2
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs

@ -153,7 +153,7 @@ public sealed class OpenIddictEntityFrameworkCoreBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -483,12 +483,12 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<
var query = context.Set<TApplication>().OrderBy(application => application.Id!).AsTracking(); var query = context.Set<TApplication>().OrderBy(application => application.Id!).AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -438,12 +438,12 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore<
.OrderBy(authorization => authorization.Id!) .OrderBy(authorization => authorization.Id!)
.AsTracking(); .AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs

@ -281,12 +281,12 @@ public class OpenIddictEntityFrameworkCoreResourceStore<
var query = context.Set<TResource>().OrderBy(resource => resource.Id!).AsTracking(); var query = context.Set<TResource>().OrderBy(resource => resource.Id!).AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -309,12 +309,12 @@ public class OpenIddictEntityFrameworkCoreScopeStore<
var query = context.Set<TScope>().OrderBy(scope => scope.Id!).AsTracking(); var query = context.Set<TScope>().OrderBy(scope => scope.Id!).AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreSessionStore.cs

@ -430,12 +430,12 @@ public class OpenIddictEntityFrameworkCoreSessionStore<
var query = context.Set<TSession>().OrderBy(session => session.Id!).AsTracking(); var query = context.Set<TSession>().OrderBy(session => session.Id!).AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -460,12 +460,12 @@ public class OpenIddictEntityFrameworkCoreTokenStore<
.OrderBy(token => token.Id!) .OrderBy(token => token.Id!)
.AsTracking(); .AsTracking();
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

2
src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs

@ -247,7 +247,7 @@ public sealed class OpenIddictMongoDbBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -354,12 +354,12 @@ public class OpenIddictMongoDbApplicationStore<
var query = (IQueryable<TApplication>) collection.AsQueryable().OrderBy(application => application.Id); var query = (IQueryable<TApplication>) collection.AsQueryable().OrderBy(application => application.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -317,12 +317,12 @@ public class OpenIddictMongoDbAuthorizationStore<
var query = (IQueryable<TAuthorization>) collection.AsQueryable().OrderBy(authorization => authorization.Id); var query = (IQueryable<TAuthorization>) collection.AsQueryable().OrderBy(authorization => authorization.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbResourceStore.cs

@ -259,12 +259,12 @@ public class OpenIddictMongoDbResourceStore<
var query = (IQueryable<TResource>) collection.AsQueryable().OrderBy(resource => resource.Id); var query = (IQueryable<TResource>) collection.AsQueryable().OrderBy(resource => resource.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -286,12 +286,12 @@ public class OpenIddictMongoDbScopeStore<
var query = (IQueryable<TScope>) collection.AsQueryable().OrderBy(scope => scope.Id); var query = (IQueryable<TScope>) collection.AsQueryable().OrderBy(scope => scope.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

4
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbSessionStore.cs

@ -343,12 +343,12 @@ public class OpenIddictMongoDbSessionStore<
var query = (IQueryable<TSession>) collection.AsQueryable().OrderBy(session => session.Id); var query = (IQueryable<TSession>) collection.AsQueryable().OrderBy(session => session.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

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

@ -367,12 +367,12 @@ public class OpenIddictMongoDbTokenStore<
var query = (IQueryable<TToken>) collection.AsQueryable().OrderBy(token => token.Id); var query = (IQueryable<TToken>) collection.AsQueryable().OrderBy(token => token.Id);
if (offset.HasValue) if (offset is not null)
{ {
query = query.Skip(offset.Value); query = query.Skip(offset.Value);
} }
if (count.HasValue) if (count is not null)
{ {
query = query.Take(count.Value); query = query.Take(count.Value);
} }

3
src/OpenIddict.Quartz/OpenIddictQuartzBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Quartz; using OpenIddict.Quartz;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -106,7 +107,7 @@ public sealed class OpenIddictQuartzBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using OpenIddict.Server.AspNetCore; using OpenIddict.Server.AspNetCore;
@ -156,7 +157,7 @@ public sealed class OpenIddictServerAspNetCoreBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using OpenIddict.Server.DataProtection; using OpenIddict.Server.DataProtection;
@ -125,7 +126,7 @@ public sealed class OpenIddictServerDataProtectionBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs

@ -141,7 +141,7 @@ public sealed class OpenIddictServerDataProtectionFormatter : IOpenIddictServerD
{ {
// Read the version of the format used to serialize the properties. // Read the version of the format used to serialize the properties.
var version = reader.ReadInt32(); var version = reader.ReadInt32();
if (version != 1) if (version is not 1)
{ {
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287)); throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
} }

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

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Server.Owin; using OpenIddict.Server.Owin;
using Owin; using Owin;
@ -145,7 +146,7 @@ public sealed class OpenIddictServerOwinBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Server/OpenIddictServerBuilder.cs

@ -2453,7 +2453,7 @@ public sealed class OpenIddictServerBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

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

@ -1833,7 +1833,7 @@ public static partial class OpenIddictServerHandlers
return; return;
} }
async ValueTask<bool> HasPermissionAsync(IEnumerable<string> types) async ValueTask<bool> HasPermissionAsync(ImmutableArray<string> types)
{ {
// Note: response type permissions are always prefixed with "rst:". // Note: response type permissions are always prefixed with "rst:".
const string prefix = Permissions.Prefixes.ResponseType; const string prefix = Permissions.Prefixes.ResponseType;
@ -1849,7 +1849,7 @@ public static partial class OpenIddictServerHandlers
// Note: response types can be specified in any order. To ensure permissions are correctly // Note: response types can be specified in any order. To ensure permissions are correctly
// checked even if the order differs from the one specified in the request, a HashSet is used. // checked even if the order differs from the one specified in the request, a HashSet is used.
var values = permission[prefix.Length..].Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries); var values = permission[prefix.Length..].Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries);
if (values.Length is not 0 && values.ToHashSet(StringComparer.Ordinal).SetEquals(types)) if (values is not [] && values.ToHashSet(StringComparer.Ordinal).SetEquals(types))
{ {
return true; return true;
} }

4
src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs

@ -1475,7 +1475,7 @@ public static partial class OpenIddictServerHandlers
TokenTypeIdentifiers.AccessToken when context.Options.DisableAccessTokenEncryption => null, TokenTypeIdentifiers.AccessToken when context.Options.DisableAccessTokenEncryption => null,
TokenTypeIdentifiers.IdentityToken => null, TokenTypeIdentifiers.IdentityToken => null,
_ => context.Options.EncryptionCredentials.First() _ => context.Options.EncryptionCredentials[0]
}; };
context.SigningCredentials = context.TokenType switch context.SigningCredentials = context.TokenType switch
@ -1485,7 +1485,7 @@ public static partial class OpenIddictServerHandlers
TokenTypeIdentifiers.IdentityToken => context.Options.SigningCredentials.First(static credentials => TokenTypeIdentifiers.IdentityToken => context.Options.SigningCredentials.First(static credentials =>
credentials.Key is AsymmetricSecurityKey), credentials.Key is AsymmetricSecurityKey),
_ => context.Options.SigningCredentials.First() _ => context.Options.SigningCredentials[0]
}; };
return ValueTask.CompletedTask; return ValueTask.CompletedTask;

15
src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs

@ -831,7 +831,8 @@ public static partial class OpenIddictServerHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0016)); throw new InvalidOperationException(SR.GetResourceString(SR.ID0016));
} }
if (!await ValidateAuthorizedParty(context.IdentityTokenHintPrincipal, context.PostLogoutRedirectUri)) if (!await ValidateAuthorizedPartyAsync(context.IdentityTokenHintPrincipal,
context.PostLogoutRedirectUri, context.CancellationToken))
{ {
context.Logger.LogWarning(6198, SR.GetResourceString(SR.ID6198)); context.Logger.LogWarning(6198, SR.GetResourceString(SR.ID6198));
@ -846,8 +847,8 @@ public static partial class OpenIddictServerHandlers
return; return;
} }
async ValueTask<bool> ValidateAuthorizedParty(ClaimsPrincipal principal, async ValueTask<bool> ValidateAuthorizedPartyAsync(ClaimsPrincipal principal,
[StringSyntax(StringSyntaxAttribute.Uri)] string uri) [StringSyntax(StringSyntaxAttribute.Uri)] string uri, CancellationToken cancellationToken)
{ {
// To be considered valid, the specified post_logout_redirect_uri must // To be considered valid, the specified post_logout_redirect_uri must
// be considered valid for one of the listed audiences/presenters. // be considered valid for one of the listed audiences/presenters.
@ -858,7 +859,7 @@ public static partial class OpenIddictServerHandlers
foreach (var identifier in identifiers) foreach (var identifier in identifiers)
{ {
var application = await _applicationManager.FindByClientIdAsync(identifier, context.CancellationToken); var application = await _applicationManager.FindByClientIdAsync(identifier, cancellationToken);
if (application is null) if (application is null)
{ {
continue; continue;
@ -866,13 +867,13 @@ public static partial class OpenIddictServerHandlers
// Note: the legacy "ept:logout" permission is still allowed for backward compatibility. // Note: the legacy "ept:logout" permission is still allowed for backward compatibility.
if (!context.Options.IgnoreEndpointPermissions && if (!context.Options.IgnoreEndpointPermissions &&
!await _applicationManager.HasPermissionAsync(application, Permissions.Endpoints.EndSession, context.CancellationToken) && !await _applicationManager.HasPermissionAsync(application, Permissions.Endpoints.EndSession, cancellationToken) &&
!await _applicationManager.HasPermissionAsync(application, "ept:logout", context.CancellationToken)) !await _applicationManager.HasPermissionAsync(application, "ept:logout", cancellationToken))
{ {
continue; continue;
} }
if (await _applicationManager.ValidatePostLogoutRedirectUriAsync(application, uri, context.CancellationToken)) if (await _applicationManager.ValidatePostLogoutRedirectUriAsync(application, uri, cancellationToken))
{ {
return true; return true;
} }

18
src/OpenIddict.Server/OpenIddictServerHandlers.cs

@ -3625,7 +3625,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.AccessTokenLifetime; lifetime ??= context.Options.AccessTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -3759,7 +3759,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.AuthorizationCodeLifetime; lifetime ??= context.Options.AuthorizationCodeLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -3883,7 +3883,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.DeviceCodeLifetime; lifetime ??= context.Options.DeviceCodeLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -4117,7 +4117,7 @@ public static partial class OpenIddictServerHandlers
_ => context.Options.IssuedTokenLifetime _ => context.Options.IssuedTokenLifetime
}; };
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -4291,7 +4291,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.RequestTokenLifetime; lifetime ??= context.Options.RequestTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -4436,7 +4436,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.RefreshTokenLifetime; lifetime ??= context.Options.RefreshTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -4612,7 +4612,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.IdentityTokenLifetime; lifetime ??= context.Options.IdentityTokenLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -4739,7 +4739,7 @@ public static partial class OpenIddictServerHandlers
// Otherwise, fall back to the global value. // Otherwise, fall back to the global value.
lifetime ??= context.Options.UserCodeLifetime; lifetime ??= context.Options.UserCodeLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }
@ -5696,7 +5696,7 @@ public static partial class OpenIddictServerHandlers
{ {
var uri = OpenIddictHelpers.CreateAbsoluteUri( var uri = OpenIddictHelpers.CreateAbsoluteUri(
left : context.BaseUri ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0127)), left : context.BaseUri ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0127)),
right: context.Options.EndUserVerificationEndpointUris.First()); right: context.Options.EndUserVerificationEndpointUris[0]);
context.Response.VerificationUri = uri.AbsoluteUri; context.Response.VerificationUri = uri.AbsoluteUri;

3
src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Validation.AspNetCore; using OpenIddict.Validation.AspNetCore;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -93,7 +94,7 @@ public sealed class OpenIddictValidationAspNetCoreBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using OpenIddict.Validation.DataProtection; using OpenIddict.Validation.DataProtection;
@ -83,7 +84,7 @@ public sealed class OpenIddictValidationDataProtectionBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs

@ -124,7 +124,7 @@ public sealed class OpenIddictValidationDataProtectionFormatter : IOpenIddictVal
{ {
// Read the version of the format used to serialize the properties. // Read the version of the format used to serialize the properties.
var version = reader.ReadInt32(); var version = reader.ReadInt32();
if (version != 1) if (version is not 1)
{ {
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287)); throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
} }

3
src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Validation.Owin; using OpenIddict.Validation.Owin;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -107,7 +108,7 @@ public sealed class OpenIddictValidationOwinBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Validation.ServerIntegration/OpenIddictValidationServerIntegrationBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using OpenIddict.Validation.ServerIntegration; using OpenIddict.Validation.ServerIntegration;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -56,7 +57,7 @@ public sealed class OpenIddictValidationServerIntegrationBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

3
src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpBuilder.cs

@ -5,6 +5,7 @@
*/ */
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Mail; using System.Net.Mail;
@ -208,7 +209,7 @@ public sealed class OpenIddictValidationSystemNetHttpBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Validation/OpenIddictValidationBuilder.cs

@ -711,7 +711,7 @@ public sealed class OpenIddictValidationBuilder
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object? obj) => base.Equals(obj); public override bool Equals([NotNullWhen(true)] object? obj) => base.Equals(obj);
/// <inheritdoc/> /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

2
src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs

@ -1007,7 +1007,7 @@ public static partial class OpenIddictValidationHandlers
{ {
ArgumentNullException.ThrowIfNull(context); ArgumentNullException.ThrowIfNull(context);
context.SecurityTokenDescriptor.SigningCredentials = context.Options.SigningCredentials.First(); context.SecurityTokenDescriptor.SigningCredentials = context.Options.SigningCredentials[0];
context.SecurityTokenHandler = context.Options.JsonWebTokenHandler; context.SecurityTokenHandler = context.Options.JsonWebTokenHandler;
return ValueTask.CompletedTask; return ValueTask.CompletedTask;

2
src/OpenIddict.Validation/OpenIddictValidationHandlers.cs

@ -531,7 +531,7 @@ public static partial class OpenIddictValidationHandlers
principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow()); principal.SetCreationDate(context.Options.TimeProvider.GetUtcNow());
var lifetime = context.Options.ClientAssertionLifetime; var lifetime = context.Options.ClientAssertionLifetime;
if (lifetime.HasValue) if (lifetime is not null)
{ {
principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value); principal.SetExpirationDate(principal.GetCreationDate() + lifetime.Value);
} }

4
test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs

@ -150,8 +150,8 @@ public class OpenIddictConverterTests
Assert.NotNull(message.GetParameter("array")); Assert.NotNull(message.GetParameter("array"));
Assert.NotNull(message.GetParameter("object")); Assert.NotNull(message.GetParameter("object"));
Assert.Empty(((string?) message.GetParameter("string"))!); Assert.Empty(((string?) message.GetParameter("string"))!);
Assert.True(((JsonElement?) message.GetParameter("array")).HasValue); Assert.True((JsonElement?) message.GetParameter("array") is not null);
Assert.True(((JsonElement?) message.GetParameter("object")).HasValue); Assert.True((JsonElement?) message.GetParameter("object") is not null);
Assert.NotNull((JsonNode?) message.GetParameter("array")); Assert.NotNull((JsonNode?) message.GetParameter("array"));
Assert.NotNull((JsonNode?) message.GetParameter("object")); Assert.NotNull((JsonNode?) message.GetParameter("object"));
} }

6
test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs

@ -193,9 +193,9 @@ public class OpenIddictMessageTests
// Assert // Assert
Assert.Empty(((string?) message.GetParameter("string"))!); Assert.Empty(((string?) message.GetParameter("string"))!);
Assert.True(((JsonElement?) message.GetParameter("array")).HasValue); Assert.True((JsonElement?) message.GetParameter("array") is not null);
Assert.True(((JsonElement?) message.GetParameter("object")).HasValue); Assert.True((JsonElement?) message.GetParameter("object") is not null);
Assert.True(((JsonElement?) message.GetParameter("value")).HasValue); Assert.True((JsonElement?) message.GetParameter("value") is not null);
Assert.NotNull((JsonNode?) message.GetParameter("node_array")); Assert.NotNull((JsonNode?) message.GetParameter("node_array"));
Assert.NotNull((JsonNode?) message.GetParameter("node_object")); Assert.NotNull((JsonNode?) message.GetParameter("node_object"));
Assert.NotNull((JsonNode?) message.GetParameter("node_value")); Assert.NotNull((JsonNode?) message.GetParameter("node_value"));

6
test/OpenIddict.Client.Tests/OpenIddictClientBuilderTests.cs

@ -88,7 +88,7 @@ public class OpenIddictClientBuilderTests
Assert.Contains(services, service => Assert.Contains(services, service =>
service.ServiceType == typeof(CustomHandler) && service.ServiceType == typeof(CustomHandler) &&
service.ImplementationInstance?.GetType() == typeof(CustomHandler) && service.ImplementationInstance?.GetType() == typeof(CustomHandler) &&
service.Lifetime == ServiceLifetime.Singleton); service.Lifetime is ServiceLifetime.Singleton);
} }
[Fact] [Fact]
@ -1510,12 +1510,12 @@ public class OpenIddictClientBuilderTests
return options.Value; return options.Value;
} }
private class CustomContext : BaseContext private sealed class CustomContext : BaseContext
{ {
public CustomContext(OpenIddictClientTransaction transaction) : base(transaction) { } public CustomContext(OpenIddictClientTransaction transaction) : base(transaction) { }
} }
private class CustomHandler : IOpenIddictClientHandler<CustomContext> private sealed class CustomHandler : IOpenIddictClientHandler<CustomContext>
{ {
public ValueTask HandleAsync(CustomContext context) => ValueTask.CompletedTask; public ValueTask HandleAsync(CustomContext context) => ValueTask.CompletedTask;
} }

2
test/OpenIddict.Core.Tests/Managers/OpenIddictApplicationManagerTests.cs

@ -3539,7 +3539,7 @@ public class OpenIddictApplicationManagerTests
public class CustomApplication; public class CustomApplication;
private class CustomApplicationManagerWithProtectedAccess : OpenIddictApplicationManager<CustomApplication> private sealed class CustomApplicationManagerWithProtectedAccess : OpenIddictApplicationManager<CustomApplication>
{ {
public CustomApplicationManagerWithProtectedAccess( public CustomApplicationManagerWithProtectedAccess(
IOpenIddictApplicationCache<CustomApplication> cache, IOpenIddictApplicationCache<CustomApplication> cache,

60
test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs

@ -65,7 +65,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictApplicationManager<>)); service.ServiceType == typeof(OpenIddictApplicationManager<>));
Assert.Equal(typeof(OpenGenericApplicationManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericApplicationManager<>), descriptor.ImplementationType);
} }
@ -110,7 +110,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictAuthorizationManager<>)); service.ServiceType == typeof(OpenIddictAuthorizationManager<>));
Assert.Equal(typeof(OpenGenericAuthorizationManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericAuthorizationManager<>), descriptor.ImplementationType);
} }
@ -155,7 +155,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictResourceManager<>)); service.ServiceType == typeof(OpenIddictResourceManager<>));
Assert.Equal(typeof(OpenGenericResourceManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericResourceManager<>), descriptor.ImplementationType);
} }
@ -200,7 +200,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictScopeManager<>)); service.ServiceType == typeof(OpenIddictScopeManager<>));
Assert.Equal(typeof(OpenGenericScopeManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericScopeManager<>), descriptor.ImplementationType);
} }
@ -245,7 +245,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictSessionManager<>)); service.ServiceType == typeof(OpenIddictSessionManager<>));
Assert.Equal(typeof(OpenGenericSessionManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericSessionManager<>), descriptor.ImplementationType);
} }
@ -290,7 +290,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
var descriptor = Assert.Single(services, service => var descriptor = Assert.Single(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(OpenIddictTokenManager<>)); service.ServiceType == typeof(OpenIddictTokenManager<>));
Assert.Equal(typeof(OpenGenericTokenManager<>), descriptor.ImplementationType); Assert.Equal(typeof(OpenGenericTokenManager<>), descriptor.ImplementationType);
} }
@ -540,7 +540,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationManager) && service.ServiceType == typeof(IOpenIddictApplicationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -557,7 +557,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationManager) && service.ServiceType == typeof(IOpenIddictAuthorizationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -574,7 +574,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceManager) && service.ServiceType == typeof(IOpenIddictResourceManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -591,7 +591,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeManager) && service.ServiceType == typeof(IOpenIddictScopeManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -608,7 +608,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictSessionManager) && service.ServiceType == typeof(IOpenIddictSessionManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -625,7 +625,7 @@ public class OpenIddictCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenManager) && service.ServiceType == typeof(IOpenIddictTokenManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -640,14 +640,14 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
return services; return services;
} }
private class CustomApplication; private sealed class CustomApplication;
private class CustomAuthorization; private sealed class CustomAuthorization;
private class CustomResource; private sealed class CustomResource;
private class CustomScope; private sealed class CustomScope;
private class CustomSession; private sealed class CustomSession;
private class CustomToken; private sealed class CustomToken;
private class ClosedGenericApplicationManager : OpenIddictApplicationManager<CustomApplication> private sealed class ClosedGenericApplicationManager : OpenIddictApplicationManager<CustomApplication>
{ {
public ClosedGenericApplicationManager( public ClosedGenericApplicationManager(
IOpenIddictApplicationCache<CustomApplication> cache, IOpenIddictApplicationCache<CustomApplication> cache,
@ -659,7 +659,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericApplicationManager<TApplication> : OpenIddictApplicationManager<TApplication> private sealed class OpenGenericApplicationManager<TApplication> : OpenIddictApplicationManager<TApplication>
where TApplication : class where TApplication : class
{ {
public OpenGenericApplicationManager( public OpenGenericApplicationManager(
@ -672,7 +672,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class ClosedGenericAuthorizationManager : OpenIddictAuthorizationManager<CustomAuthorization> private sealed class ClosedGenericAuthorizationManager : OpenIddictAuthorizationManager<CustomAuthorization>
{ {
public ClosedGenericAuthorizationManager( public ClosedGenericAuthorizationManager(
IOpenIddictAuthorizationCache<CustomAuthorization> cache, IOpenIddictAuthorizationCache<CustomAuthorization> cache,
@ -684,7 +684,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericAuthorizationManager<TAuthorization> : OpenIddictAuthorizationManager<TAuthorization> private sealed class OpenGenericAuthorizationManager<TAuthorization> : OpenIddictAuthorizationManager<TAuthorization>
where TAuthorization : class where TAuthorization : class
{ {
public OpenGenericAuthorizationManager( public OpenGenericAuthorizationManager(
@ -697,7 +697,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class ClosedGenericResourceManager : OpenIddictResourceManager<CustomResource> private sealed class ClosedGenericResourceManager : OpenIddictResourceManager<CustomResource>
{ {
public ClosedGenericResourceManager( public ClosedGenericResourceManager(
IOpenIddictResourceCache<CustomResource> cache, IOpenIddictResourceCache<CustomResource> cache,
@ -709,7 +709,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericResourceManager<TResource> : OpenIddictResourceManager<TResource> private sealed class OpenGenericResourceManager<TResource> : OpenIddictResourceManager<TResource>
where TResource : class where TResource : class
{ {
public OpenGenericResourceManager( public OpenGenericResourceManager(
@ -722,7 +722,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class ClosedGenericScopeManager : OpenIddictScopeManager<CustomScope> private sealed class ClosedGenericScopeManager : OpenIddictScopeManager<CustomScope>
{ {
public ClosedGenericScopeManager( public ClosedGenericScopeManager(
IOpenIddictScopeCache<CustomScope> cache, IOpenIddictScopeCache<CustomScope> cache,
@ -734,7 +734,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericScopeManager<TScope> : OpenIddictScopeManager<TScope> private sealed class OpenGenericScopeManager<TScope> : OpenIddictScopeManager<TScope>
where TScope : class where TScope : class
{ {
public OpenGenericScopeManager( public OpenGenericScopeManager(
@ -747,7 +747,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class ClosedGenericSessionManager : OpenIddictSessionManager<CustomSession> private sealed class ClosedGenericSessionManager : OpenIddictSessionManager<CustomSession>
{ {
public ClosedGenericSessionManager( public ClosedGenericSessionManager(
IOpenIddictSessionCache<CustomSession> cache, IOpenIddictSessionCache<CustomSession> cache,
@ -759,7 +759,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericSessionManager<TSession> : OpenIddictSessionManager<TSession> private sealed class OpenGenericSessionManager<TSession> : OpenIddictSessionManager<TSession>
where TSession : class where TSession : class
{ {
public OpenGenericSessionManager( public OpenGenericSessionManager(
@ -772,7 +772,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class ClosedGenericTokenManager : OpenIddictTokenManager<CustomToken> private sealed class ClosedGenericTokenManager : OpenIddictTokenManager<CustomToken>
{ {
public ClosedGenericTokenManager( public ClosedGenericTokenManager(
IOpenIddictTokenCache<CustomToken> cache, IOpenIddictTokenCache<CustomToken> cache,
@ -784,7 +784,7 @@ private static OpenIddictCoreBuilder CreateBuilder(IServiceCollection services)
} }
} }
private class OpenGenericTokenManager<TToken> : OpenIddictTokenManager<TToken> private sealed class OpenGenericTokenManager<TToken> : OpenIddictTokenManager<TToken>
where TToken : class where TToken : class
{ {
public OpenGenericTokenManager( public OpenGenericTokenManager(

2
test/OpenIddict.Core.Tests/OpenIddictCoreConfigurationTests.cs

@ -297,7 +297,7 @@ public class OpenIddictCoreConfigurationTests
// Assert // Assert
Assert.True(result.Succeeded); Assert.True(result.Succeeded);
} }
private class CustomTimeProvider : TimeProvider private sealed class CustomTimeProvider : TimeProvider
{ {
} }
} }

2
test/OpenIddict.Core.Tests/OpenIddictCoreOptionsTests.cs

@ -146,7 +146,7 @@ public class OpenIddictCoreOptionsTests
Assert.Same(customTimeProvider, options.TimeProvider); Assert.Same(customTimeProvider, options.TimeProvider);
} }
private class CustomTimeProvider : TimeProvider private sealed class CustomTimeProvider : TimeProvider
{ {
} }
} }

14
test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs

@ -37,27 +37,27 @@ public class OpenIddictEntityFrameworkBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkApplicationStore<CustomApplication, CustomAuthorization, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkApplicationStore<CustomApplication, CustomAuthorization, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkAuthorizationStore<CustomAuthorization, CustomApplication, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkAuthorizationStore<CustomAuthorization, CustomApplication, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkResourceStore<CustomResource, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkResourceStore<CustomResource, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkScopeStore<CustomScope, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkScopeStore<CustomScope, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) && service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkSessionStore<CustomSession, CustomApplication, CustomAuthorization, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkSessionStore<CustomSession, CustomApplication, CustomAuthorization, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkTokenStore<CustomToken, CustomApplication, CustomAuthorization, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkTokenStore<CustomToken, CustomApplication, CustomAuthorization, long>));
} }
@ -74,7 +74,7 @@ public class OpenIddictEntityFrameworkBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictEntityFrameworkContext) && service.ServiceType == typeof(IOpenIddictEntityFrameworkContext) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkContext<CustomDbContext>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkContext<CustomDbContext>));
} }

20
test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs

@ -49,23 +49,23 @@ public class OpenIddictEntityFrameworkExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationManager) && service.ServiceType == typeof(IOpenIddictApplicationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationManager) && service.ServiceType == typeof(IOpenIddictAuthorizationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceManager) && service.ServiceType == typeof(IOpenIddictResourceManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeManager) && service.ServiceType == typeof(IOpenIddictScopeManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenManager) && service.ServiceType == typeof(IOpenIddictTokenManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -82,23 +82,23 @@ public class OpenIddictEntityFrameworkExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictEntityFrameworkApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictEntityFrameworkApplication>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkApplicationStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkApplicationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictEntityFrameworkAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictEntityFrameworkAuthorization>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkAuthorizationStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkAuthorizationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictEntityFrameworkResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictEntityFrameworkResource>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkResourceStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkResourceStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictEntityFrameworkScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictEntityFrameworkScope>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkScopeStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkScopeStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictEntityFrameworkToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictEntityFrameworkToken>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkTokenStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkTokenStore));
} }

14
test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs

@ -37,27 +37,27 @@ public class OpenIddictEntityFrameworkCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreApplicationStore<CustomApplication, CustomAuthorization, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreApplicationStore<CustomApplication, CustomAuthorization, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreAuthorizationStore<CustomAuthorization, CustomApplication, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreAuthorizationStore<CustomAuthorization, CustomApplication, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreResourceStore<CustomResource, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreResourceStore<CustomResource, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreScopeStore<CustomScope, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreScopeStore<CustomScope, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) && service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreSessionStore<CustomSession, CustomApplication, CustomAuthorization, CustomToken, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreSessionStore<CustomSession, CustomApplication, CustomAuthorization, CustomToken, long>));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreTokenStore<CustomToken, CustomApplication, CustomAuthorization, long>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreTokenStore<CustomToken, CustomApplication, CustomAuthorization, long>));
} }
@ -74,7 +74,7 @@ public class OpenIddictEntityFrameworkCoreBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictEntityFrameworkCoreContext) && service.ServiceType == typeof(IOpenIddictEntityFrameworkCoreContext) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreContext<CustomDbContext>)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreContext<CustomDbContext>));
} }

20
test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs

@ -49,23 +49,23 @@ public class OpenIddictEntityFrameworkCoreExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationManager) && service.ServiceType == typeof(IOpenIddictApplicationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationManager) && service.ServiceType == typeof(IOpenIddictAuthorizationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceManager) && service.ServiceType == typeof(IOpenIddictResourceManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeManager) && service.ServiceType == typeof(IOpenIddictScopeManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenManager) && service.ServiceType == typeof(IOpenIddictTokenManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -82,23 +82,23 @@ public class OpenIddictEntityFrameworkCoreExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictEntityFrameworkCoreApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictEntityFrameworkCoreApplication>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreApplicationStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreApplicationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictEntityFrameworkCoreAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictEntityFrameworkCoreAuthorization>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreAuthorizationStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreAuthorizationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictEntityFrameworkCoreResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictEntityFrameworkCoreResource>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreResourceStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreResourceStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictEntityFrameworkCoreScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictEntityFrameworkCoreScope>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreScopeStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreScopeStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictEntityFrameworkCoreToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictEntityFrameworkCoreToken>) &&
service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreTokenStore)); service.ImplementationType == typeof(OpenIddictEntityFrameworkCoreTokenStore));
} }

12
test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs

@ -39,7 +39,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) &&
service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore<CustomApplication>)); service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore<CustomApplication>));
} }
@ -56,7 +56,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) &&
service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore<CustomAuthorization>)); service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore<CustomAuthorization>));
} }
@ -73,7 +73,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<CustomResource>) &&
service.ImplementationType == typeof(OpenIddictMongoDbResourceStore<CustomResource>)); service.ImplementationType == typeof(OpenIddictMongoDbResourceStore<CustomResource>));
} }
@ -90,7 +90,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) &&
service.ImplementationType == typeof(OpenIddictMongoDbScopeStore<CustomScope>)); service.ImplementationType == typeof(OpenIddictMongoDbScopeStore<CustomScope>));
} }
@ -107,7 +107,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) && service.ServiceType == typeof(IOpenIddictSessionStore<CustomSession>) &&
service.ImplementationType == typeof(OpenIddictMongoDbSessionStore<CustomSession>)); service.ImplementationType == typeof(OpenIddictMongoDbSessionStore<CustomSession>));
} }
@ -124,7 +124,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) &&
service.ImplementationType == typeof(OpenIddictMongoDbTokenStore<CustomToken>)); service.ImplementationType == typeof(OpenIddictMongoDbTokenStore<CustomToken>));
} }

22
test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs

@ -49,23 +49,23 @@ public class OpenIddictMongoDbExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictApplicationManager) && service.ServiceType == typeof(IOpenIddictApplicationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictAuthorizationManager) && service.ServiceType == typeof(IOpenIddictAuthorizationManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictResourceManager) && service.ServiceType == typeof(IOpenIddictResourceManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictScopeManager) && service.ServiceType == typeof(IOpenIddictScopeManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Scoped &&
service.ServiceType == typeof(IOpenIddictTokenManager) && service.ServiceType == typeof(IOpenIddictTokenManager) &&
service.ImplementationFactory is not null); service.ImplementationFactory is not null);
} }
@ -82,23 +82,23 @@ public class OpenIddictMongoDbExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictMongoDbApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<OpenIddictMongoDbApplication>) &&
service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore)); service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictMongoDbAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<OpenIddictMongoDbAuthorization>) &&
service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore)); service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictMongoDbResource>) && service.ServiceType == typeof(IOpenIddictResourceStore<OpenIddictMongoDbResource>) &&
service.ImplementationType == typeof(OpenIddictMongoDbResourceStore)); service.ImplementationType == typeof(OpenIddictMongoDbResourceStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictMongoDbScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<OpenIddictMongoDbScope>) &&
service.ImplementationType == typeof(OpenIddictMongoDbScopeStore)); service.ImplementationType == typeof(OpenIddictMongoDbScopeStore));
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictMongoDbToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<OpenIddictMongoDbToken>) &&
service.ImplementationType == typeof(OpenIddictMongoDbTokenStore)); service.ImplementationType == typeof(OpenIddictMongoDbTokenStore));
} }
@ -115,7 +115,7 @@ public class OpenIddictMongoDbExtensionsTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Singleton && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictMongoDbContext) && service.ServiceType == typeof(IOpenIddictMongoDbContext) &&
service.ImplementationType == typeof(OpenIddictMongoDbContext)); service.ImplementationType == typeof(OpenIddictMongoDbContext));
} }

6
test/OpenIddict.Quartz.Tests/OpenIddictQuartzExtensionsTests.cs

@ -45,7 +45,7 @@ public class OpenIddictQuartzExtensionsTests
// Assert // Assert
Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictQuartzJob) && Assert.Contains(services, service => service.ServiceType == typeof(OpenIddictQuartzJob) &&
service.ImplementationType == typeof(OpenIddictQuartzJob) && service.ImplementationType == typeof(OpenIddictQuartzJob) &&
service.Lifetime == ServiceLifetime.Transient); service.Lifetime is ServiceLifetime.Transient);
} }
[Fact] [Fact]
@ -63,10 +63,10 @@ public class OpenIddictQuartzExtensionsTests
// Assert // Assert
Assert.Single(services, service => service.ServiceType == typeof(OpenIddictQuartzJob) && Assert.Single(services, service => service.ServiceType == typeof(OpenIddictQuartzJob) &&
service.ImplementationType == typeof(OpenIddictQuartzJob) && service.ImplementationType == typeof(OpenIddictQuartzJob) &&
service.Lifetime == ServiceLifetime.Transient); service.Lifetime is ServiceLifetime.Transient);
Assert.Single(services, service => service.ServiceType == typeof(IConfigureOptions<QuartzOptions>) && Assert.Single(services, service => service.ServiceType == typeof(IConfigureOptions<QuartzOptions>) &&
service.ImplementationType == typeof(OpenIddictQuartzConfiguration) && service.ImplementationType == typeof(OpenIddictQuartzConfiguration) &&
service.Lifetime == ServiceLifetime.Singleton); service.Lifetime is ServiceLifetime.Singleton);
} }
} }

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

Loading…
Cancel
Save