From 27ebff1bea9421e4c19ceceb755ffc4f45f865fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sun, 26 Jul 2020 05:29:49 +0200 Subject: [PATCH] Add nullable annotations to OpenIddict.Abstractions --- Directory.Build.props | 5 + Directory.Packages.props | 1 + .../Caches/IOpenIddictApplicationCache.cs | 15 +- .../Caches/IOpenIddictAuthorizationCache.cs | 26 +- .../Caches/IOpenIddictScopeCache.cs | 11 +- .../Caches/IOpenIddictTokenCache.cs | 26 +- .../OpenIddictApplicationDescriptor.cs | 28 +- .../OpenIddictAuthorizationDescriptor.cs | 10 +- .../Descriptors/OpenIddictScopeDescriptor.cs | 15 +- .../Descriptors/OpenIddictTokenDescriptor.cs | 16 +- .../Managers/IOpenIddictApplicationManager.cs | 81 +++-- .../IOpenIddictAuthorizationManager.cs | 79 +++-- .../Managers/IOpenIddictScopeManager.cs | 61 ++-- .../Managers/IOpenIddictTokenManager.cs | 91 +++--- .../OpenIddict.Abstractions.csproj | 1 + .../OpenIddictBuilder.cs | 7 +- .../OpenIddictExceptions.cs | 24 +- .../OpenIddictExtensions.cs | 7 +- .../Primitives/OpenIddictConverter.cs | 3 +- .../Primitives/OpenIddictExtensions.cs | 286 ++++++++---------- .../Primitives/OpenIddictMessage.cs | 21 +- .../Primitives/OpenIddictParameter.cs | 107 +++++-- .../Primitives/OpenIddictRequest.cs | 161 +++++----- .../Primitives/OpenIddictResponse.cs | 57 ++-- .../Resources/OpenIddictResources.resx | 17 +- .../Stores/IOpenIddictApplicationStore.cs | 77 +++-- .../Stores/IOpenIddictAuthorizationStore.cs | 71 ++--- .../Stores/IOpenIddictScopeStore.cs | 61 ++-- .../Stores/IOpenIddictTokenStore.cs | 83 +++-- .../OpenIddictValidationHandlers.Discovery.cs | 2 +- .../Primitives/OpenIddictParameterTests.cs | 147 ++++++++- 31 files changed, 855 insertions(+), 742 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 31704373..8058bc86 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -62,6 +62,11 @@ + + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props index b5579558..0835967b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,6 +21,7 @@ + The application to add to the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask AddAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask AddAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves an application using its client identifier. @@ -34,7 +33,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByClientIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves an application using its unique identifier. @@ -45,7 +44,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified redirect_uri. @@ -53,8 +52,7 @@ namespace OpenIddict.Abstractions /// The redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified redirect_uri. - IAsyncEnumerable FindByPostLogoutRedirectUriAsync( - [NotNull] string address, CancellationToken cancellationToken); + IAsyncEnumerable FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified redirect_uri. @@ -62,8 +60,7 @@ namespace OpenIddict.Abstractions /// The redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified redirect_uri. - IAsyncEnumerable FindByRedirectUriAsync( - [NotNull] string address, CancellationToken cancellationToken); + IAsyncEnumerable FindByRedirectUriAsync(string address, CancellationToken cancellationToken); /// /// Removes the specified application from the cache. @@ -71,6 +68,6 @@ namespace OpenIddict.Abstractions /// The application to remove from the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask RemoveAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask RemoveAsync(TApplication application, CancellationToken cancellationToken); } } diff --git a/src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs b/src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs index e25fd5a7..e78a9150 100644 --- a/src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs +++ b/src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -24,7 +23,7 @@ namespace OpenIddict.Abstractions /// The authorization to add to the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask AddAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask AddAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the authorizations corresponding to the specified @@ -34,8 +33,7 @@ namespace OpenIddict.Abstractions /// The client associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the subject/client. - IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -45,8 +43,7 @@ namespace OpenIddict.Abstractions /// The authorization status. /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. - IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, [NotNull] string status, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, string status, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -58,8 +55,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, [NotNull] string status, - [NotNull] string type, CancellationToken cancellationToken); + string subject, string client, string status, + string type, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -72,8 +69,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, [NotNull] string status, - [NotNull] string type, ImmutableArray scopes, CancellationToken cancellationToken); + string subject, string client, string status, + string type, ImmutableArray scopes, CancellationToken cancellationToken); /// /// Retrieves the list of authorizations corresponding to the specified application identifier. @@ -81,8 +78,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the authorizations. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync( - [NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves an authorization using its unique identifier. @@ -93,7 +89,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the authorization corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves all the authorizations corresponding to the specified subject. @@ -101,7 +97,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken); /// /// Removes the specified authorization from the cache. @@ -109,6 +105,6 @@ namespace OpenIddict.Abstractions /// The authorization to remove from the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask RemoveAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask RemoveAsync(TAuthorization authorization, CancellationToken cancellationToken); } } diff --git a/src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs b/src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs index 7cf3eb4d..bcb6ca6b 100644 --- a/src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs +++ b/src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -24,7 +23,7 @@ namespace OpenIddict.Abstractions /// The scope to add to the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask AddAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask AddAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves a scope using its unique identifier. @@ -35,7 +34,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves a scope using its name. @@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the specified name. /// - ValueTask FindByNameAsync([NotNull] string name, CancellationToken cancellationToken); + ValueTask FindByNameAsync(string name, CancellationToken cancellationToken); /// /// Retrieves a list of scopes using their name. @@ -62,7 +61,7 @@ namespace OpenIddict.Abstractions /// The resource associated with the scopes. /// The that can be used to abort the operation. /// The scopes associated with the specified resource. - IAsyncEnumerable FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken); + IAsyncEnumerable FindByResourceAsync(string resource, CancellationToken cancellationToken); /// /// Removes the specified scope from the cache. @@ -70,6 +69,6 @@ namespace OpenIddict.Abstractions /// The scope to remove from the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask RemoveAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask RemoveAsync(TScope scope, CancellationToken cancellationToken); } } diff --git a/src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs b/src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs index 78a6a81d..75ae32c9 100644 --- a/src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs +++ b/src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -23,7 +22,7 @@ namespace OpenIddict.Abstractions /// The token to add to the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask AddAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask AddAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the tokens corresponding to the specified @@ -33,8 +32,7 @@ namespace OpenIddict.Abstractions /// The client associated with the token. /// The that can be used to abort the operation. /// The tokens corresponding to the subject/client. - IAsyncEnumerable FindAsync([NotNull] string subject, - [NotNull] string client, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, CancellationToken cancellationToken); /// /// Retrieves the tokens matching the specified parameters. @@ -44,9 +42,7 @@ namespace OpenIddict.Abstractions /// The token status. /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. - IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, string status, CancellationToken cancellationToken); /// /// Retrieves the tokens matching the specified parameters. @@ -58,8 +54,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); + string subject, string client, + string status, string type, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified application identifier. @@ -67,7 +63,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified authorization identifier. @@ -75,7 +71,7 @@ namespace OpenIddict.Abstractions /// The authorization identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified authorization. - IAsyncEnumerable FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves a token using its unique identifier. @@ -86,7 +82,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the token corresponding to the unique identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified reference identifier. @@ -98,7 +94,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the tokens corresponding to the specified reference identifier. /// - ValueTask FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified subject. @@ -106,7 +102,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken); /// /// Removes the specified token from the cache. @@ -114,6 +110,6 @@ namespace OpenIddict.Abstractions /// The token to remove from the cache. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask RemoveAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask RemoveAsync(TToken token, CancellationToken cancellationToken); } } diff --git a/src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs b/src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs index 280ee25d..399397d7 100644 --- a/src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs +++ b/src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs @@ -10,29 +10,26 @@ namespace OpenIddict.Abstractions public class OpenIddictApplicationDescriptor { /// - /// Gets or sets the client identifier - /// associated with the application. + /// Gets or sets the client identifier associated with the application. /// - public string ClientId { get; set; } + public string? ClientId { get; set; } /// /// Gets or sets the client secret associated with the application. /// Note: depending on the application manager used when creating it, /// this property may be hashed or encrypted for security reasons. /// - public string ClientSecret { get; set; } + public string? ClientSecret { get; set; } /// - /// Gets or sets the consent type - /// associated with the application. + /// Gets or sets the consent type associated with the application. /// - public string ConsentType { get; set; } + public string? ConsentType { get; set; } /// - /// Gets or sets the display name - /// associated with the application. + /// Gets or sets the display name associated with the application. /// - public string DisplayName { get; set; } + public string? DisplayName { get; set; } /// /// Gets the localized display names associated with the application. @@ -46,14 +43,12 @@ namespace OpenIddict.Abstractions public HashSet Permissions { get; } = new HashSet(StringComparer.Ordinal); /// - /// Gets the logout callback URLs - /// associated with the application. + /// Gets the logout callback URLs associated with the application. /// public HashSet PostLogoutRedirectUris { get; } = new HashSet(); /// - /// Gets the callback URLs - /// associated with the application. + /// Gets the callback URLs associated with the application. /// public HashSet RedirectUris { get; } = new HashSet(); @@ -63,9 +58,8 @@ namespace OpenIddict.Abstractions public HashSet Requirements { get; } = new HashSet(StringComparer.Ordinal); /// - /// Gets or sets the application type - /// associated with the application. + /// Gets or sets the application type associated with the application. /// - public string Type { get; set; } + public string? Type { get; set; } } } diff --git a/src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs b/src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs index 13915489..f53911a5 100644 --- a/src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs +++ b/src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs @@ -12,13 +12,13 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the application identifier associated with the authorization. /// - public string ApplicationId { get; set; } + public string? ApplicationId { get; set; } /// /// Gets or sets the optional principal associated with the authorization. /// Note: this property is not stored by the default authorization stores. /// - public ClaimsPrincipal Principal { get; set; } + public ClaimsPrincipal? Principal { get; set; } /// /// Gets the scopes associated with the authorization. @@ -28,16 +28,16 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the status associated with the authorization. /// - public string Status { get; set; } + public string? Status { get; set; } /// /// Gets or sets the subject associated with the authorization. /// - public string Subject { get; set; } + public string? Subject { get; set; } /// /// Gets or sets the type of the authorization. /// - public string Type { get; set; } + public string? Type { get; set; } } } diff --git a/src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs b/src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs index 5329a81e..3ea35327 100644 --- a/src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs +++ b/src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs @@ -10,10 +10,9 @@ namespace OpenIddict.Abstractions public class OpenIddictScopeDescriptor { /// - /// Gets or sets the description - /// associated with the scope. + /// Gets or sets the description associated with the scope. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets the localized descriptions associated with the scope. @@ -21,10 +20,9 @@ namespace OpenIddict.Abstractions public Dictionary Descriptions { get; } = new Dictionary(); /// - /// Gets or sets the display name - /// associated with the scope. + /// Gets or sets the display name associated with the scope. /// - public string DisplayName { get; set; } + public string? DisplayName { get; set; } /// /// Gets the localized display names associated with the scope. @@ -32,10 +30,9 @@ namespace OpenIddict.Abstractions public Dictionary DisplayNames { get; } = new Dictionary(); /// - /// Gets or sets the unique name - /// associated with the scope. + /// Gets or sets the unique name associated with the scope. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// Gets the resources associated with the scope. diff --git a/src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs b/src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs index 2b01b2cf..0dea593a 100644 --- a/src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs +++ b/src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs @@ -11,12 +11,12 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the application identifier associated with the token. /// - public string ApplicationId { get; set; } + public string? ApplicationId { get; set; } /// /// Gets or sets the authorization identifier associated with the token. /// - public string AuthorizationId { get; set; } + public string? AuthorizationId { get; set; } /// /// Gets or sets the creation date associated with the token. @@ -31,34 +31,34 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the payload associated with the token. /// - public string Payload { get; set; } + public string? Payload { get; set; } /// /// Gets or sets the optional principal associated with the token. /// Note: this property is not stored by the default token stores. /// - public ClaimsPrincipal Principal { get; set; } + public ClaimsPrincipal? Principal { get; set; } /// /// Gets or sets the reference identifier associated with the token. /// Note: depending on the application manager used when creating it, /// this property may be hashed or encrypted for security reasons. /// - public string ReferenceId { get; set; } + public string? ReferenceId { get; set; } /// /// Gets or sets the status associated with the token. /// - public string Status { get; set; } + public string? Status { get; set; } /// /// Gets or sets the subject associated with the token. /// - public string Subject { get; set; } + public string? Subject { get; set; } /// /// Gets or sets the token type. /// - public string Type { get; set; } + public string? Type { get; set; } } } diff --git a/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs b/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs index a518a4b4..2c877a8d 100644 --- a/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs +++ b/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs @@ -6,7 +6,6 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -40,7 +39,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of applications that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Creates a new application based on the specified descriptor. @@ -53,7 +52,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the application. /// - ValueTask CreateAsync([NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask CreateAsync(OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Creates a new application. @@ -63,7 +62,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask CreateAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask CreateAsync(object application, CancellationToken cancellationToken = default); /// /// Creates a new application. @@ -76,7 +75,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask CreateAsync([NotNull] object application, [CanBeNull] string secret, CancellationToken cancellationToken = default); + ValueTask CreateAsync(object application, string? secret, CancellationToken cancellationToken = default); /// /// Removes an existing application. @@ -86,7 +85,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask DeleteAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask DeleteAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves an application using its client identifier. @@ -97,7 +96,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByClientIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves an application using its unique identifier. @@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves all the applications associated with the specified post_logout_redirect_uri. @@ -116,7 +115,7 @@ namespace OpenIddict.Abstractions /// The post_logout_redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified post_logout_redirect_uri. - IAsyncEnumerable FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default); /// /// Retrieves all the applications associated with the specified redirect_uri. @@ -124,7 +123,7 @@ namespace OpenIddict.Abstractions /// The redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified redirect_uri. - IAsyncEnumerable FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByRedirectUriAsync(string address, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -137,7 +136,7 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -152,8 +151,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Retrieves the client identifier associated with an application. @@ -164,7 +163,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client identifier associated with the application. /// - ValueTask GetClientIdAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetClientIdAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the client type associated with an application. @@ -175,7 +174,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client type of the application (by default, "public"). /// - ValueTask GetClientTypeAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetClientTypeAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the consent type associated with an application. @@ -186,7 +185,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the consent type of the application (by default, "explicit"). /// - ValueTask GetConsentTypeAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetConsentTypeAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the display name associated with an application. @@ -197,7 +196,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the application. /// - ValueTask GetDisplayNameAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetDisplayNameAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the localized display names associated with an application. @@ -208,7 +207,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized display names associated with the application. /// - ValueTask> GetDisplayNamesAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask> GetDisplayNamesAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the unique identifier associated with an application. @@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the application. /// - ValueTask GetIdAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetIdAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the localized display name associated with an application @@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the matching localized display name associated with the application. /// - ValueTask GetLocalizedDisplayNameAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDisplayNameAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the localized display name associated with an application @@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the matching localized display name associated with the application. /// - ValueTask GetLocalizedDisplayNameAsync([NotNull] object application, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDisplayNameAsync(object application, CultureInfo culture, CancellationToken cancellationToken = default); /// /// Retrieves the permissions associated with an application. @@ -257,7 +256,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the permissions associated with the application. /// - ValueTask> GetPermissionsAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask> GetPermissionsAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the logout callback addresses associated with an application. @@ -268,7 +267,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the post_logout_redirect_uri associated with the application. /// - ValueTask> GetPostLogoutRedirectUrisAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask> GetPostLogoutRedirectUrisAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the callback addresses associated with an application. @@ -279,7 +278,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the redirect_uri associated with the application. /// - ValueTask> GetRedirectUrisAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask> GetRedirectUrisAsync(object application, CancellationToken cancellationToken = default); /// /// Retrieves the requirements associated with an application. @@ -290,7 +289,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the requirements associated with the application. /// - ValueTask> GetRequirementsAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask> GetRequirementsAsync(object application, CancellationToken cancellationToken = default); /// /// Determines whether a given application has the specified client type. @@ -299,7 +298,7 @@ namespace OpenIddict.Abstractions /// The expected client type. /// The that can be used to abort the operation. /// true if the application has the specified client type, false otherwise. - ValueTask HasClientTypeAsync([NotNull] object application, [NotNull] string type, CancellationToken cancellationToken = default); + ValueTask HasClientTypeAsync(object application, string type, CancellationToken cancellationToken = default); /// /// Determines whether a given application has the specified consent type. @@ -308,7 +307,7 @@ namespace OpenIddict.Abstractions /// The expected consent type. /// The that can be used to abort the operation. /// true if the application has the specified consent type, false otherwise. - ValueTask HasConsentTypeAsync([NotNull] object application, [NotNull] string type, CancellationToken cancellationToken = default); + ValueTask HasConsentTypeAsync(object application, string type, CancellationToken cancellationToken = default); /// /// Determines whether the specified permission has been granted to the application. @@ -317,7 +316,7 @@ namespace OpenIddict.Abstractions /// The permission. /// The that can be used to abort the operation. /// true if the application has been granted the specified permission, false otherwise. - ValueTask HasPermissionAsync([NotNull] object application, [NotNull] string permission, CancellationToken cancellationToken = default); + ValueTask HasPermissionAsync(object application, string permission, CancellationToken cancellationToken = default); /// /// Determines whether the specified requirement has been enforced for the specified application. @@ -326,7 +325,7 @@ namespace OpenIddict.Abstractions /// The requirement. /// The that can be used to abort the operation. /// true if the requirement has been enforced for the specified application, false otherwise. - ValueTask HasRequirementAsync([NotNull] object application, [NotNull] string requirement, CancellationToken cancellationToken = default); + ValueTask HasRequirementAsync(object application, string requirement, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -336,7 +335,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); + int? count = null, int? offset = null, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -346,7 +345,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -358,8 +357,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Populates the specified descriptor using the properties exposed by the application. @@ -370,7 +369,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] OpenIddictApplicationDescriptor descriptor, [NotNull] object application, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(OpenIddictApplicationDescriptor descriptor, object application, CancellationToken cancellationToken = default); /// /// Populates the application using the specified descriptor. @@ -381,7 +380,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] object application, [NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Updates an existing application. @@ -391,7 +390,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object application, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object application, CancellationToken cancellationToken = default); /// /// Updates an existing application. @@ -402,7 +401,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object application, [NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Updates an existing application and replaces the existing secret. @@ -415,7 +414,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object application, [CanBeNull] string secret, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object application, string? secret, CancellationToken cancellationToken = default); /// /// Validates the application to ensure it's in a consistent state. @@ -423,7 +422,7 @@ namespace OpenIddict.Abstractions /// The application. /// The that can be used to abort the operation. /// The validation error encountered when validating the application. - IAsyncEnumerable ValidateAsync([NotNull] object application, CancellationToken cancellationToken = default); + IAsyncEnumerable ValidateAsync(object application, CancellationToken cancellationToken = default); /// /// Validates the client_secret associated with an application. @@ -436,7 +435,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns a boolean indicating whether the client secret was valid. /// - ValueTask ValidateClientSecretAsync([NotNull] object application, [NotNull] string secret, CancellationToken cancellationToken = default); + ValueTask ValidateClientSecretAsync(object application, string secret, CancellationToken cancellationToken = default); /// /// Validates the redirect_uri to ensure it's associated with an application. @@ -448,6 +447,6 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns a boolean indicating whether the redirect_uri was valid. /// - ValueTask ValidateRedirectUriAsync([NotNull] object application, [NotNull] string address, CancellationToken cancellationToken = default); + ValueTask ValidateRedirectUriAsync(object application, string address, CancellationToken cancellationToken = default); } } diff --git a/src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs b/src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs index 3d62c5ef..d333aae6 100644 --- a/src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs +++ b/src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions /// whose result returns the number of authorizations that match the specified query. /// ValueTask CountAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Creates a new permanent authorization based on the specified parameters. @@ -56,8 +55,8 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. /// ValueTask CreateAsync( - [NotNull] ClaimsPrincipal principal, [NotNull] string subject, [NotNull] string client, - [NotNull] string type, ImmutableArray scopes, CancellationToken cancellationToken = default); + ClaimsPrincipal principal, string subject, string client, + string type, ImmutableArray scopes, CancellationToken cancellationToken = default); /// /// Creates a new authorization based on the specified descriptor. @@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation, whose result returns the authorization. /// - ValueTask CreateAsync([NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Creates a new authorization. @@ -77,7 +76,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask CreateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask CreateAsync(object authorization, CancellationToken cancellationToken = default); /// /// Removes an existing authorization. @@ -87,7 +86,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask DeleteAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask DeleteAsync(object authorization, CancellationToken cancellationToken = default); /// /// Retrieves the authorizations corresponding to the specified @@ -97,7 +96,7 @@ namespace OpenIddict.Abstractions /// The client associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the subject/client. - IAsyncEnumerable FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken = default); + IAsyncEnumerable FindAsync(string subject, string client, CancellationToken cancellationToken = default); /// /// Retrieves the authorizations matching the specified parameters. @@ -108,8 +107,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken = default); + string subject, string client, + string status, CancellationToken cancellationToken = default); /// /// Retrieves the authorizations matching the specified parameters. @@ -121,8 +120,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default); + string subject, string client, + string status, string type, CancellationToken cancellationToken = default); /// /// Retrieves the authorizations matching the specified parameters. @@ -135,8 +134,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, [NotNull] string status, - [NotNull] string type, ImmutableArray scopes, CancellationToken cancellationToken = default); + string subject, string client, string status, + string type, ImmutableArray scopes, CancellationToken cancellationToken = default); /// /// Retrieves the list of authorizations corresponding to the specified application identifier. @@ -144,7 +143,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the authorizations. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves an authorization using its unique identifier. @@ -155,7 +154,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the authorization corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves all the authorizations corresponding to the specified subject. @@ -163,7 +162,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken = default); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken = default); /// /// Retrieves the optional application identifier associated with an authorization. @@ -174,7 +173,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the application identifier associated with the authorization. /// - ValueTask GetApplicationIdAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask GetApplicationIdAsync(object authorization, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -187,7 +186,7 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -202,8 +201,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Retrieves the unique identifier associated with an authorization. @@ -214,7 +213,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the authorization. /// - ValueTask GetIdAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask GetIdAsync(object authorization, CancellationToken cancellationToken = default); /// /// Retrieves the scopes associated with an authorization. @@ -225,7 +224,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scopes associated with the specified authorization. /// - ValueTask> GetScopesAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask> GetScopesAsync(object authorization, CancellationToken cancellationToken = default); /// /// Retrieves the status associated with an authorization. @@ -236,7 +235,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the status associated with the specified authorization. /// - ValueTask GetStatusAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask GetStatusAsync(object authorization, CancellationToken cancellationToken = default); /// /// Retrieves the subject associated with an authorization. @@ -247,7 +246,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the subject associated with the specified authorization. /// - ValueTask GetSubjectAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask GetSubjectAsync(object authorization, CancellationToken cancellationToken = default); /// /// Retrieves the type associated with an authorization. @@ -258,7 +257,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the type associated with the specified authorization. /// - ValueTask GetTypeAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask GetTypeAsync(object authorization, CancellationToken cancellationToken = default); /// /// Determines whether the specified scopes are included in the authorization. @@ -267,7 +266,7 @@ namespace OpenIddict.Abstractions /// The scopes. /// The that can be used to abort the operation. /// true if the scopes are included in the authorization, false otherwise. - ValueTask HasScopesAsync([NotNull] object authorization, ImmutableArray scopes, CancellationToken cancellationToken = default); + ValueTask HasScopesAsync(object authorization, ImmutableArray scopes, CancellationToken cancellationToken = default); /// /// Determines whether a given authorization has the specified status. @@ -276,7 +275,7 @@ namespace OpenIddict.Abstractions /// The expected status. /// The that can be used to abort the operation. /// true if the authorization has the specified status, false otherwise. - ValueTask HasStatusAsync([NotNull] object authorization, [NotNull] string status, CancellationToken cancellationToken = default); + ValueTask HasStatusAsync(object authorization, string status, CancellationToken cancellationToken = default); /// /// Determines whether a given authorization has the specified type. @@ -285,7 +284,7 @@ namespace OpenIddict.Abstractions /// The expected type. /// The that can be used to abort the operation. /// true if the authorization has the specified type, false otherwise. - ValueTask HasTypeAsync([NotNull] object authorization, [NotNull] string type, CancellationToken cancellationToken = default); + ValueTask HasTypeAsync(object authorization, string type, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -295,7 +294,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); + int? count = null, int? offset = null, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -305,7 +304,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -317,8 +316,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Populates the specified descriptor using the properties exposed by the authorization. @@ -329,7 +328,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] OpenIddictAuthorizationDescriptor descriptor, [NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, object authorization, CancellationToken cancellationToken = default); /// /// Populates the authorization using the specified descriptor. @@ -340,7 +339,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] object authorization, [NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached. @@ -360,7 +359,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask SetApplicationIdAsync([NotNull] object authorization, [CanBeNull] string identifier, CancellationToken cancellationToken = default); + ValueTask SetApplicationIdAsync(object authorization, string? identifier, CancellationToken cancellationToken = default); /// /// Tries to revoke an authorization. @@ -368,7 +367,7 @@ namespace OpenIddict.Abstractions /// The authorization to revoke. /// The that can be used to abort the operation. /// true if the authorization was successfully revoked, false otherwise. - ValueTask TryRevokeAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask TryRevokeAsync(object authorization, CancellationToken cancellationToken = default); /// /// Updates an existing authorization. @@ -378,7 +377,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object authorization, CancellationToken cancellationToken = default); /// /// Updates an existing authorization. @@ -389,7 +388,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object authorization, [NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Validates the authorization to ensure it's in a consistent state. @@ -397,6 +396,6 @@ namespace OpenIddict.Abstractions /// The authorization. /// The that can be used to abort the operation. /// The validation error encountered when validating the authorization. - IAsyncEnumerable ValidateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); + IAsyncEnumerable ValidateAsync(object authorization, CancellationToken cancellationToken = default); } } diff --git a/src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs b/src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs index eec7d0fb..26bee840 100644 --- a/src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs +++ b/src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs @@ -6,7 +6,6 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -40,7 +39,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of scopes that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Creates a new scope based on the specified descriptor. @@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation, whose result returns the scope. /// - ValueTask CreateAsync([NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask CreateAsync(OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Creates a new scope. @@ -60,7 +59,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask CreateAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask CreateAsync(object scope, CancellationToken cancellationToken = default); /// /// Removes an existing scope. @@ -70,7 +69,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask DeleteAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask DeleteAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves a scope using its unique identifier. @@ -81,7 +80,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves a scope using its name. @@ -92,7 +91,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the specified name. /// - ValueTask FindByNameAsync([NotNull] string name, CancellationToken cancellationToken = default); + ValueTask FindByNameAsync(string name, CancellationToken cancellationToken = default); /// /// Retrieves a list of scopes using their name. @@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions /// The resource associated with the scopes. /// The that can be used to abort the operation. /// The scopes associated with the specified resource. - IAsyncEnumerable FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByResourceAsync(string resource, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -121,7 +120,7 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -136,8 +135,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Retrieves the description associated with a scope. @@ -148,7 +147,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the description associated with the specified scope. /// - ValueTask GetDescriptionAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetDescriptionAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the localized descriptions associated with an scope. @@ -159,7 +158,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized descriptions associated with the scope. /// - ValueTask> GetDescriptionsAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask> GetDescriptionsAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the display name associated with a scope. @@ -170,7 +169,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the scope. /// - ValueTask GetDisplayNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetDisplayNameAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the localized display names associated with an scope. @@ -181,7 +180,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized display names associated with the scope. /// - ValueTask> GetDisplayNamesAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask> GetDisplayNamesAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the unique identifier associated with a scope. @@ -192,7 +191,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the scope. /// - ValueTask GetIdAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetIdAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the localized description associated with an scope @@ -205,7 +204,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the matching localized description associated with the scope. /// - ValueTask GetLocalizedDescriptionAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDescriptionAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the localized description associated with an scope @@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the matching localized description associated with the scope. /// - ValueTask GetLocalizedDescriptionAsync([NotNull] object scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDescriptionAsync(object scope, CultureInfo culture, CancellationToken cancellationToken = default); /// /// Retrieves the localized display name associated with an scope @@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the scope. /// - ValueTask GetLocalizedDisplayNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDisplayNameAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the localized display name associated with an scope @@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the scope. /// - ValueTask GetLocalizedDisplayNameAsync([NotNull] object scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); + ValueTask GetLocalizedDisplayNameAsync(object scope, CultureInfo culture, CancellationToken cancellationToken = default); /// /// Retrieves the name associated with a scope. @@ -257,7 +256,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the name associated with the specified scope. /// - ValueTask GetNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask GetNameAsync(object scope, CancellationToken cancellationToken = default); /// /// Retrieves the resources associated with a scope. @@ -268,7 +267,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the resources associated with the scope. /// - ValueTask> GetResourcesAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask> GetResourcesAsync(object scope, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -278,7 +277,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); + int? count = null, int? offset = null, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -288,7 +287,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -300,8 +299,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Lists all the resources associated with the specified scopes. @@ -320,7 +319,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] OpenIddictScopeDescriptor descriptor, [NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(OpenIddictScopeDescriptor descriptor, object scope, CancellationToken cancellationToken = default); /// /// Populates the scope using the specified descriptor. @@ -331,7 +330,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] object scope, [NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Updates an existing scope. @@ -341,7 +340,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object scope, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object scope, CancellationToken cancellationToken = default); /// /// Updates an existing scope. @@ -352,7 +351,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object scope, [NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Validates the scope to ensure it's in a consistent state. @@ -360,6 +359,6 @@ namespace OpenIddict.Abstractions /// The scope. /// The that can be used to abort the operation. /// The validation error encountered when validating the scope. - IAsyncEnumerable ValidateAsync([NotNull] object scope, CancellationToken cancellationToken = default); + IAsyncEnumerable ValidateAsync(object scope, CancellationToken cancellationToken = default); } } diff --git a/src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs b/src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs index d0e61def..b3adb411 100644 --- a/src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs +++ b/src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs @@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -38,7 +37,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of tokens that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Creates a new token based on the specified descriptor. @@ -48,7 +47,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation, whose result returns the token. /// - ValueTask CreateAsync([NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Creates a new token. @@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask CreateAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask CreateAsync(object token, CancellationToken cancellationToken = default); /// /// Removes an existing token. @@ -68,7 +67,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask DeleteAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask DeleteAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the tokens corresponding to the specified @@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions /// The client associated with the token. /// The that can be used to abort the operation. /// The tokens corresponding to the subject/client. - IAsyncEnumerable FindAsync([NotNull] string subject, - [NotNull] string client, CancellationToken cancellationToken = default); + IAsyncEnumerable FindAsync(string subject, + string client, CancellationToken cancellationToken = default); /// /// Retrieves the tokens matching the specified parameters. @@ -90,8 +89,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken = default); + string subject, string client, + string status, CancellationToken cancellationToken = default); /// /// Retrieves the tokens matching the specified parameters. @@ -103,8 +102,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default); + string subject, string client, + string status, string type, CancellationToken cancellationToken = default); /// /// Retrieves the list of tokens corresponding to the specified application identifier. @@ -112,7 +111,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves the list of tokens corresponding to the specified authorization identifier. @@ -120,7 +119,7 @@ namespace OpenIddict.Abstractions /// The authorization identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified authorization. - IAsyncEnumerable FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + IAsyncEnumerable FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves a token using its unique identifier. @@ -131,7 +130,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the token corresponding to the unique identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves the list of tokens corresponding to the specified reference identifier. @@ -143,7 +142,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the tokens corresponding to the specified reference identifier. /// - ValueTask FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); + ValueTask FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken = default); /// /// Retrieves the list of tokens corresponding to the specified subject. @@ -151,7 +150,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken = default); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken = default); /// /// Retrieves the optional application identifier associated with a token. @@ -162,7 +161,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the application identifier associated with the token. /// - ValueTask GetApplicationIdAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetApplicationIdAsync(object token, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -175,7 +174,7 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns the first element. @@ -190,8 +189,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Retrieves the optional authorization identifier associated with a token. @@ -202,7 +201,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the authorization identifier associated with the token. /// - ValueTask GetAuthorizationIdAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetAuthorizationIdAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the creation date associated with a token. @@ -213,7 +212,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the creation date associated with the specified token. /// - ValueTask GetCreationDateAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetCreationDateAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the expiration date associated with a token. @@ -224,7 +223,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the expiration date associated with the specified token. /// - ValueTask GetExpirationDateAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetExpirationDateAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the unique identifier associated with a token. @@ -235,7 +234,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the token. /// - ValueTask GetIdAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetIdAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the payload associated with a token. @@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the payload associated with the specified token. /// - ValueTask GetPayloadAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetPayloadAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the reference identifier associated with a token. @@ -259,7 +258,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the reference identifier associated with the specified token. /// - ValueTask GetReferenceIdAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetReferenceIdAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the status associated with a token. @@ -270,7 +269,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the status associated with the specified token. /// - ValueTask GetStatusAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetStatusAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the subject associated with a token. @@ -281,7 +280,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the subject associated with the specified token. /// - ValueTask GetSubjectAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetSubjectAsync(object token, CancellationToken cancellationToken = default); /// /// Retrieves the token type associated with a token. @@ -292,7 +291,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the token type associated with the specified token. /// - ValueTask GetTypeAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask GetTypeAsync(object token, CancellationToken cancellationToken = default); /// /// Determines whether a given token has the specified status. @@ -301,7 +300,7 @@ namespace OpenIddict.Abstractions /// The expected status. /// The that can be used to abort the operation. /// true if the token has the specified status, false otherwise. - ValueTask HasStatusAsync([NotNull] object token, [NotNull] string status, CancellationToken cancellationToken = default); + ValueTask HasStatusAsync(object token, string status, CancellationToken cancellationToken = default); /// /// Determines whether a given token has the specified type. @@ -310,7 +309,7 @@ namespace OpenIddict.Abstractions /// The expected type. /// The that can be used to abort the operation. /// true if the token has the specified type, false otherwise. - ValueTask HasTypeAsync([NotNull] object token, [NotNull] string type, CancellationToken cancellationToken = default); + ValueTask HasTypeAsync(object token, string type, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -320,7 +319,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); + int? count = null, int? offset = null, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -330,7 +329,7 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, IQueryable> query, CancellationToken cancellationToken = default); + Func, IQueryable> query, CancellationToken cancellationToken = default); /// /// Executes the specified query and returns all the corresponding elements. @@ -342,8 +341,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken = default); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken = default); /// /// Populates the specified descriptor using the properties exposed by the token. @@ -354,7 +353,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] OpenIddictTokenDescriptor descriptor, [NotNull] object token, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(OpenIddictTokenDescriptor descriptor, object token, CancellationToken cancellationToken = default); /// /// Populates the token using the specified descriptor. @@ -365,7 +364,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask PopulateAsync([NotNull] object token, [NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask PopulateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Removes the tokens that are marked as expired or invalid. @@ -385,7 +384,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask SetApplicationIdAsync([NotNull] object token, [CanBeNull] string identifier, CancellationToken cancellationToken = default); + ValueTask SetApplicationIdAsync(object token, string? identifier, CancellationToken cancellationToken = default); /// /// Sets the authorization identifier associated with a token. @@ -396,7 +395,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask SetAuthorizationIdAsync([NotNull] object token, [CanBeNull] string identifier, CancellationToken cancellationToken = default); + ValueTask SetAuthorizationIdAsync(object token, string? identifier, CancellationToken cancellationToken = default); /// /// Tries to extend the specified token by replacing its expiration date. @@ -405,7 +404,7 @@ namespace OpenIddict.Abstractions /// The date on which the token will no longer be considered valid. /// The that can be used to abort the operation. /// true if the token was successfully extended, false otherwise. - ValueTask TryExtendAsync([NotNull] object token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken = default); + ValueTask TryExtendAsync(object token, DateTimeOffset? date, CancellationToken cancellationToken = default); /// /// Tries to redeem a token. @@ -413,7 +412,7 @@ namespace OpenIddict.Abstractions /// The token to redeem. /// The that can be used to abort the operation. /// true if the token was successfully redemeed, false otherwise. - ValueTask TryRedeemAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask TryRedeemAsync(object token, CancellationToken cancellationToken = default); /// /// Tries to reject a token. @@ -421,7 +420,7 @@ namespace OpenIddict.Abstractions /// The token to reject. /// The that can be used to abort the operation. /// true if the token was successfully redemeed, false otherwise. - ValueTask TryRejectAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask TryRejectAsync(object token, CancellationToken cancellationToken = default); /// /// Tries to revoke a token. @@ -429,7 +428,7 @@ namespace OpenIddict.Abstractions /// The token to revoke. /// The that can be used to abort the operation. /// true if the token was successfully revoked, false otherwise. - ValueTask TryRevokeAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask TryRevokeAsync(object token, CancellationToken cancellationToken = default); /// /// Updates an existing token. @@ -439,7 +438,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object token, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object token, CancellationToken cancellationToken = default); /// /// Updates an existing token. @@ -450,7 +449,7 @@ namespace OpenIddict.Abstractions /// /// A that can be used to monitor the asynchronous operation. /// - ValueTask UpdateAsync([NotNull] object token, [NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); + ValueTask UpdateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); /// /// Validates the token to ensure it's in a consistent state. @@ -458,6 +457,6 @@ namespace OpenIddict.Abstractions /// The token. /// The that can be used to abort the operation. /// The validation error encountered when validating the token. - IAsyncEnumerable ValidateAsync([NotNull] object token, CancellationToken cancellationToken = default); + IAsyncEnumerable ValidateAsync(object token, CancellationToken cancellationToken = default); } } diff --git a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj index cf8c65fd..97eabd87 100644 --- a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj +++ b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj @@ -3,6 +3,7 @@ net461;netstandard2.0;netstandard2.1 true + enable diff --git a/src/OpenIddict.Abstractions/OpenIddictBuilder.cs b/src/OpenIddict.Abstractions/OpenIddictBuilder.cs index c3bc62e1..6274e1e1 100644 --- a/src/OpenIddict.Abstractions/OpenIddictBuilder.cs +++ b/src/OpenIddict.Abstractions/OpenIddictBuilder.cs @@ -6,7 +6,6 @@ using System; using System.ComponentModel; -using JetBrains.Annotations; namespace Microsoft.Extensions.DependencyInjection { @@ -19,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection /// Initializes a new instance of . /// /// The services collection. - public OpenIddictBuilder([NotNull] IServiceCollection services) + public OpenIddictBuilder(IServiceCollection services) => Services = services ?? throw new ArgumentNullException(nameof(services)); /// @@ -34,7 +33,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The object to compare with the current object. /// true if the specified object is equal to the current object; otherwise, false. [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals([CanBeNull] object obj) => base.Equals(obj); + public override bool Equals(object? obj) => base.Equals(obj); /// /// Serves as the default hash function. @@ -48,6 +47,6 @@ namespace Microsoft.Extensions.DependencyInjection /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string? ToString() => base.ToString(); } } diff --git a/src/OpenIddict.Abstractions/OpenIddictExceptions.cs b/src/OpenIddict.Abstractions/OpenIddictExceptions.cs index 23cfca58..0ffd23a3 100644 --- a/src/OpenIddict.Abstractions/OpenIddictExceptions.cs +++ b/src/OpenIddict.Abstractions/OpenIddictExceptions.cs @@ -18,7 +18,7 @@ namespace OpenIddict.Abstractions /// Creates a new . /// /// The exception message. - public ConcurrencyException(string message) + public ConcurrencyException(string? message) : this(message, exception: null) { } @@ -28,7 +28,7 @@ namespace OpenIddict.Abstractions /// /// The exception message. /// The inner exception. - public ConcurrencyException(string message, Exception exception) + public ConcurrencyException(string? message, Exception? exception) : base(message, exception) { } @@ -43,7 +43,7 @@ namespace OpenIddict.Abstractions /// Creates a new . /// /// The exception message. - public GenericException(string message) + public GenericException(string? message) : this(message, null) { } @@ -53,7 +53,7 @@ namespace OpenIddict.Abstractions /// /// The exception message. /// The error type. - public GenericException(string message, string error) + public GenericException(string? message, string? error) : this(message, error, description: null) { } @@ -64,7 +64,7 @@ namespace OpenIddict.Abstractions /// The exception message. /// The error type. /// The error description. - public GenericException(string message, string error, string description) + public GenericException(string? message, string? error, string? description) : this(message, error, description, uri: null) { } @@ -76,7 +76,7 @@ namespace OpenIddict.Abstractions /// The error type. /// The error description. /// The error URI. - public GenericException(string message, string error, string description, string uri) + public GenericException(string? message, string? error, string? description, string? uri) : base(message) { Error = error; @@ -87,17 +87,17 @@ namespace OpenIddict.Abstractions /// /// Gets the error type. /// - public string Error { get; } + public string? Error { get; } /// /// Gets the error description. /// - public string ErrorDescription { get; } + public string? ErrorDescription { get; } /// /// Gets the error URI. /// - public string ErrorUri { get; } + public string? ErrorUri { get; } } /// @@ -109,7 +109,7 @@ namespace OpenIddict.Abstractions /// Creates a new . /// /// The exception message. - public ValidationException(string message) + public ValidationException(string? message) : this(message, ImmutableArray.Create()) { } @@ -119,7 +119,7 @@ namespace OpenIddict.Abstractions /// /// The exception message. /// The validation results. - public ValidationException(string message, ImmutableArray results) + public ValidationException(string? message, ImmutableArray results) : this(message, results, exception: null) { } @@ -130,7 +130,7 @@ namespace OpenIddict.Abstractions /// The exception message. /// The validation results. /// The inner exception. - public ValidationException(string message, ImmutableArray results, Exception exception) + public ValidationException(string? message, ImmutableArray results, Exception? exception) : base(message, exception) { Results = results; diff --git a/src/OpenIddict.Abstractions/OpenIddictExtensions.cs b/src/OpenIddict.Abstractions/OpenIddictExtensions.cs index 8e75e14d..4baf3d55 100644 --- a/src/OpenIddict.Abstractions/OpenIddictExtensions.cs +++ b/src/OpenIddict.Abstractions/OpenIddictExtensions.cs @@ -5,7 +5,6 @@ */ using System; -using JetBrains.Annotations; namespace Microsoft.Extensions.DependencyInjection { @@ -20,7 +19,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The services collection. /// This extension can be safely called multiple times. /// The . - public static OpenIddictBuilder AddOpenIddict([NotNull] this IServiceCollection services) + public static OpenIddictBuilder AddOpenIddict(this IServiceCollection services) { if (services == null) { @@ -37,9 +36,7 @@ namespace Microsoft.Extensions.DependencyInjection /// The configuration delegate used to register new services. /// This extension can be safely called multiple times. /// The . - public static IServiceCollection AddOpenIddict( - [NotNull] this IServiceCollection services, - [NotNull] Action configuration) + public static IServiceCollection AddOpenIddict(this IServiceCollection services, Action configuration) { if (services == null) { diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs index 4505dc8a..461fe14f 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs @@ -7,7 +7,6 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using JetBrains.Annotations; using SR = OpenIddict.Abstractions.OpenIddictResources; namespace OpenIddict.Abstractions @@ -22,7 +21,7 @@ namespace OpenIddict.Abstractions /// /// The type to convert. /// true if the type is supported, false otherwise. - public override bool CanConvert([NotNull] Type typeToConvert) + public override bool CanConvert(Type typeToConvert) { if (typeToConvert == null) { diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs index e7c9ad1c..783ea397 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs @@ -13,7 +13,6 @@ using System.Linq; using System.Security.Claims; using System.Text.Encodings.Web; using System.Text.Json; -using JetBrains.Annotations; using Microsoft.Extensions.Primitives; using static OpenIddict.Abstractions.OpenIddictConstants; using SR = OpenIddict.Abstractions.OpenIddictResources; @@ -30,76 +29,56 @@ namespace OpenIddict.Abstractions /// Extracts the authentication context class values from an . /// /// The instance. - public static ImmutableArray GetAcrValues([NotNull] this OpenIddictRequest request) + public static ImmutableArray GetAcrValues(this OpenIddictRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } - if (string.IsNullOrEmpty(request.AcrValues)) - { - return ImmutableArray.Create(); - } - - return GetValues(request.AcrValues, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray(); + return GetValues(request.AcrValues, Separators.Space); } /// /// Extracts the prompt values from an . /// /// The instance. - public static ImmutableArray GetPrompts([NotNull] this OpenIddictRequest request) + public static ImmutableArray GetPrompts(this OpenIddictRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } - if (string.IsNullOrEmpty(request.Prompt)) - { - return ImmutableArray.Create(); - } - - return GetValues(request.Prompt, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray(); + return GetValues(request.Prompt, Separators.Space); } /// /// Extracts the response types from an . /// /// The instance. - public static ImmutableArray GetResponseTypes([NotNull] this OpenIddictRequest request) + public static ImmutableArray GetResponseTypes(this OpenIddictRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } - if (string.IsNullOrEmpty(request.ResponseType)) - { - return ImmutableArray.Create(); - } - - return GetValues(request.ResponseType, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray(); + return GetValues(request.ResponseType, Separators.Space); } /// /// Extracts the scopes from an . /// /// The instance. - public static ImmutableArray GetScopes([NotNull] this OpenIddictRequest request) + public static ImmutableArray GetScopes(this OpenIddictRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } - if (string.IsNullOrEmpty(request.Scope)) - { - return ImmutableArray.Create(); - } - - return GetValues(request.Scope, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray(); + return GetValues(request.Scope, Separators.Space); } /// @@ -107,7 +86,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The component to look for in the parameter. - public static bool HasAcrValue([NotNull] this OpenIddictRequest request, [NotNull] string value) + public static bool HasAcrValue(this OpenIddictRequest request, string value) { if (request == null) { @@ -127,7 +106,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The component to look for in the parameter. - public static bool HasPrompt([NotNull] this OpenIddictRequest request, [NotNull] string prompt) + public static bool HasPrompt(this OpenIddictRequest request, string prompt) { if (request == null) { @@ -147,7 +126,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The component to look for in the parameter. - public static bool HasResponseType([NotNull] this OpenIddictRequest request, [NotNull] string type) + public static bool HasResponseType(this OpenIddictRequest request, string type) { if (request == null) { @@ -167,7 +146,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The component to look for in the parameter. - public static bool HasScope([NotNull] this OpenIddictRequest request, [NotNull] string scope) + public static bool HasScope(this OpenIddictRequest request, string scope) { if (request == null) { @@ -188,7 +167,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a response_type=none request, false otherwise. - public static bool IsNoneFlow([NotNull] this OpenIddictRequest request) + public static bool IsNoneFlow(this OpenIddictRequest request) { if (request == null) { @@ -215,7 +194,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a code flow request, false otherwise. - public static bool IsAuthorizationCodeFlow([NotNull] this OpenIddictRequest request) + public static bool IsAuthorizationCodeFlow(this OpenIddictRequest request) { if (request == null) { @@ -243,7 +222,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is an implicit flow request, false otherwise. - public static bool IsImplicitFlow([NotNull] this OpenIddictRequest request) + public static bool IsImplicitFlow(this OpenIddictRequest request) { if (request == null) { @@ -297,7 +276,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is an hybrid flow request, false otherwise. - public static bool IsHybridFlow([NotNull] this OpenIddictRequest request) + public static bool IsHybridFlow(this OpenIddictRequest request) { if (request == null) { @@ -364,7 +343,7 @@ namespace OpenIddict.Abstractions /// true if the request specified the fragment response mode or if /// it's the default value for the requested flow, false otherwise. /// - public static bool IsFragmentResponseMode([NotNull] this OpenIddictRequest request) + public static bool IsFragmentResponseMode(this OpenIddictRequest request) { if (request == null) { @@ -397,7 +376,7 @@ namespace OpenIddict.Abstractions /// true if the request specified the query response mode or if /// it's the default value for the requested flow, false otherwise. /// - public static bool IsQueryResponseMode([NotNull] this OpenIddictRequest request) + public static bool IsQueryResponseMode(this OpenIddictRequest request) { if (request == null) { @@ -429,7 +408,7 @@ namespace OpenIddict.Abstractions /// true if the request specified the form post response mode or if /// it's the default value for the requested flow, false otherwise. /// - public static bool IsFormPostResponseMode([NotNull] this OpenIddictRequest request) + public static bool IsFormPostResponseMode(this OpenIddictRequest request) { if (request == null) { @@ -445,7 +424,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a code grant request, false otherwise. - public static bool IsAuthorizationCodeGrantType([NotNull] this OpenIddictRequest request) + public static bool IsAuthorizationCodeGrantType(this OpenIddictRequest request) { if (request == null) { @@ -461,7 +440,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a client credentials grant request, false otherwise. - public static bool IsClientCredentialsGrantType([NotNull] this OpenIddictRequest request) + public static bool IsClientCredentialsGrantType(this OpenIddictRequest request) { if (request == null) { @@ -477,7 +456,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a device code grant request, false otherwise. - public static bool IsDeviceCodeGrantType([NotNull] this OpenIddictRequest request) + public static bool IsDeviceCodeGrantType(this OpenIddictRequest request) { if (request == null) { @@ -493,7 +472,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a password grant request, false otherwise. - public static bool IsPasswordGrantType([NotNull] this OpenIddictRequest request) + public static bool IsPasswordGrantType(this OpenIddictRequest request) { if (request == null) { @@ -509,7 +488,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// true if the request is a refresh token grant request, false otherwise. - public static bool IsRefreshTokenGrantType([NotNull] this OpenIddictRequest request) + public static bool IsRefreshTokenGrantType(this OpenIddictRequest request) { if (request == null) { @@ -524,14 +503,14 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The destinations associated with the claim. - public static ImmutableArray GetDestinations([NotNull] this Claim claim) + public static ImmutableArray GetDestinations(this Claim claim) { if (claim == null) { throw new ArgumentNullException(nameof(claim)); } - claim.Properties.TryGetValue(Properties.Destinations, out string destinations); + claim.Properties.TryGetValue(Properties.Destinations, out string? destinations); if (string.IsNullOrEmpty(destinations)) { @@ -548,7 +527,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The required destination. - public static bool HasDestination([NotNull] this Claim claim, [NotNull] string destination) + public static bool HasDestination(this Claim claim, string destination) { if (claim == null) { @@ -560,7 +539,7 @@ namespace OpenIddict.Abstractions throw new ArgumentException(SR.GetResourceString(SR.ID1180), nameof(destination)); } - claim.Properties.TryGetValue(Properties.Destinations, out string destinations); + claim.Properties.TryGetValue(Properties.Destinations, out string? destinations); if (string.IsNullOrEmpty(destinations)) { @@ -576,7 +555,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The destinations. - public static Claim SetDestinations([NotNull] this Claim claim, ImmutableArray destinations) + public static Claim SetDestinations(this Claim claim, ImmutableArray destinations) { if (claim == null) { @@ -610,7 +589,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The destinations. - public static Claim SetDestinations([NotNull] this Claim claim, [CanBeNull] IEnumerable destinations) + public static Claim SetDestinations(this Claim claim, IEnumerable? destinations) => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -618,7 +597,7 @@ namespace OpenIddict.Abstractions /// /// The instance. /// The destinations. - public static Claim SetDestinations([NotNull] this Claim claim, [CanBeNull] params string[] destinations) + public static Claim SetDestinations(this Claim claim, params string[]? destinations) => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -626,7 +605,7 @@ namespace OpenIddict.Abstractions /// /// The principal. /// The destinations, returned as a flattened dictionary. - public static ImmutableDictionary GetDestinations([NotNull] this ClaimsPrincipal principal) + public static ImmutableDictionary GetDestinations(this ClaimsPrincipal principal) { if (principal == null) { @@ -664,9 +643,7 @@ namespace OpenIddict.Abstractions /// The principal. /// The destinations, as a flattened dictionary. /// The principal. - public static ClaimsPrincipal SetDestinations( - [NotNull] this ClaimsPrincipal principal, - [NotNull] ImmutableDictionary destinations) + public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary destinations) { if (principal == null) { @@ -697,9 +674,7 @@ namespace OpenIddict.Abstractions /// The delegate filtering the claims: return true /// to accept the claim, false to remove it. /// - public static ClaimsIdentity Clone( - [NotNull] this ClaimsIdentity identity, - [NotNull] Func filter) + public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func filter) { if (identity == null) { @@ -739,9 +714,7 @@ namespace OpenIddict.Abstractions /// The delegate filtering the claims: return true /// to accept the claim, false to remove it. /// - public static ClaimsPrincipal Clone( - [NotNull] this ClaimsPrincipal principal, - [NotNull] Func filter) + public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func filter) { if (principal == null) { @@ -769,9 +742,7 @@ namespace OpenIddict.Abstractions /// The identity. /// The type associated with the claim. /// The value associated with the claim. - public static ClaimsIdentity AddClaim( - [NotNull] this ClaimsIdentity identity, - [NotNull] string type, [NotNull] string value) + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value) { if (identity == null) { @@ -799,10 +770,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claim. /// The value associated with the claim. /// The destinations associated with the claim. - public static ClaimsIdentity AddClaim( - [NotNull] this ClaimsIdentity identity, - [NotNull] string type, [NotNull] string value, - [NotNull] ImmutableArray destinations) + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, ImmutableArray destinations) { if (identity == null) { @@ -835,10 +803,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claim. /// The value associated with the claim. /// The destinations associated with the claim. - public static ClaimsIdentity AddClaim( - [NotNull] this ClaimsIdentity identity, - [NotNull] string type, [NotNull] string value, - [NotNull] params string[] destinations) + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, params string[]? destinations) => identity.AddClaim(type, value, destinations?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -847,7 +812,7 @@ namespace OpenIddict.Abstractions /// The identity. /// The type associated with the claim. /// The claim value. - public static string GetClaim([NotNull] this ClaimsIdentity identity, [NotNull] string type) + public static string? GetClaim(this ClaimsIdentity identity, string type) { if (identity == null) { @@ -868,7 +833,7 @@ namespace OpenIddict.Abstractions /// The principal. /// The type associated with the claim. /// The claim value. - public static string GetClaim([NotNull] this ClaimsPrincipal principal, [NotNull] string type) + public static string? GetClaim(this ClaimsPrincipal principal, string type) { if (principal == null) { @@ -889,7 +854,7 @@ namespace OpenIddict.Abstractions /// The identity. /// The type associated with the claims. /// The claim values. - public static ImmutableArray GetClaims([NotNull] this ClaimsIdentity identity, [NotNull] string type) + public static ImmutableArray GetClaims(this ClaimsIdentity identity, string type) { if (identity == null) { @@ -910,7 +875,7 @@ namespace OpenIddict.Abstractions /// The claims identity. /// The claim type. /// true if the identity contains at least one claim of the specified type. - public static bool HasClaim([NotNull] this ClaimsIdentity identity, [NotNull] string type) + public static bool HasClaim(this ClaimsIdentity identity, string type) { if (identity == null) { @@ -931,7 +896,7 @@ namespace OpenIddict.Abstractions /// The principal. /// The type associated with the claims. /// The claim values. - public static ImmutableArray GetClaims([NotNull] this ClaimsPrincipal principal, [NotNull] string type) + public static ImmutableArray GetClaims(this ClaimsPrincipal principal, string type) { if (principal == null) { @@ -952,7 +917,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The claim type. /// true if the principal contains at least one claim of the specified type. - public static bool HasClaim([NotNull] this ClaimsPrincipal principal, [NotNull] string type) + public static bool HasClaim(this ClaimsPrincipal principal, string type) { if (principal == null) { @@ -973,7 +938,7 @@ namespace OpenIddict.Abstractions /// The identity. /// The type associated with the claims. /// The claims identity. - public static ClaimsIdentity RemoveClaims([NotNull] this ClaimsIdentity identity, [NotNull] string type) + public static ClaimsIdentity RemoveClaims(this ClaimsIdentity identity, string type) { if (identity == null) { @@ -999,7 +964,7 @@ namespace OpenIddict.Abstractions /// The principal. /// The type associated with the claims. /// The claims identity. - public static ClaimsPrincipal RemoveClaims([NotNull] this ClaimsPrincipal principal, [NotNull] string type) + public static ClaimsPrincipal RemoveClaims(this ClaimsPrincipal principal, string type) { if (principal == null) { @@ -1029,9 +994,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claims. /// The claim value. /// The claims identity. - public static ClaimsIdentity SetClaims( - [NotNull] this ClaimsIdentity identity, - [NotNull] string type, [CanBeNull] string value) + public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, string? value) { if (identity == null) { @@ -1060,9 +1023,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claims. /// The claim value. /// The claims identity. - public static ClaimsPrincipal SetClaim( - [NotNull] this ClaimsPrincipal principal, - [NotNull] string type, [CanBeNull] string value) + public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string? value) { if (principal == null) { @@ -1091,8 +1052,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claims. /// The claim values. /// The claims identity. - public static ClaimsIdentity SetClaims([NotNull] this ClaimsIdentity identity, - [NotNull] string type, [NotNull] ImmutableArray values) + public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray values) { if (identity == null) { @@ -1121,8 +1081,7 @@ namespace OpenIddict.Abstractions /// The type associated with the claims. /// The claim values. /// The claims identity. - public static ClaimsPrincipal SetClaims([NotNull] this ClaimsPrincipal principal, - [NotNull] string type, [NotNull] ImmutableArray values) + public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray values) { if (principal == null) { @@ -1149,7 +1108,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The creation date or null if the claim cannot be found. - public static DateTimeOffset? GetCreationDate([NotNull] this ClaimsPrincipal principal) + public static DateTimeOffset? GetCreationDate(this ClaimsPrincipal principal) { if (principal == null) { @@ -1175,7 +1134,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The expiration date or null if the claim cannot be found. - public static DateTimeOffset? GetExpirationDate([NotNull] this ClaimsPrincipal principal) + public static DateTimeOffset? GetExpirationDate(this ClaimsPrincipal principal) { if (principal == null) { @@ -1201,7 +1160,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The audiences list or an empty set if the claims cannot be found. - public static ImmutableArray GetAudiences([NotNull] this ClaimsPrincipal principal) + public static ImmutableArray GetAudiences(this ClaimsPrincipal principal) => principal.GetClaims(Claims.Private.Audience); /// @@ -1209,7 +1168,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The presenters list or an empty set if the claims cannot be found. - public static ImmutableArray GetPresenters([NotNull] this ClaimsPrincipal principal) + public static ImmutableArray GetPresenters(this ClaimsPrincipal principal) => principal.GetClaims(Claims.Private.Presenter); /// @@ -1217,7 +1176,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The resources list or an empty set if the claims cannot be found. - public static ImmutableArray GetResources([NotNull] this ClaimsPrincipal principal) + public static ImmutableArray GetResources(this ClaimsPrincipal principal) => principal.GetClaims(Claims.Private.Resource); /// @@ -1225,7 +1184,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The scopes list or an empty set if the claim cannot be found. - public static ImmutableArray GetScopes([NotNull] this ClaimsPrincipal principal) + public static ImmutableArray GetScopes(this ClaimsPrincipal principal) => principal.GetClaims(Claims.Private.Scope); /// @@ -1233,7 +1192,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The access token lifetime or null if the claim cannot be found. - public static TimeSpan? GetAccessTokenLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetAccessTokenLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.AccessTokenLifetime); /// @@ -1241,7 +1200,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The authorization code lifetime or null if the claim cannot be found. - public static TimeSpan? GetAuthorizationCodeLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetAuthorizationCodeLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.AuthorizationCodeLifetime); /// @@ -1249,7 +1208,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The device code lifetime or null if the claim cannot be found. - public static TimeSpan? GetDeviceCodeLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetDeviceCodeLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.DeviceCodeLifetime); /// @@ -1257,7 +1216,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The identity token lifetime or null if the claim cannot be found. - public static TimeSpan? GetIdentityTokenLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetIdentityTokenLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.IdentityTokenLifetime); /// @@ -1265,7 +1224,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The refresh token lifetime or null if the claim cannot be found. - public static TimeSpan? GetRefreshTokenLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetRefreshTokenLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.RefreshTokenLifetime); /// @@ -1273,7 +1232,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The user code lifetime or null if the claim cannot be found. - public static TimeSpan? GetUserCodeLifetime([NotNull] this ClaimsPrincipal principal) + public static TimeSpan? GetUserCodeLifetime(this ClaimsPrincipal principal) => GetLifetime(principal, Claims.Private.UserCodeLifetime); /// @@ -1281,7 +1240,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The unique identifier or null if the claim cannot be found. - public static string GetAuthorizationId([NotNull] this ClaimsPrincipal principal) + public static string? GetAuthorizationId(this ClaimsPrincipal principal) => principal.GetClaim(Claims.Private.AuthorizationId); /// @@ -1289,7 +1248,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The unique identifier or null if the claim cannot be found. - public static string GetTokenId([NotNull] this ClaimsPrincipal principal) + public static string? GetTokenId(this ClaimsPrincipal principal) => principal.GetClaim(Claims.Private.TokenId); /// @@ -1297,7 +1256,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// The token type or null if the claim cannot be found. - public static string GetTokenType([NotNull] this ClaimsPrincipal principal) + public static string? GetTokenType(this ClaimsPrincipal principal) => principal.GetClaim(Claims.Private.TokenType); /// @@ -1305,7 +1264,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// true if the principal contains at least one audience. - public static bool HasAudience([NotNull] this ClaimsPrincipal principal) + public static bool HasAudience(this ClaimsPrincipal principal) => principal.HasClaim(Claims.Private.Audience); /// @@ -1314,7 +1273,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The audience. /// true if the principal contains the given audience. - public static bool HasAudience([NotNull] this ClaimsPrincipal principal, [NotNull] string audience) + public static bool HasAudience(this ClaimsPrincipal principal, string audience) { if (principal == null) { @@ -1334,7 +1293,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// true if the principal contains at least one presenter. - public static bool HasPresenter([NotNull] this ClaimsPrincipal principal) + public static bool HasPresenter(this ClaimsPrincipal principal) => principal.HasClaim(Claims.Private.Presenter); /// @@ -1343,7 +1302,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The presenter. /// true if the principal contains the given presenter. - public static bool HasPresenter([NotNull] this ClaimsPrincipal principal, [NotNull] string presenter) + public static bool HasPresenter(this ClaimsPrincipal principal, string presenter) { if (principal == null) { @@ -1363,7 +1322,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// true if the principal contains at least one resource. - public static bool HasResource([NotNull] this ClaimsPrincipal principal) + public static bool HasResource(this ClaimsPrincipal principal) => principal.HasClaim(Claims.Private.Resource); /// @@ -1372,7 +1331,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The resource. /// true if the principal contains the given resource. - public static bool HasResource([NotNull] this ClaimsPrincipal principal, [NotNull] string resource) + public static bool HasResource(this ClaimsPrincipal principal, string resource) { if (principal == null) { @@ -1392,7 +1351,7 @@ namespace OpenIddict.Abstractions /// /// The claims principal. /// true if the principal contains at least one scope. - public static bool HasScope([NotNull] this ClaimsPrincipal principal) + public static bool HasScope(this ClaimsPrincipal principal) => principal.HasClaim(Claims.Private.Scope); /// @@ -1401,7 +1360,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The scope. /// true if the principal contains the given scope. - public static bool HasScope([NotNull] this ClaimsPrincipal principal, [NotNull] string scope) + public static bool HasScope(this ClaimsPrincipal principal, string scope) { if (principal == null) { @@ -1422,7 +1381,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The token type. /// true if the token type matches the specified type. - public static bool HasTokenType([NotNull] this ClaimsPrincipal principal, [NotNull] string type) + public static bool HasTokenType(this ClaimsPrincipal principal, string type) { if (principal == null) { @@ -1443,7 +1402,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The creation date /// The claims principal. - public static ClaimsPrincipal SetCreationDate([NotNull] this ClaimsPrincipal principal, [CanBeNull] DateTimeOffset? date) + public static ClaimsPrincipal SetCreationDate(this ClaimsPrincipal principal, DateTimeOffset? date) => principal.SetClaim(Claims.Private.CreationDate, date?.ToString("r", CultureInfo.InvariantCulture)); /// @@ -1452,7 +1411,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The expiration date /// The claims principal. - public static ClaimsPrincipal SetExpirationDate([NotNull] this ClaimsPrincipal principal, [CanBeNull] DateTimeOffset? date) + public static ClaimsPrincipal SetExpirationDate(this ClaimsPrincipal principal, DateTimeOffset? date) => principal.SetClaim(Claims.Private.ExpirationDate, date?.ToString("r", CultureInfo.InvariantCulture)); /// @@ -1462,8 +1421,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The audiences to store. /// The claims principal. - public static ClaimsPrincipal SetAudiences( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray audiences) + public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray audiences) => principal.SetClaims(Claims.Private.Audience, audiences); /// @@ -1473,8 +1431,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The audiences to store. /// The claims principal. - public static ClaimsPrincipal SetAudiences( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable audiences) + public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable? audiences) => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1484,8 +1441,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The audiences to store. /// The claims principal. - public static ClaimsPrincipal SetAudiences( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] audiences) + public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences) => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1495,8 +1451,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The presenters to store. /// The claims principal. - public static ClaimsPrincipal SetPresenters( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray presenters) + public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray presenters) => principal.SetClaims(Claims.Private.Presenter, presenters); /// @@ -1506,8 +1461,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The presenters to store. /// The claims principal. - public static ClaimsPrincipal SetPresenters( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable presenters) + public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable? presenters) => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1517,8 +1471,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The presenters to store. /// The claims principal. - public static ClaimsPrincipal SetPresenters( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] presenters) + public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters) => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1528,8 +1481,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The resources to store. /// The claims principal. - public static ClaimsPrincipal SetResources( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray resources) + public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray resources) => principal.SetClaims(Claims.Private.Resource, resources); /// @@ -1539,8 +1491,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The resources to store. /// The claims principal. - public static ClaimsPrincipal SetResources( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable resources) + public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable? resources) => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1550,8 +1501,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The resources to store. /// The claims principal. - public static ClaimsPrincipal SetResources( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] resources) + public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources) => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1561,8 +1511,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The scopes to store. /// The claims principal. - public static ClaimsPrincipal SetScopes( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray scopes) + public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray scopes) => principal.SetClaims(Claims.Private.Scope, scopes); /// @@ -1572,8 +1521,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The scopes to store. /// The claims principal. - public static ClaimsPrincipal SetScopes( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable scopes) + public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable? scopes) => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1583,8 +1531,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The scopes to store. /// The claims principal. - public static ClaimsPrincipal SetScopes( - [NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] scopes) + public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes) => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create()); /// @@ -1593,7 +1540,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The access token lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetAccessTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetAccessTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.AccessTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1602,7 +1549,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The authorization code lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetAuthorizationCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetAuthorizationCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.AuthorizationCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1611,7 +1558,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The device code lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetDeviceCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetDeviceCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.DeviceCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1620,7 +1567,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The identity token lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetIdentityTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetIdentityTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.IdentityTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1629,7 +1576,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The refresh token lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetRefreshTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetRefreshTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.RefreshTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1638,7 +1585,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The user code lifetime to store. /// The claims principal. - public static ClaimsPrincipal SetUserCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) + public static ClaimsPrincipal SetUserCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime) => principal.SetClaim(Claims.Private.UserCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); /// @@ -1647,7 +1594,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The unique identifier to store. /// The claims principal. - public static ClaimsPrincipal SetAuthorizationId([NotNull] this ClaimsPrincipal principal, string identifier) + public static ClaimsPrincipal SetAuthorizationId(this ClaimsPrincipal principal, string? identifier) => principal.SetClaim(Claims.Private.AuthorizationId, identifier); /// @@ -1656,7 +1603,7 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The unique identifier to store. /// The claims principal. - public static ClaimsPrincipal SetTokenId([NotNull] this ClaimsPrincipal principal, string identifier) + public static ClaimsPrincipal SetTokenId(this ClaimsPrincipal principal, string? identifier) => principal.SetClaim(Claims.Private.TokenId, identifier); /// @@ -1665,13 +1612,19 @@ namespace OpenIddict.Abstractions /// The claims principal. /// The token type to store. /// The claims principal. - public static ClaimsPrincipal SetTokenType([NotNull] this ClaimsPrincipal principal, string type) + public static ClaimsPrincipal SetTokenType(this ClaimsPrincipal principal, string? type) => principal.SetClaim(Claims.Private.TokenType, type); - private static IEnumerable GetValues(string source, char[] separators) + private static ImmutableArray GetValues(string? source, char[] separators) { - Debug.Assert(!string.IsNullOrEmpty(source), SR.GetResourceString(SR.ID5000)); - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + + if (string.IsNullOrEmpty(source)) + { + return ImmutableArray.Create(); + } + + var builder = ImmutableArray.CreateBuilder(); foreach (var element in new StringTokenizer(source, separators)) { @@ -1681,22 +1634,27 @@ namespace OpenIddict.Abstractions continue; } - yield return segment.Value; + if (builder.Contains(segment.Value, StringComparer.Ordinal)) + { + continue; + } + + builder.Add(segment.Value); } - yield break; + return builder.ToImmutable(); } - private static bool HasValue(string source, string value, char[] separators) + private static bool HasValue(string? source, string value, char[] separators) { + Debug.Assert(!string.IsNullOrEmpty(value), SR.GetResourceString(SR.ID5002)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); + if (string.IsNullOrEmpty(source)) { return false; } - Debug.Assert(!string.IsNullOrEmpty(value), SR.GetResourceString(SR.ID5002)); - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); - foreach (var element in new StringTokenizer(source, separators)) { var segment = Trim(element, separators); @@ -1716,7 +1674,7 @@ namespace OpenIddict.Abstractions private static StringSegment TrimStart(StringSegment segment, char[] separators) { - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); var index = segment.Offset; @@ -1735,7 +1693,7 @@ namespace OpenIddict.Abstractions private static StringSegment TrimEnd(StringSegment segment, char[] separators) { - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); var index = segment.Offset + segment.Length - 1; @@ -1754,16 +1712,16 @@ namespace OpenIddict.Abstractions private static StringSegment Trim(StringSegment segment, char[] separators) { - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); return TrimEnd(TrimStart(segment, separators), separators); } private static bool IsSeparator(char character, char[] separators) { - Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); + Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001)); - for (var index = 0; index < separators.Length; index++) + for (var index = 0; index < separators!.Length; index++) { if (character == separators[index]) { diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs index cae04435..31924dc1 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs @@ -14,7 +14,6 @@ using System.Text; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; -using JetBrains.Annotations; using Microsoft.Extensions.Primitives; using SR = OpenIddict.Abstractions.OpenIddictResources; @@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict message. /// /// The message parameters. - public OpenIddictMessage([NotNull] IEnumerable> parameters) + public OpenIddictMessage(IEnumerable> parameters) { if (parameters == null) { @@ -84,7 +83,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict message. /// /// The message parameters. - public OpenIddictMessage([NotNull] IEnumerable> parameters) + public OpenIddictMessage(IEnumerable> parameters) { if (parameters == null) { @@ -112,7 +111,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict message. /// /// The message parameters. - public OpenIddictMessage([NotNull] IEnumerable> parameters) + public OpenIddictMessage(IEnumerable> parameters) { if (parameters == null) { @@ -139,7 +138,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict message. /// /// The message parameters. - public OpenIddictMessage([NotNull] IEnumerable> parameters) + public OpenIddictMessage(IEnumerable> parameters) { if (parameters == null) { @@ -189,7 +188,7 @@ namespace OpenIddict.Abstractions /// The parameter name. /// The parameter value. /// The current instance, which allows chaining calls. - public OpenIddictMessage AddParameter([NotNull] string name, OpenIddictParameter value) + public OpenIddictMessage AddParameter(string name, OpenIddictParameter value) { if (string.IsNullOrEmpty(name)) { @@ -211,7 +210,7 @@ namespace OpenIddict.Abstractions /// /// The parameter name. /// The parameter value, or null if it cannot be found. - public OpenIddictParameter? GetParameter([NotNull] string name) + public OpenIddictParameter? GetParameter(string name) { if (string.IsNullOrEmpty(name)) { @@ -238,7 +237,7 @@ namespace OpenIddict.Abstractions /// /// The parameter name. /// true if the parameter is present, false otherwise. - public bool HasParameter([NotNull] string name) + public bool HasParameter(string name) { if (string.IsNullOrEmpty(name)) { @@ -253,7 +252,7 @@ namespace OpenIddict.Abstractions /// /// The parameter name. /// The current instance, which allows chaining calls. - public OpenIddictMessage RemoveParameter([NotNull] string name) + public OpenIddictMessage RemoveParameter(string name) { if (string.IsNullOrEmpty(name)) { @@ -272,7 +271,7 @@ namespace OpenIddict.Abstractions /// The parameter name. /// The parameter value. /// The current instance, which allows chaining calls. - public OpenIddictMessage SetParameter([NotNull] string name, [CanBeNull] OpenIddictParameter? value) + public OpenIddictMessage SetParameter(string name, OpenIddictParameter? value) { if (string.IsNullOrEmpty(name)) { @@ -299,7 +298,7 @@ namespace OpenIddict.Abstractions /// The parameter name. /// The parameter value. /// true if the parameter could be found, false otherwise. - public bool TryGetParameter([NotNull] string name, out OpenIddictParameter value) + public bool TryGetParameter(string name, out OpenIddictParameter value) { if (string.IsNullOrEmpty(name)) { diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs index 6584d6bd..93adf1bc 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs @@ -12,7 +12,6 @@ using System.Globalization; using System.Linq; using System.Text.Encodings.Web; using System.Text.Json; -using JetBrains.Annotations; using SR = OpenIddict.Abstractions.OpenIddictResources; namespace OpenIddict.Abstractions @@ -57,13 +56,13 @@ namespace OpenIddict.Abstractions /// Initializes a new parameter using the specified value. /// /// The parameter value. - public OpenIddictParameter(string value) => Value = value; + public OpenIddictParameter(string? value) => Value = value; /// /// Initializes a new parameter using the specified value. /// /// The parameter value. - public OpenIddictParameter(string[] value) => Value = value; + public OpenIddictParameter(string?[]? value) => Value = value; /// /// Gets the child item corresponding to the specified index. @@ -86,7 +85,7 @@ namespace OpenIddict.Abstractions public int Count => Value switch { // If the parameter is a primitive array of strings, return its length. - string[] value => value.Length, + string?[] value => value.Length, // If the parameter is a JSON array, return its length. JsonElement value when value.ValueKind == JsonValueKind.Array => value.GetArrayLength(), @@ -100,7 +99,7 @@ namespace OpenIddict.Abstractions /// (e.g bool, string, long), an array of strings or a complex JSON object. /// [EditorBrowsable(EditorBrowsableState.Advanced)] - public object Value { get; } + public object? Value { get; } /// /// Determines whether the current @@ -121,7 +120,7 @@ namespace OpenIddict.Abstractions (_, null) => false, // If the two parameters are string arrays, use SequenceEqual(). - (string[] left, string[] right) => left.SequenceEqual(right), + (string?[] left, string?[] right) => left.SequenceEqual(right), // If the two parameters are JsonElement instances, use the custom comparer. (JsonElement left, JsonElement right) => Equals(left, right), @@ -220,7 +219,7 @@ namespace OpenIddict.Abstractions /// /// The other object to which to compare this instance. /// true if the two instances are equal, false otherwise. - public override bool Equals(object obj) => obj is OpenIddictParameter parameter && Equals(parameter); + public override bool Equals(object? obj) => obj is OpenIddictParameter parameter && Equals(parameter); /// /// Returns the hash code of the current instance. @@ -295,7 +294,7 @@ namespace OpenIddict.Abstractions /// /// The name of the child item. /// An instance containing the item value. - public OpenIddictParameter? GetNamedParameter([NotNull] string name) + public OpenIddictParameter? GetNamedParameter(string name) { if (string.IsNullOrEmpty(name)) { @@ -328,7 +327,7 @@ namespace OpenIddict.Abstractions throw new ArgumentOutOfRangeException(nameof(index), SR.GetResourceString(SR.ID1192)); } - if (Value is string[] array) + if (Value is string?[] array) { // If the specified index goes beyond the // number of items in the array, return null. @@ -385,7 +384,7 @@ namespace OpenIddict.Abstractions /// An enumeration of all the unnamed parameters associated with the current instance. public IReadOnlyList GetUnnamedParameters() { - if (Value is string[] array) + if (Value is string?[] array) { var parameters = new List(); @@ -416,12 +415,12 @@ namespace OpenIddict.Abstractions /// Returns the representation of the current instance. /// /// The representation associated with the parameter value. - public override string ToString() => Value switch + public override string? ToString() => Value switch { null => string.Empty, - string value => value, - string[] value => string.Join(", ", value), + string value => value, + string?[] value => string.Join(", ", value), JsonElement value => value.ToString(), @@ -434,11 +433,11 @@ namespace OpenIddict.Abstractions /// The name of the child item. /// An instance containing the item value. /// true if the parameter could be found, false otherwise. - public bool TryGetParameter([NotNull] string name, out OpenIddictParameter value) + public bool TryGetNamedParameter(string name, out OpenIddictParameter value) { if (string.IsNullOrEmpty(name)) { - throw new ArgumentException(SR.GetResourceString(SR.ID1189), nameof(name)); + throw new ArgumentException(SR.GetResourceString(SR.ID1191), nameof(name)); } if (Value is JsonElement element && element.ValueKind == JsonValueKind.Object && @@ -454,6 +453,52 @@ namespace OpenIddict.Abstractions return false; } + /// + /// Tries to get the child item corresponding to the specified index. + /// + /// The index of the child item. + /// An instance containing the item value. + /// true if the parameter could be found, false otherwise. + public bool TryGetUnnamedParameter(int index, out OpenIddictParameter value) + { + if (index < 0) + { + throw new ArgumentOutOfRangeException(nameof(index), SR.GetResourceString(SR.ID1192)); + } + + if (Value is string?[] array) + { + if (index >= array.Length) + { + value = default; + + return false; + } + + value = new OpenIddictParameter(array[index]); + + return true; + } + + if (Value is JsonElement element && element.ValueKind == JsonValueKind.Array) + { + if (index >= element.GetArrayLength()) + { + value = default; + + return false; + } + + value = new OpenIddictParameter(element[index]); + + return true; + } + + value = default; + + return false; + } + /// /// Writes the parameter value to the specified JSON writer. /// @@ -485,7 +530,7 @@ namespace OpenIddict.Abstractions writer.WriteStringValue(value); break; - case string[] value: + case string?[] value: writer.WriteStartArray(); for (var index = 0; index < value.Length; index++) @@ -654,7 +699,7 @@ namespace OpenIddict.Abstractions /// /// The parameter to convert. /// The converted value. - public static explicit operator string(OpenIddictParameter? parameter) => parameter?.Value switch + public static explicit operator string?(OpenIddictParameter? parameter) => parameter?.Value switch { // When the parameter is a null value, return null. null => null, @@ -692,7 +737,7 @@ namespace OpenIddict.Abstractions /// /// The parameter to convert. /// The converted value. - public static explicit operator string[](OpenIddictParameter? parameter) + public static explicit operator string?[]?(OpenIddictParameter? parameter) { return parameter?.Value switch { @@ -700,16 +745,16 @@ namespace OpenIddict.Abstractions null => null, // When the parameter is already an array of strings, return it as-is. - string[] value => value, + string?[] value => value, // When the parameter is a string value, return an array with a single entry. - string value => new string[] { value }, + string value => new string?[] { value }, // When the parameter is a boolean value, return an array with its string representation. - bool value => new string[] { value.ToString() }, + bool value => new string?[] { value.ToString() }, // When the parameter is an integer, return an array with its string representation. - long value => new string[] { value.ToString(CultureInfo.InvariantCulture) }, + long value => new string?[] { value.ToString(CultureInfo.InvariantCulture) }, // When the parameter is a JsonElement representing null, return null. JsonElement value when value.ValueKind == JsonValueKind.Undefined => null, @@ -717,15 +762,15 @@ namespace OpenIddict.Abstractions // When the parameter is a JsonElement representing a string, return an array with a single entry. JsonElement value when value.ValueKind == JsonValueKind.String - => new string[] { value.GetString() }, + => new string?[] { value.GetString() }, // When the parameter is a JsonElement representing a number, return an array with a single entry. JsonElement value when value.ValueKind == JsonValueKind.Number - => new string[] { value.GetInt64().ToString(CultureInfo.InvariantCulture) }, + => new string?[] { value.GetInt64().ToString(CultureInfo.InvariantCulture) }, // When the parameter is a JsonElement representing a boolean, return an array with a single entry. - JsonElement value when value.ValueKind == JsonValueKind.False => new string[] { bool.FalseString }, - JsonElement value when value.ValueKind == JsonValueKind.True => new string[] { bool.TrueString }, + JsonElement value when value.ValueKind == JsonValueKind.False => new string?[] { bool.FalseString }, + JsonElement value when value.ValueKind == JsonValueKind.True => new string?[] { bool.TrueString }, // When the parameter is a JsonElement representing an array of strings, return it. JsonElement value when value.ValueKind == JsonValueKind.Array => CreateArray(value), @@ -734,7 +779,7 @@ namespace OpenIddict.Abstractions _ => null }; - static string[] CreateArray(JsonElement value) + static string?[]? CreateArray(JsonElement value) { var array = new string[value.GetArrayLength()]; using var enumerator = value.EnumerateArray(); @@ -794,14 +839,14 @@ namespace OpenIddict.Abstractions /// /// The value to convert /// An instance. - public static implicit operator OpenIddictParameter(string value) => new OpenIddictParameter(value); + public static implicit operator OpenIddictParameter(string? value) => new OpenIddictParameter(value); /// /// Converts an array of strings to an instance. /// /// The value to convert /// An instance. - public static implicit operator OpenIddictParameter(string[] value) => new OpenIddictParameter(value); + public static implicit operator OpenIddictParameter(string?[]? value) => new OpenIddictParameter(value); /// /// Determines whether a parameter is null or empty. @@ -814,8 +859,8 @@ namespace OpenIddict.Abstractions { null => true, - string value => string.IsNullOrEmpty(value), - string[] value => value.Length == 0, + string value => string.IsNullOrEmpty(value), + string?[] value => value.Length == 0, JsonElement value when value.ValueKind == JsonValueKind.Undefined => true, JsonElement value when value.ValueKind == JsonValueKind.Null => true, diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs index e9222a8c..9bdc44a2 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text.Json; using System.Text.Json.Serialization; -using JetBrains.Annotations; using Microsoft.Extensions.Primitives; namespace OpenIddict.Abstractions @@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict request. /// /// The request parameters. - public OpenIddictRequest([NotNull] IEnumerable> parameters) + public OpenIddictRequest(IEnumerable> parameters) : base(parameters) { } @@ -55,7 +54,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict request. /// /// The request parameters. - public OpenIddictRequest([NotNull] IEnumerable> parameters) + public OpenIddictRequest(IEnumerable> parameters) : base(parameters) { } @@ -64,7 +63,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict request. /// /// The request parameters. - public OpenIddictRequest([NotNull] IEnumerable> parameters) + public OpenIddictRequest(IEnumerable> parameters) : base(parameters) { } @@ -73,7 +72,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict request. /// /// The request parameters. - public OpenIddictRequest([NotNull] IEnumerable> parameters) + public OpenIddictRequest(IEnumerable> parameters) : base(parameters) { } @@ -81,36 +80,36 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "access_token" parameter. /// - public string AccessToken + public string? AccessToken { - get => (string) GetParameter(OpenIddictConstants.Parameters.AccessToken); + get => (string?) GetParameter(OpenIddictConstants.Parameters.AccessToken); set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value); } /// /// Gets or sets the "acr_values" parameter. /// - public string AcrValues + public string? AcrValues { - get => (string) GetParameter(OpenIddictConstants.Parameters.AcrValues); + get => (string?) GetParameter(OpenIddictConstants.Parameters.AcrValues); set => SetParameter(OpenIddictConstants.Parameters.AcrValues, value); } /// /// Gets or sets the "assertion" parameter. /// - public string Assertion + public string? Assertion { - get => (string) GetParameter(OpenIddictConstants.Parameters.Assertion); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Assertion); set => SetParameter(OpenIddictConstants.Parameters.Assertion, value); } /// /// Gets or sets the "audience" parameters. /// - public string[] Audiences + public string[]? Audiences { - get => (string[]) GetParameter(OpenIddictConstants.Parameters.Audience); + get => (string[]?) GetParameter(OpenIddictConstants.Parameters.Audience); set => SetParameter(OpenIddictConstants.Parameters.Audience, value); } @@ -126,135 +125,135 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "claims_locales" parameter. /// - public string ClaimsLocales + public string? ClaimsLocales { - get => (string) GetParameter(OpenIddictConstants.Parameters.ClaimsLocales); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ClaimsLocales); set => SetParameter(OpenIddictConstants.Parameters.ClaimsLocales, value); } /// /// Gets or sets the "client_assertion" parameter. /// - public string ClientAssertion + public string? ClientAssertion { - get => (string) GetParameter(OpenIddictConstants.Parameters.ClientAssertion); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientAssertion); set => SetParameter(OpenIddictConstants.Parameters.ClientAssertion, value); } /// /// Gets or sets the "client_assertion_type" parameter. /// - public string ClientAssertionType + public string? ClientAssertionType { - get => (string) GetParameter(OpenIddictConstants.Parameters.ClientAssertionType); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientAssertionType); set => SetParameter(OpenIddictConstants.Parameters.ClientAssertionType, value); } /// /// Gets or sets the "client_id" parameter. /// - public string ClientId + public string? ClientId { - get => (string) GetParameter(OpenIddictConstants.Parameters.ClientId); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientId); set => SetParameter(OpenIddictConstants.Parameters.ClientId, value); } /// /// Gets or sets the "client_secret" parameter. /// - public string ClientSecret + public string? ClientSecret { - get => (string) GetParameter(OpenIddictConstants.Parameters.ClientSecret); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientSecret); set => SetParameter(OpenIddictConstants.Parameters.ClientSecret, value); } /// /// Gets or sets the "code" parameter. /// - public string Code + public string? Code { - get => (string) GetParameter(OpenIddictConstants.Parameters.Code); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Code); set => SetParameter(OpenIddictConstants.Parameters.Code, value); } /// /// Gets or sets the "code_challenge" parameter. /// - public string CodeChallenge + public string? CodeChallenge { - get => (string) GetParameter(OpenIddictConstants.Parameters.CodeChallenge); + get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeChallenge); set => SetParameter(OpenIddictConstants.Parameters.CodeChallenge, value); } /// /// Gets or sets the "code_challenge_method" parameter. /// - public string CodeChallengeMethod + public string? CodeChallengeMethod { - get => (string) GetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod); + get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod); set => SetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod, value); } /// /// Gets or sets the "code_verifier" parameter. /// - public string CodeVerifier + public string? CodeVerifier { - get => (string) GetParameter(OpenIddictConstants.Parameters.CodeVerifier); + get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeVerifier); set => SetParameter(OpenIddictConstants.Parameters.CodeVerifier, value); } /// /// Gets or sets the "device_code" parameter. /// - public string DeviceCode + public string? DeviceCode { - get => (string) GetParameter(OpenIddictConstants.Parameters.DeviceCode); + get => (string?) GetParameter(OpenIddictConstants.Parameters.DeviceCode); set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value); } /// /// Gets or sets the "display" parameter. /// - public string Display + public string? Display { - get => (string) GetParameter(OpenIddictConstants.Parameters.Display); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Display); set => SetParameter(OpenIddictConstants.Parameters.Display, value); } /// /// Gets or sets the "grant_type" parameter. /// - public string GrantType + public string? GrantType { - get => (string) GetParameter(OpenIddictConstants.Parameters.GrantType); + get => (string?) GetParameter(OpenIddictConstants.Parameters.GrantType); set => SetParameter(OpenIddictConstants.Parameters.GrantType, value); } /// /// Gets or sets the "identity_provider" parameter. /// - public string IdentityProvider + public string? IdentityProvider { - get => (string) GetParameter(OpenIddictConstants.Parameters.IdentityProvider); + get => (string?) GetParameter(OpenIddictConstants.Parameters.IdentityProvider); set => SetParameter(OpenIddictConstants.Parameters.IdentityProvider, value); } /// /// Gets or sets the "id_token_hint" parameter. /// - public string IdTokenHint + public string? IdTokenHint { - get => (string) GetParameter(OpenIddictConstants.Parameters.IdTokenHint); + get => (string?) GetParameter(OpenIddictConstants.Parameters.IdTokenHint); set => SetParameter(OpenIddictConstants.Parameters.IdTokenHint, value); } /// /// Gets or sets the "login_hint" parameter. /// - public string LoginHint + public string? LoginHint { - get => (string) GetParameter(OpenIddictConstants.Parameters.LoginHint); + get => (string?) GetParameter(OpenIddictConstants.Parameters.LoginHint); set => SetParameter(OpenIddictConstants.Parameters.LoginHint, value); } @@ -270,144 +269,144 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "nonce" parameter. /// - public string Nonce + public string? Nonce { - get => (string) GetParameter(OpenIddictConstants.Parameters.Nonce); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Nonce); set => SetParameter(OpenIddictConstants.Parameters.Nonce, value); } /// /// Gets or sets the "password" parameter. /// - public string Password + public string? Password { - get => (string) GetParameter(OpenIddictConstants.Parameters.Password); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Password); set => SetParameter(OpenIddictConstants.Parameters.Password, value); } /// /// Gets or sets the "post_logout_redirect_uri" parameter. /// - public string PostLogoutRedirectUri + public string? PostLogoutRedirectUri { - get => (string) GetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri); + get => (string?) GetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri); set => SetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri, value); } /// /// Gets or sets the "prompt" parameter. /// - public string Prompt + public string? Prompt { - get => (string) GetParameter(OpenIddictConstants.Parameters.Prompt); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Prompt); set => SetParameter(OpenIddictConstants.Parameters.Prompt, value); } /// /// Gets or sets the "redirect_uri" parameter. /// - public string RedirectUri + public string? RedirectUri { - get => (string) GetParameter(OpenIddictConstants.Parameters.RedirectUri); + get => (string?) GetParameter(OpenIddictConstants.Parameters.RedirectUri); set => SetParameter(OpenIddictConstants.Parameters.RedirectUri, value); } /// /// Gets or sets the "refresh_token" parameter. /// - public string RefreshToken + public string? RefreshToken { - get => (string) GetParameter(OpenIddictConstants.Parameters.RefreshToken); + get => (string?) GetParameter(OpenIddictConstants.Parameters.RefreshToken); set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value); } /// /// Gets or sets the "request" parameter. /// - public string Request + public string? Request { - get => (string) GetParameter(OpenIddictConstants.Parameters.Request); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Request); set => SetParameter(OpenIddictConstants.Parameters.Request, value); } /// /// Gets or sets the "request_id" parameter. /// - public string RequestId + public string? RequestId { - get => (string) GetParameter(OpenIddictConstants.Parameters.RequestId); + get => (string?) GetParameter(OpenIddictConstants.Parameters.RequestId); set => SetParameter(OpenIddictConstants.Parameters.RequestId, value); } /// /// Gets or sets the "request_uri" parameter. /// - public string RequestUri + public string? RequestUri { - get => (string) GetParameter(OpenIddictConstants.Parameters.RequestUri); + get => (string?) GetParameter(OpenIddictConstants.Parameters.RequestUri); set => SetParameter(OpenIddictConstants.Parameters.RequestUri, value); } /// /// Gets or sets the "resource" parameters. /// - public string[] Resources + public string[]? Resources { - get => (string[]) GetParameter(OpenIddictConstants.Parameters.Resource); + get => (string[]?) GetParameter(OpenIddictConstants.Parameters.Resource); set => SetParameter(OpenIddictConstants.Parameters.Resource, value); } /// /// Gets or sets the "response_mode" parameter. /// - public string ResponseMode + public string? ResponseMode { - get => (string) GetParameter(OpenIddictConstants.Parameters.ResponseMode); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ResponseMode); set => SetParameter(OpenIddictConstants.Parameters.ResponseMode, value); } /// /// Gets or sets the "response_type" parameter. /// - public string ResponseType + public string? ResponseType { - get => (string) GetParameter(OpenIddictConstants.Parameters.ResponseType); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ResponseType); set => SetParameter(OpenIddictConstants.Parameters.ResponseType, value); } /// /// Gets or sets the "scope" parameter. /// - public string Scope + public string? Scope { - get => (string) GetParameter(OpenIddictConstants.Parameters.Scope); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Scope); set => SetParameter(OpenIddictConstants.Parameters.Scope, value); } /// /// Gets or sets the "state" parameter. /// - public string State + public string? State { - get => (string) GetParameter(OpenIddictConstants.Parameters.State); + get => (string?) GetParameter(OpenIddictConstants.Parameters.State); set => SetParameter(OpenIddictConstants.Parameters.State, value); } /// /// Gets or sets the "token" parameter. /// - public string Token + public string? Token { - get => (string) GetParameter(OpenIddictConstants.Parameters.Token); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Token); set => SetParameter(OpenIddictConstants.Parameters.Token, value); } /// /// Gets or sets the "token_type_hint" parameter. /// - public string TokenTypeHint + public string? TokenTypeHint { - get => (string) GetParameter(OpenIddictConstants.Parameters.TokenTypeHint); + get => (string?) GetParameter(OpenIddictConstants.Parameters.TokenTypeHint); set => SetParameter(OpenIddictConstants.Parameters.TokenTypeHint, value); } @@ -423,27 +422,27 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "ui_locales" parameter. /// - public string UiLocales + public string? UiLocales { - get => (string) GetParameter(OpenIddictConstants.Parameters.UiLocales); + get => (string?) GetParameter(OpenIddictConstants.Parameters.UiLocales); set => SetParameter(OpenIddictConstants.Parameters.UiLocales, value); } /// /// Gets or sets the "user_code" parameter. /// - public string UserCode + public string? UserCode { - get => (string) GetParameter(OpenIddictConstants.Parameters.UserCode); + get => (string?) GetParameter(OpenIddictConstants.Parameters.UserCode); set => SetParameter(OpenIddictConstants.Parameters.UserCode, value); } /// /// Gets or sets the "username" parameter. /// - public string Username + public string? Username { - get => (string) GetParameter(OpenIddictConstants.Parameters.Username); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Username); set => SetParameter(OpenIddictConstants.Parameters.Username, value); } } diff --git a/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs b/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs index fce4ab35..1d242c86 100644 --- a/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs +++ b/src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text.Json; using System.Text.Json.Serialization; -using JetBrains.Annotations; using Microsoft.Extensions.Primitives; namespace OpenIddict.Abstractions @@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict response. /// /// The response parameters. - public OpenIddictResponse([NotNull] IEnumerable> parameters) + public OpenIddictResponse(IEnumerable> parameters) : base(parameters) { } @@ -55,7 +54,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict response. /// /// The response parameters. - public OpenIddictResponse([NotNull] IEnumerable> parameters) + public OpenIddictResponse(IEnumerable> parameters) : base(parameters) { } @@ -64,7 +63,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict response. /// /// The response parameters. - public OpenIddictResponse([NotNull] IEnumerable> parameters) + public OpenIddictResponse(IEnumerable> parameters) : base(parameters) { } @@ -73,7 +72,7 @@ namespace OpenIddict.Abstractions /// Initializes a new OpenIddict response. /// /// The response parameters. - public OpenIddictResponse([NotNull] IEnumerable> parameters) + public OpenIddictResponse(IEnumerable> parameters) : base(parameters) { } @@ -81,54 +80,54 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "access_token" parameter. /// - public string AccessToken + public string? AccessToken { - get => (string) GetParameter(OpenIddictConstants.Parameters.AccessToken); + get => (string?) GetParameter(OpenIddictConstants.Parameters.AccessToken); set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value); } /// /// Gets or sets the "code" parameter. /// - public string Code + public string? Code { - get => (string) GetParameter(OpenIddictConstants.Parameters.Code); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Code); set => SetParameter(OpenIddictConstants.Parameters.Code, value); } /// /// Gets or sets the "device_code" parameter. /// - public string DeviceCode + public string? DeviceCode { - get => (string) GetParameter(OpenIddictConstants.Parameters.DeviceCode); + get => (string?) GetParameter(OpenIddictConstants.Parameters.DeviceCode); set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value); } /// /// Gets or sets the "error" parameter. /// - public string Error + public string? Error { - get => (string) GetParameter(OpenIddictConstants.Parameters.Error); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Error); set => SetParameter(OpenIddictConstants.Parameters.Error, value); } /// /// Gets or sets the "error_description" parameter. /// - public string ErrorDescription + public string? ErrorDescription { - get => (string) GetParameter(OpenIddictConstants.Parameters.ErrorDescription); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ErrorDescription); set => SetParameter(OpenIddictConstants.Parameters.ErrorDescription, value); } /// /// Gets or sets the "error_uri" parameter. /// - public string ErrorUri + public string? ErrorUri { - get => (string) GetParameter(OpenIddictConstants.Parameters.ErrorUri); + get => (string?) GetParameter(OpenIddictConstants.Parameters.ErrorUri); set => SetParameter(OpenIddictConstants.Parameters.ErrorUri, value); } @@ -144,54 +143,54 @@ namespace OpenIddict.Abstractions /// /// Gets or sets the "id_token" parameter. /// - public string IdToken + public string? IdToken { - get => (string) GetParameter(OpenIddictConstants.Parameters.IdToken); + get => (string?) GetParameter(OpenIddictConstants.Parameters.IdToken); set => SetParameter(OpenIddictConstants.Parameters.IdToken, value); } /// /// Gets or sets the "refresh_token" parameter. /// - public string RefreshToken + public string? RefreshToken { - get => (string) GetParameter(OpenIddictConstants.Parameters.RefreshToken); + get => (string?) GetParameter(OpenIddictConstants.Parameters.RefreshToken); set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value); } /// /// Gets or sets the "scope" parameter. /// - public string Scope + public string? Scope { - get => (string) GetParameter(OpenIddictConstants.Parameters.Scope); + get => (string?) GetParameter(OpenIddictConstants.Parameters.Scope); set => SetParameter(OpenIddictConstants.Parameters.Scope, value); } /// /// Gets or sets the "state" parameter. /// - public string State + public string? State { - get => (string) GetParameter(OpenIddictConstants.Parameters.State); + get => (string?) GetParameter(OpenIddictConstants.Parameters.State); set => SetParameter(OpenIddictConstants.Parameters.State, value); } /// /// Gets or sets the "token_type" parameter. /// - public string TokenType + public string? TokenType { - get => (string) GetParameter(OpenIddictConstants.Parameters.TokenType); + get => (string?) GetParameter(OpenIddictConstants.Parameters.TokenType); set => SetParameter(OpenIddictConstants.Parameters.TokenType, value); } /// /// Gets or sets the "user_code" parameter. /// - public string UserCode + public string? UserCode { - get => (string) GetParameter(OpenIddictConstants.Parameters.UserCode); + get => (string?) GetParameter(OpenIddictConstants.Parameters.UserCode); set => SetParameter(OpenIddictConstants.Parameters.UserCode, value); } } diff --git a/src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx b/src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx index 1406f152..00b89ba1 100644 --- a/src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx +++ b/src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx @@ -1451,7 +1451,7 @@ Consider creating non-generic classes derived from the default entities for the Callback URLs must be valid absolute URLs. - The source string shouldn't be null or empty. + The '{0}' parameter shouldn't be null or empty at this point. The separators collection shouldn't be null or empty. @@ -1468,6 +1468,21 @@ Consider creating non-generic classes derived from the default entities for the ECDsa.ExportParameters() shouldn't return an unnamed curve. + + The principal shouldn't be null at this point. + + + The response shouldn't be null at this point. + + + The request shouldn't be null at this point. + + + The token type shouldn't be null or empty. + + + The token shouldn't be null or empty at this point. + An error occurred while validating the token '{Token}'. diff --git a/src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs b/src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs index 2ef81444..aaf6e880 100644 --- a/src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs +++ b/src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs @@ -12,7 +12,6 @@ using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -42,7 +41,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of applications that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken); /// /// Creates a new application. @@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions /// The application to create. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken); /// /// Removes an existing application. @@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions /// The application to delete. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves an application using its unique identifier. @@ -69,7 +68,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves an application using its client identifier. @@ -80,7 +79,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// - ValueTask FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByClientIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified post_logout_redirect_uri. @@ -88,7 +87,7 @@ namespace OpenIddict.Abstractions /// The post_logout_redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified post_logout_redirect_uri. - IAsyncEnumerable FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); + IAsyncEnumerable FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified redirect_uri. @@ -96,7 +95,7 @@ namespace OpenIddict.Abstractions /// The redirect_uri associated with the applications. /// The that can be used to abort the operation. /// The client applications corresponding to the specified redirect_uri. - IAsyncEnumerable FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); + IAsyncEnumerable FindByRedirectUriAsync(string address, CancellationToken cancellationToken); /// /// Executes the specified query and returns the first element. @@ -111,8 +110,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Retrieves the client identifier associated with an application. @@ -123,7 +122,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client identifier associated with the application. /// - ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetClientIdAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the client secret associated with an application. @@ -136,7 +135,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client secret associated with the application. /// - ValueTask GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetClientSecretAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the client type associated with an application. @@ -147,7 +146,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the client type of the application (by default, "public"). /// - ValueTask GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetClientTypeAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the consent type associated with an application. @@ -158,7 +157,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the consent type of the application (by default, "explicit"). /// - ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the display name associated with an application. @@ -169,7 +168,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the application. /// - ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the localized display names associated with an application. @@ -180,7 +179,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized display names associated with the application. /// - ValueTask> GetDisplayNamesAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the unique identifier associated with an application. @@ -191,7 +190,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the application. /// - ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask GetIdAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the permissions associated with an application. @@ -202,7 +201,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the permissions associated with the application. /// - ValueTask> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the logout callback addresses associated with an application. @@ -213,7 +212,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the post_logout_redirect_uri associated with the application. /// - ValueTask> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the additional properties associated with an application. @@ -224,7 +223,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the additional properties associated with the application. /// - ValueTask> GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the callback addresses associated with an application. @@ -235,7 +234,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the redirect_uri associated with the application. /// - ValueTask> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken); /// /// Retrieves the requirements associated with an application. @@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the requirements associated with the application. /// - ValueTask> GetRequirementsAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken); /// /// Instantiates a new application. @@ -265,7 +264,7 @@ namespace OpenIddict.Abstractions /// The number of results to skip. /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. - IAsyncEnumerable ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); + IAsyncEnumerable ListAsync(int? count, int? offset, CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. @@ -277,8 +276,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Sets the client identifier associated with an application. @@ -287,7 +286,7 @@ namespace OpenIddict.Abstractions /// The client identifier associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetClientIdAsync([NotNull] TApplication application, [CanBeNull] string identifier, CancellationToken cancellationToken); + ValueTask SetClientIdAsync(TApplication application, string? identifier, CancellationToken cancellationToken); /// /// Sets the client secret associated with an application. @@ -298,7 +297,7 @@ namespace OpenIddict.Abstractions /// The client secret associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetClientSecretAsync([NotNull] TApplication application, [CanBeNull] string secret, CancellationToken cancellationToken); + ValueTask SetClientSecretAsync(TApplication application, string? secret, CancellationToken cancellationToken); /// /// Sets the client type associated with an application. @@ -307,7 +306,7 @@ namespace OpenIddict.Abstractions /// The client type associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetClientTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); + ValueTask SetClientTypeAsync(TApplication application, string? type, CancellationToken cancellationToken); /// /// Sets the consent type associated with an application. @@ -316,7 +315,7 @@ namespace OpenIddict.Abstractions /// The consent type associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetConsentTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); + ValueTask SetConsentTypeAsync(TApplication application, string? type, CancellationToken cancellationToken); /// /// Sets the display name associated with an application. @@ -325,7 +324,7 @@ namespace OpenIddict.Abstractions /// The display name associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDisplayNameAsync([NotNull] TApplication application, [CanBeNull] string name, CancellationToken cancellationToken); + ValueTask SetDisplayNameAsync(TApplication application, string? name, CancellationToken cancellationToken); /// /// Sets the localized display names associated with an application. @@ -334,8 +333,8 @@ namespace OpenIddict.Abstractions /// The localized display names associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDisplayNamesAsync([NotNull] TApplication application, - [CanBeNull] ImmutableDictionary names, CancellationToken cancellationToken); + ValueTask SetDisplayNamesAsync(TApplication application, + ImmutableDictionary names, CancellationToken cancellationToken); /// /// Sets the permissions associated with an application. @@ -344,7 +343,7 @@ namespace OpenIddict.Abstractions /// The permissions associated with the application /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPermissionsAsync([NotNull] TApplication application, ImmutableArray permissions, CancellationToken cancellationToken); + ValueTask SetPermissionsAsync(TApplication application, ImmutableArray permissions, CancellationToken cancellationToken); /// /// Sets the logout callback addresses associated with an application. @@ -353,7 +352,7 @@ namespace OpenIddict.Abstractions /// The logout callback addresses associated with the application /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, + ValueTask SetPostLogoutRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken); /// @@ -363,8 +362,8 @@ namespace OpenIddict.Abstractions /// The additional properties associated with the application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPropertiesAsync([NotNull] TApplication application, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken); + ValueTask SetPropertiesAsync(TApplication application, + ImmutableDictionary properties, CancellationToken cancellationToken); /// /// Sets the callback addresses associated with an application. @@ -373,7 +372,7 @@ namespace OpenIddict.Abstractions /// The callback addresses associated with the application /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetRedirectUrisAsync([NotNull] TApplication application, + ValueTask SetRedirectUrisAsync(TApplication application, ImmutableArray addresses, CancellationToken cancellationToken); /// @@ -383,7 +382,7 @@ namespace OpenIddict.Abstractions /// The requirements associated with the application /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetRequirementsAsync([NotNull] TApplication application, ImmutableArray requirements, CancellationToken cancellationToken); + ValueTask SetRequirementsAsync(TApplication application, ImmutableArray requirements, CancellationToken cancellationToken); /// /// Updates an existing application. @@ -391,6 +390,6 @@ namespace OpenIddict.Abstractions /// The application to update. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken); + ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs b/src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs index 5a005816..f2e00fca 100644 --- a/src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs +++ b/src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of authorizations that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken); /// /// Creates a new authorization. @@ -49,7 +48,7 @@ namespace OpenIddict.Abstractions /// The authorization to create. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Removes an existing authorization. @@ -57,7 +56,7 @@ namespace OpenIddict.Abstractions /// The authorization to delete. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the authorizations corresponding to the specified @@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions /// The client associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the subject/client. - IAsyncEnumerable FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken); + string subject, string client, + string status, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -91,8 +90,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); + string subject, string client, + string status, string type, CancellationToken cancellationToken); /// /// Retrieves the authorizations matching the specified parameters. @@ -105,8 +104,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The authorizations corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, + string subject, string client, + string status, string type, ImmutableArray scopes, CancellationToken cancellationToken); /// @@ -115,7 +114,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the authorizations. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves an authorization using its unique identifier. @@ -126,7 +125,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the authorization corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves all the authorizations corresponding to the specified subject. @@ -134,7 +133,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the authorization. /// The that can be used to abort the operation. /// The authorizations corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken); /// /// Retrieves the optional application identifier associated with an authorization. @@ -145,7 +144,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the application identifier associated with the authorization. /// - ValueTask GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Executes the specified query and returns the first element. @@ -160,8 +159,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Retrieves the unique identifier associated with an authorization. @@ -172,7 +171,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the authorization. /// - ValueTask GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the additional properties associated with an authorization. @@ -183,7 +182,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the additional properties associated with the authorization. /// - ValueTask> GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the scopes associated with an authorization. @@ -194,7 +193,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scopes associated with the specified authorization. /// - ValueTask> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the status associated with an authorization. @@ -205,7 +204,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the status associated with the specified authorization. /// - ValueTask GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the subject associated with an authorization. @@ -216,7 +215,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the subject associated with the specified authorization. /// - ValueTask GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Retrieves the type associated with an authorization. @@ -227,7 +226,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the type associated with the specified authorization. /// - ValueTask GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken); /// /// Instantiates a new authorization. @@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions /// The number of results to skip. /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. - IAsyncEnumerable ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); + IAsyncEnumerable ListAsync(int? count, int? offset, CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. @@ -258,8 +257,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached. @@ -275,8 +274,7 @@ namespace OpenIddict.Abstractions /// The unique identifier associated with the client application. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetApplicationIdAsync([NotNull] TAuthorization authorization, - [CanBeNull] string identifier, CancellationToken cancellationToken); + ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken); /// /// Sets the additional properties associated with an authorization. @@ -285,8 +283,8 @@ namespace OpenIddict.Abstractions /// The additional properties associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPropertiesAsync([NotNull] TAuthorization authorization, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken); + ValueTask SetPropertiesAsync(TAuthorization authorization, + ImmutableDictionary properties, CancellationToken cancellationToken); /// /// Sets the scopes associated with an authorization. @@ -295,7 +293,7 @@ namespace OpenIddict.Abstractions /// The scopes associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetScopesAsync([NotNull] TAuthorization authorization, + ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray scopes, CancellationToken cancellationToken); /// @@ -305,8 +303,7 @@ namespace OpenIddict.Abstractions /// The status associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetStatusAsync([NotNull] TAuthorization authorization, - [CanBeNull] string status, CancellationToken cancellationToken); + ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken); /// /// Sets the subject associated with an authorization. @@ -315,8 +312,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetSubjectAsync([NotNull] TAuthorization authorization, - [CanBeNull] string subject, CancellationToken cancellationToken); + ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken); /// /// Sets the type associated with an authorization. @@ -325,8 +321,7 @@ namespace OpenIddict.Abstractions /// The type associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetTypeAsync([NotNull] TAuthorization authorization, - [CanBeNull] string type, CancellationToken cancellationToken); + ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken); /// /// Updates an existing authorization. @@ -334,6 +329,6 @@ namespace OpenIddict.Abstractions /// The authorization to update. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); + ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs b/src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs index ac34d0be..829404da 100644 --- a/src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs +++ b/src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs @@ -12,7 +12,6 @@ using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -42,7 +41,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of scopes that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken); /// /// Creates a new scope. @@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions /// The scope to create. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken); /// /// Removes an existing scope. @@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions /// The scope to delete. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves a scope using its unique identifier. @@ -69,7 +68,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves a scope using its name. @@ -80,7 +79,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the scope corresponding to the specified name. /// - ValueTask FindByNameAsync([NotNull] string name, CancellationToken cancellationToken); + ValueTask FindByNameAsync(string name, CancellationToken cancellationToken); /// /// Retrieves a list of scopes using their name. @@ -96,7 +95,7 @@ namespace OpenIddict.Abstractions /// The resource associated with the scopes. /// The that can be used to abort the operation. /// The scopes associated with the specified resource. - IAsyncEnumerable FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken); + IAsyncEnumerable FindByResourceAsync(string resource, CancellationToken cancellationToken); /// /// Executes the specified query and returns the first element. @@ -111,8 +110,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Retrieves the description associated with a scope. @@ -123,7 +122,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the description associated with the specified scope. /// - ValueTask GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask GetDescriptionAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the localized descriptions associated with a scope. @@ -134,7 +133,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized descriptions associated with the specified scope. /// - ValueTask> GetDescriptionsAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the display name associated with a scope. @@ -145,7 +144,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the scope. /// - ValueTask GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the localized display names associated with a scope. @@ -156,7 +155,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the localized display names associated with the scope. /// - ValueTask> GetDisplayNamesAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the unique identifier associated with a scope. @@ -167,7 +166,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the scope. /// - ValueTask GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask GetIdAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the name associated with a scope. @@ -178,7 +177,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the name associated with the specified scope. /// - ValueTask GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask GetNameAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the additional properties associated with a scope. @@ -189,7 +188,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, whose /// result returns all the additional properties associated with the scope. /// - ValueTask> GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken); /// /// Retrieves the resources associated with a scope. @@ -200,7 +199,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the resources associated with the scope. /// - ValueTask> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask> GetResourcesAsync(TScope scope, CancellationToken cancellationToken); /// /// Instantiates a new scope. @@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions /// The number of results to skip. /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. - IAsyncEnumerable ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); + IAsyncEnumerable ListAsync(int? count, int? offset, CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. @@ -231,8 +230,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Sets the description associated with a scope. @@ -241,7 +240,7 @@ namespace OpenIddict.Abstractions /// The description associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDescriptionAsync([NotNull] TScope scope, [CanBeNull] string description, CancellationToken cancellationToken); + ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken); /// /// Sets the localized descriptions associated with a scope. @@ -250,8 +249,8 @@ namespace OpenIddict.Abstractions /// The localized descriptions associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDescriptionsAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary descriptions, CancellationToken cancellationToken); + ValueTask SetDescriptionsAsync(TScope scope, + ImmutableDictionary descriptions, CancellationToken cancellationToken); /// /// Sets the display name associated with a scope. @@ -260,7 +259,7 @@ namespace OpenIddict.Abstractions /// The display name associated with the scope. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDisplayNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken); + ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken); /// /// Sets the localized display names associated with a scope. @@ -269,8 +268,8 @@ namespace OpenIddict.Abstractions /// The localized display names associated with the scope. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetDisplayNamesAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary names, CancellationToken cancellationToken); + ValueTask SetDisplayNamesAsync(TScope scope, + ImmutableDictionary names, CancellationToken cancellationToken); /// /// Sets the name associated with a scope. @@ -279,7 +278,7 @@ namespace OpenIddict.Abstractions /// The name associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken); + ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken); /// /// Sets the additional properties associated with a scope. @@ -288,8 +287,8 @@ namespace OpenIddict.Abstractions /// The additional properties associated with the scope. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPropertiesAsync([NotNull] TScope scope, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken); + ValueTask SetPropertiesAsync(TScope scope, + ImmutableDictionary properties, CancellationToken cancellationToken); /// /// Sets the resources associated with a scope. @@ -298,7 +297,7 @@ namespace OpenIddict.Abstractions /// The resources associated with the scope. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetResourcesAsync([NotNull] TScope scope, ImmutableArray resources, CancellationToken cancellationToken); + ValueTask SetResourcesAsync(TScope scope, ImmutableArray resources, CancellationToken cancellationToken); /// /// Updates an existing scope. @@ -306,6 +305,6 @@ namespace OpenIddict.Abstractions /// The scope to update. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken); + ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs b/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs index b5adbc07..04918101 100644 --- a/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs +++ b/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; namespace OpenIddict.Abstractions { @@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of tokens that match the specified query. /// - ValueTask CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken); + ValueTask CountAsync(Func, IQueryable> query, CancellationToken cancellationToken); /// /// Creates a new token. @@ -49,7 +48,7 @@ namespace OpenIddict.Abstractions /// The token to create. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask CreateAsync(TToken token, CancellationToken cancellationToken); /// /// Removes a token. @@ -57,7 +56,7 @@ namespace OpenIddict.Abstractions /// The token to delete. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the tokens corresponding to the specified @@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions /// The client associated with the token. /// The that can be used to abort the operation. /// The tokens corresponding to the subject/client. - IAsyncEnumerable FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); + IAsyncEnumerable FindAsync(string subject, string client, CancellationToken cancellationToken); /// /// Retrieves the tokens matching the specified parameters. @@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, CancellationToken cancellationToken); + string subject, string client, + string status, CancellationToken cancellationToken); /// /// Retrieves the tokens matching the specified parameters. @@ -91,8 +90,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// The tokens corresponding to the criteria. IAsyncEnumerable FindAsync( - [NotNull] string subject, [NotNull] string client, - [NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); + string subject, string client, + string status, string type, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified application identifier. @@ -100,7 +99,7 @@ namespace OpenIddict.Abstractions /// The application identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified application. - IAsyncEnumerable FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified authorization identifier. @@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions /// The authorization identifier associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified authorization. - IAsyncEnumerable FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + IAsyncEnumerable FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves a token using its unique identifier. @@ -119,7 +118,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the token corresponding to the unique identifier. /// - ValueTask FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified reference identifier. @@ -131,7 +130,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the tokens corresponding to the specified reference identifier. /// - ValueTask FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken); + ValueTask FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken); /// /// Retrieves the list of tokens corresponding to the specified subject. @@ -139,7 +138,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the tokens. /// The that can be used to abort the operation. /// The tokens corresponding to the specified subject. - IAsyncEnumerable FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); + IAsyncEnumerable FindBySubjectAsync(string subject, CancellationToken cancellationToken); /// /// Retrieves the optional application identifier associated with a token. @@ -150,7 +149,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the application identifier associated with the token. /// - ValueTask GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetApplicationIdAsync(TToken token, CancellationToken cancellationToken); /// /// Executes the specified query and returns the first element. @@ -165,8 +164,8 @@ namespace OpenIddict.Abstractions /// whose result returns the first element returned when executing the query. /// ValueTask GetAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Retrieves the optional authorization identifier associated with a token. @@ -177,7 +176,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the authorization identifier associated with the token. /// - ValueTask GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the creation date associated with a token. @@ -188,7 +187,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the creation date associated with the specified token. /// - ValueTask GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetCreationDateAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the expiration date associated with a token. @@ -199,7 +198,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the expiration date associated with the specified token. /// - ValueTask GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetExpirationDateAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the unique identifier associated with a token. @@ -210,7 +209,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the token. /// - ValueTask GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetIdAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the payload associated with a token. @@ -221,7 +220,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the payload associated with the specified token. /// - ValueTask GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetPayloadAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the additional properties associated with a token. @@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns all the additional properties associated with the token. /// - ValueTask> GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask> GetPropertiesAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the reference identifier associated with a token. @@ -245,7 +244,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the reference identifier associated with the specified token. /// - ValueTask GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetReferenceIdAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the status associated with a token. @@ -256,7 +255,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the status associated with the specified token. /// - ValueTask GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetStatusAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the subject associated with a token. @@ -267,7 +266,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the subject associated with the specified token. /// - ValueTask GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetSubjectAsync(TToken token, CancellationToken cancellationToken); /// /// Retrieves the token type associated with a token. @@ -278,7 +277,7 @@ namespace OpenIddict.Abstractions /// A that can be used to monitor the asynchronous operation, /// whose result returns the token type associated with the specified token. /// - ValueTask GetTypeAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask GetTypeAsync(TToken token, CancellationToken cancellationToken); /// /// Instantiates a new token. @@ -297,7 +296,7 @@ namespace OpenIddict.Abstractions /// The number of results to skip. /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. - IAsyncEnumerable ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); + IAsyncEnumerable ListAsync(int? count, int? offset, CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. @@ -309,8 +308,8 @@ namespace OpenIddict.Abstractions /// The that can be used to abort the operation. /// All the elements returned when executing the specified query. IAsyncEnumerable ListAsync( - [NotNull] Func, TState, IQueryable> query, - [CanBeNull] TState state, CancellationToken cancellationToken); + Func, TState, IQueryable> query, + TState state, CancellationToken cancellationToken); /// /// Removes the tokens that are marked as expired or invalid. @@ -326,7 +325,7 @@ namespace OpenIddict.Abstractions /// The unique identifier associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetApplicationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); + ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken); /// /// Sets the authorization identifier associated with a token. @@ -335,7 +334,7 @@ namespace OpenIddict.Abstractions /// The unique identifier associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetAuthorizationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); + ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken); /// /// Sets the creation date associated with a token. @@ -344,7 +343,7 @@ namespace OpenIddict.Abstractions /// The creation date. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetCreationDateAsync([NotNull] TToken token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken); + ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken); /// /// Sets the expiration date associated with a token. @@ -353,7 +352,7 @@ namespace OpenIddict.Abstractions /// The expiration date. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetExpirationDateAsync([NotNull] TToken token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken); + ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken); /// /// Sets the payload associated with a token. @@ -362,7 +361,7 @@ namespace OpenIddict.Abstractions /// The payload associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPayloadAsync([NotNull] TToken token, [CanBeNull] string payload, CancellationToken cancellationToken); + ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken); /// /// Sets the additional properties associated with a token. @@ -371,8 +370,8 @@ namespace OpenIddict.Abstractions /// The additional properties associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetPropertiesAsync([NotNull] TToken token, - [CanBeNull] ImmutableDictionary properties, CancellationToken cancellationToken); + ValueTask SetPropertiesAsync(TToken token, + ImmutableDictionary properties, CancellationToken cancellationToken); /// /// Sets the reference identifier associated with a token. @@ -383,7 +382,7 @@ namespace OpenIddict.Abstractions /// The reference identifier associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetReferenceIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); + ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken); /// /// Sets the status associated with a token. @@ -392,7 +391,7 @@ namespace OpenIddict.Abstractions /// The status associated with the authorization. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetStatusAsync([NotNull] TToken token, [CanBeNull] string status, CancellationToken cancellationToken); + ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken); /// /// Sets the subject associated with a token. @@ -401,7 +400,7 @@ namespace OpenIddict.Abstractions /// The subject associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetSubjectAsync([NotNull] TToken token, [CanBeNull] string subject, CancellationToken cancellationToken); + ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken); /// /// Sets the token type associated with a token. @@ -410,7 +409,7 @@ namespace OpenIddict.Abstractions /// The token type associated with the token. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask SetTypeAsync([NotNull] TToken token, [CanBeNull] string type, CancellationToken cancellationToken); + ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken); /// /// Updates an existing token. @@ -418,6 +417,6 @@ namespace OpenIddict.Abstractions /// The token to update. /// The that can be used to abort the operation. /// A that can be used to monitor the asynchronous operation. - ValueTask UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken); + ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs index 0a747e22..4ed60560 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs @@ -304,7 +304,7 @@ namespace OpenIddict.Validation key.X5t = (string) keys[index][JsonWebKeyParameterNames.X5t]; key.X5tS256 = (string) keys[index][JsonWebKeyParameterNames.X5tS256]; - if (keys[index].TryGetParameter(JsonWebKeyParameterNames.X5c, out var chain)) + if (keys[index].TryGetNamedParameter(JsonWebKeyParameterNames.X5c, out var chain)) { foreach (var certificate in chain.GetNamedParameters()) { diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs index 931eee0a..2cea4bb6 100644 --- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs +++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs @@ -351,7 +351,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives } [Fact] - public void GetParameter_ReturnsNullForOutOfRangeArrayIndex() + public void GetUnnamedParameter_ReturnsNullForOutOfRangeArrayIndex() { // Arrange var parameter = new OpenIddictParameter(new[] @@ -689,40 +689,169 @@ namespace OpenIddict.Abstractions.Tests.Primitives [Theory] [InlineData(null)] [InlineData("")] - public void TryGetParameter_ThrowsAnExceptionForNullOrEmptyName(string name) + public void TryGetNamedParameter_ThrowsAnExceptionForNullOrEmptyName(string name) { // Arrange var parameter = new OpenIddictParameter(); // Act - var exception = Assert.Throws(() => parameter.TryGetParameter(name, out var value)); + var exception = Assert.Throws(() => parameter.TryGetNamedParameter(name, out _)); // Assert Assert.Equal("name", exception.ParamName); - Assert.StartsWith(SR.GetResourceString(SR.ID1189), exception.Message); + Assert.StartsWith(SR.GetResourceString(SR.ID1191), exception.Message); + } + + [Fact] + public void TryGetNamedParameter_ReturnsFalseForPrimitiveValues() + { + // Arrange + var parameter = new OpenIddictParameter(42); + + // Act and assert + Assert.False(parameter.TryGetNamedParameter("parameter", out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetNamedParameter_ReturnsFalseForArrays() + { + // Arrange + var parameter = new OpenIddictParameter(new[] + { + "Fabrikam", + "Contoso" + }); + + // Act and assert + Assert.False(parameter.TryGetNamedParameter("Fabrikam", out var value)); + Assert.Equal(default, value); } [Fact] - public void TryGetParameter_ReturnsTrueAndExpectedParameter() + public void TryGetNamedParameter_ReturnsFalseForNonexistentItem() + { + // Arrange + var parameter = new OpenIddictParameter(new JsonElement()); + + // Act and assert + Assert.False(parameter.TryGetNamedParameter("parameter", out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetNamedParameter_ReturnsFalseForJsonArrays() + { + // Arrange + var parameter = new OpenIddictParameter( + JsonSerializer.Deserialize(@"[""Fabrikam"",""Contoso""]")); + + // Act and assert + Assert.False(parameter.TryGetNamedParameter("Fabrikam", out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetNamedParameter_ReturnsExpectedParameterForJsonObject() { // Arrange var parameter = new OpenIddictParameter( JsonSerializer.Deserialize(@"{""parameter"":""value""}")); // Act and assert - Assert.True(parameter.TryGetParameter("parameter", out var value)); + Assert.True(parameter.TryGetNamedParameter("parameter", out var value)); Assert.Equal("value", (string) value); } [Fact] - public void TryGetParameter_ReturnsFalse() + public void TryGetUnnamedParameter_ThrowsAnExceptionForNegativeIndex() { // Arrange var parameter = new OpenIddictParameter(); + // Act + var exception = Assert.Throws(() => parameter.TryGetUnnamedParameter(-1, out _)); + + // Assert + Assert.Equal("index", exception.ParamName); + Assert.StartsWith(SR.GetResourceString(SR.ID1192), exception.Message); + } + + [Fact] + public void TryGetUnnamedParameter_ReturnsFalseForPrimitiveValues() + { + // Arrange + var parameter = new OpenIddictParameter(42); + + // Act and assert + Assert.False(parameter.TryGetUnnamedParameter(0, out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void GetParameter_ReturnsFalseForOutOfRangeArrayIndex() + { + // Arrange + var parameter = new OpenIddictParameter(new[] + { + "Fabrikam", + "Contoso" + }); + + // Act and assert + Assert.False(parameter.TryGetUnnamedParameter(2, out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetUnnamedParameter_ReturnsExpectedNodeForArray() + { + // Arrange + var parameter = new OpenIddictParameter(new[] + { + "Fabrikam", + "Contoso" + }); + + // Act and assert + Assert.True(parameter.TryGetUnnamedParameter(0, out var value)); + Assert.Equal("Fabrikam", (string) value); + } + + [Fact] + public void TryGetUnnamedParameter_ReturnsFalseForOutOfRangeJsonArrayIndex() + { + // Arrange + var parameter = new OpenIddictParameter( + JsonSerializer.Deserialize(@"[""Fabrikam"",""Contoso""]")); + + // Act and assert + Assert.False(parameter.TryGetUnnamedParameter(2, out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetUnnamedParameter_ReturnsFalseForJsonObjects() + { + // Arrange + var parameter = new OpenIddictParameter( + JsonSerializer.Deserialize(@"{""parameter"":""value""}")); + + // Act and assert + Assert.False(parameter.TryGetUnnamedParameter(0, out var value)); + Assert.Equal(default, value); + } + + [Fact] + public void TryGetUnnamedParameter_ReturnsExpectedNodeForJsonArray() + { + // Arrange + var parameter = new OpenIddictParameter( + JsonSerializer.Deserialize(@"[""Fabrikam"",""Contoso""]")); + // Act and assert - Assert.False(parameter.TryGetParameter("parameter", out var value)); - Assert.Null(value.Value); + Assert.True(parameter.TryGetUnnamedParameter(0, out var value)); + Assert.Equal("Fabrikam", (string) value); } [Fact]