Skip to content

Commit e39c635

Browse files
committed
Decorate the claim extensions with [OverloadResolutionPriority] and collection expressions for ImmutableArray<T>
1 parent b17b3fe commit e39c635

File tree

123 files changed

+486
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+486
-393
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public async Task<ActionResult> Authorize()
156156
.SetClaim(Claims.Email, user.Email)
157157
.SetClaim(Claims.Name, user.UserName)
158158
.SetClaim(Claims.PreferredUsername, user.UserName)
159-
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
159+
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
160160

161161
// Note: in this sample, the granted scopes match the requested scope
162162
// but you may want to allow the user to uncheck specific scopes.
@@ -280,7 +280,7 @@ public async Task<ActionResult> Accept()
280280
.SetClaim(Claims.Email, user.Email)
281281
.SetClaim(Claims.Name, user.UserName)
282282
.SetClaim(Claims.PreferredUsername, user.UserName)
283-
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
283+
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
284284

285285
// Note: in this sample, the granted scopes match the requested scope
286286
// but you may want to allow the user to uncheck specific scopes.
@@ -400,7 +400,7 @@ public async Task<ActionResult> Exchange()
400400
.SetClaim(Claims.Email, user.Email)
401401
.SetClaim(Claims.Name, user.UserName)
402402
.SetClaim(Claims.PreferredUsername, user.UserName)
403-
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
403+
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
404404

405405
identity.SetDestinations(GetDestinations);
406406

sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public async Task<IActionResult> Authorize()
190190
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
191191
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
192192
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
193-
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
193+
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
194194

195195
// Note: in this sample, the granted scopes match the requested scope
196196
// but you may want to allow the user to uncheck specific scopes.
@@ -289,7 +289,7 @@ public async Task<IActionResult> Accept()
289289
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
290290
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
291291
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
292-
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
292+
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
293293

294294
// Note: in this sample, the granted scopes match the requested scope
295295
// but you may want to allow the user to uncheck specific scopes.
@@ -381,7 +381,7 @@ public async Task<IActionResult> VerifyAccept()
381381
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
382382
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
383383
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
384-
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
384+
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
385385

386386
// Note: in this sample, the granted scopes match the requested scope
387387
// but you may want to allow the user to uncheck specific scopes.
@@ -496,7 +496,7 @@ public async Task<IActionResult> Exchange()
496496
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
497497
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
498498
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
499-
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
499+
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
500500

501501
// Note: in this sample, the granted scopes match the requested scope
502502
// but you may want to allow the user to uncheck specific scopes.
@@ -550,7 +550,7 @@ public async Task<IActionResult> Exchange()
550550
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
551551
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
552552
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
553-
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
553+
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
554554

555555
identity.SetDestinations(GetDestinations);
556556

shared/OpenIddict.Extensions/OpenIddictHelpers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ private class FormReader
11281128

11291129
private readonly TextReader _reader;
11301130
private readonly char[] _buffer;
1131-
private readonly StringBuilder _builder = new StringBuilder();
1131+
private readonly StringBuilder _builder = new();
11321132
private int _bufferOffset;
11331133
private int _bufferCount;
11341134
private string? _currentKey;

src/OpenIddict.Abstractions/OpenIddictExceptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public sealed class ValidationException : Exception
109109
/// </summary>
110110
/// <param name="message">The exception message.</param>
111111
public ValidationException(string? message)
112-
: this(message, ImmutableArray<ValidationResult>.Empty)
112+
: this(message, [])
113113
{
114114
}
115115

0 commit comments

Comments
 (0)