Skip to content

Commit 783d845

Browse files
Partial nullable support
1 parent 46f9a4a commit 783d845

File tree

52 files changed

+234
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+234
-206
lines changed

Src/DSInternals.ADSI/packages.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
},
1515
"Polyfill": {
1616
"type": "Direct",
17-
"requested": "[9.5.0, )",
18-
"resolved": "9.5.0",
19-
"contentHash": "T3E8+K+W0u78495PwSSJOzT6QUbnZSdkDK4B3nfvxUo9nctDr6ChSDLV4l/RD2ZmA5oHM2YbLvyp+a2uE0ftOQ=="
17+
"requested": "[9.7.7, )",
18+
"resolved": "9.7.7",
19+
"contentHash": "L4iI95ONeG95Wc5ViCGL5Z47yA53NCX1tP5W6ddlaF9h/C/tYR6i56GZkH/33d2H9+jwhF22nL4olnO5efmoFw=="
2020
},
2121
"Microsoft.Bcl.AsyncInterfaces": {
2222
"type": "Transitive",

Src/DSInternals.Common.Test/packages.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
},
6666
"Polyfill": {
6767
"type": "Direct",
68-
"requested": "[9.5.0, )",
69-
"resolved": "9.5.0",
70-
"contentHash": "T3E8+K+W0u78495PwSSJOzT6QUbnZSdkDK4B3nfvxUo9nctDr6ChSDLV4l/RD2ZmA5oHM2YbLvyp+a2uE0ftOQ=="
68+
"requested": "[9.7.7, )",
69+
"resolved": "9.7.7",
70+
"contentHash": "L4iI95ONeG95Wc5ViCGL5Z47yA53NCX1tP5W6ddlaF9h/C/tYR6i56GZkH/33d2H9+jwhF22nL4olnO5efmoFw=="
7171
},
7272
"Microsoft.ApplicationInsights": {
7373
"type": "Transitive",

Src/DSInternals.Common/Cryptography/Asn1/Pkcs1/DigestInfo.asn1.xml.generated.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ internal static DigestInfo Decode(ReadOnlyMemory<byte> encoded, AsnEncodingRules
1818
{
1919
return Decode(Asn1Tag.Sequence, encoded, ruleSet);
2020
}
21-
21+
2222
internal static DigestInfo Decode(Asn1Tag expectedTag, ReadOnlyMemory<byte> encoded, AsnEncodingRules ruleSet)
2323
{
2424
AsnReader reader = new AsnReader(encoded, ruleSet);
25-
2625
Decode(reader, expectedTag, out DigestInfo decoded);
2726
reader.ThrowIfNotEmpty();
2827
return decoded;
@@ -45,9 +44,8 @@ internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out DigestInf
4544
AsnReader sequenceReader = reader.ReadSequence(expectedTag);
4645

4746
DSInternals.Common.Cryptography.Asn1.X509.AlgorithmIdentifier.Decode(sequenceReader, out decoded.DigestAlgorithm);
48-
decoded.Digest = sequenceReader.ReadOctetString();
49-
50-
47+
decoded.Digest = sequenceReader.ReadOctetString();
48+
5149
sequenceReader.ThrowIfNotEmpty();
5250
}
5351
}

Src/DSInternals.Common/Cryptography/CngSoftwareProviderTransportBlob.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public class CngSoftwareProviderTransportBlob
1212
private const int BlobHeaderLength = (MasterKeyFileCount + 9) * sizeof(int);
1313
private const string Magic = "MIB1";
1414

15-
public string KeyContainerName
15+
public string? KeyContainerName
1616
{
1717
get;
1818
private set;
1919
}
2020

21-
public byte[] KeyData
21+
public byte[]? KeyData
2222
{
2323
get;
2424
private set;

Src/DSInternals.Common/Cryptography/HashEqualityComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class HashEqualityComparer : IEqualityComparer<byte[]>
44
{
55
// Singleton
6-
private static HashEqualityComparer instance;
6+
private static HashEqualityComparer? instance;
77

88
public static HashEqualityComparer GetInstance()
99
{
@@ -16,7 +16,7 @@ public static HashEqualityComparer GetInstance()
1616

1717
private HashEqualityComparer() { }
1818

19-
public bool Equals(byte[] x, byte[] y)
19+
public bool Equals(byte[]? x, byte[]? y)
2020
{
2121
if (x == null || y == null)
2222
{

Src/DSInternals.Common/Data/DirectoryObject.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public void ReadAttribute(string name, out bool value)
3030
public abstract void ReadAttribute(string name, out string value, bool unicode = true);
3131
public abstract void ReadAttribute(string name, out string[] values, bool unicode = true);
3232

33-
public virtual void ReadAttribute(string name, out RawSecurityDescriptor value)
33+
public virtual void ReadAttribute(string name, out RawSecurityDescriptor? value)
3434
{
35-
this.ReadAttribute(name, out byte[] binarySecurityDescriptor);
35+
this.ReadAttribute(name, out byte[]? binarySecurityDescriptor);
3636
value = (binarySecurityDescriptor != null) ? new RawSecurityDescriptor(binarySecurityDescriptor, 0) : null;
3737
}
3838

@@ -53,19 +53,19 @@ public abstract SecurityIdentifier Sid
5353
get;
5454
}
5555

56-
public void ReadAttribute(string name, out SecurityIdentifier value)
56+
public void ReadAttribute(string name, out SecurityIdentifier? value)
5757
{
58-
this.ReadAttribute(name, out byte[] binarySid);
59-
value = binarySid.ToSecurityIdentifier(this.HasBigEndianRid);
58+
this.ReadAttribute(name, out byte[]? binarySid);
59+
value = binarySid?.ToSecurityIdentifier(this.HasBigEndianRid);
6060
}
6161

6262
public abstract void ReadAttribute(string name, out DistinguishedName value);
6363

64-
public void ReadAttribute(string name, out SecurityIdentifier[] value)
64+
public void ReadAttribute(string name, out SecurityIdentifier[]? value)
6565
{
6666
value = null;
6767
// TODO: Always big endian?
68-
this.ReadAttribute(name, out byte[][] binarySids);
68+
this.ReadAttribute(name, out byte[][]? binarySids);
6969
if (binarySids != null)
7070
{
7171
value = binarySids.Select(binarySid => binarySid.ToSecurityIdentifier(this.HasBigEndianRid)).ToArray();

Src/DSInternals.Common/Data/DistinguishedName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public static DistinguishedName GetDNFromDNSName(string domainName)
264264
return dn;
265265
}
266266

267-
public override bool Equals(object obj)
267+
public override bool Equals(object? obj)
268268
{
269269
// Check for null values and compare run-time types.
270270
if (obj == null || GetType() != obj.GetType())

Src/DSInternals.Common/Data/LAPS/LapsClearTextPassword.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ namespace DSInternals.Common.Data;
1111
public class LapsClearTextPassword
1212
{
1313
[JsonPropertyName("n")]
14-
public string AccountName;
14+
public string? AccountName;
1515

1616
[JsonPropertyName("t")]
17-
public string UpdateTimestampString;
17+
public string? UpdateTimestampString;
1818

1919
[JsonPropertyName("p")]
20-
public string Password;
20+
public string? Password;
2121

2222
[JsonIgnore]
2323
public DateTime? UpdateTimestamp
@@ -47,11 +47,11 @@ public DateTime? UpdateTimestamp
4747
public static LapsClearTextPassword Parse(string json)
4848
{
4949
ArgumentNullException.ThrowIfNull(json);
50-
return LenientJsonSerializer.DeserializeLenient<LapsClearTextPassword>(json);
50+
return LenientJsonSerializer.DeserializeLenient<LapsClearTextPassword>(json)!;
5151
}
5252

5353
public static LapsClearTextPassword Parse(ReadOnlySpan<byte> binaryJson, bool utf16 = false)
5454
{
55-
return LenientJsonSerializer.DeserializeLenient<LapsClearTextPassword>(binaryJson, utf16);
55+
return LenientJsonSerializer.DeserializeLenient<LapsClearTextPassword>(binaryJson, utf16)!;
5656
}
5757
}

Src/DSInternals.Common/Data/LAPS/LapsEncryptedPassword.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public LapsEncryptedPassword(ReadOnlyMemory<byte> buffer)
5555
this.EncryptedBlob = CngProtectedDataBlob.Decode(encryptedPassword);
5656
}
5757

58-
public LapsClearTextPassword Decrypt()
58+
public LapsClearTextPassword? Decrypt()
5959
{
6060
var binaryLapsPassword = EncryptedBlob.Decrypt();
6161

@@ -68,7 +68,7 @@ public LapsClearTextPassword Decrypt()
6868
return LapsClearTextPassword.Parse(binaryLapsPassword, utf16: true);
6969
}
7070

71-
public bool TryDecrypt(out LapsClearTextPassword lapsPassword)
71+
public bool TryDecrypt(out LapsClearTextPassword? lapsPassword)
7272
{
7373
bool success = EncryptedBlob.TryDecrypt(out ReadOnlySpan<byte> binaryLapsPassword);
7474

Src/DSInternals.Common/Data/LAPS/LapsPasswordInformation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public LapsPasswordInformation(string computerName, LapsEncryptedPassword encryp
8282
}
8383

8484
// Decrypt the data using the native Win32 API, which uses the pre-cached group keys if available.
85-
bool isSuccess = encryptedPassword.TryDecrypt(out LapsClearTextPassword decryptedPassword);
85+
bool isSuccess = encryptedPassword.TryDecrypt(out LapsClearTextPassword? decryptedPassword);
8686

8787
if (isSuccess)
8888
{
@@ -105,12 +105,12 @@ public LapsPasswordInformation(string computerName, LapsEncryptedPassword encryp
105105
/// <summary>
106106
/// Gets the account name that the password applies to.
107107
/// </summary>
108-
public string Account { get; private set; }
108+
public string? Account { get; private set; }
109109

110110
/// <summary>
111111
/// Gets the cleartext password.
112112
/// </summary>
113-
public string Password { get; private set; }
113+
public string? Password { get; private set; }
114114

115115
/// <summary>
116116
/// Gets the date and time when the password was last updated.

0 commit comments

Comments
 (0)