diff --git a/src/Testcontainers/Clients/TestcontainersClient.cs b/src/Testcontainers/Clients/TestcontainersClient.cs index d7b397c1b..4d54139cb 100644 --- a/src/Testcontainers/Clients/TestcontainersClient.cs +++ b/src/Testcontainers/Clients/TestcontainersClient.cs @@ -98,10 +98,10 @@ public Task GetContainerExitCodeAsync(string id, CancellationToken ct = de /// 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)) @@ -269,11 +269,11 @@ public async Task ReadFileAsync(string id, string filePath, Cancellation var readBytes = new byte[entry.Size]; -#if NETSTANDARD2_1_OR_GREATER - _ = await tarInputStream.ReadAsync(new Memory(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 diff --git a/src/Testcontainers/Containers/ResourceReaper.cs b/src/Testcontainers/Containers/ResourceReaper.cs index 617ee0c37..f941f2f92 100644 --- a/src/Testcontainers/Containers/ResourceReaper.cs +++ b/src/Testcontainers/Containers/ResourceReaper.cs @@ -306,11 +306,11 @@ await tcpClient.ConnectAsync(host, port) { using (var messageBuffer = new MemoryStream()) { -#if NETSTANDARD2_1_OR_GREATER - await stream.WriteAsync(new ReadOnlyMemory(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 @@ -321,11 +321,11 @@ await stream.FlushAsync(ct) do { -#if NETSTANDARD2_1_OR_GREATER - var numberOfBytes = await stream.ReadAsync(new Memory(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 @@ -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(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 } diff --git a/src/Testcontainers/Containers/TarOutputMemoryStream.cs b/src/Testcontainers/Containers/TarOutputMemoryStream.cs index 245362f98..99ae0d99c 100644 --- a/src/Testcontainers/Containers/TarOutputMemoryStream.cs +++ b/src/Testcontainers/Containers/TarOutputMemoryStream.cs @@ -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 diff --git a/src/Testcontainers/Images/IgnoreFile.cs b/src/Testcontainers/Images/IgnoreFile.cs index 7698787be..d5d3ec336 100644 --- a/src/Testcontainers/Images/IgnoreFile.cs +++ b/src/Testcontainers/Images/IgnoreFile.cs @@ -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}?");