Skip to content

Commit 0a5bb69

Browse files
authored
chore: Remove Sonar findings (#1646)
1 parent 934e972 commit 0a5bb69

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/Testcontainers/Builders/ContainerBuilder`3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public TBuilderEntity WithResourceMapping(Uri source, DirectoryPath target, uint
329329
var fileName = Path.GetFileName(source.LocalPath);
330330

331331
_ = Guard.Argument(source, nameof(source))
332-
.ThrowIf(_ => string.IsNullOrEmpty(fileName), _ => new ArgumentException(string.Format(message, source), nameof(source)));
332+
.ThrowIf(_ => string.IsNullOrEmpty(fileName), argument => new ArgumentException(string.Format(message, argument.Value), argument.Name));
333333

334334
var filePath = FilePath.Of(Path.Combine(target.Value, fileName));
335335
return WithResourceMapping(source, filePath, uid, gid, fileMode);

src/Testcontainers/Builders/DirectoryPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ public override string ToString()
5252
return Value;
5353
}
5454
}
55-
}
55+
}

src/Testcontainers/Builders/DockerConfig.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ public Uri GetCurrentEndpoint()
9696

9797
using (var sha256 = SHA256.Create())
9898
{
99-
var dockerContextHash = BitConverter.ToString(sha256.ComputeHash(Encoding.Default.GetBytes(dockerContext))).Replace("-", string.Empty).ToLowerInvariant();
99+
var hashBytes = sha256.ComputeHash(Encoding.Default.GetBytes(dockerContext));
100+
101+
#if NET10_0_OR_GREATER
102+
var dockerContextHash = Convert.ToHexStringLower(hashBytes);
103+
#else
104+
var dockerContextHash = BitConverter.ToString(hashBytes).Replace("-", string.Empty).ToLowerInvariant();
105+
#endif
106+
100107
var metaFilePath = Path.Combine(_dockerConfigDirectoryPath, "contexts", "meta", dockerContextHash, "meta.json");
101108

102109
try

src/Testcontainers/Builders/FilePath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ public override string ToString()
5252
return Value;
5353
}
5454
}
55-
}
55+
}

src/Testcontainers/Configurations/WaitStrategies/UntilDatabaseIsAvailable.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace DotNet.Testcontainers.Configurations
55
using System.Threading.Tasks;
66
using DotNet.Testcontainers.Containers;
77

8-
internal class UntilDatabaseIsAvailable : IWaitUntil
8+
internal sealed class UntilDatabaseIsAvailable : IWaitUntil
99
{
1010
private readonly DbProviderFactory _dbProviderFactory;
1111

@@ -45,7 +45,12 @@ await connection.OpenAsync()
4545
}
4646
finally
4747
{
48+
#if NETSTANDARD2_0
4849
connection.Dispose();
50+
#else
51+
await connection.DisposeAsync()
52+
.ConfigureAwait(false);
53+
#endif
4954
}
5055
}
5156
}

0 commit comments

Comments
 (0)