8000 [release/v7.4.0-preview.7]Fix `Test-Connection` due to .NET 8 changes by adityapatwardhan · Pull Request #20531 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

[release/v7.4.0-preview.7]Fix Test-Connection due to .NET 8 changes #20531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TestConnectionCommand : PSCmdlet, IDisposable

#region Private Fields

private static byte[]? s_DefaultSendBuffer;
private static readonly byte[] s_DefaultSendBuffer = Array.Empty<byte>();

private readonly CancellationTokenSource _dnsLookupCancel = new();

Expand Down Expand Up @@ -484,7 +484,10 @@ private void ProcessTraceroute(string targetNameOrAddress)
reply.Status == IPStatus.Success
? reply.RoundtripTime
: timer.ElapsedMilliseconds,
buffer.Length,

// If we use the empty buffer, then .NET actually uses a 32 byte buffer so we want to show
// as the result object the actual buffer size used instead of 0.
buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length,
pingNum: i);
WriteObject(new TraceStatus(
currentHop,
Expand Down Expand Up @@ -707,7 +710,7 @@ private void ProcessPing(string targetNameOrAddress)
resolvedTargetName,
reply,
reply.RoundtripTime,
buffer.Length,
buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length,
pingNum: (uint)i));
}

Expand Down Expand Up @@ -862,7 +865,7 @@ private IPHostEntry GetCancellableHostEntry(string targetNameOrAddress)
// Creates and fills a send buffer. This follows the ping.exe and CoreFX model.
private static byte[] GetSendBuffer(int bufferSize)
{
if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer != null)
if (bufferSize == DefaultSendBufferSize)
{
return s_DefaultSendBuffer;
}
Expand All @@ -874,11 +877,6 @@ private static byte[] GetSendBuffer(int bufferSize)
sendBuffer[i] = (byte)((int)'a' + i % 23);
}

if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer == null)
{
s_DefaultSendBuffer = sendBuffer;
}

return sendBuffer;
}

Expand Down
0