From e39c635631918e4316592a8c36a20944e29aede8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sat, 15 Mar 2025 15:59:42 +0100 Subject: [PATCH] Decorate the claim extensions with [OverloadResolutionPriority] and collection expressions for ImmutableArray --- .../Controllers/AuthorizationController.cs | 6 +- .../Controllers/AuthorizationController.cs | 10 +- .../OpenIddictHelpers.cs | 2 +- .../OpenIddictExceptions.cs | 2 +- .../Primitives/OpenIddictExtensions.cs | 104 +++++++++++------- .../Primitives/OpenIddictParameter.cs | 2 +- ...ClientAspNetCoreHandlers.Authentication.cs | 5 +- ...nIddictClientAspNetCoreHandlers.Session.cs | 5 +- .../OpenIddictClientAspNetCoreHandlers.cs | 5 +- ...ClientDataProtectionHandlers.Protection.cs | 5 +- .../OpenIddictClientDataProtectionHandlers.cs | 3 +- ...IddictClientOwinHandlers.Authentication.cs | 5 +- .../OpenIddictClientOwinHandlers.Session.cs | 5 +- .../OpenIddictClientOwinHandlers.cs | 5 +- ...ystemIntegrationHandlers.Authentication.cs | 5 +- ...ClientSystemIntegrationHandlers.Session.cs | 5 +- ...enIddictClientSystemIntegrationHandlers.cs | 5 +- ...ientSystemNetHttpHandlers.Authorization.cs | 5 +- ...ddictClientSystemNetHttpHandlers.Device.cs | 5 +- ...ctClientSystemNetHttpHandlers.Discovery.cs | 5 +- ...ictClientSystemNetHttpHandlers.Exchange.cs | 5 +- ...ientSystemNetHttpHandlers.Introspection.cs | 5 +- ...tClientSystemNetHttpHandlers.Revocation.cs | 5 +- ...ictClientSystemNetHttpHandlers.Userinfo.cs | 5 +- .../OpenIddictClientSystemNetHttpHandlers.cs | 5 +- ...ntWebIntegrationHandlers.Authentication.cs | 5 +- ...dictClientWebIntegrationHandlers.Device.cs | 5 +- ...tClientWebIntegrationHandlers.Discovery.cs | 5 +- ...ctClientWebIntegrationHandlers.Exchange.cs | 5 +- ...ClientWebIntegrationHandlers.Protection.cs | 5 +- ...ClientWebIntegrationHandlers.Revocation.cs | 5 +- ...ctClientWebIntegrationHandlers.Userinfo.cs | 5 +- .../OpenIddictClientWebIntegrationHandlers.cs | 5 +- .../OpenIddictClientHandlerDescriptor.cs | 9 +- ...OpenIddictClientHandlers.Authentication.cs | 5 +- .../OpenIddictClientHandlers.Device.cs | 5 +- .../OpenIddictClientHandlers.Discovery.cs | 5 +- .../OpenIddictClientHandlers.Exchange.cs | 5 +- .../OpenIddictClientHandlers.Introspection.cs | 14 +-- .../OpenIddictClientHandlers.Protection.cs | 7 +- .../OpenIddictClientHandlers.Revocation.cs | 5 +- .../OpenIddictClientHandlers.Session.cs | 5 +- .../OpenIddictClientHandlers.Userinfo.cs | 5 +- .../OpenIddictClientHandlers.cs | 7 +- .../OpenIddictClientService.cs | 4 +- .../Managers/OpenIddictApplicationManager.cs | 8 +- .../OpenIddictAuthorizationManager.cs | 2 +- .../Managers/OpenIddictScopeManager.cs | 2 +- ...enIddictEntityFrameworkApplicationStore.cs | 8 +- ...IddictEntityFrameworkAuthorizationStore.cs | 2 +- .../OpenIddictEntityFrameworkScopeStore.cs | 2 +- ...dictEntityFrameworkCoreApplicationStore.cs | 8 +- ...ctEntityFrameworkCoreAuthorizationStore.cs | 2 +- ...OpenIddictEntityFrameworkCoreScopeStore.cs | 2 +- .../OpenIddictMongoDbApplication.cs | 8 +- .../OpenIddictMongoDbAuthorization.cs | 2 +- .../OpenIddictMongoDbScope.cs | 2 +- ...enIddictMongoDbApplicationStoreResolver.cs | 2 +- ...IddictMongoDbAuthorizationStoreResolver.cs | 2 +- .../OpenIddictMongoDbScopeStoreResolver.cs | 2 +- .../OpenIddictMongoDbTokenStoreResolver.cs | 2 +- .../OpenIddictMongoDbApplicationStore.cs | 16 +-- .../OpenIddictMongoDbAuthorizationStore.cs | 4 +- .../Stores/OpenIddictMongoDbScopeStore.cs | 4 +- ...ServerAspNetCoreHandlers.Authentication.cs | 5 +- ...enIddictServerAspNetCoreHandlers.Device.cs | 5 +- ...ddictServerAspNetCoreHandlers.Discovery.cs | 5 +- ...IddictServerAspNetCoreHandlers.Exchange.cs | 5 +- ...tServerAspNetCoreHandlers.Introspection.cs | 5 +- ...dictServerAspNetCoreHandlers.Revocation.cs | 5 +- ...nIddictServerAspNetCoreHandlers.Session.cs | 5 +- ...IddictServerAspNetCoreHandlers.Userinfo.cs | 5 +- .../OpenIddictServerAspNetCoreHandlers.cs | 5 +- ...ServerDataProtectionHandlers.Protection.cs | 5 +- .../OpenIddictServerDataProtectionHandlers.cs | 3 +- ...IddictServerOwinHandlers.Authentication.cs | 5 +- .../OpenIddictServerOwinHandlers.Device.cs | 5 +- .../OpenIddictServerOwinHandlers.Discovery.cs | 5 +- .../OpenIddictServerOwinHandlers.Exchange.cs | 5 +- ...nIddictServerOwinHandlers.Introspection.cs | 5 +- ...OpenIddictServerOwinHandlers.Revocation.cs | 5 +- .../OpenIddictServerOwinHandlers.Session.cs | 5 +- .../OpenIddictServerOwinHandlers.Userinfo.cs | 5 +- .../OpenIddictServerOwinHandlers.cs | 5 +- .../OpenIddictServerHandlerDescriptor.cs | 7 +- ...OpenIddictServerHandlers.Authentication.cs | 9 +- .../OpenIddictServerHandlers.Device.cs | 7 +- .../OpenIddictServerHandlers.Discovery.cs | 5 +- .../OpenIddictServerHandlers.Exchange.cs | 7 +- .../OpenIddictServerHandlers.Introspection.cs | 5 +- .../OpenIddictServerHandlers.Protection.cs | 7 +- .../OpenIddictServerHandlers.Revocation.cs | 5 +- .../OpenIddictServerHandlers.Session.cs | 5 +- .../OpenIddictServerHandlers.Userinfo.cs | 5 +- .../OpenIddictServerHandlers.cs | 5 +- .../OpenIddictValidationAspNetCoreHandlers.cs | 5 +- ...dationDataProtectionHandlers.Protection.cs | 5 +- ...nIddictValidationDataProtectionHandlers.cs | 3 +- .../OpenIddictValidationOwinHandlers.cs | 5 +- ...lidationSystemNetHttpHandlers.Discovery.cs | 5 +- ...tionSystemNetHttpHandlers.Introspection.cs | 5 +- ...enIddictValidationSystemNetHttpHandlers.cs | 5 +- .../OpenIddictValidationHandlerDescriptor.cs | 9 +- .../OpenIddictValidationHandlers.Discovery.cs | 5 +- ...nIddictValidationHandlers.Introspection.cs | 14 +-- ...OpenIddictValidationHandlers.Protection.cs | 7 +- .../OpenIddictValidationHandlers.cs | 5 +- .../Primitives/OpenIddictExtensionsTests.cs | 58 +++++----- .../Primitives/OpenIddictMessageTests.cs | 4 +- .../Primitives/OpenIddictParameterTests.cs | 36 +++--- .../OpenIddictQuartzBuilderTests.cs | 2 +- ...nIddictServerAspNetCoreIntegrationTests.cs | 8 +- ...ctServerIntegrationTests.Authentication.cs | 24 ++-- ...OpenIddictServerIntegrationTests.Device.cs | 6 +- ...nIddictServerIntegrationTests.Discovery.cs | 34 +++--- ...enIddictServerIntegrationTests.Exchange.cs | 12 +- ...ictServerIntegrationTests.Introspection.cs | 4 +- ...IddictServerIntegrationTests.Protection.cs | 14 +-- ...IddictServerIntegrationTests.Revocation.cs | 2 +- ...penIddictServerIntegrationTests.Session.cs | 6 +- ...enIddictServerIntegrationTests.Userinfo.cs | 4 +- .../OpenIddictServerIntegrationTests.cs | 8 +- .../OpenIddictServerOwinIntegrationTests.cs | 4 +- 123 files changed, 486 insertions(+), 393 deletions(-) diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs b/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs index 7244449f..30ce56ff 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs @@ -156,7 +156,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, user.Email) .SetClaim(Claims.Name, user.UserName) .SetClaim(Claims.PreferredUsername, user.UserName) - .SetClaims(Claims.Role, (await context.Get().GetRolesAsync(user.Id)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await context.Get().GetRolesAsync(user.Id)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -280,7 +280,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, user.Email) .SetClaim(Claims.Name, user.UserName) .SetClaim(Claims.PreferredUsername, user.UserName) - .SetClaims(Claims.Role, (await context.Get().GetRolesAsync(user.Id)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await context.Get().GetRolesAsync(user.Id)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -400,7 +400,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, user.Email) .SetClaim(Claims.Name, user.UserName) .SetClaim(Claims.PreferredUsername, user.UserName) - .SetClaims(Claims.Role, (await context.Get().GetRolesAsync(user.Id)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await context.Get().GetRolesAsync(user.Id)]); identity.SetDestinations(GetDestinations); diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs index 9bc8de93..48be99da 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs @@ -190,7 +190,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, await _userManager.GetEmailAsync(user)) .SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user)) .SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user)) - .SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -289,7 +289,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, await _userManager.GetEmailAsync(user)) .SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user)) .SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user)) - .SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -381,7 +381,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, await _userManager.GetEmailAsync(user)) .SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user)) .SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user)) - .SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -496,7 +496,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, await _userManager.GetEmailAsync(user)) .SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user)) .SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user)) - .SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]); // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. @@ -550,7 +550,7 @@ public class AuthorizationController : Controller .SetClaim(Claims.Email, await _userManager.GetEmailAsync(user)) .SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user)) .SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user)) - .SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray()); + .SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]); identity.SetDestinations(GetDestinations); diff --git a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs index ef6902e1..cc23d160 100644 --- a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs +++ b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs @@ -1128,7 +1128,7 @@ internal static class OpenIddictHelpers private readonly TextReader _reader; private readonly char[] _buffer; - private readonly StringBuilder _builder = new StringBuilder(); + private readonly StringBuilder _builder = new(); private int _bufferOffset; private int _bufferCount; private string? _currentKey; diff --git a/src/OpenIddict.Abstractions/OpenIddictExceptions.cs b/src/OpenIddict.Abstractions/OpenIddictExceptions.cs index 5273f53f..6e65c16b 100644 --- a/src/OpenIddict.Abstractions/OpenIddictExceptions.cs +++ b/src/OpenIddict.Abstractions/OpenIddictExceptions.cs @@ -109,7 +109,7 @@ public static class OpenIddictExceptions /// /// The exception message. public ValidationException(string? message) - : this(message, ImmutableArray.Empty) + : this(message, []) { } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs index 1f983d21..ccc8a217 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs @@ -7,6 +7,7 @@ using System.Collections.Immutable; using System.Diagnostics; using System.Globalization; +using System.Runtime.CompilerServices; using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; @@ -510,7 +511,7 @@ public static class OpenIddictExtensions if (string.IsNullOrEmpty(destinations)) { - return ImmutableArray.Empty; + return []; } using var document = JsonDocument.Parse(destinations); @@ -573,6 +574,7 @@ public static class OpenIddictExtensions /// /// The instance. /// The destinations. + [OverloadResolutionPriority(0)] public static Claim SetDestinations(this Claim claim, ImmutableArray destinations) { if (claim is null) @@ -619,16 +621,18 @@ public static class OpenIddictExtensions /// /// The instance. /// The destinations. - public static Claim SetDestinations(this Claim claim, IEnumerable? destinations) - => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static Claim SetDestinations(this Claim claim, params string[]? destinations) + => claim.SetDestinations([.. destinations ?? []]); /// /// Adds specific destinations to a claim. /// /// The instance. /// The destinations. - public static Claim SetDestinations(this Claim claim, params string[]? destinations) - => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static Claim SetDestinations(this Claim claim, IEnumerable? destinations) + => claim.SetDestinations([.. destinations ?? []]); /// /// Gets the destinations associated with all the claims of the given identity. @@ -2923,6 +2927,7 @@ public static class OpenIddictExtensions /// The claims identity. /// The audiences to store. /// The claims identity. + [OverloadResolutionPriority(0)] public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, ImmutableArray audiences) => identity.SetClaims(Claims.Private.Audience, audiences); @@ -2933,6 +2938,7 @@ public static class OpenIddictExtensions /// The claims principal. /// The audiences to store. /// The claims principal. + [OverloadResolutionPriority(0)] public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray audiences) => principal.SetClaims(Claims.Private.Audience, audiences); @@ -2943,8 +2949,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The audiences to store. /// The claims identity. - public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, IEnumerable? audiences) - => identity.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, params string[]? audiences) + => identity.SetAudiences([.. audiences ?? []]); /// /// Sets the audiences list in the claims principal. @@ -2953,8 +2960,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The audiences to store. /// The claims principal. - public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable? audiences) - => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences) + => principal.SetAudiences([.. audiences ?? []]); /// /// Sets the audiences list in the claims identity. @@ -2963,8 +2971,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The audiences to store. /// The claims identity. - public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, params string[]? audiences) - => identity.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, IEnumerable? audiences) + => identity.SetAudiences([.. audiences ?? []]); /// /// Sets the audiences list in the claims principal. @@ -2973,8 +2982,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The audiences to store. /// The claims principal. - public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences) - => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable? audiences) + => principal.SetAudiences([.. audiences ?? []]); /// /// Sets the presenters list in the claims identity. @@ -2983,6 +2993,7 @@ public static class OpenIddictExtensions /// The claims identity. /// The presenters to store. /// The claims identity. + [OverloadResolutionPriority(0)] public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, ImmutableArray presenters) => identity.SetClaims(Claims.Private.Presenter, presenters); @@ -2993,6 +3004,7 @@ public static class OpenIddictExtensions /// The claims principal. /// The presenters to store. /// The claims principal. + [OverloadResolutionPriority(0)] public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray presenters) => principal.SetClaims(Claims.Private.Presenter, presenters); @@ -3003,8 +3015,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The presenters to store. /// The claims identity. - public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, IEnumerable? presenters) - => identity.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, params string[]? presenters) + => identity.SetPresenters([.. presenters ?? []]); /// /// Sets the presenters list in the claims principal. @@ -3013,8 +3026,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The presenters to store. /// The claims principal. - public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable? presenters) - => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters) + => principal.SetPresenters([.. presenters ?? []]); /// /// Sets the presenters list in the claims identity. @@ -3023,8 +3037,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The presenters to store. /// The claims identity. - public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, params string[]? presenters) - => identity.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, IEnumerable? presenters) + => identity.SetPresenters([.. presenters ?? []]); /// /// Sets the presenters list in the claims principal. @@ -3033,8 +3048,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The presenters to store. /// The claims principal. - public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters) - => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable? presenters) + => principal.SetPresenters([.. presenters ?? []]); /// /// Sets the resources list in the claims identity. @@ -3043,6 +3059,7 @@ public static class OpenIddictExtensions /// The claims identity. /// The resources to store. /// The claims identity. + [OverloadResolutionPriority(0)] public static ClaimsIdentity SetResources(this ClaimsIdentity identity, ImmutableArray resources) => identity.SetClaims(Claims.Private.Resource, resources); @@ -3053,6 +3070,7 @@ public static class OpenIddictExtensions /// The claims principal. /// The resources to store. /// The claims principal. + [OverloadResolutionPriority(0)] public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray resources) => principal.SetClaims(Claims.Private.Resource, resources); @@ -3063,8 +3081,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The resources to store. /// The claims identity. - public static ClaimsIdentity SetResources(this ClaimsIdentity identity, IEnumerable? resources) - => identity.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsIdentity SetResources(this ClaimsIdentity identity, params string[]? resources) + => identity.SetResources([.. resources ?? []]); /// /// Sets the resources list in the claims principal. @@ -3073,8 +3092,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The resources to store. /// The claims principal. - public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable? resources) - => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources) + => principal.SetResources([.. resources ?? []]); /// /// Sets the resources list in the claims identity. @@ -3083,8 +3103,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The resources to store. /// The claims identity. - public static ClaimsIdentity SetResources(this ClaimsIdentity identity, params string[]? resources) - => identity.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsIdentity SetResources(this ClaimsIdentity identity, IEnumerable? resources) + => identity.SetResources([.. resources ?? []]); /// /// Sets the resources list in the claims principal. @@ -3093,8 +3114,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The resources to store. /// The claims principal. - public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources) - => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable? resources) + => principal.SetResources([.. resources ?? []]); /// /// Sets the scopes list in the claims identity. @@ -3103,6 +3125,7 @@ public static class OpenIddictExtensions /// The claims identity. /// The scopes to store. /// The claims identity. + [OverloadResolutionPriority(0)] public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, ImmutableArray scopes) => identity.SetClaims(Claims.Private.Scope, scopes); @@ -3113,6 +3136,7 @@ public static class OpenIddictExtensions /// The claims principal. /// The scopes to store. /// The claims principal. + [OverloadResolutionPriority(0)] public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray scopes) => principal.SetClaims(Claims.Private.Scope, scopes); @@ -3123,8 +3147,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The scopes to store. /// The claims identity. - public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, IEnumerable? scopes) - => identity.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, params string[]? scopes) + => identity.SetScopes([.. scopes ?? []]); /// /// Sets the scopes list in the claims principal. @@ -3133,8 +3158,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The scopes to store. /// The claims principal. - public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable? scopes) - => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-1)] + public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes) + => principal.SetScopes([.. scopes ?? []]); /// /// Sets the scopes list in the claims identity. @@ -3143,8 +3169,9 @@ public static class OpenIddictExtensions /// The claims identity. /// The scopes to store. /// The claims identity. - public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, params string[]? scopes) - => identity.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, IEnumerable? scopes) + => identity.SetScopes([.. scopes ?? []]); /// /// Sets the scopes list in the claims principal. @@ -3153,8 +3180,9 @@ public static class OpenIddictExtensions /// The claims principal. /// The scopes to store. /// The claims principal. - public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes) - => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Empty); + [OverloadResolutionPriority(-2)] + public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable? scopes) + => principal.SetScopes([.. scopes ?? []]); /// /// Sets the access token lifetime associated with the claims identity. @@ -3342,7 +3370,7 @@ public static class OpenIddictExtensions if (string.IsNullOrEmpty(source)) { - return ImmutableArray.Empty; + return []; } var builder = ImmutableArray.CreateBuilder(); diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs index 0caf8ef5..5c27e9d3 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs @@ -528,7 +528,7 @@ public readonly struct OpenIddictParameter : IEquatable is JsonElement { ValueKind: JsonValueKind.Array } element => GetParametersFromJsonElement(element), - _ => ImmutableList.Create() + _ => [] }; static IReadOnlyList GetParametersFromArray(string?[] array) diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs index b407d2fd..0187420f 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs @@ -14,7 +14,8 @@ public static partial class OpenIddictClientAspNetCoreHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request processing: */ @@ -38,7 +39,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers ProcessPassthroughErrorResponse.Descriptor, ProcessStatusCodePagesErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for processing authorization requests using 302 redirects. diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs index a42b052f..2e974751 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs @@ -14,7 +14,8 @@ public static partial class OpenIddictClientAspNetCoreHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End session request processing: */ @@ -38,7 +39,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers ProcessPassthroughErrorResponse.Descriptor, ProcessStatusCodePagesErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for processing end session requests using 302 redirects. diff --git a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs index cc84deb2..e8c88f23 100644 --- a/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs +++ b/src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs @@ -27,7 +27,8 @@ namespace OpenIddict.Client.AspNetCore; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientAspNetCoreHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -72,7 +73,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers .. Authentication.DefaultHandlers, .. Session.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment. diff --git a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs index d2600e04..26d3cdc0 100644 --- a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs +++ b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictClientDataProtectionHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ @@ -32,7 +33,7 @@ public static partial class OpenIddictClientDataProtectionHandlers */ OverrideGeneratedTokenFormat.Descriptor, GenerateDataProtectionToken.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating tokens generated using Data Protection. diff --git a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs index 608da23f..93c06fa5 100644 --- a/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs +++ b/src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs @@ -12,6 +12,5 @@ namespace OpenIddict.Client.DataProtection; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientDataProtectionHandlers { - public static ImmutableArray DefaultHandlers { get; } - = ImmutableArray.Create([.. Protection.DefaultHandlers]); + public static ImmutableArray DefaultHandlers { get; } = [.. Protection.DefaultHandlers]; } diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs index b4383490..f0fb8953 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs @@ -13,7 +13,8 @@ public static partial class OpenIddictClientOwinHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request processing: */ @@ -38,7 +39,7 @@ public static partial class OpenIddictClientOwinHandlers AttachCacheControlHeader.Descriptor, ProcessPassthroughErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for processing authorization requests using 302 redirects. diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs index 3b764f02..4447af9b 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs @@ -13,7 +13,8 @@ public static partial class OpenIddictClientOwinHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End session request processing: */ @@ -36,7 +37,7 @@ public static partial class OpenIddictClientOwinHandlers AttachCacheControlHeader.Descriptor, ProcessPassthroughErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for processing end session requests using 302 redirects. diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs index b7821699..19f327e2 100644 --- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs +++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs @@ -25,7 +25,8 @@ namespace OpenIddict.Client.Owin; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientOwinHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -69,7 +70,7 @@ public static partial class OpenIddictClientOwinHandlers .. Authentication.DefaultHandlers, .. Session.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the OWIN environment. diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs index ee71bd28..a194a34a 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs @@ -43,7 +43,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request processing: */ @@ -67,7 +68,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers ProcessEmptyHttpResponse.Descriptor, ProcessProtocolActivationResponse.Descriptor, ProcessPlatformCallbackResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for initiating authorization requests using an AS web authentication session. diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs index 47ef9ee7..052c32d6 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs @@ -43,7 +43,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End session request processing: */ @@ -67,7 +68,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers ProcessEmptyHttpResponse.Descriptor, ProcessProtocolActivationResponse.Descriptor, ProcessPlatformCallbackResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for initiating end session requests using an AS web authentication session. diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs index 48141587..9ed00b50 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs @@ -24,7 +24,8 @@ namespace OpenIddict.Client.SystemIntegration; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientSystemIntegrationHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -86,7 +87,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers .. Authentication.DefaultHandlers, .. Session.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the HTTP listener request. diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs index 2b447bd1..40232674 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Authorization { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Pushed authorization request processing: */ @@ -35,6 +36,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs index 8b594e3e..7cf61663 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device authorization request processing: */ @@ -35,6 +36,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs index e4f6bc23..3c1bd118 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration request processing: */ @@ -56,6 +57,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs index bc024fd8..6f53cdc9 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token request processing: */ @@ -39,6 +40,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs index f9f45e45..c9064590 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection request processing: */ @@ -39,6 +40,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs index 169543d2..b43ab26d 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation request processing: */ @@ -40,6 +41,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractEmptyHttpResponse.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs index 7a3a6cdd..8cf46d54 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo request processing: */ @@ -40,7 +41,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for attaching the access token to the HTTP Authorization header. diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs index 5bbeccc3..da2fec76 100644 --- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs @@ -25,7 +25,8 @@ namespace OpenIddict.Client.SystemNetHttp; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientSystemNetHttpHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authentication processing: */ @@ -54,7 +55,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers .. Introspection.DefaultHandlers, .. Revocation.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for negotiating the best token endpoint client diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs index 624c831c..50be0cbf 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs @@ -13,12 +13,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request preparation: */ MapNonStandardRequestParameters.Descriptor - ]); + ]; /// /// Contains the logic responsible for mapping non-standard request parameters diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs index 9a700d08..21101060 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs @@ -15,12 +15,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device authorization response extraction: */ MapNonStandardResponseParameters.Descriptor - ]); + ]; /// /// Contains the logic responsible for mapping non-standard response parameters diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs index ec803484..449e11c1 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs @@ -15,7 +15,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration response handling: */ @@ -25,7 +26,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers AmendScopes.Descriptor, AmendClientAuthenticationMethods.Descriptor, AmendEndpoints.Descriptor - ]); + ]; /// /// Contains the logic responsible for amending the issuer for the providers that require it. diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs index a8c9211f..ae355c89 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs @@ -24,7 +24,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token request preparation: */ @@ -38,7 +39,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers * Token response extraction: */ MapNonStandardResponseParameters.Descriptor - ]); + ]; /// /// Contains the logic responsible for mapping non-standard request parameters diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs index 95f5f51a..3f09df24 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs @@ -14,12 +14,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ AmendTokenValidationParameters.Descriptor - ]); + ]; /// /// Contains the logic responsible for amending the token validation parameters for the providers that require it. diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs index e504d4f3..219d087f 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs @@ -17,7 +17,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation request preparation: */ @@ -29,7 +30,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers * Revocation response extraction: */ NormalizeContentType.Descriptor - ]); + ]; /// /// Contains the logic responsible for mapping non-standard request parameters diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs index 9ba1ce40..8ec89168 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo request preparation: */ @@ -37,7 +38,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers NormalizeContentType.Descriptor, UnwrapUserInfoResponse.Descriptor, MapNonStandardResponseParameters.Descriptor, - ]); + ]; /// /// Contains the logic responsible for overriding the HTTP method for the providers that require it. diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs index c9d73c50..df37a9bb 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs @@ -18,7 +18,8 @@ namespace OpenIddict.Client.WebIntegration; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientWebIntegrationHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authentication processing: */ @@ -64,7 +65,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers .. Protection.DefaultHandlers, .. Revocation.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for validating the signature or message authentication diff --git a/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs b/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs index fff7022a..d6c52053 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs @@ -31,7 +31,7 @@ public sealed class OpenIddictClientHandlerDescriptor /// Gets the list of filters responsible for excluding the handler /// from the activated handlers if it doesn't meet the criteria. /// - public ImmutableArray FilterTypes { get; private set; } = ImmutableArray.Empty; + public ImmutableArray FilterTypes { get; private set; } = []; /// /// Gets the order assigned to the handler. @@ -53,8 +53,7 @@ public sealed class OpenIddictClientHandlerDescriptor /// /// The event context type. /// A new descriptor builder. - public static Builder CreateBuilder() where TContext : BaseContext - => new Builder(); + public static Builder CreateBuilder() where TContext : BaseContext => new(); /// /// Contains methods allowing to build a descriptor instance. @@ -269,10 +268,10 @@ public sealed class OpenIddictClientHandlerDescriptor /// Build a new descriptor instance, based on the parameters that were previously set. /// /// The builder instance, so that calls can be easily chained. - public OpenIddictClientHandlerDescriptor Build() => new OpenIddictClientHandlerDescriptor + public OpenIddictClientHandlerDescriptor Build() => new() { ContextType = typeof(TContext), - FilterTypes = _filters.ToImmutableArray(), + FilterTypes = [.. _filters], Order = _order, ServiceDescriptor = _descriptor ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0105)), Type = _type diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs index 1cc346d6..8bedc3e2 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs @@ -15,7 +15,8 @@ public static partial class OpenIddictClientHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request top-level processing: */ @@ -53,7 +54,7 @@ public static partial class OpenIddictClientHandlers * Redirection request validation: */ ValidateTokens.Descriptor - ]); + ]; /// /// Contains the logic responsible for preparing authorization requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs index bc241523..367a9285 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs @@ -15,7 +15,8 @@ public static partial class OpenIddictClientHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device authorization response handling: */ @@ -23,7 +24,7 @@ public static partial class OpenIddictClientHandlers HandleErrorResponse.Descriptor, ValidateVerificationEndpointUri.Descriptor, ValidateExpiration.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the device authorization response. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs index 3bf29d14..a3e61f78 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs @@ -17,7 +17,8 @@ public static partial class OpenIddictClientHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration response handling: */ @@ -59,7 +60,7 @@ public static partial class OpenIddictClientHandlers ValidateWellKnownJsonWebKeySetParameters.Descriptor, HandleJsonWebKeySetErrorResponse.Descriptor, ExtractSigningKeys.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the configuration response. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs index aee20ab4..623ee907 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs @@ -14,13 +14,14 @@ public static partial class OpenIddictClientHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token response handling: */ ValidateWellKnownParameters.Descriptor, HandleErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the token response. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs index f5f0c2c1..3533d6b8 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs @@ -18,7 +18,8 @@ public static partial class OpenIddictClientHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection response handling: */ @@ -30,7 +31,7 @@ public static partial class OpenIddictClientHandlers ValidateTokenUsage.Descriptor, PopulateClaims.Descriptor, MapInternalClaims.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the introspection response. @@ -504,18 +505,17 @@ public static partial class OpenIddictClientHandlers // Map the internal "oi_prst" claims from the standard "client_id" claim, if available. context.Principal.SetPresenters(context.Principal.GetClaim(Claims.ClientId) switch { - string identifier when !string.IsNullOrEmpty(identifier) - => ImmutableArray.Create(identifier), + string identifier when !string.IsNullOrEmpty(identifier) => [identifier], - _ => ImmutableArray.Empty + _ => [] }); // Map the internal "oi_scp" claims from the standard, space-separated "scope" claim, if available. context.Principal.SetScopes(context.Principal.GetClaim(Claims.Scope) switch { - string scope => scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries).ToImmutableArray(), + string scope => [.. scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries)], - _ => ImmutableArray.Empty + _ => [] }); return default; diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs index b008be37..1d96367f 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs @@ -19,7 +19,8 @@ public static partial class OpenIddictClientHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ @@ -40,7 +41,7 @@ public static partial class OpenIddictClientHandlers CreateTokenEntry.Descriptor, GenerateIdentityModelToken.Descriptor, AttachTokenPayload.Descriptor - ]); + ]; /// /// Contains the logic responsible for resolving the validation parameters used to validate tokens. @@ -287,7 +288,7 @@ public static partial class OpenIddictClientHandlers { 0 => true, // If no specific token type is expected, accept all token types at this stage. 1 => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ElementAt(0)), - _ => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ToImmutableArray()) + _ => await _tokenManager.HasTypeAsync(token, [.. context.ValidTokenTypes]) })) { context.Reject( diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs index 05dcbf05..2decd155 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs @@ -14,13 +14,14 @@ public static partial class OpenIddictClientHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation response handling: */ ValidateWellKnownParameters.Descriptor, HandleErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the revocation response. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs index a0e4016c..b1809ca3 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs @@ -14,7 +14,8 @@ public static partial class OpenIddictClientHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * EndSession request top-level processing: */ @@ -39,7 +40,7 @@ public static partial class OpenIddictClientHandlers * Post-logout redirection request validation: */ ValidateTokens.Descriptor - ]); + ]; /// /// Contains the logic responsible for preparing authorization requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs index e974aaf5..305130a3 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs @@ -16,14 +16,15 @@ public static partial class OpenIddictClientHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo response handling: */ ValidateWellKnownParameters.Descriptor, HandleErrorResponse.Descriptor, PopulateClaims.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the userinfo response. diff --git a/src/OpenIddict.Client/OpenIddictClientHandlers.cs b/src/OpenIddict.Client/OpenIddictClientHandlers.cs index 00d1e606..95b42782 100644 --- a/src/OpenIddict.Client/OpenIddictClientHandlers.cs +++ b/src/OpenIddict.Client/OpenIddictClientHandlers.cs @@ -23,7 +23,8 @@ namespace OpenIddict.Client; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictClientHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -217,7 +218,7 @@ public static partial class OpenIddictClientHandlers .. Revocation.DefaultHandlers, .. Session.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for inferring the endpoint type from the request URI. @@ -5385,7 +5386,7 @@ public static partial class OpenIddictClientHandlers principal.SetClaim(Claims.Private.Nonce, context.Nonce); // Store the requested scopes in the state token. - principal.SetClaims(Claims.Private.Scope, context.Scopes.ToImmutableArray()); + principal.SetClaims(Claims.Private.Scope, [.. context.Scopes]); context.StateTokenPrincipal = principal; diff --git a/src/OpenIddict.Client/OpenIddictClientService.cs b/src/OpenIddict.Client/OpenIddictClientService.cs index 7a7ca810..d0ebfcaf 100644 --- a/src/OpenIddict.Client/OpenIddictClientService.cs +++ b/src/OpenIddict.Client/OpenIddictClientService.cs @@ -48,8 +48,8 @@ public class OpenIddictClientService var options = _provider.GetRequiredService>(); return new(options.CurrentValue.Registrations switch { - [ ] => ImmutableArray.Empty, - [..] registrations => registrations.ToImmutableArray() + [ ] => [], + [..] registrations => [.. registrations] }); } diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs index 5dda3db0..0a3a89c1 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs @@ -1025,12 +1025,10 @@ public class OpenIddictApplicationManager : IOpenIddictApplication await Store.SetDisplayNamesAsync(application, descriptor.DisplayNames.ToImmutableDictionary(), cancellationToken); await Store.SetJsonWebKeySetAsync(application, descriptor.JsonWebKeySet, cancellationToken); await Store.SetPermissionsAsync(application, descriptor.Permissions.ToImmutableArray(), cancellationToken); - await Store.SetPostLogoutRedirectUrisAsync(application, - descriptor.PostLogoutRedirectUris.Select(uri => uri.OriginalString).ToImmutableArray(), cancellationToken); + await Store.SetPostLogoutRedirectUrisAsync(application, [.. descriptor.PostLogoutRedirectUris.Select(uri => uri.OriginalString)], cancellationToken); await Store.SetPropertiesAsync(application, descriptor.Properties.ToImmutableDictionary(), cancellationToken); - await Store.SetRedirectUrisAsync(application, - descriptor.RedirectUris.Select(uri => uri.OriginalString).ToImmutableArray(), cancellationToken); - await Store.SetRequirementsAsync(application, descriptor.Requirements.ToImmutableArray(), cancellationToken); + await Store.SetRedirectUrisAsync(application, [.. descriptor.RedirectUris.Select(uri => uri.OriginalString)], cancellationToken); + await Store.SetRequirementsAsync(application, [.. descriptor.Requirements], cancellationToken); await Store.SetSettingsAsync(application, descriptor.Settings.ToImmutableDictionary(), cancellationToken); } diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs index 6288ba30..0989dda1 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs @@ -781,7 +781,7 @@ public class OpenIddictAuthorizationManager : IOpenIddictAuthori await Store.SetApplicationIdAsync(authorization, descriptor.ApplicationId, cancellationToken); await Store.SetCreationDateAsync(authorization, descriptor.CreationDate, cancellationToken); await Store.SetPropertiesAsync(authorization, descriptor.Properties.ToImmutableDictionary(), cancellationToken); - await Store.SetScopesAsync(authorization, descriptor.Scopes.ToImmutableArray(), cancellationToken); + await Store.SetScopesAsync(authorization, [.. descriptor.Scopes], cancellationToken); await Store.SetStatusAsync(authorization, descriptor.Status, cancellationToken); await Store.SetSubjectAsync(authorization, descriptor.Subject, cancellationToken); await Store.SetTypeAsync(authorization, descriptor.Type, cancellationToken); diff --git a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs index 072fb5e2..c222d1ec 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs @@ -783,7 +783,7 @@ public class OpenIddictScopeManager : IOpenIddictScopeManager where TSco await Store.SetDisplayNamesAsync(scope, descriptor.DisplayNames.ToImmutableDictionary(), cancellationToken); await Store.SetNameAsync(scope, descriptor.Name, cancellationToken); await Store.SetPropertiesAsync(scope, descriptor.Properties.ToImmutableDictionary(), cancellationToken); - await Store.SetResourcesAsync(scope, descriptor.Resources.ToImmutableArray(), cancellationToken); + await Store.SetResourcesAsync(scope, [.. descriptor.Resources], cancellationToken); } /// diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs index 392ef6e5..6e127fac 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs @@ -475,7 +475,7 @@ public class OpenIddictEntityFrameworkApplicationStore.Empty); + return new([]); } // Note: parsing the stringified permissions is an expensive operation. @@ -516,7 +516,7 @@ public class OpenIddictEntityFrameworkApplicationStore.Empty); + return new([]); } // Note: parsing the stringified URIs is an expensive operation. @@ -592,7 +592,7 @@ public class OpenIddictEntityFrameworkApplicationStore.Empty); + return new([]); } // Note: parsing the stringified URIs is an expensive operation. @@ -633,7 +633,7 @@ public class OpenIddictEntityFrameworkApplicationStore.Empty); + return new([]); } // Note: parsing the stringified requirements is an expensive operation. diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs index 34f970b8..bfada819 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs @@ -377,7 +377,7 @@ public class OpenIddictEntityFrameworkAuthorizationStore.Empty); + return new([]); } // Note: parsing the stringified scopes is an expensive operation. diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs index a81c2e3d..dc1bcbc2 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs @@ -407,7 +407,7 @@ public class OpenIddictEntityFrameworkScopeStore : IOpen if (string.IsNullOrEmpty(scope.Resources)) { - return new(ImmutableArray.Empty); + return new([]); } // Note: parsing the stringified resources is an expensive operation. diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs index 756d4af1..7ed453eb 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs @@ -558,7 +558,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore.Empty); + return new([]); } // Note: parsing the stringified permissions is an expensive operation. @@ -599,7 +599,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore.Empty); + return new([]); } // Note: parsing the stringified URIs is an expensive operation. @@ -675,7 +675,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore.Empty); + return new([]); } // Note: parsing the stringified URIs is an expensive operation. @@ -716,7 +716,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore.Empty); + return new([]); } // Note: parsing the stringified requirements is an expensive operation. diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs index a989cf04..57b89213 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs @@ -464,7 +464,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore.Empty); + return new([]); } // Note: parsing the stringified scopes is an expensive operation. diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs index fd5a876a..6436df02 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs @@ -423,7 +423,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore : I if (string.IsNullOrEmpty(scope.Resources)) { - return new(ImmutableArray.Empty); + return new([]); } // Note: parsing the stringified resources is an expensive operation. diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs index f8a354dd..ebae6239 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs @@ -82,13 +82,13 @@ public class OpenIddictMongoDbApplication /// Gets or sets the permissions associated with the current application. /// [BsonElement("permissions"), BsonIgnoreIfNull] - public virtual IReadOnlyList? Permissions { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? Permissions { get; set; } = []; /// /// Gets or sets the post-logout redirect URIs associated with the current application. /// [BsonElement("post_logout_redirect_uris"), BsonIgnoreIfNull] - public virtual IReadOnlyList? PostLogoutRedirectUris { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? PostLogoutRedirectUris { get; set; } = []; /// /// Gets or sets the additional properties associated with the current application. @@ -100,13 +100,13 @@ public class OpenIddictMongoDbApplication /// Gets or sets the redirect URIs associated with the current application. /// [BsonElement("redirect_uris"), BsonIgnoreIfNull] - public virtual IReadOnlyList? RedirectUris { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? RedirectUris { get; set; } = []; /// /// Gets or sets the requirements associated with the current application. /// [BsonElement("requirements"), BsonIgnoreIfNull] - public virtual IReadOnlyList? Requirements { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? Requirements { get; set; } = []; /// /// Gets or sets the settings associated with the current application. diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs index d512b616..d71c4038 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs @@ -49,7 +49,7 @@ public class OpenIddictMongoDbAuthorization /// Gets or sets the scopes associated with the current authorization. /// [BsonElement("scopes"), BsonIgnoreIfNull] - public virtual IReadOnlyList? Scopes { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? Scopes { get; set; } = []; /// /// Gets or sets the status of the current authorization. diff --git a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs index 641796c9..c7b2cb52 100644 --- a/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs +++ b/src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs @@ -69,5 +69,5 @@ public class OpenIddictMongoDbScope /// Gets or sets the resources associated with the current scope. /// [BsonElement("resources"), BsonIgnoreIfNull] - public virtual IReadOnlyList? Resources { get; set; } = ImmutableList.Create(); + public virtual IReadOnlyList? Resources { get; set; } = []; } diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs index 689b39cd..cedc2f48 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs @@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb; /// public sealed class OpenIddictMongoDbApplicationStoreResolver : IOpenIddictApplicationStoreResolver { - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); private readonly IServiceProvider _provider; public OpenIddictMongoDbApplicationStoreResolver(IServiceProvider provider) diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs index fa6d7430..fcd360bd 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs @@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb; /// public sealed class OpenIddictMongoDbAuthorizationStoreResolver : IOpenIddictAuthorizationStoreResolver { - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); private readonly IServiceProvider _provider; public OpenIddictMongoDbAuthorizationStoreResolver(IServiceProvider provider) diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs index 990df738..ea653d41 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs @@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb; /// public sealed class OpenIddictMongoDbScopeStoreResolver : IOpenIddictScopeStoreResolver { - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); private readonly IServiceProvider _provider; public OpenIddictMongoDbScopeStoreResolver(IServiceProvider provider) diff --git a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs index b7ce4604..0c502058 100644 --- a/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs +++ b/src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs @@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb; /// public sealed class OpenIddictMongoDbTokenStoreResolver : IOpenIddictTokenStoreResolver { - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); private readonly IServiceProvider _provider; public OpenIddictMongoDbTokenStoreResolver(IServiceProvider provider) diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs index 75766cfd..63b300ae 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs @@ -323,10 +323,10 @@ public class OpenIddictMongoDbApplicationStore : IOpenIddictApplic if (application.Permissions is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(application.Permissions.ToImmutableArray()); + return new([.. application.Permissions]); } /// @@ -340,10 +340,10 @@ public class OpenIddictMongoDbApplicationStore : IOpenIddictApplic if (application.PostLogoutRedirectUris is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(application.PostLogoutRedirectUris.ToImmutableArray()); + return new([.. application.PostLogoutRedirectUris]); } /// @@ -381,10 +381,10 @@ public class OpenIddictMongoDbApplicationStore : IOpenIddictApplic if (application.RedirectUris is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(application.RedirectUris.ToImmutableArray()); + return new([.. application.RedirectUris]); } /// @@ -397,10 +397,10 @@ public class OpenIddictMongoDbApplicationStore : IOpenIddictApplic if (application.Requirements is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(application.Requirements.ToImmutableArray()); + return new([.. application.Requirements]); } /// diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs index c8c20327..811e1381 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs @@ -302,10 +302,10 @@ public class OpenIddictMongoDbAuthorizationStore : IOpenIddictAu if (authorization.Scopes is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(authorization.Scopes.ToImmutableArray()); + return new([.. authorization.Scopes]); } /// diff --git a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs index de100876..d9925239 100644 --- a/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs +++ b/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs @@ -302,10 +302,10 @@ public class OpenIddictMongoDbScopeStore : IOpenIddictScopeStore if (scope.Resources is not { Count: > 0 }) { - return new(ImmutableArray.Empty); + return new([]); } - return new(scope.Resources.ToImmutableArray()); + return new([.. scope.Resources]); } /// diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs index 570d1980..e4b4ae85 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs @@ -20,7 +20,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request extraction: */ @@ -58,7 +59,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for restoring cached requests from the request_id, if specified. diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs index b1e5bef5..c28ec37b 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs @@ -14,7 +14,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device request extraction: */ @@ -50,7 +51,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers ProcessStatusCodePagesErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor, ProcessEmptyResponse.Descriptor - ]); + ]; } /// diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs index cde269f4..028063e2 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration request extraction: */ @@ -36,6 +37,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachHttpResponseCode.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs index 7c97520c..e76c2972 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token request extraction: */ @@ -32,6 +33,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs index a6a67db9..5ac7e188 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection request extraction: */ @@ -26,6 +27,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachHttpResponseCode.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs index 36cdcba2..77368682 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation request extraction: */ @@ -27,6 +28,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs index ad4f82a7..e3a28ab0 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs @@ -17,7 +17,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End-session request extraction: */ @@ -40,7 +41,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers ProcessStatusCodePagesErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor, ProcessEmptyResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for restoring cached requests from the request_id, if specified. diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs index 03df37ad..7db31228 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo request extraction: */ @@ -31,6 +32,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers AttachWwwAuthenticateHeader.Descriptor, ProcessChallengeErrorResponse.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs index 070a6c92..e7405851 100644 --- a/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs +++ b/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs @@ -25,7 +25,8 @@ namespace OpenIddict.Server.AspNetCore; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictServerAspNetCoreHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -57,7 +58,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers .. Revocation.DefaultHandlers, .. Session.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment. diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs index 0e2de127..398311e2 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictServerDataProtectionHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ @@ -32,7 +33,7 @@ public static partial class OpenIddictServerDataProtectionHandlers */ OverrideGeneratedTokenFormat.Descriptor, GenerateDataProtectionToken.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating tokens generated using Data Protection. diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs index db1b618a..41f1dce4 100644 --- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs +++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs @@ -12,6 +12,5 @@ namespace OpenIddict.Server.DataProtection; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictServerDataProtectionHandlers { - public static ImmutableArray DefaultHandlers { get; } - = ImmutableArray.Create([.. Protection.DefaultHandlers]); + public static ImmutableArray DefaultHandlers { get; } = [.. Protection.DefaultHandlers]; } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs index f7a7f7d3..d42d326a 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs @@ -19,7 +19,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request extraction: */ @@ -60,7 +61,7 @@ public static partial class OpenIddictServerOwinHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor, - ]); + ]; /// /// Contains the logic responsible for restoring cached requests from the request_id, if specified. diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs index afad7238..8ed20bd7 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs @@ -14,7 +14,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device request extraction: */ @@ -53,7 +54,7 @@ public static partial class OpenIddictServerOwinHandlers ProcessPassthroughErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor, ProcessEmptyResponse.Descriptor - ]); + ]; } /// diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs index cf013196..1e4019cc 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration request extraction: */ @@ -40,6 +41,6 @@ public static partial class OpenIddictServerOwinHandlers SuppressFormsAuthenticationRedirect.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs index a121ab59..86968326 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token request extraction: */ @@ -34,6 +35,6 @@ public static partial class OpenIddictServerOwinHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs index e644376b..58c449be 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection request extraction: */ @@ -28,6 +29,6 @@ public static partial class OpenIddictServerOwinHandlers SuppressFormsAuthenticationRedirect.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs index fd62f19a..fcb34cc4 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation request extraction: */ @@ -29,6 +30,6 @@ public static partial class OpenIddictServerOwinHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs index 201497d5..e1462269 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End-session request extraction: */ @@ -40,7 +41,7 @@ public static partial class OpenIddictServerOwinHandlers ProcessPassthroughErrorResponse.Descriptor, ProcessLocalErrorResponse.Descriptor, ProcessEmptyResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for restoring cached requests from the request_id, if specified. diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs index 1ff0976c..8e1123a5 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo request extraction: */ @@ -33,6 +34,6 @@ public static partial class OpenIddictServerOwinHandlers AttachWwwAuthenticateHeader.Descriptor, ProcessChallengeErrorResponse.Descriptor, ProcessJsonResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs index ca80f331..a0ea78cc 100644 --- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs +++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs @@ -23,7 +23,8 @@ namespace OpenIddict.Server.Owin; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictServerOwinHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -55,7 +56,7 @@ public static partial class OpenIddictServerOwinHandlers .. Revocation.DefaultHandlers, .. Session.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the OWIN environment. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs index b141bc6f..51f38776 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs @@ -31,7 +31,7 @@ public sealed class OpenIddictServerHandlerDescriptor /// Gets the list of filters responsible for excluding the handler /// from the activated handlers if it doesn't meet the criteria. /// - public ImmutableArray FilterTypes { get; private set; } = ImmutableArray.Empty; + public ImmutableArray FilterTypes { get; private set; } = []; /// /// Gets the order assigned to the handler. @@ -53,8 +53,7 @@ public sealed class OpenIddictServerHandlerDescriptor /// /// The event context type. /// A new descriptor builder. - public static Builder CreateBuilder() where TContext : BaseContext - => new Builder(); + public static Builder CreateBuilder() where TContext : BaseContext => new(); /// /// Contains methods allowing to build a descriptor instance. @@ -269,7 +268,7 @@ public sealed class OpenIddictServerHandlerDescriptor /// Build a new descriptor instance, based on the parameters that were previously set. /// /// The builder instance, so that calls can be easily chained. - public OpenIddictServerHandlerDescriptor Build() => new OpenIddictServerHandlerDescriptor + public OpenIddictServerHandlerDescriptor Build() => new() { ContextType = typeof(TContext), FilterTypes = _filters.ToImmutableArray(), diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs index 790c109c..a71918ed 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs @@ -20,7 +20,8 @@ public static partial class OpenIddictServerHandlers { public static class Authentication { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authorization request top-level processing: */ @@ -110,7 +111,7 @@ public static partial class OpenIddictServerHandlers * Pushed authorization request handling: */ AttachPushedPrincipal.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting authorization requests and invoking the corresponding event handlers. @@ -1509,7 +1510,7 @@ public static partial class OpenIddictServerHandlers throw new InvalidOperationException(SR.GetResourceString(SR.ID0016)); } - await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) + await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes])) { var name = await _scopeManager.GetNameAsync(scope); if (!string.IsNullOrEmpty(name)) @@ -3466,7 +3467,7 @@ public static partial class OpenIddictServerHandlers throw new InvalidOperationException(SR.GetResourceString(SR.ID0016)); } - await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) + await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes])) { var name = await _scopeManager.GetNameAsync(scope); if (!string.IsNullOrEmpty(name)) diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs index e310ae75..010c94b0 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs @@ -18,7 +18,8 @@ public static partial class OpenIddictServerHandlers { public static class Device { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Device request top-level processing: */ @@ -61,7 +62,7 @@ public static partial class OpenIddictServerHandlers * Verification request handling: */ AttachUserCodePrincipal.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting device requests and invoking the corresponding event handlers. @@ -502,7 +503,7 @@ public static partial class OpenIddictServerHandlers throw new InvalidOperationException(SR.GetResourceString(SR.ID0016)); } - await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) + await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes])) { var name = await _scopeManager.GetNameAsync(scope); if (!string.IsNullOrEmpty(name)) diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs index 8f0b8b4b..26beb1a7 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs @@ -18,7 +18,8 @@ public static partial class OpenIddictServerHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration request top-level processing: */ @@ -59,7 +60,7 @@ public static partial class OpenIddictServerHandlers * JSON Web Key Set request handling: */ AttachSigningKeys.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting configuration requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs index 7a0f6726..dbaa441c 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers { public static class Exchange { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token request top-level processing: */ @@ -65,7 +66,7 @@ public static partial class OpenIddictServerHandlers * Token response handling: */ NormalizeErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting token requests and invoking the corresponding event handlers. @@ -873,7 +874,7 @@ public static partial class OpenIddictServerHandlers throw new InvalidOperationException(SR.GetResourceString(SR.ID0016)); } - await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray())) + await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes])) { var name = await _scopeManager.GetNameAsync(scope); if (!string.IsNullOrEmpty(name)) diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs index b12989e5..0d81a61b 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection request top-level processing: */ @@ -52,7 +53,7 @@ public static partial class OpenIddictServerHandlers * Introspection response handling: */ NormalizeErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting introspection requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs index 4df45238..27ee1f28 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs @@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ @@ -44,7 +45,7 @@ public static partial class OpenIddictServerHandlers CreateTokenEntry.Descriptor, GenerateIdentityModelToken.Descriptor, AttachTokenPayload.Descriptor - ]); + ]; /// /// Contains the logic responsible for resolving the validation parameters used to validate tokens. @@ -338,7 +339,7 @@ public static partial class OpenIddictServerHandlers { 0 => true, // If no specific token type is expected, accept all token types at this stage. 1 => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ElementAt(0)), - _ => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ToImmutableArray()) + _ => await _tokenManager.HasTypeAsync(token, [.. context.ValidTokenTypes]) })) { context.Reject( diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs index 3aedeb0c..c12c1e22 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs @@ -15,7 +15,8 @@ public static partial class OpenIddictServerHandlers { public static class Revocation { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Revocation request top-level processing: */ @@ -45,7 +46,7 @@ public static partial class OpenIddictServerHandlers * Revocation response handling: */ NormalizeErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting revocation requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs index 9ecb5e2a..00c0b570 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs @@ -20,7 +20,8 @@ public static partial class OpenIddictServerHandlers { public static class Session { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * End-session request top-level processing: */ @@ -53,7 +54,7 @@ public static partial class OpenIddictServerHandlers */ AttachPostLogoutRedirectUri.Descriptor, AttachResponseState.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting end session requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs index 9767dc97..430e888f 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs @@ -15,7 +15,8 @@ public static partial class OpenIddictServerHandlers { public static class UserInfo { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * UserInfo request top-level processing: */ @@ -38,7 +39,7 @@ public static partial class OpenIddictServerHandlers AttachPrincipal.Descriptor, AttachAudiences.Descriptor, AttachClaims.Descriptor - ]); + ]; /// /// Contains the logic responsible for extracting userinfo requests and invoking the corresponding event handlers. diff --git a/src/OpenIddict.Server/OpenIddictServerHandlers.cs b/src/OpenIddict.Server/OpenIddictServerHandlers.cs index d8c0ec95..003f1881 100644 --- a/src/OpenIddict.Server/OpenIddictServerHandlers.cs +++ b/src/OpenIddict.Server/OpenIddictServerHandlers.cs @@ -23,7 +23,8 @@ namespace OpenIddict.Server; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictServerHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Top-level request processing: */ @@ -126,7 +127,7 @@ public static partial class OpenIddictServerHandlers .. Revocation.DefaultHandlers, .. Session.DefaultHandlers, .. UserInfo.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for inferring the endpoint type from the request URI. diff --git a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs index b5232854..ce37c6a6 100644 --- a/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs +++ b/src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs @@ -23,7 +23,8 @@ namespace OpenIddict.Validation.AspNetCore; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictValidationAspNetCoreHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Request top-level processing: */ @@ -55,7 +56,7 @@ public static partial class OpenIddictValidationAspNetCoreHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessChallengeErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment. diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs index c13fd25a..22df9b75 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs @@ -21,12 +21,13 @@ public static partial class OpenIddictValidationDataProtectionHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ ValidateDataProtectionToken.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating tokens generated using Data Protection. diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs index 61e672a0..0f50dfe8 100644 --- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs +++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs @@ -12,6 +12,5 @@ namespace OpenIddict.Validation.DataProtection; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictValidationDataProtectionHandlers { - public static ImmutableArray DefaultHandlers { get; } - = ImmutableArray.Create([.. Protection.DefaultHandlers]); + public static ImmutableArray DefaultHandlers { get; } = [.. Protection.DefaultHandlers]; } diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs index 49c13e80..c7c0a681 100644 --- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs +++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs @@ -22,7 +22,8 @@ namespace OpenIddict.Validation.Owin; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictValidationOwinHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Request top-level processing: */ @@ -58,7 +59,7 @@ public static partial class OpenIddictValidationOwinHandlers AttachCacheControlHeader.Descriptor, AttachWwwAuthenticateHeader.Descriptor, ProcessChallengeErrorResponse.Descriptor - ]); + ]; /// /// Contains the logic responsible for resolving the request URI from the OWIN environment. diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs index 4854c4cd..eed3daed 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration request processing: */ @@ -56,6 +57,6 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs index 1fb9578b..f13fa061 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs @@ -12,7 +12,8 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection request processing: */ @@ -35,6 +36,6 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers ExtractWwwAuthenticateHeader.Descriptor, ValidateHttpResponse.Descriptor, DisposeHttpResponse.Descriptor - ]); + ]; } } diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs index 6fc0d608..8bc6698a 100644 --- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs +++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs @@ -24,7 +24,8 @@ namespace OpenIddict.Validation.SystemNetHttp; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictValidationSystemNetHttpHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authentication processing: */ @@ -32,7 +33,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers .. Discovery.DefaultHandlers, .. Introspection.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for negotiating the best introspection endpoint client diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs index 93831036..f22f5dc3 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs @@ -31,7 +31,7 @@ public sealed class OpenIddictValidationHandlerDescriptor /// Gets the list of filters responsible for excluding the handler /// from the activated handlers if it doesn't meet the criteria. /// - public ImmutableArray FilterTypes { get; private set; } = ImmutableArray.Empty; + public ImmutableArray FilterTypes { get; private set; } = []; /// /// Gets the order assigned to the handler. @@ -53,8 +53,7 @@ public sealed class OpenIddictValidationHandlerDescriptor /// /// The event context type. /// A new descriptor builder. - public static Builder CreateBuilder() where TContext : BaseContext - => new Builder(); + public static Builder CreateBuilder() where TContext : BaseContext => new(); /// /// Contains methods allowing to build a descriptor instance. @@ -269,10 +268,10 @@ public sealed class OpenIddictValidationHandlerDescriptor /// Build a new descriptor instance, based on the parameters that were previously set. /// /// The builder instance, so that calls can be easily chained. - public OpenIddictValidationHandlerDescriptor Build() => new OpenIddictValidationHandlerDescriptor + public OpenIddictValidationHandlerDescriptor Build() => new() { ContextType = typeof(TContext), - FilterTypes = _filters.ToImmutableArray(), + FilterTypes = [.. _filters], Order = _order, ServiceDescriptor = _descriptor ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0105)), Type = _type diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs index 9bbe9929..dad16eb0 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs @@ -16,7 +16,8 @@ public static partial class OpenIddictValidationHandlers { public static class Discovery { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Configuration response handling: */ @@ -34,7 +35,7 @@ public static partial class OpenIddictValidationHandlers ValidateWellKnownJsonWebKeySetParameters.Descriptor, HandleJsonWebKeySetErrorResponse.Descriptor, ExtractSigningKeys.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the configuration response. diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs index cac1389a..dc1d42a6 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Introspection.cs @@ -18,7 +18,8 @@ public static partial class OpenIddictValidationHandlers { public static class Introspection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Introspection response handling: */ @@ -30,7 +31,7 @@ public static partial class OpenIddictValidationHandlers ValidateTokenUsage.Descriptor, PopulateClaims.Descriptor, MapInternalClaims.Descriptor - ]); + ]; /// /// Contains the logic responsible for validating the well-known parameters contained in the introspection response. @@ -494,18 +495,17 @@ public static partial class OpenIddictValidationHandlers // Map the internal "oi_prst" claims from the standard "client_id" claim, if available. context.Principal.SetPresenters(context.Principal.GetClaim(Claims.ClientId) switch { - string identifier when !string.IsNullOrEmpty(identifier) - => ImmutableArray.Create(identifier), + string identifier when !string.IsNullOrEmpty(identifier) => [identifier], - _ => ImmutableArray.Empty + _ => [] }); // Map the internal "oi_scp" claims from the standard, space-separated "scope" claim, if available. context.Principal.SetScopes(context.Principal.GetClaim(Claims.Scope) switch { - string scope => scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries).ToImmutableArray(), + string scope => [.. scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries)], - _ => ImmutableArray.Empty + _ => [] }); return default; diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs index 329b7a42..136b429f 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Protection.cs @@ -18,7 +18,8 @@ public static partial class OpenIddictValidationHandlers { public static class Protection { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Token validation: */ @@ -40,7 +41,7 @@ public static partial class OpenIddictValidationHandlers */ AttachSecurityCredentials.Descriptor, GenerateIdentityModelToken.Descriptor - ]); + ]; /// /// Contains the logic responsible for resolving the validation parameters used to validate tokens. @@ -231,7 +232,7 @@ public static partial class OpenIddictValidationHandlers { 0 => true, // If no specific token type is expected, accept all token types at this stage. 1 => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ElementAt(0)), - _ => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ToImmutableArray()) + _ => await _tokenManager.HasTypeAsync(token, [.. context.ValidTokenTypes]) })) { context.Reject( diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs index 25c13e0b..8cdf6b11 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.cs @@ -18,7 +18,8 @@ namespace OpenIddict.Validation; [EditorBrowsable(EditorBrowsableState.Never)] public static partial class OpenIddictValidationHandlers { - public static ImmutableArray DefaultHandlers { get; } = ImmutableArray.Create([ + public static ImmutableArray DefaultHandlers { get; } = + [ /* * Authentication processing: */ @@ -53,7 +54,7 @@ public static partial class OpenIddictValidationHandlers .. Discovery.DefaultHandlers, .. Introspection.DefaultHandlers, .. Protection.DefaultHandlers - ]); + ]; /// /// Contains the logic responsible for selecting the token types that should be validated. diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs index 41792bed..317d3b7a 100644 --- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs +++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs @@ -1002,7 +1002,7 @@ public class OpenIddictExtensionsTests { // Arrange var claim = new Claim(Claims.Name, "Bob le Bricoleur"); - claim.SetDestinations(new[] { "destination1", "destination2", "destination3" }); + claim.SetDestinations(["destination1", "destination2", "destination3"]); // Act var hasDestination = claim.HasDestination("destination2"); @@ -1125,8 +1125,8 @@ public class OpenIddictExtensionsTests // Assert Assert.Equal(2, destinations.Count); - Assert.Equal(new[] { Destinations.AccessToken, Destinations.IdentityToken }, destinations[Claims.Name]); - Assert.Equal(new[] { Destinations.IdentityToken }, destinations[Claims.Email]); + Assert.Equal([Destinations.AccessToken, Destinations.IdentityToken], destinations[Claims.Name]); + Assert.Equal([Destinations.IdentityToken], destinations[Claims.Email]); } [Fact] @@ -1159,8 +1159,8 @@ public class OpenIddictExtensionsTests // Assert Assert.Equal(2, destinations.Count); - Assert.Equal(new[] { Destinations.AccessToken, Destinations.IdentityToken }, destinations[Claims.Name]); - Assert.Equal(new[] { Destinations.IdentityToken }, destinations[Claims.Email]); + Assert.Equal([Destinations.AccessToken, Destinations.IdentityToken], destinations[Claims.Name]); + Assert.Equal([Destinations.IdentityToken], destinations[Claims.Email]); } [Fact] @@ -2084,7 +2084,7 @@ public class OpenIddictExtensionsTests var identity = (ClaimsIdentity) null!; // Act and assert - var exception = Assert.Throws(() => identity.AddClaims("type", ImmutableArray.Empty)); + var exception = Assert.Throws(() => identity.AddClaims("type", [])); Assert.Equal("identity", exception.ParamName); } @@ -2096,7 +2096,7 @@ public class OpenIddictExtensionsTests var principal = (ClaimsPrincipal) null!; // Act and assert - var exception = Assert.Throws(() => principal.AddClaims("type", ImmutableArray.Empty)); + var exception = Assert.Throws(() => principal.AddClaims("type", [])); Assert.Equal("principal", exception.ParamName); } @@ -2108,7 +2108,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(); // Act and assert - var exception = Assert.Throws(() => principal.AddClaims("type", ImmutableArray.Create("value1", "value2"))); + var exception = Assert.Throws(() => principal.AddClaims("type", ["value1", "value2"])); Assert.Equal("principal", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0286), exception.Message); @@ -2123,7 +2123,7 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act and assert - var exception = Assert.Throws(() => identity.AddClaims(type!, ImmutableArray.Empty)); + var exception = Assert.Throws(() => identity.AddClaims(type!, [])); Assert.Equal("type", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0184), exception.Message); @@ -2138,7 +2138,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act and assert - var exception = Assert.Throws(() => principal.AddClaims(type!, ImmutableArray.Empty)); + var exception = Assert.Throws(() => principal.AddClaims(type!, [])); Assert.Equal("type", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0184), exception.Message); @@ -2151,7 +2151,7 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act - identity.AddClaims("type", ImmutableArray.Create("value1", "value2"), "issuer"); + identity.AddClaims("type", ["value1", "value2"], "issuer"); // Assert var claims = identity.FindAll("type").ToArray(); @@ -2171,7 +2171,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act - principal.AddClaims("type", ImmutableArray.Create("value1", "value2"), "issuer"); + principal.AddClaims("type", ["value1", "value2"], "issuer"); // Assert var claims = principal.FindAll("type").ToArray(); @@ -2191,10 +2191,10 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act - identity.AddClaims("TYPE", ImmutableArray.Create("value1", "value2")); + identity.AddClaims("TYPE", ["value1", "value2"]); // Assert - Assert.Equal(ImmutableArray.Create("value1", "value2"), identity.GetClaims("type")); + Assert.Equal(["value1", "value2"], identity.GetClaims("type")); } [Fact] @@ -2204,10 +2204,10 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act - principal.AddClaims("TYPE", ImmutableArray.Create("value1", "value2")); + principal.AddClaims("TYPE", ["value1", "value2"]); // Assert - Assert.Equal(ImmutableArray.Create("value1", "value2"), principal.GetClaims("type")); + Assert.Equal(["value1", "value2"], principal.GetClaims("type")); } [Fact] @@ -3650,7 +3650,7 @@ public class OpenIddictExtensionsTests var identity = (ClaimsIdentity) null!; // Act and assert - var exception = Assert.Throws(() => identity.SetClaims("type", ImmutableArray.Empty)); + var exception = Assert.Throws(() => identity.SetClaims("type", [])); Assert.Equal("identity", exception.ParamName); } @@ -3662,7 +3662,7 @@ public class OpenIddictExtensionsTests var principal = (ClaimsPrincipal) null!; // Act and assert - var exception = Assert.Throws(() => principal.SetClaims("type", ImmutableArray.Empty)); + var exception = Assert.Throws(() => principal.SetClaims("type", [])); Assert.Equal("principal", exception.ParamName); } @@ -3674,7 +3674,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(); // Act and assert - var exception = Assert.Throws(() => principal.SetClaims("type", ImmutableArray.Create("value1", "value2"))); + var exception = Assert.Throws(() => principal.SetClaims("type", ["value1", "value2"])); Assert.Equal("principal", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0286), exception.Message); @@ -3689,7 +3689,7 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act and assert - var exception = Assert.Throws(() => identity.SetClaims(type!, ImmutableArray.Empty)); + var exception = Assert.Throws(() => identity.SetClaims(type!, [])); Assert.Equal("type", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0184), exception.Message); @@ -3704,7 +3704,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act and assert - var exception = Assert.Throws(() => principal.SetClaims(type!, ImmutableArray.Empty)); + var exception = Assert.Throws(() => principal.SetClaims(type!, [])); Assert.Equal("type", exception.ParamName); Assert.StartsWith(SR.GetResourceString(SR.ID0184), exception.Message); @@ -3717,7 +3717,7 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act - identity.SetClaims("type", ImmutableArray.Create("value1", "value2"), "issuer"); + identity.SetClaims("type", ["value1", "value2"], "issuer"); // Assert var claims = identity.FindAll("type").ToArray(); @@ -3737,7 +3737,7 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act - principal.SetClaims("type", ImmutableArray.Create("value1", "value2"), "issuer"); + principal.SetClaims("type", ["value1", "value2"], "issuer"); // Assert var claims = principal.FindAll("type").ToArray(); @@ -3756,10 +3756,10 @@ public class OpenIddictExtensionsTests var identity = new ClaimsIdentity(); // Act - identity.SetClaims("TYPE", ImmutableArray.Create("value1", "value2")); + identity.SetClaims("TYPE", ["value1", "value2"]); // Assert - Assert.Equal(ImmutableArray.Create("value1", "value2"), identity.GetClaims("type")); + Assert.Equal(["value1", "value2"], identity.GetClaims("type")); } [Fact] @@ -3769,10 +3769,10 @@ public class OpenIddictExtensionsTests var principal = new ClaimsPrincipal(new ClaimsIdentity()); // Act - principal.SetClaims("TYPE", ImmutableArray.Create("value1", "value2")); + principal.SetClaims("TYPE", ["value1", "value2"]); // Assert - Assert.Equal(ImmutableArray.Create("value1", "value2"), principal.GetClaims("type")); + Assert.Equal(["value1", "value2"], principal.GetClaims("type")); } [Fact] @@ -3783,7 +3783,7 @@ public class OpenIddictExtensionsTests identity.AddClaim("type", "value"); // Act - identity.SetClaims("type", ImmutableArray.Empty); + identity.SetClaims("type", []); // Assert Assert.Empty(identity.GetClaims("type")); @@ -3797,7 +3797,7 @@ public class OpenIddictExtensionsTests principal.AddClaim("type", "value"); // Act - principal.SetClaims("type", ImmutableArray.Empty); + principal.SetClaims("type", []); // Assert Assert.Empty(principal.GetClaims("type")); diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs index 663b7e2d..3f9ec073 100644 --- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs +++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs @@ -98,7 +98,7 @@ public class OpenIddictMessageTests // Assert Assert.Equal(1, message.Count); - Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) message.GetParameter("parameter")); + Assert.Equal(["Fabrikam", "Contoso"], (string?[]?) message.GetParameter("parameter")); } [Fact] @@ -112,7 +112,7 @@ public class OpenIddictMessageTests // Assert Assert.Equal(1, message.Count); - Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) message.GetParameter("parameter")); + Assert.Equal(["Fabrikam", "Contoso"], (string?[]?) message.GetParameter("parameter")); } [Fact] diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs index 017606f5..81c29ed0 100644 --- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs +++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs @@ -1040,7 +1040,7 @@ public class OpenIddictParameterTests { // Arrange, act and assert Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter(string.Empty))); - Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter(Array.Empty()))); + Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter([]))); Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter( JsonSerializer.Deserialize("[]")))); @@ -2054,9 +2054,9 @@ public class OpenIddictParameterTests public void StringArrayConverter_CanCreateParameterFromPrimitiveValues() { // Arrange, act and assert - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter("Fabrikam")); - Assert.Equal(new[] { "false" }, (string?[]?) new OpenIddictParameter(false)); - Assert.Equal(new[] { "42" }, (string?[]?) new OpenIddictParameter(42)); + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter("Fabrikam")); + Assert.Equal(["false"], (string?[]?) new OpenIddictParameter(false)); + Assert.Equal(["42"], (string?[]?) new OpenIddictParameter(42)); } [Fact] @@ -2070,7 +2070,7 @@ public class OpenIddictParameterTests public void StringArrayConverter_ReturnsSingleElementArrayForStringValue() { // Arrange, act and assert - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter("Fabrikam")); + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter("Fabrikam")); } [Fact] @@ -2093,25 +2093,25 @@ public class OpenIddictParameterTests public void StringArrayConverter_CanConvertFromJsonValues() { // Arrange, act and assert - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"{""field"":""Fabrikam""}").GetProperty("field"))); - Assert.Equal(new[] { "false" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["false"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"{""field"":false}").GetProperty("field"))); - Assert.Equal(new[] { "42" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["42"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"{""field"":42}").GetProperty("field"))); - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"[""Fabrikam""]"))); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"[""Contoso"",""Fabrikam""]"))); - Assert.Equal(new[] { "value", "42", "true" }, (string?[]?) new OpenIddictParameter( + Assert.Equal(["value", "42", "true"], (string?[]?) new OpenIddictParameter( JsonSerializer.Deserialize(@"[""value"",42,true]"))); - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter(JsonValue.Create("Fabrikam"))); - Assert.Equal(new[] { "false" }, (string?[]?) new OpenIddictParameter(JsonValue.Create(false))); - Assert.Equal(new[] { "42" }, (string?[]?) new OpenIddictParameter(JsonValue.Create(42))); - Assert.Equal(new[] { "42" }, (string?[]?) new OpenIddictParameter(JsonValue.Create(42L))); - Assert.Equal(new[] { "Fabrikam" }, (string?[]?) new OpenIddictParameter(new JsonArray("Fabrikam"))); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string?[]?) new OpenIddictParameter(new JsonArray("Contoso", "Fabrikam"))); - Assert.Equal(new[] { "value", "42", "true" }, (string?[]?) new OpenIddictParameter(new JsonArray("value", 42, true))); + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter(JsonValue.Create("Fabrikam"))); + Assert.Equal(["false"], (string?[]?) new OpenIddictParameter(JsonValue.Create(false))); + Assert.Equal(["42"], (string?[]?) new OpenIddictParameter(JsonValue.Create(42))); + Assert.Equal(["42"], (string?[]?) new OpenIddictParameter(JsonValue.Create(42L))); + Assert.Equal(["Fabrikam"], (string?[]?) new OpenIddictParameter(new JsonArray("Fabrikam"))); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) new OpenIddictParameter(new JsonArray("Contoso", "Fabrikam"))); + Assert.Equal(["value", "42", "true"], (string?[]?) new OpenIddictParameter(new JsonArray("value", 42, true))); } } diff --git a/test/OpenIddict.Quartz.Tests/OpenIddictQuartzBuilderTests.cs b/test/OpenIddict.Quartz.Tests/OpenIddictQuartzBuilderTests.cs index c88a1636..91330763 100644 --- a/test/OpenIddict.Quartz.Tests/OpenIddictQuartzBuilderTests.cs +++ b/test/OpenIddict.Quartz.Tests/OpenIddictQuartzBuilderTests.cs @@ -173,7 +173,7 @@ public class OpenIddictQuartzBuilderTests => new ServiceCollection().AddOptions(); private static OpenIddictQuartzBuilder CreateBuilder(IServiceCollection services) - => new OpenIddictQuartzBuilder(services); + => new(services); private static OpenIddictQuartzOptions GetOptions(IServiceCollection services) { diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs index 165c54b4..dbec364b 100644 --- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs +++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs @@ -257,11 +257,11 @@ public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServ Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["array_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind); Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]); Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["node_array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["node_array_parameter"]); Assert.IsType((JsonNode?) response["node_array_parameter"]); Assert.Equal("value", (string?) response["node_object_parameter"]?["parameter"]); Assert.IsType((JsonNode?) response["node_object_parameter"]); @@ -488,11 +488,11 @@ public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServ Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["array_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind); Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]); Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["node_array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["node_array_parameter"]); Assert.IsType((JsonNode?) response["node_array_parameter"]); Assert.Equal("value", (string?) response["node_object_parameter"]?["parameter"]); Assert.IsType((JsonNode?) response["node_object_parameter"]); diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Authentication.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Authentication.cs index 498cf0e6..82245903 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Authentication.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Authentication.cs @@ -1345,7 +1345,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(application); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Create("rst:" + type)); + .ReturnsAsync(["rst:" + type]); mock.Setup(manager => manager.ValidateRedirectUriAsync(application, "http://www.fabrikam.com/path", It.IsAny())) .ReturnsAsync(true); @@ -1417,7 +1417,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(true); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Empty); + .ReturnsAsync([]); }); await using var server = await CreateServerAsync(options => @@ -1593,7 +1593,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(true); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Empty); + .ReturnsAsync([]); }); await using var server = await CreateServerAsync(options => @@ -1640,7 +1640,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(application); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Create("rst:" + type)); + .ReturnsAsync(["rst:" + type]); mock.Setup(manager => manager.ValidateRedirectUriAsync(application, "http://www.fabrikam.com/path", It.IsAny())) .ReturnsAsync(true); @@ -2541,7 +2541,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Null(response.ErrorUri); Assert.NotNull(response.AccessToken); Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Theory] @@ -2683,7 +2683,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] @@ -4089,7 +4089,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(application); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Create("rst:" + type)); + .ReturnsAsync(["rst:" + type]); mock.Setup(manager => manager.ValidateRedirectUriAsync(application, "http://www.fabrikam.com/path", It.IsAny())) .ReturnsAsync(true); @@ -4152,7 +4152,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(true); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Empty); + .ReturnsAsync([]); }); await using var server = await CreateServerAsync(options => @@ -4328,7 +4328,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(true); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Empty); + .ReturnsAsync([]); }); await using var server = await CreateServerAsync(options => @@ -4375,7 +4375,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(application); mock.Setup(manager => manager.GetPermissionsAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Create("rst:" + type)); + .ReturnsAsync(["rst:" + type]); mock.Setup(manager => manager.ValidateRedirectUriAsync(application, "http://www.fabrikam.com/path", It.IsAny())) .ReturnsAsync(true); @@ -5231,7 +5231,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Null(response.ErrorUri); Assert.NotNull(response.RequestUri); Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] @@ -5306,6 +5306,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Device.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Device.cs index 26a9faa9..0c094227 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Device.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Device.cs @@ -1051,7 +1051,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Null(response.ErrorUri); Assert.NotNull(response.DeviceCode); Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] @@ -1136,7 +1136,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Theory] @@ -1496,7 +1496,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs index 355c35d0..5dc941db 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Discovery.cs @@ -423,7 +423,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.TokenEndpointAuthMethodsSupported]; + var methods = (string?[]?) response[Metadata.TokenEndpointAuthMethodsSupported]; // Assert Assert.NotNull(methods); @@ -465,7 +465,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.IntrospectionEndpointAuthMethodsSupported]; + var methods = (string?[]?) response[Metadata.IntrospectionEndpointAuthMethodsSupported]; // Assert Assert.NotNull(methods); @@ -507,7 +507,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.RevocationEndpointAuthMethodsSupported]; + var methods = (string?[]?) response[Metadata.RevocationEndpointAuthMethodsSupported]; // Assert Assert.NotNull(methods); @@ -550,7 +550,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.DeviceAuthorizationEndpointAuthMethodsSupported]; + var methods = (string?[]?) response[Metadata.DeviceAuthorizationEndpointAuthMethodsSupported]; // Assert Assert.NotNull(methods); @@ -592,7 +592,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.PushedAuthorizationRequestEndpointAuthMethodsSupported]; + var methods = (string?[]?) response[Metadata.PushedAuthorizationRequestEndpointAuthMethodsSupported]; // Assert Assert.NotNull(methods); @@ -617,7 +617,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var types = (string[]?) response[Metadata.GrantTypesSupported]; + var types = (string?[]?) response[Metadata.GrantTypesSupported]; // Assert Assert.NotNull(types); @@ -659,7 +659,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var methods = (string[]?) response[Metadata.CodeChallengeMethodsSupported]; + var methods = (string?[]?) response[Metadata.CodeChallengeMethodsSupported]; // Assert Assert.NotNull(methods); @@ -701,7 +701,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var modes = (string[]?) response[Metadata.ResponseModesSupported]; + var modes = (string?[]?) response[Metadata.ResponseModesSupported]; // Assert Assert.NotNull(modes); @@ -743,7 +743,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var types = (string[]?) response[Metadata.ResponseTypesSupported]; + var types = (string?[]?) response[Metadata.ResponseTypesSupported]; // Assert Assert.NotNull(types); @@ -785,7 +785,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var scopes = (string[]?) response[Metadata.ScopesSupported]; + var scopes = (string?[]?) response[Metadata.ScopesSupported]; // Assert Assert.NotNull(scopes); @@ -827,7 +827,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var claims = (string[]?) response[Metadata.ClaimsSupported]; + var claims = (string?[]?) response[Metadata.ClaimsSupported]; // Assert Assert.NotNull(claims); @@ -850,7 +850,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var types = (string[]?) response[Metadata.SubjectTypesSupported]; + var types = (string?[]?) response[Metadata.SubjectTypesSupported]; // Assert Assert.NotNull(types); @@ -874,7 +874,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var types = (string[]?) response[Metadata.PromptValuesSupported]; + var types = (string?[]?) response[Metadata.PromptValuesSupported]; // Assert Assert.NotNull(types); @@ -905,7 +905,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var algorithms = (string[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; + var algorithms = (string?[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; // Assert Assert.NotNull(algorithms); @@ -927,7 +927,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var algorithms = (string[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; + var algorithms = (string?[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; // Assert Assert.NotNull(algorithms); @@ -953,7 +953,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Act var response = await client.GetAsync("/.well-known/openid-configuration"); - var algorithms = (string[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; + var algorithms = (string?[]?) response[Metadata.IdTokenSigningAlgValuesSupported]; // Assert Assert.NotNull(algorithms); @@ -1646,6 +1646,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Exchange.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Exchange.cs index 181ee382..5cd286bf 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Exchange.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Exchange.cs @@ -2816,7 +2816,7 @@ public abstract partial class OpenIddictServerIntegrationTests public async Task HandleTokenRequest_RevokesTokensWhenAuthorizationCodeIsAlreadyRedeemed() { // Arrange - var tokens = ImmutableArray.Create(new OpenIddictToken(), new OpenIddictToken(), new OpenIddictToken()); + ImmutableArray tokens = [new(), new(), new()]; var manager = CreateTokenManager(mock => { @@ -2915,7 +2915,7 @@ public abstract partial class OpenIddictServerIntegrationTests public async Task HandleTokenRequest_RevokesTokensWhenRefreshTokenIsAlreadyRedeemedAndLeewayIsNull() { // Arrange - var tokens = ImmutableArray.Create(new OpenIddictToken(), new OpenIddictToken(), new OpenIddictToken()); + ImmutableArray tokens = [new(), new(), new()]; var manager = CreateTokenManager(mock => { @@ -3006,7 +3006,7 @@ public abstract partial class OpenIddictServerIntegrationTests public async Task HandleTokenRequest_RevokesTokensWhenRefreshTokenIsAlreadyRedeemedAndCannotBeReused() { // Arrange - var tokens = ImmutableArray.Create(new OpenIddictToken(), new OpenIddictToken(), new OpenIddictToken()); + ImmutableArray tokens = [new(), new(), new()]; var manager = CreateTokenManager(mock => { @@ -3097,7 +3097,7 @@ public abstract partial class OpenIddictServerIntegrationTests public async Task HandleTokenRequest_DoesNotRevokeTokensWhenRefreshTokenIsAlreadyRedeemedAndCanBeReused() { // Arrange - var tokens = ImmutableArray.Create(new OpenIddictToken(), new OpenIddictToken(), new OpenIddictToken()); + ImmutableArray tokens = [new(), new(), new()]; var manager = CreateTokenManager(mock => { @@ -4284,7 +4284,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Null(response.ErrorUri); Assert.NotNull(response.AccessToken); Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] @@ -4375,6 +4375,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Introspection.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Introspection.cs index 7edf5fd6..a9ffdaf8 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Introspection.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Introspection.cs @@ -1048,7 +1048,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(JsonValueKind.True, ((JsonElement) response["boolean_claim"]).ValueKind); Assert.Equal(42, (long) response["integer_claim"]); Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_claim"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_claim"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["array_claim"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_claim"]).ValueKind); Assert.Equal("value", (string?) response["object_claim"]?["parameter"]); Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_claim"]).ValueKind); @@ -1835,6 +1835,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Protection.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Protection.cs index 89a3cfa8..ea6da45f 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Protection.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Protection.cs @@ -297,7 +297,7 @@ public abstract partial class OpenIddictServerIntegrationTests context.Principal = new ClaimsPrincipal(new ClaimsIdentity("Bearer")) .SetTokenType(TokenTypeHints.AccessToken) .SetClaim(Claims.Subject, "Bob le Magnifique") - .SetClaims(Claims.Audience, ImmutableArray.Create("Fabrikam", "Contoso")); + .SetClaims(Claims.Audience, ["Fabrikam", "Contoso"]); return default; }); @@ -316,8 +316,8 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("Bob le Magnifique", (string?) response[Claims.Subject]); - Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) response[Claims.Audience]); - Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) response[Claims.Private.Audience]); + Assert.Equal(["Fabrikam", "Contoso"], (string?[]?) response[Claims.Audience]); + Assert.Equal(["Fabrikam", "Contoso"], (string?[]?) response[Claims.Private.Audience]); } [Fact] @@ -347,7 +347,7 @@ public abstract partial class OpenIddictServerIntegrationTests context.Principal = new ClaimsPrincipal(new ClaimsIdentity("Bearer")) .SetTokenType(TokenTypeHints.AccessToken) .SetClaim(Claims.Subject, "Bob le Magnifique") - .SetClaims(Claims.Scope, ImmutableArray.Create(Scopes.OpenId, Scopes.Profile)); + .SetClaims(Claims.Scope, [Scopes.OpenId, Scopes.Profile]); return default; }); @@ -415,7 +415,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("Bob le Magnifique", (string?) response[Claims.Subject]); - Assert.Equal(new[] { Scopes.OpenId, Scopes.Profile }, (string[]?) response[Claims.Private.Scope]); + Assert.Equal([Scopes.OpenId, Scopes.Profile], (string?[]?) response[Claims.Private.Scope]); } [Fact] @@ -445,7 +445,7 @@ public abstract partial class OpenIddictServerIntegrationTests context.Principal = new ClaimsPrincipal(new ClaimsIdentity("Bearer")) .SetTokenType(TokenTypeHints.AccessToken) .SetClaim(Claims.Subject, "Bob le Magnifique") - .SetClaims(Claims.Scope, ImmutableArray.Create(Scopes.OpenId, Scopes.Profile)); + .SetClaims(Claims.Scope, [Scopes.OpenId, Scopes.Profile]); return default; }); @@ -464,7 +464,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("Bob le Magnifique", (string?) response[Claims.Subject]); - Assert.Equal(new[] { Scopes.OpenId, Scopes.Profile }, (string[]?) response[Claims.Private.Scope]); + Assert.Equal([Scopes.OpenId, Scopes.Profile], (string?[]?) response[Claims.Private.Scope]); } [Fact] diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Revocation.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Revocation.cs index 90b2d442..5e2cb3dd 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Revocation.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Revocation.cs @@ -1166,6 +1166,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Session.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Session.cs index d7f8329b..9e28d10b 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Session.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Session.cs @@ -546,7 +546,7 @@ public abstract partial class OpenIddictServerIntegrationTests .ReturnsAsync(application); mock.Setup(manager => manager.GetPostLogoutRedirectUrisAsync(application, It.IsAny())) - .ReturnsAsync(ImmutableArray.Create("http://www.fabrikam.com/path")); + .ReturnsAsync(["http://www.fabrikam.com/path"]); mock.Setup(manager => manager.HasPermissionAsync(application, Permissions.Endpoints.EndSession, It.IsAny())) @@ -1064,7 +1064,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] @@ -1146,7 +1146,7 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } [Fact] diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Userinfo.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Userinfo.cs index 332c7218..49c6f673 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Userinfo.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.Userinfo.cs @@ -387,7 +387,7 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(3, response.Count); Assert.Equal("http://localhost/", (string?) response[Claims.Issuer]); Assert.Equal("Bob le Magnifique", (string?) response[Claims.Subject]); - Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) response[Claims.Audience]); + Assert.Equal(["Fabrikam", "Contoso"], (string?[]?) response[Claims.Audience]); } [Fact] @@ -808,6 +808,6 @@ public abstract partial class OpenIddictServerIntegrationTests // Assert Assert.Equal("custom_value", (string?) response["custom_parameter"]); - Assert.Equal(new[] { "custom_value_1", "custom_value_2" }, (string[]?) response["parameter_with_multiple_values"]); + Assert.Equal(["custom_value_1", "custom_value_2"], (string?[]?) response["parameter_with_multiple_values"]); } } diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.cs index 254f3e42..16237d28 100644 --- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.cs +++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTests.cs @@ -1456,11 +1456,11 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["array_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind); Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]); Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["node_array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["node_array_parameter"]); Assert.IsType((JsonNode?) response["node_array_parameter"]); Assert.Equal("value", (string?) response["node_object_parameter"]?["parameter"]); Assert.IsType((JsonNode?) response["node_object_parameter"]); @@ -3899,11 +3899,11 @@ public abstract partial class OpenIddictServerIntegrationTests Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["array_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind); Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]); Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind); - Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["node_array_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["node_array_parameter"]); Assert.IsType((JsonNode?) response["node_array_parameter"]); Assert.Equal("value", (string?) response["node_object_parameter"]?["parameter"]); Assert.IsType((JsonNode?) response["node_object_parameter"]); diff --git a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs index 67fb892d..ddc488e5 100644 --- a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs +++ b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs @@ -254,7 +254,7 @@ public partial class OpenIddictServerOwinIntegrationTests : OpenIddictServerInte Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(["Contoso", "Fabrikam"], (string[]?) response["json_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["json_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["json_parameter"]).ValueKind); } @@ -479,7 +479,7 @@ public partial class OpenIddictServerOwinIntegrationTests : OpenIddictServerInte Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind); Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]); Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind); - Assert.Equal(["Contoso", "Fabrikam"], (string[]?) response["json_parameter"]); + Assert.Equal(["Contoso", "Fabrikam"], (string?[]?) response["json_parameter"]); Assert.Equal(JsonValueKind.Array, ((JsonElement) response["json_parameter"]).ValueKind); }