Skip to content

Commit 64d4695

Browse files
fix: use null instead of ` for default string` args
1 parent 0ceaa1e commit 64d4695

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/Amazon.SecretsManager.Extensions.Caching/ISecretsManagerCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public interface ISecretsManagerCache : IDisposable
3939
/// <param name="versionStage">The version stage.</param>
4040
/// <param name="cancellationToken">The cancellation token used for the Secrets Manager API call.</param>
4141
/// <returns>The <c>SecretBinary</c>.</returns>
42-
Task<byte[]> GetSecretBinary(string secretId, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default);
42+
Task<byte[]> GetSecretBinary(string secretId, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default);
4343

4444
/// <summary>
4545
/// Asynchronously retrieves the specified <c>SecretString</c> after calling <see cref="GetCachedSecret"/>.
@@ -50,7 +50,7 @@ public interface ISecretsManagerCache : IDisposable
5050
/// <param name="versionStage">The version stage.</param>
5151
/// <param name="cancellationToken">The cancellation token used for the Secrets Manager API call.</param>
5252
/// <returns>The <c>SecretString</c>.</returns>
53-
Task<string> GetSecretString(string secretId, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default);
53+
Task<string> GetSecretString(string secretId, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default);
5454

5555
/// <summary>
5656
/// Requests the secret value from SecretsManager asynchronously and updates the cache entry with any changes.

src/Amazon.SecretsManager.Extensions.Caching/SecretCacheItem.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected override async Task<DescribeSecretResponse> ExecuteRefreshAsync(Cancel
4646
/// <summary>
4747
/// Asynchronously retrieves the GetSecretValueResponse from the proper SecretCacheVersion.
4848
/// </summary>
49-
protected override async Task<GetSecretValueResponse> GetSecretValueAsync(DescribeSecretResponse result, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default)
49+
protected override async Task<GetSecretValueResponse> GetSecretValueAsync(DescribeSecretResponse result, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default)
5050
{
5151
SecretCacheVersion version = GetVersion(result, versionId, versionStage);
5252
if (version == null)
@@ -75,19 +75,19 @@ public override bool Equals(object obj)
7575
/// Retrieves the SecretCacheVersion corresponding to the Version Stage
7676
/// specified by the SecretCacheConfiguration.
7777
/// </summary>
78-
private SecretCacheVersion GetVersion(DescribeSecretResponse describeResult, string versionId = "", string versionStage = "")
78+
private SecretCacheVersion GetVersion(DescribeSecretResponse describeResult, string versionId = null, string versionStage = null)
7979
{
8080
if (null == describeResult?.VersionIdsToStages) return null;
8181
String currentVersionId = null;
8282
foreach (KeyValuePair<String, List<String>> entry in describeResult.VersionIdsToStages)
8383
{
84-
if (versionId != string.Empty && entry.Key.Equals(versionId))
84+
if (versionId != null && entry.Key.Equals(versionId))
8585
{
8686
currentVersionId = versionId;
8787
break;
8888
}
8989

90-
if ((versionStage != string.Empty && entry.Value.Contains(versionStage)) || entry.Value.Contains(config.VersionStage))
90+
if ((versionStage != null && entry.Value.Contains(versionStage)) || entry.Value.Contains(config.VersionStage))
9191
{
9292
currentVersionId = entry.Key;
9393
break;

src/Amazon.SecretsManager.Extensions.Caching/SecretCacheObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public SecretCacheObject(String secretId, IAmazonSecretsManager client, SecretCa
9696

9797
protected abstract Task<T> ExecuteRefreshAsync(CancellationToken cancellationToken = default);
9898

99-
protected abstract Task<GetSecretValueResponse> GetSecretValueAsync(T result, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default);
99+
protected abstract Task<GetSecretValueResponse> GetSecretValueAsync(T result, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default);
100100

101101
/// <summary>
102102
/// Return the typed result object.
@@ -209,7 +209,7 @@ public async Task<bool> RefreshNowAsync(CancellationToken cancellationToken = de
209209
/// If the secret is due for a refresh, the refresh will occur before the result is returned.
210210
/// If the refresh fails, the cached result is returned, or the cached exception is thrown.
211211
/// </summary>
212-
public async Task<GetSecretValueResponse> GetSecretValue(CancellationToken cancellationToken, string versionId = "", string versionStage = "")
212+
public async Task<GetSecretValueResponse> GetSecretValue(CancellationToken cancellationToken, string versionId = null, string versionStage = null)
213213
{
214214
bool success = false;
215215
await Lock.WaitAsync(cancellationToken);

src/Amazon.SecretsManager.Extensions.Caching/SecretCacheVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected override async Task<GetSecretValueResponse> ExecuteRefreshAsync(Cancel
5656
return await this.client.GetSecretValueAsync(new GetSecretValueRequest { SecretId = this.secretId, VersionId = this.versionId }, cancellationToken);
5757
}
5858

59-
protected override Task<GetSecretValueResponse> GetSecretValueAsync(GetSecretValueResponse result, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default)
59+
protected override Task<GetSecretValueResponse> GetSecretValueAsync(GetSecretValueResponse result, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default)
6060
{
6161
return Task.FromResult(result);
6262
}

src/Amazon.SecretsManager.Extensions.Caching/SecretsManagerCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void Dispose()
9494
/// <param name="versionStage">The version stage.</param>
9595
/// <param name="cancellationToken">The cancellation token used for the Secrets Manager API call.</param>
9696
/// <returns>The <c>SecretString</c>.</returns>
97-
public async Task<String> GetSecretString(String secretId, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default)
97+
public async Task<String> GetSecretString(String secretId, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default)
9898
{
9999
SecretCacheItem secret = GetCachedSecret(secretId);
100100
GetSecretValueResponse response = null;
@@ -111,7 +111,7 @@ public async Task<String> GetSecretString(String secretId, string versionId = ""
111111
/// <param name="versionStage">The version stage.</param>
112112
/// <param name="cancellationToken">The cancellation token used for the Secrets Manager API call.</param>
113113
/// <returns>The <c>SecretBinary</c>.</returns>
114-
public async Task<byte[]> GetSecretBinary(String secretId, string versionId = "", string versionStage = "", CancellationToken cancellationToken = default)
114+
public async Task<byte[]> GetSecretBinary(String secretId, string versionId = null, string versionStage = null, CancellationToken cancellationToken = default)
115115
{
116116
SecretCacheItem secret = GetCachedSecret(secretId);
117117
GetSecretValueResponse response = null;

0 commit comments

Comments
 (0)