Skip to content

Commit

Permalink
chore: Invert #if NETSTANDARD* conditional compilation conditions (#1079
Browse files Browse the repository at this point in the history
)

Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
  • Loading branch information
0xced and HofmeisterAn authored Dec 28, 2023
1 parent e3be24f commit 5ca4b6b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/Testcontainers/Clients/TestcontainersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public Task<long> GetContainerExitCodeAsync(string id, CancellationToken ct = de
/// <inheritdoc />
public Task<(string Stdout, string Stderr)> GetContainerLogsAsync(string id, DateTime since = default, DateTime until = default, bool timestampsEnabled = true, CancellationToken ct = default)
{
#if NETSTANDARD2_1_OR_GREATER
var unixEpoch = DateTime.UnixEpoch;
#else
#if NETSTANDARD2_0
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
#else
var unixEpoch = DateTime.UnixEpoch;
#endif

if (default(DateTime).Equals(since))
Expand Down Expand Up @@ -269,11 +269,11 @@ public async Task<byte[]> ReadFileAsync(string id, string filePath, Cancellation

var readBytes = new byte[entry.Size];

#if NETSTANDARD2_1_OR_GREATER
_ = await tarInputStream.ReadAsync(new Memory<byte>(readBytes), ct)
#if NETSTANDARD2_0
_ = await tarInputStream.ReadAsync(readBytes, 0, readBytes.Length, ct)
.ConfigureAwait(false);
#else
_ = await tarInputStream.ReadAsync(readBytes, 0, readBytes.Length, ct)
_ = await tarInputStream.ReadAsync(readBytes, ct)
.ConfigureAwait(false);
#endif

Expand Down
18 changes: 9 additions & 9 deletions src/Testcontainers/Containers/ResourceReaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ await tcpClient.ConnectAsync(host, port)
{
using (var messageBuffer = new MemoryStream())
{
#if NETSTANDARD2_1_OR_GREATER
await stream.WriteAsync(new ReadOnlyMemory<byte>(sendBytes), ct)
#if NETSTANDARD2_0
await stream.WriteAsync(sendBytes, 0, sendBytes.Length, ct)
.ConfigureAwait(false);
#else
await stream.WriteAsync(sendBytes, 0, sendBytes.Length, ct)
await stream.WriteAsync(sendBytes, ct)
.ConfigureAwait(false);
#endif

Expand All @@ -321,11 +321,11 @@ await stream.FlushAsync(ct)

do
{
#if NETSTANDARD2_1_OR_GREATER
var numberOfBytes = await stream.ReadAsync(new Memory<byte>(readBytes), ct)
#if NETSTANDARD2_0
var numberOfBytes = await stream.ReadAsync(readBytes, 0, readBytes.Length, ct)
.ConfigureAwait(false);
#else
var numberOfBytes = await stream.ReadAsync(readBytes, 0, readBytes.Length, ct)
var numberOfBytes = await stream.ReadAsync(readBytes, ct)
.ConfigureAwait(false);
#endif

Expand Down Expand Up @@ -367,11 +367,11 @@ await Task.Delay(TimeSpan.FromSeconds(RetryTimeoutInSeconds), ct)
while (!_maintainConnectionCts.IsCancellationRequested)
{
// Keep the connection to Ryuk up.
#if NETSTANDARD2_1_OR_GREATER
_ = await stream.ReadAsync(new Memory<byte>(readBytes), _maintainConnectionCts.Token)
#if NETSTANDARD2_0
_ = await stream.ReadAsync(readBytes, 0, readBytes.Length, _maintainConnectionCts.Token)
.ConfigureAwait(false);
#else
_ = await stream.ReadAsync(readBytes, 0, readBytes.Length, _maintainConnectionCts.Token)
_ = await stream.ReadAsync(readBytes, _maintainConnectionCts.Token)
.ConfigureAwait(false);
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions src/Testcontainers/Containers/TarOutputMemoryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public async Task AddAsync(IResourceMapping resourceMapping, CancellationToken c
await PutNextEntryAsync(tarEntry, ct)
.ConfigureAwait(false);

#if NETSTANDARD2_1_OR_GREATER
await WriteAsync(fileContent, ct)
#if NETSTANDARD2_0
await WriteAsync(fileContent, 0, fileContent.Length, ct)
.ConfigureAwait(false);
#else
await WriteAsync(fileContent, 0, fileContent.Length, ct)
await WriteAsync(fileContent, ct)
.ConfigureAwait(false);
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/Testcontainers/Images/IgnoreFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public string Replace(string input)
}

// Replace the last non recursive wildcard with a match-zero-or-one quantifier regular expression.
#if NETSTANDARD2_1_OR_GREATER
if (input.Contains('*') && index >= 0)
#else
#if NETSTANDARD2_0
if (input.Contains("*") && index >= 0)
#else
if (input.Contains('*') && index >= 0)
#endif
{
input = input.Remove(index, 1).Insert(index, $"{MatchAllExceptPathSeparator}?");
Expand Down

0 comments on commit 5ca4b6b

Please sign in to comment.