Skip to content

Commit b6102f0

Browse files
authored
[Models] Enable nullable (2 of 2) (#585)
1 parent b7f1735 commit b6102f0

30 files changed

+78
-54
lines changed

Src/Fido2.Models/AssertionOptions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Fido2NetLib;
1111
/// </summary>
1212
public class AssertionOptions
1313
{
14+
#nullable disable
15+
1416
/// <summary>
1517
/// This member represents a challenge that the selected authenticator signs, along with other data, when producing an authentication assertion.
1618
/// See the §13.1 Cryptographic Challenges security consideration.

Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public AuthenticationExtensionsClientOutputs Extensions
3838
[JsonPropertyName("clientExtensionResults"), Required]
3939
public AuthenticationExtensionsClientOutputs ClientExtensionResults { get; set; }
4040

41+
#nullable enable
42+
4143
public sealed class AssertionResponse
4244
{
4345
[JsonConverter(typeof(Base64UrlConverter))]
@@ -52,8 +54,6 @@ public sealed class AssertionResponse
5254
[JsonPropertyName("clientDataJSON")]
5355
public required byte[] ClientDataJson { get; init; }
5456

55-
#nullable enable
56-
5757
[JsonPropertyName("userHandle")]
5858
[JsonConverter(typeof(Base64UrlConverter))]
5959
public byte[]? UserHandle { get; init; }

Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
#nullable disable
2+
3+
using System.ComponentModel.DataAnnotations;
24
using System.Text.Json.Serialization;
35

46
using Fido2NetLib.Objects;

Src/Fido2.Models/Converters/Base64UrlConverter.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#nullable enable
2-
3-
using System.Buffers;
1+
using System.Buffers;
42
using System.Buffers.Text;
53
using System.Text.Json;
64
using System.Text.Json.Serialization;

Src/Fido2.Models/Converters/EnumNameMapper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ private static FrozenDictionary<TEnum, string> GetIdToNameMap()
4747
{
4848
var description = field.GetCustomAttribute<EnumMemberAttribute>(false);
4949

50-
var value = (TEnum)field.GetValue(null);
50+
var value = (TEnum)field.GetValue(null)!;
5151

52-
items.Add(new(value, description is not null ? description.Value : value.ToString()));
52+
items.Add(new(value, description is not null ? description.Value! : value.ToString()));
5353
}
5454

5555
return items.ToFrozenDictionary();

Src/Fido2.Models/Converters/FidoEnumConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial
1212
switch (reader.TokenType)
1313
{
1414
case JsonTokenType.String:
15-
string text = reader.GetString();
15+
string text = reader.GetString()!;
1616
if (EnumNameMapper<T>.TryGetValue(text, out T value))
1717
return value;
1818
else

Src/Fido2.Models/CredentialCreateOptions.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Fido2NetLib;
99
public sealed class CredentialCreateOptions
1010
{
1111
/// <summary>
12-
///
1312
/// This member contains data about the Relying Party responsible for the request.
1413
/// Its value’s name member is required.
1514
/// Its value’s id member specifies the relying party identifier with which the credential should be associated.If omitted, its value will be the CredentialsContainer object’s relevant settings object's origin's effective domain.
@@ -58,12 +57,16 @@ public sealed class CredentialCreateOptions
5857
[JsonPropertyName("attestationFormats")]
5958
public IReadOnlyList<AttestationStatementFormatIdentifier> AttestationFormats { get; set; } = [];
6059

60+
#nullable disable
61+
6162
/// <summary>
6263
/// This member is intended for use by Relying Parties that wish to select the appropriate authenticators to participate in the create() operation.
6364
/// </summary>
6465
[JsonPropertyName("authenticatorSelection")]
6566
public AuthenticatorSelection AuthenticatorSelection { get; set; }
6667

68+
#nullable enable
69+
6770
private IReadOnlyList<PublicKeyCredentialHint> _hints = Array.Empty<PublicKeyCredentialHint>();
6871

6972
/// <summary>
@@ -113,7 +116,7 @@ public IReadOnlyList<PublicKeyCredentialHint> Hints
113116
/// </summary>
114117
[JsonPropertyName("extensions")]
115118
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
116-
public AuthenticationExtensionsClientInputs Extensions { get; set; }
119+
public AuthenticationExtensionsClientInputs? Extensions { get; set; }
117120

118121
public static CredentialCreateOptions Create(
119122
Fido2Configuration config,
@@ -122,7 +125,7 @@ public static CredentialCreateOptions Create(
122125
AuthenticatorSelection authenticatorSelection,
123126
AttestationConveyancePreference attestationConveyancePreference,
124127
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
125-
AuthenticationExtensionsClientInputs extensions,
128+
AuthenticationExtensionsClientInputs? extensions,
126129
IReadOnlyList<PubKeyCredParam> pubKeyCredParams)
127130

128131
{
@@ -147,12 +150,10 @@ public string ToJson()
147150

148151
public static CredentialCreateOptions FromJson(string json)
149152
{
150-
return JsonSerializer.Deserialize(json, FidoModelSerializerContext.Default.CredentialCreateOptions);
153+
return JsonSerializer.Deserialize(json, FidoModelSerializerContext.Default.CredentialCreateOptions)!;
151154
}
152155
}
153156

154-
#nullable enable
155-
156157
/// <summary>
157158
/// Constructs a PubKeyCredParam instance
158159
/// </summary>

Src/Fido2.Models/Fido2.Models.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<RootNamespace>Fido2NetLib</RootNamespace>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<IsTrimmable>true</IsTrimmable>
8+
<Nullable>enable</Nullable>
89
<NoWarn>$(NoWarn);CS1591</NoWarn>
910
<IsPackable>true</IsPackable>
1011
</PropertyGroup>

Src/Fido2.Models/Fido2Configuration.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Runtime.Serialization;
1+
#nullable disable
2+
3+
using System.Runtime.Serialization;
24

35
namespace Fido2NetLib;
46

Src/Fido2.Models/Metadata/BiometricStatusReport.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ public class BiometricStatusReport
3131
/// <para>If no date is given, the status is assumed to be effective while present.</para>
3232
/// </summary>
3333
[JsonPropertyName("effectiveDate")]
34-
public string EffectiveDate { get; set; }
34+
public string? EffectiveDate { get; set; }
3535

3636
/// <summary>
3737
/// Gets or sets the externally visible aspects of the Biometric Certification evaluation.
3838
/// </summary>
3939
[JsonPropertyName("certificationDescriptor")]
40-
public string CertificationDescriptor { get; set; }
40+
public string? CertificationDescriptor { get; set; }
4141

4242
/// <summary>
4343
/// Gets or sets the unique identifier for the issued Biometric Certification.
4444
/// </summary>
4545
[JsonPropertyName("certificateNumber")]
46-
public string CertificateNumber { get; set; }
46+
public string? CertificateNumber { get; set; }
4747

4848
/// <summary>
4949
/// Gets or sets the version of the Biometric Certification Policy the implementation is Certified to.
@@ -52,7 +52,7 @@ public class BiometricStatusReport
5252
/// For example: "1.0.0".
5353
/// </remarks>
5454
[JsonPropertyName("certificationPolicyVersion")]
55-
public string CertificationPolicyVersion { get; set; }
55+
public string? CertificationPolicyVersion { get; set; }
5656

5757
/// <summary>
5858
/// Gets or sets the version of the Biometric Requirements the implementation is certified to.
@@ -61,5 +61,5 @@ public class BiometricStatusReport
6161
/// For example: "1.0.0".
6262
/// </remarks>
6363
[JsonPropertyName("certificationRequirementsVersion")]
64-
public string CertificationRequirementsVersion { get; set; }
64+
public string? CertificationRequirementsVersion { get; set; }
6565
}

Src/Fido2.Models/Metadata/DisplayPNGCharacteristicsDescriptor.cs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public sealed class DisplayPNGCharacteristicsDescriptor
5252
[JsonPropertyName("interlace")]
5353
public required byte Interlace { get; set; }
5454

55+
#nullable disable
56+
5557
/// <summary>
5658
/// Gets or sets the palette (1 to 256 palette entries).
5759
/// </summary>

Src/Fido2.Models/Metadata/MetadataBLOBPayload.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib;
54

@@ -18,28 +17,30 @@ public sealed class MetadataBLOBPayload
1817
/// This value MAY contain URL(s) pointing to further information, such as a full Terms and Conditions statement.
1918
/// </remarks>
2019
[JsonPropertyName("legalHeader")]
21-
public string LegalHeader { get; set; }
20+
public string? LegalHeader { get; set; }
2221

2322
/// <summary>
2423
/// Gets or sets the serial number of this UAF Metadata BLOB Payload.
2524
/// </summary>
2625
/// <remarks>
2726
/// Serial numbers MUST be consecutive and strictly monotonic, i.e. the successor BLOB will have a no value exactly incremented by one.
2827
/// </remarks>
29-
[JsonPropertyName("no"), Required]
30-
public int Number { get; set; }
28+
[JsonPropertyName("no")]
29+
public required int Number { get; set; }
3130

3231
/// <summary>
3332
/// Gets or sets a formatted date (ISO-8601) when the next update will be provided at latest.
3433
/// </summary>
35-
[JsonPropertyName("nextUpdate"), Required]
36-
public string NextUpdate { get; set; }
34+
[JsonPropertyName("nextUpdate")]
35+
public required string NextUpdate { get; set; }
3736

3837
/// <summary>
3938
/// Gets or sets a list of zero or more entries of <see cref="MetadataBLOBPayloadEntry"/>.
4039
/// </summary>
41-
[JsonPropertyName("entries"), Required]
42-
public MetadataBLOBPayloadEntry[] Entries { get; set; }
40+
[JsonPropertyName("entries")]
41+
public required MetadataBLOBPayloadEntry[] Entries { get; set; }
42+
43+
#nullable disable
4344

4445
/// <summary>
4546
/// The "alg" property from the original JWT header. Used to validate MetadataStatements.

Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
#nullable disable
2+
3+
using System.ComponentModel.DataAnnotations;
24
using System.Text.Json.Serialization;
35

46
namespace Fido2NetLib;

Src/Fido2.Models/Metadata/MetadataStatement.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
#nullable disable
2+
3+
using System.ComponentModel.DataAnnotations;
24
using System.Text.Json.Serialization;
35

46
namespace Fido2NetLib;

Src/Fido2.Models/Metadata/RgbPaletteEntry.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public bool Equals(RgbPaletteEntry other)
4343
&& B == other.B;
4444
}
4545

46-
public override bool Equals(object obj)
46+
public override bool Equals(object? obj)
4747
{
4848
return obj is RgbPaletteEntry other && Equals(other);
4949
}

Src/Fido2.Models/Metadata/StatusReport.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
#nullable disable
2+
3+
using System.ComponentModel.DataAnnotations;
24
using System.Text.Json.Serialization;
35

46
namespace Fido2NetLib;

Src/Fido2.Models/Metadata/UafVersion.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public bool Equals(UafVersion other)
3535
&& Minor == other.Minor;
3636
}
3737

38-
public override bool Equals(object obj)
38+
public override bool Equals(object? obj)
3939
{
4040
return obj is UafVersion other && Equals(other);
4141
}

Src/Fido2.Models/Metadata/VerificationMethodDescriptor.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
#nullable disable
2+
3+
using System.Text.Json.Serialization;
24

35
namespace Fido2NetLib;
46

Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
#nullable disable
2+
3+
using System.Text.Json.Serialization;
24

35
namespace Fido2NetLib.Objects;
46

@@ -40,6 +42,7 @@ public sealed class AuthenticationExtensionsClientInputs
4042
public bool? UserVerificationMethod { private get; set; }
4143

4244
#nullable enable
45+
4346
/// <summary>
4447
/// This client registration extension facilitates reporting certain credential properties known by the client to the requesting WebAuthn Relying Party upon creation of a public key credential source as a result of a registration ceremony.
4548
/// </summary>

Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ public class AuthenticationExtensionsClientOutputs
1111
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1212
public bool? Example { get; set; }
1313

14-
#nullable enable
15-
1614
/// <summary>
1715
/// This extension allows WebAuthn Relying Parties that have previously registered a credential using the legacy FIDO JavaScript APIs to request an assertion.
1816
/// https://www.w3.org/TR/webauthn/#sctn-appid-extension

Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobInputs.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#nullable enable
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib.Objects;
54

Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobOutputs.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#nullable enable
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib.Objects;
54

Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
#nullable disable
2+
3+
using System.Text.Json.Serialization;
24

35
namespace Fido2NetLib.Objects;
46

Src/Fido2.Models/Objects/AuthenticationExtensionsPRFOutputs.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
#nullable disable
2+
3+
using System.Text.Json.Serialization;
24

35
namespace Fido2NetLib.Objects;
46

Src/Fido2.Models/Objects/AuthenticationExtensionsPRFValues.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#nullable enable
2-
3-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
42

53
namespace Fido2NetLib.Objects;
64

Src/Fido2.Models/Objects/CredentialPropertiesOutput.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#nullable enable
2-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Fido2NetLib.Objects;
54

Src/Fido2.Models/Objects/PublicKeyCredentialUserEntity.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
#nullable disable
2+
3+
using System.ComponentModel.DataAnnotations;
24

35
namespace Fido2NetLib.Objects;
46

Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
#nullable disable
2+
3+
using System.Text.Json.Serialization;
24

35
namespace Fido2NetLib.Objects;
46

Src/Fido2.Models/Objects/VerifyAssertionResult.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Fido2NetLib.Objects;
1+
#nullable disable
2+
3+
namespace Fido2NetLib.Objects;
24

35
/// <summary>
46
/// Result of the MakeAssertion verification

Src/Fido2/Metadata/ConformanceMetadataRepository.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public async Task<MetadataBLOBPayload> GetBLOBAsync(CancellationToken cancellati
7878
var combinedBlob = new MetadataBLOBPayload
7979
{
8080
Number = -1,
81-
NextUpdate = "2099-08-07"
81+
NextUpdate = "2099-08-07",
82+
Entries = []
8283
};
8384

8485
var entries = new List<MetadataBLOBPayloadEntry>();

0 commit comments

Comments
 (0)