diff --git a/Src/Fido2.Development/DevelopmentInMemoryStore.cs b/Src/Fido2.Development/DevelopmentInMemoryStore.cs index a8e7aec0..3d910520 100644 --- a/Src/Fido2.Development/DevelopmentInMemoryStore.cs +++ b/Src/Fido2.Development/DevelopmentInMemoryStore.cs @@ -51,7 +51,7 @@ public Task> GetUsersByCredentialIdAsync(byte[] credentialId, Ca var cred = _storedCredentials.FirstOrDefault(c => c.Descriptor.Id.AsSpan().SequenceEqual(credentialId)); if (cred is null) - return Task.FromResult(new List()); + return Task.FromResult>([]); return Task.FromResult(_storedUsers.Where(u => u.Value.Id.SequenceEqual(cred.UserId)).Select(u => u.Value).ToList()); } diff --git a/Src/Fido2.Models/AssertionOptions.cs b/Src/Fido2.Models/AssertionOptions.cs index 95c50be8..1160357f 100644 --- a/Src/Fido2.Models/AssertionOptions.cs +++ b/Src/Fido2.Models/AssertionOptions.cs @@ -41,7 +41,7 @@ public class AssertionOptions /// This OPTIONAL member contains a list of PublicKeyCredentialDescriptor objects representing public key credentials acceptable to the caller, in descending order of the caller’s preference(the first item in the list is the most preferred credential, and so on down the list) /// [JsonPropertyName("allowCredentials")] - public IReadOnlyList AllowCredentials { get; set; } = Array.Empty(); + public IReadOnlyList AllowCredentials { get; set; } = []; /// /// This member describes the Relying Party's requirements regarding user verification for the get() operation. @@ -54,7 +54,7 @@ public class AssertionOptions /// This OPTIONAL member contains zero or more elements from to guide the user agent in interacting with the user. Note that the elements have type DOMString despite being taken from that enumeration. /// [JsonPropertyName("hints")] - public IReadOnlyList Hints { get; set; } = Array.Empty(); + public IReadOnlyList Hints { get; set; } = []; /// /// This OPTIONAL member contains additional parameters requesting additional processing by the client and authenticator. diff --git a/Src/Fido2.Models/Converters/EnumNameMapper.cs b/Src/Fido2.Models/Converters/EnumNameMapper.cs index b04c3d1a..8bd0f56d 100644 --- a/Src/Fido2.Models/Converters/EnumNameMapper.cs +++ b/Src/Fido2.Models/Converters/EnumNameMapper.cs @@ -41,7 +41,7 @@ public static IEnumerable GetNames() private static FrozenDictionary GetIdToNameMap() { - var items = new List>(); + List> items = []; foreach (var field in typeof(TEnum).GetFields(BindingFlags.Public | BindingFlags.Static)) { diff --git a/Src/Fido2.Models/CredentialCreateOptions.cs b/Src/Fido2.Models/CredentialCreateOptions.cs index c076c453..94e41c54 100644 --- a/Src/Fido2.Models/CredentialCreateOptions.cs +++ b/Src/Fido2.Models/CredentialCreateOptions.cs @@ -67,7 +67,7 @@ public sealed class CredentialCreateOptions #nullable enable - private IReadOnlyList _hints = Array.Empty(); + private IReadOnlyList _hints = []; /// /// Guides the user agent in interacting with the user. This OPTIONAL member contains zero or more elements from . @@ -126,8 +126,8 @@ public static CredentialCreateOptions Create( AttestationConveyancePreference attestationConveyancePreference, IReadOnlyList excludeCredentials, AuthenticationExtensionsClientInputs? extensions, - IReadOnlyList pubKeyCredParams) - + IReadOnlyList pubKeyCredParams) + { return new CredentialCreateOptions { @@ -184,8 +184,8 @@ public sealed class PubKeyCredParam( public static readonly PubKeyCredParam PS384 = new(COSE.Algorithm.PS384); public static readonly PubKeyCredParam PS512 = new(COSE.Algorithm.PS512); public static readonly PubKeyCredParam Ed25519 = new(COSE.Algorithm.EdDSA); - public static readonly PubKeyCredParam RS1 = new(COSE.Algorithm.RS1); - + public static readonly PubKeyCredParam RS1 = new(COSE.Algorithm.RS1); + /// /// The default algorithms supported by the library /// diff --git a/Src/Fido2/Asn1Element.cs b/Src/Fido2/Asn1Element.cs index f0433d82..bca78906 100644 --- a/Src/Fido2/Asn1Element.cs +++ b/Src/Fido2/Asn1Element.cs @@ -162,7 +162,7 @@ public static Asn1Element Decode(ReadOnlyMemory data) private static List ReadElements(AsnReader reader) { - var elements = new List(); + List elements = []; while (reader.HasData) { diff --git a/Src/Fido2/AttestationFormat/FidoU2f.cs b/Src/Fido2/AttestationFormat/FidoU2f.cs index 4d33b429..cb2f7540 100644 --- a/Src/Fido2/AttestationFormat/FidoU2f.cs +++ b/Src/Fido2/AttestationFormat/FidoU2f.cs @@ -85,7 +85,7 @@ .. publicKeyU2F // 7. Optionally, inspect x5c and consult externally provided knowledge to determine whether attStmt conveys a Basic or AttCA attestation - var trustPath = new X509Certificate2[1] { attCert }; + X509Certificate2[] trustPath = [attCert]; return new(new VerifyAttestationResult(AttestationType.AttCa, trustPath)); } diff --git a/Src/Fido2/Cbor/CborArray.cs b/Src/Fido2/Cbor/CborArray.cs index c646b649..57cb1b19 100644 --- a/Src/Fido2/Cbor/CborArray.cs +++ b/Src/Fido2/Cbor/CborArray.cs @@ -7,7 +7,7 @@ public sealed class CborArray : CborObject, IEnumerable { public CborArray() { - Values = new List(); + Values = []; } public CborArray(List values) diff --git a/Src/Fido2/Cbor/CborObject.cs b/Src/Fido2/Cbor/CborObject.cs index 6309a173..ebdffd36 100644 --- a/Src/Fido2/Cbor/CborObject.cs +++ b/Src/Fido2/Cbor/CborObject.cs @@ -86,7 +86,7 @@ private static CborArray ReadArray(CborReader reader) var items = count != null ? new List(count.Value) - : new List(); + : []; while (!(reader.PeekState() is CborReaderState.EndArray or CborReaderState.Finished)) { diff --git a/Src/Fido2/GetAssertionOptionsParams.cs b/Src/Fido2/GetAssertionOptionsParams.cs index 563b3fbf..63bdc614 100644 --- a/Src/Fido2/GetAssertionOptionsParams.cs +++ b/Src/Fido2/GetAssertionOptionsParams.cs @@ -22,7 +22,7 @@ public sealed class GetAssertionOptionsParams /// /// The list is ordered in descending order of preference: the first item in the list is the most preferred credential, and the last is the least preferred. /// - public IReadOnlyList AllowedCredentials { get; init; } = Array.Empty(); + public IReadOnlyList AllowedCredentials { get; init; } = []; /// /// This OPTIONAL member specifies the Relying Party's requirements regarding user verification for the get() operation. The value SHOULD be a member of UserVerificationRequirement but client platforms MUST ignore unknown values, treating an unknown value as if the member does not exist. Eligible authenticators are filtered to only those capable of satisfying this requirement. diff --git a/Src/Fido2/Metadata/ConformanceMetadataRepository.cs b/Src/Fido2/Metadata/ConformanceMetadataRepository.cs index 82ad224b..3995e062 100644 --- a/Src/Fido2/Metadata/ConformanceMetadataRepository.cs +++ b/Src/Fido2/Metadata/ConformanceMetadataRepository.cs @@ -82,7 +82,7 @@ public async Task GetBLOBAsync(CancellationToken cancellati Entries = [] }; - var entries = new List(); + List entries = []; foreach (var blobUrl in conformanceEndpoints) { diff --git a/Src/Fido2/RequestNewCredentialParams.cs b/Src/Fido2/RequestNewCredentialParams.cs index 354c903d..97193930 100644 --- a/Src/Fido2/RequestNewCredentialParams.cs +++ b/Src/Fido2/RequestNewCredentialParams.cs @@ -18,8 +18,7 @@ public sealed class RequestNewCredentialParams /// /// The Relying Party SHOULD use this OPTIONAL member to list any existing credentials mapped to this user account (as identified by user.id). This ensures that the new credential is not created on an authenticator that already contains a credential mapped to this user account. If it would be, the client is requested to instead guide the user to use a different authenticator, or return an error if that fails. /// - public IReadOnlyList ExcludeCredentials { get; init; } = - Array.Empty(); + public IReadOnlyList ExcludeCredentials { get; init; } = []; /// /// The Relying Party MAY use this OPTIONAL member to specify capabilities and settings that the authenticator MUST or SHOULD satisfy to participate in the create() operation. See § 5.4.4 Authenticator Selection Criteria (dictionary AuthenticatorSelectionCriteria).