Skip to content

Commit b3b8763

Browse files
FuPingFrancoFranco Fung
authored and
Brent Schmaltz
committed
Adding nullable into extensions dir (#2203)
Co-authored-by: Franco Fung <[email protected]>
1 parent 3b735d2 commit b3b8763

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

src/Microsoft.IdentityModel.KeyVaultExtensions/KeyVaultKeyWrapProvider.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public KeyVaultKeyWrapProvider(SecurityKey key, string algorithm)
3939
/// <param name="key">The <see cref="SecurityKey"/> that will be used for key wrap operations.</param>
4040
/// <param name="algorithm">The key wrap algorithm to apply.</param>
4141
/// <param name="client">A mock <see cref="IKeyVaultClient"/> used for testing purposes.</param>
42-
internal KeyVaultKeyWrapProvider(SecurityKey key, string algorithm, IKeyVaultClient client)
42+
internal KeyVaultKeyWrapProvider(SecurityKey key, string algorithm, IKeyVaultClient? client)
4343
{
4444
_algorithm = string.IsNullOrEmpty(algorithm) ? throw LogHelper.LogArgumentNullException(nameof(algorithm)) : algorithm;
4545
if (key == null)
4646
throw LogHelper.LogArgumentNullException(nameof(key));
4747

4848
_key = key as KeyVaultSecurityKey ?? throw LogHelper.LogExceptionMessage(new NotSupportedException(key.GetType().ToString()));
49-
_client = client ?? new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(_key.Callback));
49+
_client = client ?? new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(_key.Callback!));
5050
}
5151

5252
/// <summary>
@@ -58,7 +58,7 @@ internal KeyVaultKeyWrapProvider(SecurityKey key, string algorithm, IKeyVaultCli
5858
/// Gets or sets a user context for a <see cref="KeyWrapProvider"/>.
5959
/// </summary>
6060
/// <remarks>This is null by default. This can be used by runtimes or for extensibility scenarios.</remarks>
61-
public override string Context { get; set; }
61+
public override string? Context { get; set; }
6262

6363
/// <summary>
6464
/// Gets the <see cref="SecurityKey"/> that is being used.

src/Microsoft.IdentityModel.KeyVaultExtensions/KeyVaultSecurityKey.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.IdentityModel.KeyVaultExtensions
1717
public class KeyVaultSecurityKey : SecurityKey
1818
{
1919
private int? _keySize;
20-
private string _keyId;
20+
private string? _keyId;
2121

2222
/// <summary>
2323
/// The authentication callback delegate which is to be implemented by the client code.
@@ -58,14 +58,14 @@ internal KeyVaultSecurityKey(string keyIdentifier, int keySize)
5858
/// <summary>
5959
/// The authentication callback delegate that retrieves an access token for the KeyVault.
6060
/// </summary>
61-
public AuthenticationCallback Callback { get; protected set; }
61+
public AuthenticationCallback? Callback { get; protected set; }
6262

6363
/// <summary>
6464
/// The uniform resource identifier of the security key.
6565
/// </summary>
6666
public override string KeyId
6767
{
68-
get => _keyId;
68+
get => _keyId!;
6969
set
7070
{
7171
if (string.IsNullOrEmpty(value))
@@ -90,7 +90,7 @@ public override int KeySize
9090
if (!_keySize.HasValue)
9191
Initialize();
9292

93-
return _keySize.Value;
93+
return _keySize!.Value;
9494
}
9595
}
9696

@@ -99,7 +99,7 @@ public override int KeySize
9999
/// </summary>
100100
private void Initialize()
101101
{
102-
using (var client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(Callback)))
102+
using (var client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(Callback!)))
103103
{
104104
var bundle = client.GetKeyAsync(_keyId, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult();
105105
_keySize = new BitArray(bundle.Key.N).Length;

src/Microsoft.IdentityModel.KeyVaultExtensions/KeyVaultSignatureProvider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public KeyVaultSignatureProvider(SecurityKey key, string algorithm, bool willCre
4141
/// <param name="algorithm">The signature algorithm to apply.</param>
4242
/// <param name="willCreateSignatures">Whether this <see cref="KeyVaultSignatureProvider"/> is required to create signatures then set this to true.</param>
4343
/// <param name="client">A mock <see cref="IKeyVaultClient"/> used for testing purposes.</param>
44-
internal KeyVaultSignatureProvider(SecurityKey key, string algorithm, bool willCreateSignatures, IKeyVaultClient client)
44+
internal KeyVaultSignatureProvider(SecurityKey key, string algorithm, bool willCreateSignatures, IKeyVaultClient? client)
4545
: base(key, algorithm)
4646
{
4747
_key = key as KeyVaultSecurityKey ?? throw LogHelper.LogArgumentNullException(nameof(key));
48-
_client = client ?? new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(_key.Callback));
48+
_client = client ?? new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(_key.Callback!));
4949
WillCreateSignatures = willCreateSignatures;
5050

5151
switch (algorithm)

src/Microsoft.IdentityModel.KeyVaultExtensions/Microsoft.IdentityModel.KeyVaultExtensions.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<TargetFrameworks Condition="'$(TargetNet8)' == 'True'">netstandard2.0;net6.0;net8.0</TargetFrameworks>
1111
<TargetFrameworks Condition="'$(TargetNet8)' != 'True'">netstandard2.0;net6.0</TargetFrameworks>
1212
<PackageTags>.NET;Windows;Authentication;Identity;Azure;Key;Vault;Extensions</PackageTags>
13+
<Nullable>enable</Nullable>
1314
</PropertyGroup>
1415

1516
<PropertyGroup Condition="'$(Configuration)'=='Debug'">

src/Microsoft.IdentityModel.LoggingExtensions/Microsoft.IdentityModel.LoggingExtensions.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageId>Microsoft.IdentityModel.LoggingExtensions</PackageId>
1010
<PackageTags>.NET;Windows;Authentication;Identity;Extensions;Logging</PackageTags>
1111
<TargetFrameworks>netstandard2.0</TargetFrameworks>
12+
<Nullable>enable</Nullable>
1213
</PropertyGroup>
1314

1415
<PropertyGroup Condition="'$(Configuration)'=='Debug'">

src/Microsoft.IdentityModel.ManagedKeyVaultSecurityKey/Microsoft.IdentityModel.ManagedKeyVaultSecurityKey.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageId>Microsoft.IdentityModel.ManagedKeyVaultSecurityKey</PackageId>
1111
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1212
<PackageTags>.NET;Windows;Authentication;Identity;Azure;Key;Vault;Extensions</PackageTags>
13+
<Nullable>enable</Nullable>
1314
</PropertyGroup>
1415

1516
<PropertyGroup Condition="'$(Configuration)'=='Debug'">

src/Microsoft.IdentityModel.TestExtensions/Microsoft.IdentityModel.TestExtensions.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
1111
<PackageId>Microsoft.IdentityModel.TestExtensions</PackageId>
1212
<SignAssembly>true</SignAssembly>
13+
<Nullable>enable</Nullable>
1314
</PropertyGroup>
1415

1516
<ItemGroup>

src/Microsoft.IdentityModel.TestExtensions/TestTokenCreator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public class TestTokenCreator
136136
/// <summary>
137137
/// Gets or sets the SigningCredentials used to sign the tokens created.
138138
/// </summary>
139-
public SigningCredentials SigningCredentials { get; set; }
139+
public SigningCredentials? SigningCredentials { get; set; }
140140

141141
#region Create Test Token Methods
142142
/// <summary>

0 commit comments

Comments
 (0)