diff --git a/build/dependencies.props b/build/dependencies.props
index d37b8f56..8d155c26 100644
--- a/build/dependencies.props
+++ b/build/dependencies.props
@@ -15,6 +15,7 @@
4.7.63
4.0.1
1.0.0
+ 4.0.0
15.0.0
4.1.0
4.1.0
diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
index 295acc5a..e9099c30 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
@@ -327,10 +327,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application.
///
- public virtual Task GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@@ -346,10 +346,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client type of the application (by default, "public").
///
- public virtual async Task GetClientTypeAsync(
+ public virtual ValueTask GetClientTypeAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
@@ -357,18 +357,23 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(application));
}
- var type = await Store.GetClientTypeAsync(application, cancellationToken);
-
- // Ensure the application type returned by the store is supported by the manager.
- if (!string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(type, OpenIddictConstants.ClientTypes.Hybrid, StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
+ async Task ResolveClientTypeAsync()
{
- throw new InvalidOperationException("Only 'confidential', 'hybrid' or 'public' applications are " +
- "supported by the default application manager.");
+ var type = await Store.GetClientTypeAsync(application, cancellationToken);
+
+ // Ensure the application type returned by the store is supported by the manager.
+ if (!string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, StringComparison.OrdinalIgnoreCase) &&
+ !string.Equals(type, OpenIddictConstants.ClientTypes.Hybrid, StringComparison.OrdinalIgnoreCase) &&
+ !string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
+ {
+ throw new InvalidOperationException("Only 'confidential', 'hybrid' or 'public' applications are " +
+ "supported by the default application manager.");
+ }
+
+ return type;
}
- return type;
+ return new ValueTask(ResolveClientTypeAsync());
}
///
@@ -377,23 +382,28 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the consent type of the application (by default, "explicit").
///
- public virtual async Task GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- var type = await Store.GetConsentTypeAsync(application, cancellationToken);
- if (string.IsNullOrEmpty(type))
+ async Task ResolveConsentTypeAsync()
{
- return OpenIddictConstants.ConsentTypes.Explicit;
+ var type = await Store.GetConsentTypeAsync(application, cancellationToken);
+ if (string.IsNullOrEmpty(type))
+ {
+ return OpenIddictConstants.ConsentTypes.Explicit;
+ }
+
+ return type;
}
- return type;
+ return new ValueTask(ResolveConsentTypeAsync());
}
///
@@ -402,10 +412,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application.
///
- public virtual Task GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@@ -421,10 +431,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
///
- public virtual Task GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@@ -440,10 +450,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application.
///
- public virtual Task> GetPermissionsAsync(
+ public virtual ValueTask> GetPermissionsAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
@@ -460,10 +470,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the post_logout_redirect_uri associated with the application.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the post_logout_redirect_uri associated with the application.
///
- public virtual Task> GetPostLogoutRedirectUrisAsync(
+ public virtual ValueTask> GetPostLogoutRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
@@ -480,10 +490,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application.
///
- public virtual Task> GetRedirectUrisAsync(
+ public virtual ValueTask> GetRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
index c362a269..c944105c 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
@@ -386,10 +386,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization.
///
- public virtual Task GetApplicationIdAsync(
+ public virtual ValueTask GetApplicationIdAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
@@ -446,10 +446,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization.
///
- public virtual Task GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@@ -465,10 +465,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the scopes associated with the specified authorization.
///
- public virtual Task> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
+ public virtual ValueTask> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@@ -484,10 +484,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization.
///
- public virtual Task GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@@ -503,10 +503,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified authorization.
///
- public virtual Task GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@@ -522,10 +522,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the type associated with the specified authorization.
///
- public virtual Task GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
diff --git a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
index b0eecfb4..ec4015d4 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
@@ -248,10 +248,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the description associated with the specified scope.
///
- public virtual Task GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@@ -267,10 +267,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
///
- public virtual Task GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@@ -286,10 +286,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope.
///
- public virtual Task GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@@ -305,10 +305,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the name associated with the specified scope.
///
- public virtual Task GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@@ -324,10 +324,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the resources associated with the scope.
///
- public virtual Task> GetResourcesAsync(
+ public virtual ValueTask> GetResourcesAsync(
[NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
diff --git a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
index 6dc9cad0..2ea62973 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
@@ -279,10 +279,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the token.
///
- public virtual Task GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -338,10 +338,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the authorization identifier associated with the token.
///
- public virtual Task GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -357,10 +357,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the creation date associated with the specified token.
///
- public virtual Task GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -376,10 +376,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the expiration date associated with the specified token.
///
- public virtual Task GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -395,10 +395,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the token.
///
- public virtual Task GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -414,10 +414,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the payload associated with the specified token.
///
- public virtual Task GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -435,10 +435,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the reference identifier associated with the specified token.
///
- public virtual Task GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -454,10 +454,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified token.
///
- public virtual Task GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ public virtual ValueTask GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@@ -467,6 +467,44 @@ namespace OpenIddict.Core
return Store.GetStatusAsync(token, cancellationToken);
}
+ ///
+ /// Retrieves the subject associated with a token.
+ ///
+ /// The token.
+ /// The that can be used to abort the operation.
+ ///
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the subject associated with the specified token.
+ ///
+ public virtual ValueTask GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ {
+ if (token == null)
+ {
+ throw new ArgumentNullException(nameof(token));
+ }
+
+ return Store.GetSubjectAsync(token, cancellationToken);
+ }
+
+ ///
+ /// Retrieves the token type associated with a token.
+ ///
+ /// The token.
+ /// The that can be used to abort the operation.
+ ///
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the token type associated with the specified token.
+ ///
+ public virtual ValueTask GetTokenTypeAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
+ {
+ if (token == null)
+ {
+ throw new ArgumentNullException(nameof(token));
+ }
+
+ return Store.GetTokenTypeAsync(token, cancellationToken);
+ }
+
///
/// Determines whether a given token has already been redemeed.
///
diff --git a/src/OpenIddict.Core/OpenIddict.Core.csproj b/src/OpenIddict.Core/OpenIddict.Core.csproj
index f8081a3d..316ea0d6 100644
--- a/src/OpenIddict.Core/OpenIddict.Core.csproj
+++ b/src/OpenIddict.Core/OpenIddict.Core.csproj
@@ -26,6 +26,7 @@
+
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
index 11f11698..c9f023e7 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
@@ -128,10 +128,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application.
///
- Task GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the client secret associated with an application.
@@ -141,10 +141,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client secret associated with the application.
///
- Task GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the client type associated with an application.
@@ -152,10 +152,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client type of the application (by default, "public").
///
- Task GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the consent type associated with an application.
@@ -163,10 +163,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the consent type of the application (by default, "explicit").
///
- Task GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the display name associated with an application.
@@ -174,10 +174,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application.
///
- Task GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the unique identifier associated with an application.
@@ -185,10 +185,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
///
- Task GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the permissions associated with an application.
@@ -196,10 +196,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application.
///
- Task> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the logout callback addresses associated with an application.
@@ -207,10 +207,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the post_logout_redirect_uri associated with the application.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the post_logout_redirect_uri associated with the application.
///
- Task> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the additional properties associated with an application.
@@ -218,10 +218,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the additional properties associated with the application.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the additional properties associated with the application.
///
- Task GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Retrieves the callback addresses associated with an application.
@@ -229,20 +229,20 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application.
///
- Task> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken);
+ ValueTask> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken);
///
/// Instantiates a new application.
///
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose result
- /// returns the instantiated application, that can be persisted in the database.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the instantiated application, that can be persisted in the database.
///
- Task InstantiateAsync(CancellationToken cancellationToken);
+ ValueTask InstantiateAsync(CancellationToken cancellationToken);
///
/// Executes the specified query and returns all the corresponding elements.
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs
index 38073448..95dd042d 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs
@@ -135,10 +135,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization.
///
- Task GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Executes the specified query and returns the first element.
@@ -162,10 +162,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization.
///
- Task GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Retrieves the additional properties associated with an authorization.
@@ -173,10 +173,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the additional properties associated with the authorization.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the additional properties associated with the authorization.
///
- Task GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Retrieves the scopes associated with an authorization.
@@ -184,10 +184,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the scopes associated with the specified authorization.
///
- Task> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Retrieves the status associated with an authorization.
@@ -195,10 +195,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization.
///
- Task GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Retrieves the subject associated with an authorization.
@@ -206,10 +206,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified authorization.
///
- Task GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Retrieves the type associated with an authorization.
@@ -217,20 +217,20 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the type associated with the specified authorization.
///
- Task GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
+ ValueTask GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
///
/// Instantiates a new authorization.
///
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose result
- /// returns the instantiated authorization, that can be persisted in the database.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the instantiated authorization, that can be persisted in the database.
///
- Task InstantiateAsync(CancellationToken cancellationToken);
+ ValueTask InstantiateAsync(CancellationToken cancellationToken);
///
/// Executes the specified query and returns all the corresponding elements.
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs
index f0f2ade9..996405db 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs
@@ -117,10 +117,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the description associated with the specified scope.
///
- Task GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Retrieves the display name associated with a scope.
@@ -128,10 +128,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
///
- Task GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Retrieves the unique identifier associated with a scope.
@@ -139,10 +139,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope.
///
- Task GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Retrieves the name associated with a scope.
@@ -150,10 +150,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the name associated with the specified scope.
///
- Task GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Retrieves the additional properties associated with a scope.
@@ -161,10 +161,10 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
+ /// A that can be used to monitor the asynchronous operation, whose
/// result returns all the additional properties associated with the scope.
///
- Task GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Retrieves the resources associated with a scope.
@@ -172,20 +172,20 @@ namespace OpenIddict.Core
/// The scope.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the resources associated with the scope.
///
- Task> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken);
+ ValueTask> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken);
///
/// Instantiates a new scope.
///
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the instantiated scope, that can be persisted in the database.
///
- Task InstantiateAsync(CancellationToken cancellationToken);
+ ValueTask InstantiateAsync(CancellationToken cancellationToken);
///
/// Executes the specified query and returns all the corresponding elements.
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
index 57daeb73..59f4cef3 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
@@ -122,10 +122,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the token.
///
- Task GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Executes the specified query and returns the first element.
@@ -149,10 +149,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the authorization identifier associated with the token.
///
- Task GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the creation date associated with a token.
@@ -160,10 +160,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the creation date associated with the specified token.
///
- Task GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the expiration date associated with a token.
@@ -171,10 +171,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the expiration date associated with the specified token.
///
- Task GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the unique identifier associated with a token.
@@ -182,10 +182,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the token.
///
- Task GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the payload associated with a token.
@@ -193,10 +193,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the payload associated with the specified token.
///
- Task GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the additional properties associated with a token.
@@ -204,10 +204,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the additional properties associated with the token.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the additional properties associated with the token.
///
- Task GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the reference identifier associated with a token.
@@ -217,10 +217,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the reference identifier associated with the specified token.
///
- Task GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the status associated with a token.
@@ -228,10 +228,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified token.
///
- Task GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the subject associated with a token.
@@ -239,10 +239,10 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified token.
///
- Task GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Retrieves the token type associated with a token.
@@ -250,20 +250,20 @@ namespace OpenIddict.Core
/// The token.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the token type associated with the specified token.
///
- Task GetTokenTypeAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ValueTask GetTokenTypeAsync([NotNull] TToken token, CancellationToken cancellationToken);
///
/// Instantiates a new token.
///
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the instantiated token, that can be persisted in the database.
///
- Task InstantiateAsync(CancellationToken cancellationToken);
+ ValueTask InstantiateAsync(CancellationToken cancellationToken);
///
/// Executes the specified query and returns all the corresponding elements.
diff --git a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
index 9956092b..08142fd5 100644
--- a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
+++ b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
@@ -255,17 +255,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application.
///
- public virtual Task GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(application.ClientId);
+ return new ValueTask(application.ClientId);
}
///
@@ -276,17 +276,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client secret associated with the application.
///
- public virtual Task GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(application.ClientSecret);
+ return new ValueTask(application.ClientSecret);
}
///
@@ -295,17 +295,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the client type of the application (by default, "public").
///
- public virtual Task GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(application.Type);
+ return new ValueTask(application.Type);
}
///
@@ -314,17 +314,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the consent type of the application (by default, "explicit").
///
- public virtual Task GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(application.ConsentType);
+ return new ValueTask(application.ConsentType);
}
///
@@ -333,17 +333,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application.
///
- public virtual Task GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(application.DisplayName);
+ return new ValueTask(application.DisplayName);
}
///
@@ -352,17 +352,17 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
///
- public virtual Task GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
throw new ArgumentNullException(nameof(application));
}
- return Task.FromResult(ConvertIdentifierToString(application.Id));
+ return new ValueTask(ConvertIdentifierToString(application.Id));
}
///
@@ -371,10 +371,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application.
///
- public virtual Task> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@@ -383,7 +383,7 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(application.Permissions))
{
- return Task.FromResult(ImmutableArray.Create());
+ return new ValueTask>(ImmutableArray.Create());
}
// Note: parsing the stringified permissions is an expensive operation.
@@ -398,7 +398,7 @@ namespace OpenIddict.Core
.ToImmutableArray());
}
- return Task.FromResult(permissions.GetValueOrDefault());
+ return new ValueTask>(permissions.GetValueOrDefault());
}
///
@@ -407,10 +407,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the post_logout_redirect_uri associated with the application.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the post_logout_redirect_uri associated with the application.
///
- public virtual Task> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@@ -419,7 +419,7 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(application.PostLogoutRedirectUris))
{
- return Task.FromResult(ImmutableArray.Create());
+ return new ValueTask>(ImmutableArray.Create());
}
// Note: parsing the stringified addresses is an expensive operation.
@@ -434,7 +434,7 @@ namespace OpenIddict.Core
.ToImmutableArray());
}
- return Task.FromResult(addresses.GetValueOrDefault());
+ return new ValueTask>(addresses.GetValueOrDefault());
}
///
@@ -443,10 +443,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the additional properties associated with the application.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the additional properties associated with the application.
///
- public virtual Task GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@@ -455,10 +455,10 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(application.Properties))
{
- return Task.FromResult(new JObject());
+ return new ValueTask(new JObject());
}
- return Task.FromResult(JObject.Parse(application.Properties));
+ return new ValueTask(JObject.Parse(application.Properties));
}
///
@@ -467,10 +467,10 @@ namespace OpenIddict.Core
/// The application.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application.
///
- public virtual Task> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
+ public virtual ValueTask> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@@ -479,7 +479,7 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(application.RedirectUris))
{
- return Task.FromResult(ImmutableArray.Create());
+ return new ValueTask>(ImmutableArray.Create());
}
// Note: parsing the stringified addresses is an expensive operation.
@@ -494,7 +494,7 @@ namespace OpenIddict.Core
.ToImmutableArray());
}
- return Task.FromResult(addresses.GetValueOrDefault());
+ return new ValueTask>(addresses.GetValueOrDefault());
}
///
@@ -502,10 +502,11 @@ namespace OpenIddict.Core
///
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose result
- /// returns the instantiated application, that can be persisted in the database.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the instantiated application, that can be persisted in the database.
///
- public virtual Task InstantiateAsync(CancellationToken cancellationToken) => Task.FromResult(new TApplication());
+ public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken)
+ => new ValueTask(new TApplication());
///
/// Executes the specified query and returns all the corresponding elements.
diff --git a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs
index 2d0689cf..6eae3a68 100644
--- a/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs
+++ b/src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs
@@ -278,10 +278,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization.
///
- public virtual async Task GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
+ public virtual ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{
@@ -290,17 +290,22 @@ namespace OpenIddict.Core
if (authorization.Application != null)
{
- return ConvertIdentifierToString(authorization.Application.Id);
+ return new ValueTask(ConvertIdentifierToString(authorization.Application.Id));
}
- IQueryable Query(IQueryable authorizations, TKey key)
- => from element in authorizations
- where element.Id.Equals(key) &&
- element.Application != null
- select element.Application.Id;
+ async Task RetrieveApplicationIdAsync()
+ {
+ IQueryable Query(IQueryable authorizations, TKey key)
+ => from element in authorizations
+ where element.Id.Equals(key) &&
+ element.Application != null
+ select element.Application.Id;
+
+ return ConvertIdentifierToString(await GetAsync(
+ (authorizations, key) => Query(authorizations, key), authorization.Id, cancellationToken));
+ }
- return ConvertIdentifierToString(await GetAsync(
- (authorizations, key) => Query(authorizations, key), authorization.Id, cancellationToken));
+ return new ValueTask(RetrieveApplicationIdAsync());
}
///
@@ -325,17 +330,17 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization.
///
- public virtual Task GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
+ public virtual ValueTask GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{
throw new ArgumentNullException(nameof(authorization));
}
- return Task.FromResult(ConvertIdentifierToString(authorization.Id));
+ return new ValueTask(ConvertIdentifierToString(authorization.Id));
}
///
@@ -344,10 +349,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation, whose
- /// result returns all the additional properties associated with the authorization.
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns all the additional properties associated with the authorization.
///
- public virtual Task GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
+ public virtual ValueTask GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{
@@ -356,10 +361,10 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(authorization.Properties))
{
- return Task.FromResult(new JObject());
+ return new ValueTask(new JObject());
}
- return Task.FromResult(JObject.Parse(authorization.Properties));
+ return new ValueTask(JObject.Parse(authorization.Properties));
}
///
@@ -368,10 +373,10 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the scopes associated with the specified authorization.
///
- public virtual Task> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
+ public virtual ValueTask> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{
@@ -380,10 +385,10 @@ namespace OpenIddict.Core
if (string.IsNullOrEmpty(authorization.Scopes))
{
- return Task.FromResult(ImmutableArray.Create());
+ return new ValueTask>(ImmutableArray.Create());
}
- return Task.FromResult(JArray.Parse(authorization.Scopes).Select(element => (string) element).ToImmutableArray());
+ return new ValueTask>(JArray.Parse(authorization.Scopes).Select(element => (string) element).ToImmutableArray());
}
///
@@ -392,12 +397,17 @@ namespace OpenIddict.Core
/// The authorization.
/// The that can be used to abort the operation.
///
- /// A that can be used to monitor the asynchronous operation,
+ /// A that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization.
///
- public virtual Task GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
+ public virtual ValueTask GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
{
- return Task.FromResult(authorization.Status);
+ if (authorization == null)
+ {
+ throw new ArgumentNullException(nameof(authorization));
+ }
+
+ return new ValueTask