From 8592dce45b145c35ae6c53aae7e9a195b3b76a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sun, 25 Feb 2018 17:16:45 +0100 Subject: [PATCH] Update the Get*Async() managers/stores methods to return ValueTask instead of Task --- build/dependencies.props | 1 + .../Managers/OpenIddictApplicationManager.cs | 34 ++-- .../OpenIddictAuthorizationManager.cs | 24 +-- .../Managers/OpenIddictScopeManager.cs | 20 +-- .../Managers/OpenIddictTokenManager.cs | 70 ++++++-- src/OpenIddict.Core/OpenIddict.Core.csproj | 1 + .../Stores/IOpenIddictApplicationStore.cs | 50 +++--- .../Stores/IOpenIddictAuthorizationStore.cs | 36 ++--- .../Stores/IOpenIddictScopeStore.cs | 28 ++-- .../Stores/IOpenIddictTokenStore.cs | 50 +++--- .../Stores/OpenIddictApplicationStore.cs | 79 ++++----- .../Stores/OpenIddictAuthorizationStore.cs | 58 ++++--- .../Stores/OpenIddictScopeStore.cs | 47 +++--- .../Stores/OpenIddictTokenStore.cs | 71 ++++---- .../Stores/OpenIddictAuthorizationStore.cs | 4 +- .../Stores/OpenIddictTokenStore.cs | 8 +- .../Stores/OpenIddictAuthorizationStore.cs | 4 +- .../Stores/OpenIddictTokenStore.cs | 8 +- .../OpenIddictProviderTests.Authentication.cs | 16 +- .../OpenIddictProviderTests.Exchange.cs | 72 ++++----- .../OpenIddictProviderTests.Introspection.cs | 18 +-- .../OpenIddictProviderTests.Revocation.cs | 10 +- .../OpenIddictProviderTests.Serialization.cs | 152 +++++++++--------- .../OpenIddictProviderTests.cs | 48 +++--- 24 files changed, 479 insertions(+), 430 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5a2b5b76..cedd715a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -16,6 +16,7 @@ 2.0.0 2.0.0 2.0.0 + 4.4.0 15.3.0 2.3.1 diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs index e60ab678..c9869f39 100644 --- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs +++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs @@ -326,10 +326,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) { @@ -345,10 +345,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 async ValueTask GetClientTypeAsync( [NotNull] TApplication application, CancellationToken cancellationToken = default) { if (application == null) @@ -376,10 +376,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"). /// - public virtual async Task GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken = default) + public virtual async ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken = default) { if (application == null) { @@ -401,10 +401,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) { @@ -420,10 +420,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) { @@ -439,10 +439,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) @@ -459,10 +459,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) @@ -479,10 +479,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 2d2f3931..32092ff8 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 dabc46e4..9b6a88a1 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs @@ -254,17 +254,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); } /// @@ -275,17 +275,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); } /// @@ -294,17 +294,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); } /// @@ -313,17 +313,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); } /// @@ -332,17 +332,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); } /// @@ -351,17 +351,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)); } /// @@ -370,10 +370,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) { @@ -382,7 +382,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. @@ -397,7 +397,7 @@ namespace OpenIddict.Core .ToImmutableArray()); } - return Task.FromResult(permissions.GetValueOrDefault()); + return new ValueTask>(permissions.GetValueOrDefault()); } /// @@ -406,10 +406,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) { @@ -418,7 +418,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. @@ -433,7 +433,7 @@ namespace OpenIddict.Core .ToImmutableArray()); } - return Task.FromResult(addresses.GetValueOrDefault()); + return new ValueTask>(addresses.GetValueOrDefault()); } /// @@ -442,10 +442,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) { @@ -454,10 +454,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)); } /// @@ -466,10 +466,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) { @@ -478,7 +478,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. @@ -493,7 +493,7 @@ namespace OpenIddict.Core .ToImmutableArray()); } - return Task.FromResult(addresses.GetValueOrDefault()); + return new ValueTask>(addresses.GetValueOrDefault()); } /// @@ -501,10 +501,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 0a846ce0..97dcc6cd 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 async ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { @@ -325,17 +325,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 +344,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 +356,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 +368,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 +380,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 +392,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(authorization.Status); } /// @@ -406,17 +411,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 subject associated with the specified authorization. /// - public virtual Task GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public virtual ValueTask GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return Task.FromResult(authorization.Subject); + return new ValueTask(authorization.Subject); } /// @@ -425,17 +430,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 type associated with the specified authorization. /// - public virtual Task GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public virtual ValueTask GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } - return Task.FromResult(authorization.Type); + return new ValueTask(authorization.Type); } /// @@ -443,10 +448,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 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. /// - public virtual Task InstantiateAsync(CancellationToken cancellationToken) => Task.FromResult(new TAuthorization()); + public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) + => new ValueTask(new TAuthorization()); /// /// Executes the specified query and returns all the corresponding elements. diff --git a/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs b/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs index 5bd08b87..b7686484 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs @@ -183,17 +183,17 @@ 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) + public virtual ValueTask GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return Task.FromResult(scope.Description); + return new ValueTask(scope.Description); } /// @@ -202,17 +202,17 @@ 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) + public virtual ValueTask GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return Task.FromResult(scope.DisplayName); + return new ValueTask(scope.DisplayName); } /// @@ -221,17 +221,17 @@ 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) + public virtual ValueTask GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return Task.FromResult(ConvertIdentifierToString(scope.Id)); + return new ValueTask(ConvertIdentifierToString(scope.Id)); } /// @@ -240,17 +240,17 @@ 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) + public virtual ValueTask GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { throw new ArgumentNullException(nameof(scope)); } - return Task.FromResult(scope.Name); + return new ValueTask(scope.Name); } /// @@ -259,10 +259,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 - /// result returns all the additional properties associated with the scope. + /// A that can be used to monitor the asynchronous operation, + /// whose result returns all the additional properties associated with the scope. /// - public virtual Task GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken) + public virtual ValueTask GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -271,10 +271,10 @@ namespace OpenIddict.Core if (string.IsNullOrEmpty(scope.Properties)) { - return Task.FromResult(new JObject()); + return new ValueTask(new JObject()); } - return Task.FromResult(JObject.Parse(scope.Properties)); + return new ValueTask(JObject.Parse(scope.Properties)); } /// @@ -283,10 +283,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([NotNull] TScope scope, CancellationToken cancellationToken) + public virtual ValueTask> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken) { if (scope == null) { @@ -295,7 +295,7 @@ namespace OpenIddict.Core if (string.IsNullOrEmpty(scope.Resources)) { - return Task.FromResult(ImmutableArray.Create()); + return new ValueTask>(ImmutableArray.Create()); } // Note: parsing the stringified resources is an expensive operation. @@ -310,7 +310,7 @@ namespace OpenIddict.Core .ToImmutableArray()); } - return Task.FromResult(resources.GetValueOrDefault()); + return new ValueTask>(resources.GetValueOrDefault()); } /// @@ -318,10 +318,11 @@ namespace OpenIddict.Core /// /// 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. /// - public virtual Task InstantiateAsync(CancellationToken cancellationToken) => Task.FromResult(new TScope()); + public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) + => new ValueTask(new TScope()); /// /// Executes the specified query and returns all the corresponding elements. diff --git a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs index aea470fc..9ef06ac0 100644 --- a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs @@ -236,10 +236,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 async Task GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public virtual async ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -266,10 +266,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 async Task GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public virtual async ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -296,17 +296,17 @@ 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) + public virtual ValueTask GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.CreationDate); + return new ValueTask(token.CreationDate); } /// @@ -315,17 +315,17 @@ 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) + public virtual ValueTask GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.ExpirationDate); + return new ValueTask(token.ExpirationDate); } /// @@ -334,17 +334,17 @@ 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) + public virtual ValueTask GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(ConvertIdentifierToString(token.Id)); + return new ValueTask(ConvertIdentifierToString(token.Id)); } /// @@ -353,17 +353,17 @@ 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) + public virtual ValueTask GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.Payload); + return new ValueTask(token.Payload); } /// @@ -372,10 +372,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. /// - public virtual Task GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken) + public virtual ValueTask GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -384,10 +384,10 @@ namespace OpenIddict.Core if (string.IsNullOrEmpty(token.Properties)) { - return Task.FromResult(new JObject()); + return new ValueTask(new JObject()); } - return Task.FromResult(JObject.Parse(token.Properties)); + return new ValueTask(JObject.Parse(token.Properties)); } /// @@ -398,17 +398,17 @@ 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) + public virtual ValueTask GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.ReferenceId); + return new ValueTask(token.ReferenceId); } /// @@ -417,17 +417,17 @@ 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) + public virtual ValueTask GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.Status); + return new ValueTask(token.Status); } /// @@ -436,17 +436,17 @@ 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. /// - public virtual Task GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken) + public virtual ValueTask GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.Subject); + return new ValueTask(token.Subject); } /// @@ -455,17 +455,17 @@ 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. /// - public virtual Task GetTokenTypeAsync([NotNull] TToken token, CancellationToken cancellationToken) + public virtual ValueTask GetTokenTypeAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { throw new ArgumentNullException(nameof(token)); } - return Task.FromResult(token.Type); + return new ValueTask(token.Type); } /// @@ -473,10 +473,11 @@ namespace OpenIddict.Core /// /// 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. /// - public virtual Task InstantiateAsync(CancellationToken cancellationToken) => Task.FromResult(new TToken()); + public virtual ValueTask InstantiateAsync(CancellationToken cancellationToken) + => new ValueTask(new TToken()); /// /// Executes the specified query and returns all the corresponding elements. diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs index dc436919..00939ab9 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictAuthorizationStore.cs @@ -213,10 +213,10 @@ namespace OpenIddict.EntityFramework /// 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 override async Task GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public override async ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { diff --git a/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs index bc34ecc9..c401c05b 100644 --- a/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.EntityFramework/Stores/OpenIddictTokenStore.cs @@ -200,10 +200,10 @@ namespace OpenIddict.EntityFramework /// 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 override async Task GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override async ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -262,10 +262,10 @@ namespace OpenIddict.EntityFramework /// 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 override async Task GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override async ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs index 1f941f5a..654eef1f 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs @@ -365,10 +365,10 @@ namespace OpenIddict.EntityFrameworkCore /// 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 override async Task GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) + public override async ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs index 2b646a7a..ff047cc4 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs @@ -264,10 +264,10 @@ namespace OpenIddict.EntityFrameworkCore /// 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 override async Task GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override async ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { @@ -326,10 +326,10 @@ namespace OpenIddict.EntityFrameworkCore /// 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 override async Task GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) + public override async ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) { if (token == null) { diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.Authentication.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.Authentication.cs index d279ea50..623019c2 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.Authentication.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.Authentication.cs @@ -235,7 +235,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.HasPermissionAsync(application, OpenIddictConstants.Permissions.Endpoints.Authorization, It.IsAny())) @@ -296,7 +296,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.HasPermissionAsync(application, OpenIddictConstants.Permissions.Endpoints.Authorization, It.IsAny())) @@ -524,7 +524,7 @@ namespace OpenIddict.Tests .ReturnsAsync(application); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); }); var server = CreateAuthorizationServer(builder => @@ -820,7 +820,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(cache.Object); @@ -891,10 +891,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(CreateTokenManager(instance => @@ -905,7 +905,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); }); @@ -975,7 +975,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(cache.Object); diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.Exchange.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.Exchange.cs index 172b7de5..750af5de 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.Exchange.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.Exchange.cs @@ -397,7 +397,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); }); var server = CreateAuthorizationServer(builder => @@ -447,7 +447,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); }); var server = CreateAuthorizationServer(builder => @@ -499,7 +499,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); }); var server = CreateAuthorizationServer(builder => @@ -551,7 +551,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Hybrid); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Hybrid)); }); var server = CreateAuthorizationServer(builder => @@ -603,7 +603,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(false); @@ -663,7 +663,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -755,7 +755,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Configure(options => options.AuthorizationCodeFormat = format.Object); @@ -815,7 +815,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Configure(options => options.RefreshTokenFormat = format.Object); @@ -880,7 +880,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -947,7 +947,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -997,7 +997,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1021,7 +1021,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -1073,7 +1073,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1097,7 +1097,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -1167,7 +1167,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(CreateTokenManager(instance => @@ -1178,10 +1178,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetAuthorizationIdAsync(token, It.IsAny())) - .ReturnsAsync("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0"); + .Returns(new ValueTask("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1258,7 +1258,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(CreateTokenManager(instance => @@ -1269,10 +1269,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetAuthorizationIdAsync(token, It.IsAny())) - .ReturnsAsync("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0"); + .Returns(new ValueTask("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1333,16 +1333,16 @@ namespace OpenIddict.Tests .ReturnsAsync(tokens[0]); instance.Setup(mock => mock.GetIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetIdAsync(tokens[1], It.IsAny())) - .ReturnsAsync("481FCAC6-06BC-43EE-92DB-37A78AA09B59"); + .Returns(new ValueTask("481FCAC6-06BC-43EE-92DB-37A78AA09B595073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[2], It.IsAny())) - .ReturnsAsync("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8"); + .Returns(new ValueTask("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8")); instance.Setup(mock => mock.GetAuthorizationIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0"); + .Returns(new ValueTask("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0")); instance.Setup(mock => mock.IsRedeemedAsync(tokens[0], It.IsAny())) .ReturnsAsync(true); @@ -1369,7 +1369,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(CreateAuthorizationManager(instance => @@ -1436,16 +1436,16 @@ namespace OpenIddict.Tests .ReturnsAsync(tokens[0]); instance.Setup(mock => mock.GetIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetIdAsync(tokens[1], It.IsAny())) - .ReturnsAsync("481FCAC6-06BC-43EE-92DB-37A78AA09B59"); + .Returns(new ValueTask("481FCAC6-06BC-43EE-92DB-37A78AA09B595073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[2], It.IsAny())) - .ReturnsAsync("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8"); + .Returns(new ValueTask("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8")); instance.Setup(mock => mock.GetAuthorizationIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0"); + .Returns(new ValueTask("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0")); instance.Setup(mock => mock.IsRedeemedAsync(tokens[0], It.IsAny())) .ReturnsAsync(true); @@ -1472,7 +1472,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(CreateAuthorizationManager(instance => @@ -1534,7 +1534,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -1561,7 +1561,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -1614,7 +1614,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -1641,7 +1641,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -1710,7 +1710,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1750,7 +1750,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.Introspection.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.Introspection.cs index 3e877e90..7be4104b 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.Introspection.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.Introspection.cs @@ -153,7 +153,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); }); var server = CreateAuthorizationServer(builder => @@ -197,7 +197,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(false); @@ -266,7 +266,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -324,7 +324,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -383,7 +383,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -434,7 +434,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -492,10 +492,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); instance.Setup(mock => mock.FindByIdAsync("3E228451-1555-46F7-A471-951EFBA23A56", It.IsAny())) .ReturnsAsync(token); @@ -518,7 +518,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.Revocation.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.Revocation.cs index e55604a3..5678746b 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.Revocation.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.Revocation.cs @@ -156,7 +156,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); }); var server = CreateAuthorizationServer(builder => @@ -201,7 +201,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); }); var server = CreateAuthorizationServer(builder => @@ -246,7 +246,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Hybrid); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Hybrid)); }); var server = CreateAuthorizationServer(builder => @@ -291,7 +291,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(false); @@ -520,7 +520,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.Serialization.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.Serialization.cs index 12f310aa..80664613 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.Serialization.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.Serialization.cs @@ -45,7 +45,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -123,7 +123,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -164,7 +164,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -181,7 +181,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -223,10 +223,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -243,7 +243,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -290,10 +290,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); }); var server = CreateAuthorizationServer(builder => @@ -310,7 +310,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -371,10 +371,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); instance.Setup(mock => mock.FindByIdAsync("3E228451-1555-46F7-A471-951EFBA23A56", It.IsAny())) .ReturnsAsync(token); @@ -383,10 +383,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetCreationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero))); instance.Setup(mock => mock.GetExpirationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero))); }); var server = CreateAuthorizationServer(builder => @@ -403,7 +403,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -469,7 +469,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -530,7 +530,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -554,7 +554,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -596,7 +596,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -617,7 +617,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -660,10 +660,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -684,7 +684,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -732,10 +732,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); }); var server = CreateAuthorizationServer(builder => @@ -756,7 +756,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -817,10 +817,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); instance.Setup(mock => mock.FindByIdAsync("3E228451-1555-46F7-A471-951EFBA23A56", It.IsAny())) .ReturnsAsync(token); @@ -829,10 +829,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetCreationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero))); instance.Setup(mock => mock.GetExpirationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero))); }); var server = CreateAuthorizationServer(builder => @@ -853,7 +853,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -927,7 +927,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -980,7 +980,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -1036,16 +1036,16 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); instance.Setup(mock => mock.GetCreationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero))); instance.Setup(mock => mock.GetExpirationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero))); }); var server = CreateAuthorizationServer(builder => @@ -1066,7 +1066,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -1123,7 +1123,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Confidential); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Confidential)); instance.Setup(mock => mock.ValidateClientSecretAsync(application, "7Fjfp0ZBr1KtDRbnfVdmIw", It.IsAny())) .ReturnsAsync(true); @@ -1180,7 +1180,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -1221,7 +1221,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -1260,10 +1260,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync(value: null); + .Returns(new ValueTask(result: null)); }); var server = CreateAuthorizationServer(builder => @@ -1307,10 +1307,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); }); var server = CreateAuthorizationServer(builder => @@ -1365,10 +1365,10 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.GetPayloadAsync(token, It.IsAny())) - .ReturnsAsync("2YotnFZFEjr1zCsicMWpAA"); + .Returns(new ValueTask("2YotnFZFEjr1zCsicMWpAA")); instance.Setup(mock => mock.FindByIdAsync("3E228451-1555-46F7-A471-951EFBA23A56", It.IsAny())) .ReturnsAsync(token); @@ -1377,10 +1377,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetCreationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero))); instance.Setup(mock => mock.GetExpirationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero))); }); var server = CreateAuthorizationServer(builder => @@ -1508,16 +1508,16 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); instance.Setup(mock => mock.GetCreationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 01, 00, 00, 00, TimeSpan.Zero))); instance.Setup(mock => mock.GetExpirationDateAsync(token, It.IsAny())) - .ReturnsAsync(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero)); + .Returns(new ValueTask(new DateTimeOffset(2017, 01, 10, 00, 00, 00, TimeSpan.Zero))); }); var server = CreateAuthorizationServer(builder => @@ -1597,7 +1597,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.ObfuscateReferenceIdAsync(It.IsAny(), It.IsAny())) .ReturnsAsync("B1F0D503-55A4-4B03-B05B-EF07713C18E1"); @@ -1656,7 +1656,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -1677,10 +1677,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -1723,7 +1723,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -1789,7 +1789,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -1834,7 +1834,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -1858,10 +1858,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -1913,7 +1913,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.ObfuscateReferenceIdAsync(It.IsAny(), It.IsAny())) .ReturnsAsync("B1F0D503-55A4-4B03-B05B-EF07713C18E1"); @@ -1940,10 +1940,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -1996,7 +1996,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -2020,10 +2020,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -2062,7 +2062,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -2086,10 +2086,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(CreateAuthorizationManager(instance => @@ -2152,7 +2152,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -2245,7 +2245,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -2300,7 +2300,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.ObfuscateReferenceIdAsync(It.IsAny(), It.IsAny())) .ReturnsAsync("B1F0D503-55A4-4B03-B05B-EF07713C18E1"); @@ -2359,7 +2359,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => @@ -2380,10 +2380,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -2424,7 +2424,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); }); var server = CreateAuthorizationServer(builder => diff --git a/test/OpenIddict.Tests/OpenIddictProviderTests.cs b/test/OpenIddict.Tests/OpenIddictProviderTests.cs index b8da921b..e9afe2d1 100644 --- a/test/OpenIddict.Tests/OpenIddictProviderTests.cs +++ b/test/OpenIddict.Tests/OpenIddictProviderTests.cs @@ -70,7 +70,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); }); @@ -156,7 +156,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -224,7 +224,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -251,7 +251,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -308,7 +308,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -426,7 +426,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -450,7 +450,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -503,7 +503,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); instance.Setup(mock => mock.IsValidAsync(token, It.IsAny())) .ReturnsAsync(true); @@ -530,7 +530,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); builder.Services.AddSingleton(manager); @@ -589,7 +589,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -655,7 +655,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -787,16 +787,16 @@ namespace OpenIddict.Tests .ReturnsAsync(tokens[0]); instance.Setup(mock => mock.GetIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[1], It.IsAny())) - .ReturnsAsync("481FCAC6-06BC-43EE-92DB-37A78AA09B59"); + .Returns(new ValueTask("481FCAC6-06BC-43EE-92DB-37A78AA09B595073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[2], It.IsAny())) - .ReturnsAsync("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8"); + .Returns(new ValueTask("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8")); instance.Setup(mock => mock.GetAuthorizationIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0"); + .Returns(new ValueTask("18D15F73-BE2B-6867-DC01-B3C1E8AFDED0")); instance.Setup(mock => mock.IsRedeemedAsync(tokens[0], It.IsAny())) .ReturnsAsync(false); @@ -868,13 +868,13 @@ namespace OpenIddict.Tests .ReturnsAsync(tokens[0]); instance.Setup(mock => mock.GetIdAsync(tokens[0], It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[1], It.IsAny())) - .ReturnsAsync("481FCAC6-06BC-43EE-92DB-37A78AA09B59"); + .Returns(new ValueTask("481FCAC6-06BC-43EE-92DB-37A78AA09B595073CC313103")); instance.Setup(mock => mock.GetIdAsync(tokens[2], It.IsAny())) - .ReturnsAsync("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8"); + .Returns(new ValueTask("3BEA7A94-5ADA-49AF-9F41-8AB6156E31A8")); instance.Setup(mock => mock.IsRedeemedAsync(tokens[0], It.IsAny())) .ReturnsAsync(false); @@ -940,7 +940,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -1075,7 +1075,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("60FFF7EA-F98E-437B-937E-5073CC313103"); + .Returns(new ValueTask("60FFF7EA-F98E-437B-937E-5073CC313103")); instance.Setup(mock => mock.IsRedeemedAsync(token, It.IsAny())) .ReturnsAsync(false); @@ -1150,10 +1150,10 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); instance.Setup(mock => mock.GetIdAsync(application, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(CreateTokenManager(instance => @@ -1162,7 +1162,7 @@ namespace OpenIddict.Tests .ReturnsAsync(token); instance.Setup(mock => mock.GetIdAsync(token, It.IsAny())) - .ReturnsAsync("3E228451-1555-46F7-A471-951EFBA23A56"); + .Returns(new ValueTask("3E228451-1555-46F7-A471-951EFBA23A56")); })); builder.Services.AddSingleton(manager); @@ -1214,7 +1214,7 @@ namespace OpenIddict.Tests .ReturnsAsync(true); instance.Setup(mock => mock.GetClientTypeAsync(application, It.IsAny())) - .ReturnsAsync(OpenIddictConstants.ClientTypes.Public); + .Returns(new ValueTask(OpenIddictConstants.ClientTypes.Public)); })); });