diff --git a/Directory.Packages.props b/Directory.Packages.props
index b38e6fba..2e464b35 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -20,40 +20,40 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj b/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj
index c8b52ada..63106125 100644
--- a/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj
+++ b/sandbox/OpenIddict.Sandbox.AspNet.Client/OpenIddict.Sandbox.AspNet.Client.csproj
@@ -7,7 +7,6 @@
false
disable
CA3147
- false
diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj b/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj
index e0d2cc92..decf5a59 100644
--- a/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj
+++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/OpenIddict.Sandbox.AspNet.Server.csproj
@@ -7,7 +7,6 @@
false
disable
CA3147
- false
diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/Authorize.cshtml b/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/Authorize.cshtml
index c2241406..f7ce3eb5 100644
--- a/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/Authorize.cshtml
+++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/Authorize.cshtml
@@ -14,10 +14,10 @@
foreach (var parameter in string.Equals(Request.HttpMethod, "POST", StringComparison.OrdinalIgnoreCase) ?
from name in Request.Form.AllKeys
from value in Request.Form.GetValues(name)
- select new KeyValuePair(name, value) :
+ select KeyValuePair.Create(name, value) :
from name in Request.QueryString.AllKeys
from value in Request.QueryString.GetValues(name)
- select new KeyValuePair(name, value))
+ select KeyValuePair.Create(name, value))
{
}
diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/EndSession.cshtml b/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/EndSession.cshtml
index 4d270f90..3f254754 100644
--- a/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/EndSession.cshtml
+++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/Views/Authorization/EndSession.cshtml
@@ -12,10 +12,10 @@
foreach (var parameter in string.Equals(Request.HttpMethod, "POST", StringComparison.OrdinalIgnoreCase) ?
from name in Request.Form.AllKeys
from value in Request.Form.GetValues(name)
- select new KeyValuePair(name, value) :
+ select KeyValuePair.Create(name, value) :
from name in Request.QueryString.AllKeys
from value in Request.QueryString.GetValues(name)
- select new KeyValuePair(name, value))
+ select KeyValuePair.Create(name, value))
{
}
diff --git a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
index 7ca3e7ab..e314c520 100644
--- a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
+++ b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
@@ -1193,7 +1193,7 @@ internal static class OpenIddictHelpers
ReadNextPairImpl();
if (ReadSucceeded())
{
- return new KeyValuePair(_currentKey, _currentValue);
+ return KeyValuePair.Create(_currentKey, _currentValue);
}
return null;
}
@@ -1220,7 +1220,7 @@ internal static class OpenIddictHelpers
await ReadNextPairAsyncImpl(cancellationToken);
if (ReadSucceeded())
{
- return new KeyValuePair(_currentKey, _currentValue);
+ return KeyValuePair.Create(_currentKey, _currentValue);
}
return null;
}
diff --git a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs
index 78d8e04d..11332e11 100644
--- a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs
+++ b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs
@@ -258,16 +258,6 @@ internal static class OpenIddictPolyfills
#endif
}
- extension(ValueTask)
- {
-#if !SUPPORTS_VALUETASK_COMPLETED_TASK
- ///
- /// Gets a task that has already completed successfully.
- ///
- public static ValueTask CompletedTask => default;
-#endif
- }
-
extension(ValueTask)
{
#if !SUPPORTS_VALUETASK_COMPLETED_TASK
diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs
index ae9fed9f..d48dbe52 100644
--- a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs
+++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs
@@ -152,6 +152,37 @@ public class OpenIddictMessage
///
/// The message parameters.
/// Parameters with a null or empty key are always ignored.
+ public OpenIddictMessage(IEnumerable>> parameters)
+ {
+ ArgumentNullException.ThrowIfNull(parameters);
+
+ foreach (var parameter in parameters)
+ {
+ // Ignore parameters whose name is null or empty.
+ if (string.IsNullOrEmpty(parameter.Key))
+ {
+ continue;
+ }
+
+ // Note: the core OAuth 2.0 specification requires that request parameters
+ // not be present more than once but derived specifications like the
+ // token exchange specification deliberately allow specifying multiple
+ // parameters with the same name to represent a multi-valued parameter.
+ AddParameter(parameter.Key, parameter.Value switch
+ {
+ { IsDefaultOrEmpty: true } => default,
+ [string value] => new OpenIddictParameter(value),
+ [..] values => new OpenIddictParameter(values)
+ });
+ }
+ }
+
+ ///
+ /// Initializes a new OpenIddict message.
+ ///
+ /// The message parameters.
+ /// Parameters with a null or empty key are always ignored.
+ [Obsolete("This constructor is obsolete and will be removed in a future version.")]
public OpenIddictMessage(IEnumerable?>> parameters)
{
ArgumentNullException.ThrowIfNull(parameters);
@@ -170,9 +201,9 @@ public class OpenIddictMessage
// parameters with the same name to represent a multi-valued parameter.
AddParameter(parameter.Key, parameter.Value switch
{
- null or [] => default,
- [string value] => new OpenIddictParameter(value),
- [..] values => new OpenIddictParameter(values)
+ null or { IsDefaultOrEmpty: true } => default,
+ [string value] => new OpenIddictParameter(value),
+ [..] values => new OpenIddictParameter(values)
});
}
}
diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs
index c64b4613..1968f9c8 100644
--- a/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs
+++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs
@@ -80,6 +80,17 @@ public class OpenIddictRequest : OpenIddictMessage
///
/// The request parameters.
/// Parameters with a null or empty key are always ignored.
+ public OpenIddictRequest(IEnumerable>> parameters)
+ : base(parameters)
+ {
+ }
+
+ ///
+ /// Initializes a new OpenIddict request.
+ ///
+ /// The request parameters.
+ /// Parameters with a null or empty key are always ignored.
+ [Obsolete("This constructor is obsolete and will be removed in a future version.")]
public OpenIddictRequest(IEnumerable?>> parameters)
: base(parameters)
{
diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs
index 60dbce34..de24ad79 100644
--- a/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs
+++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs
@@ -79,6 +79,17 @@ public class OpenIddictResponse : OpenIddictMessage
///
/// The response parameters.
/// Parameters with a null or empty key are always ignored.
+ public OpenIddictResponse(IEnumerable>> parameters)
+ : base(parameters)
+ {
+ }
+
+ ///
+ /// Initializes a new OpenIddict response.
+ ///
+ /// The response parameters.
+ /// Parameters with a null or empty key are always ignored.
+ [Obsolete("This constructor is obsolete and will be removed in a future version.")]
public OpenIddictResponse(IEnumerable?>> parameters)
: base(parameters)
{
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
index af9c0d70..24714ad7 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
@@ -245,7 +245,7 @@ public static partial class OpenIddictClientOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in request.Query
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else if (string.Equals(request.Method, "POST", StringComparison.OrdinalIgnoreCase))
@@ -279,7 +279,7 @@ public static partial class OpenIddictClientOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in await request.ReadFormAsync()
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs
index 058cb87d..a72696e8 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs
@@ -1148,7 +1148,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
let values = (ImmutableArray?) parameter.Value
where values is not null
from value in values.GetValueOrDefault()
- select new KeyValuePair(parameter.Key, value));
+ select KeyValuePair.Create(parameter.Key, value));
}
return ValueTask.CompletedTask;
@@ -1590,7 +1590,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
value = parameter[start..index].Trim();
}
- yield return new KeyValuePair(key, value);
+ yield return KeyValuePair.Create(key, value);
}
}
}
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
index 04092b9b..f311a339 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
@@ -493,7 +493,7 @@ public static partial class OpenIddictServerOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in request.Query
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else
@@ -544,7 +544,7 @@ public static partial class OpenIddictServerOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in request.Query
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else if (string.Equals(request.Method, "POST", StringComparison.OrdinalIgnoreCase))
@@ -578,7 +578,7 @@ public static partial class OpenIddictServerOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in await request.ReadFormAsync()
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else
@@ -653,7 +653,7 @@ public static partial class OpenIddictServerOwinHandlers
context.Transaction.Request = new OpenIddictRequest(
from parameter in await request.ReadFormAsync()
let values = new StringValues(parameter.Value)
- select new KeyValuePair(parameter.Key, values));
+ select KeyValuePair.Create(parameter.Key, values));
}
else
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs
index 27aab0df..8a99c535 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.cs
@@ -548,7 +548,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
let values = (ImmutableArray?) parameter.Value
where values is not null
from value in values.GetValueOrDefault()
- select new KeyValuePair(parameter.Key, value));
+ select KeyValuePair.Create(parameter.Key, value));
}
return ValueTask.CompletedTask;
@@ -990,7 +990,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
value = parameter[start..index].Trim();
}
- yield return new KeyValuePair(key, value);
+ yield return KeyValuePair.Create(key, value);
}
}
}
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
index d7eb1c5d..05ee45ec 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
@@ -36,8 +36,8 @@ public class OpenIddictMessageTests
{
return new OpenIddictMessage(
[
- new KeyValuePair("parameter", "Fabrikam"),
- new KeyValuePair("parameter", "Contoso")
+ KeyValuePair.Create("parameter", new OpenIddictParameter("Fabrikam")),
+ KeyValuePair.Create("parameter", new OpenIddictParameter("Contoso"))
]);
});
@@ -51,7 +51,7 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair("parameter", 42)
+ KeyValuePair.Create("parameter", new OpenIddictParameter(42))
]);
// Assert
@@ -66,7 +66,7 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair(name!, "Fabrikam")
+ KeyValuePair.Create(name!, new OpenIddictParameter("Fabrikam"))
]);
// Assert
@@ -79,8 +79,8 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair("null-parameter", (string?) null),
- new KeyValuePair("empty-parameter", string.Empty)
+ KeyValuePair.Create("null-parameter", new OpenIddictParameter((string?) null)),
+ KeyValuePair.Create("empty-parameter", new OpenIddictParameter(string.Empty))
]);
// Assert
@@ -93,8 +93,8 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair("parameter", "Fabrikam"),
- new KeyValuePair("parameter", "Contoso")
+ KeyValuePair.Create("parameter", "Fabrikam"),
+ KeyValuePair.Create("parameter", "Contoso")
]);
// Assert
@@ -109,7 +109,7 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair?>("parameter", ["Fabrikam", "Contoso"])
+ KeyValuePair.Create>("parameter", ["Fabrikam", "Contoso"])
]);
// Assert
@@ -124,7 +124,7 @@ public class OpenIddictMessageTests
// Arrange and act
var message = new OpenIddictMessage(
[
- new KeyValuePair?>("parameter", ["Fabrikam"])
+ KeyValuePair.Create>("parameter", ["Fabrikam"])
]);
// Assert
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
index 58289682..483cef5d 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
@@ -823,8 +823,7 @@ public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServ
}
var claims = result.Principal.Claims.GroupBy(claim => claim.Type)
- .Select(group => new KeyValuePair?>(
- group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
+ .Select(group => KeyValuePair.Create(group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(new OpenIddictResponse(claims)));
diff --git a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs
index e56b44e2..4eac4c33 100644
--- a/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs
+++ b/test/OpenIddict.Server.IntegrationTests/OpenIddictServerIntegrationTestClient.cs
@@ -204,7 +204,7 @@ public class OpenIddictServerIntegrationTestClient : IAsyncDisposable
let values = (ImmutableArray?) parameter.Value
where values is not null
from value in values.GetValueOrDefault()
- select new KeyValuePair(parameter.Key, value));
+ select KeyValuePair.Create(parameter.Key, value));
}
return message;
@@ -295,7 +295,7 @@ public class OpenIddictServerIntegrationTestClient : IAsyncDisposable
value = parameter[start..index].Trim();
}
- yield return new KeyValuePair(key, value);
+ yield return KeyValuePair.Create(key, value);
}
}
}
@@ -356,14 +356,14 @@ public class OpenIddictServerIntegrationTestClient : IAsyncDisposable
var value = UnescapeDataString(segment.Substring(index + 1, segment.Length - (index + 1)));
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
else if (string.Equals(message.Content?.Headers?.ContentType?.MediaType, "application/json", StringComparison.OrdinalIgnoreCase))
@@ -399,14 +399,14 @@ public class OpenIddictServerIntegrationTestClient : IAsyncDisposable
var value = element.GetAttribute("value");
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
else if (string.Equals(message.Content?.Headers?.ContentType?.MediaType, "text/plain", StringComparison.OrdinalIgnoreCase))
@@ -438,14 +438,14 @@ public class OpenIddictServerIntegrationTestClient : IAsyncDisposable
var value = line[(index + 1)..];
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
return new OpenIddictResponse();
diff --git a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs
index 5c3ae12f..0c3d36c5 100644
--- a/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs
+++ b/test/OpenIddict.Server.Owin.IntegrationTests/OpenIddictServerOwinIntegrationTests.cs
@@ -776,8 +776,7 @@ public partial class OpenIddictServerOwinIntegrationTests : OpenIddictServerInte
}
var claims = result.Identity.Claims.GroupBy(claim => claim.Type)
- .Select(group => new KeyValuePair?>(
- group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
+ .Select(group => KeyValuePair.Create(group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(new OpenIddictResponse(claims)));
diff --git a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs
index 552717d7..626386cc 100644
--- a/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs
+++ b/test/OpenIddict.Validation.AspNetCore.IntegrationTests/OpenIddictValidationAspNetCoreIntegrationTests.cs
@@ -185,8 +185,7 @@ public partial class OpenIddictValidationAspNetCoreIntegrationTests : OpenIddict
}
var claims = result.Principal.Claims.GroupBy(claim => claim.Type)
- .Select(group => new KeyValuePair?>(
- group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
+ .Select(group => KeyValuePair.Create(group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(new OpenIddictResponse(claims)));
diff --git a/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTestClient.cs b/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTestClient.cs
index 8528faab..a286ad59 100644
--- a/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTestClient.cs
+++ b/test/OpenIddict.Validation.IntegrationTests/OpenIddictValidationIntegrationTestClient.cs
@@ -204,7 +204,7 @@ public class OpenIddictValidationIntegrationTestClient : IAsyncDisposable
let values = (ImmutableArray?) parameter.Value
where values is not null
from value in values.GetValueOrDefault()
- select new KeyValuePair(parameter.Key, value));
+ select KeyValuePair.Create(parameter.Key, value));
}
return message;
@@ -295,7 +295,7 @@ public class OpenIddictValidationIntegrationTestClient : IAsyncDisposable
value = parameter[start..index].Trim();
}
- yield return new KeyValuePair(key, value);
+ yield return KeyValuePair.Create(key, value);
}
}
}
@@ -356,14 +356,14 @@ public class OpenIddictValidationIntegrationTestClient : IAsyncDisposable
var value = UnescapeDataString(segment.Substring(index + 1, segment.Length - (index + 1)));
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
else if (string.Equals(message.Content?.Headers?.ContentType?.MediaType, "application/json", StringComparison.OrdinalIgnoreCase))
@@ -399,14 +399,14 @@ public class OpenIddictValidationIntegrationTestClient : IAsyncDisposable
var value = element.GetAttribute("value");
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
else if (string.Equals(message.Content?.Headers?.ContentType?.MediaType, "text/plain", StringComparison.OrdinalIgnoreCase))
@@ -438,14 +438,14 @@ public class OpenIddictValidationIntegrationTestClient : IAsyncDisposable
var value = line[(index + 1)..];
- parameters.Add(new KeyValuePair(name, value));
+ parameters.Add(KeyValuePair.Create(name, value));
}
return new OpenIddictResponse(
from parameter in parameters
group parameter by parameter.Key into grouping
let values = grouping.Select(parameter => parameter.Value)
- select new KeyValuePair(grouping.Key, values.ToArray()));
+ select KeyValuePair.Create(grouping.Key, new StringValues(values.ToArray())));
}
return new OpenIddictResponse();
diff --git a/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddictValidationOwinIntegrationTests.cs b/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddictValidationOwinIntegrationTests.cs
index 3eaf0731..a7dc3951 100644
--- a/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddictValidationOwinIntegrationTests.cs
+++ b/test/OpenIddict.Validation.Owin.IntegrationTests/OpenIddictValidationOwinIntegrationTests.cs
@@ -170,8 +170,7 @@ public partial class OpenIddictValidationOwinIntegrationTests : OpenIddictValida
}
var claims = result.Identity.Claims.GroupBy(claim => claim.Type)
- .Select(group => new KeyValuePair?>(
- group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
+ .Select(group => KeyValuePair.Create(group.Key, group.Select(claim => claim.Value).ToImmutableArray()));
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(new OpenIddictResponse(claims)));