From 3af7126cc7bb0ecd5446e962f625123bdd87fee3 Mon Sep 17 00:00:00 2001
From: vexx32 <32407840+vexx32@users.noreply.github.com>
Date: Fri, 13 Dec 2019 00:39:13 -0500
Subject: [PATCH 01/14] :bug: Fallback to DisplayAddress if no Destination
- When doing traceroutes, Destination is set as the router name.
If no router name is available, it ends up as string.Empty.
- Change Hostname property to fallback to DisplayAddress if needed.
---
.../management/TestConnectionCommand.cs | 21 +++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 9a213b7a864..9104197bd7f 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -1022,10 +1022,23 @@ internal TraceStatus(
///
public string? Hostname
{
- get => _status.Destination != IPAddress.Any.ToString()
- && _status.Destination != IPAddress.IPv6Any.ToString()
- ? _status.Destination
- : null;
+ get
+ {
+ if (_status.Address?.ToString() == IPAddress.Any.ToString()
+ || _status.Address?.ToString() == IPAddress.IPv6Any.ToString())
+ {
+ // There was no response to the ping (TimedOut).
+ return null;
+ }
+
+ if (_status.Destination == string.Empty)
+ {
+ // There was a response, but the destination field is empty; use DisplayAddress.
+ return _status.DisplayAddress;
+ }
+
+ return _status.Destination;
+ }
}
///
From 36544acc4b3f966c1975d9f0a1583ee3a3014ad5 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Fri, 13 Dec 2019 10:53:40 -0600
Subject: [PATCH 02/14] :bug: Ensure destination field is filled in trace
- Previously, the Destination field of the PingStatus could be empty
- Change ensures that it will always be populated with the IP address
if no hostname is available.
- The getter for TraceStatus.Hostname was adjusted to make better use
of the underlying properties as well.
---
.../commands/management/TestConnectionCommand.cs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 9104197bd7f..1a7a22c3a6a 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -402,13 +402,16 @@ private void ProcessTraceroute(string targetNameOrAddress)
}
}
#endif
+
reply = SendCancellablePing(hopAddress, timeout, buffer, pingOptions, timer);
if (!Quiet.IsPresent)
{
var status = new PingStatus(
Source,
- routerName,
+ routerName != string.Empty
+ ? routerName
+ : hopAddressString,
reply,
reply.Status == IPStatus.Success
? reply.RoundtripTime
@@ -1031,12 +1034,7 @@ public string? Hostname
return null;
}
- if (_status.Destination == string.Empty)
- {
- // There was a response, but the destination field is empty; use DisplayAddress.
- return _status.DisplayAddress;
- }
-
+ // We have a usable IP address from this ping reply.
return _status.Destination;
}
}
From 4399a9c42751909c7aa9272804fa918c522e8af2 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Fri, 13 Dec 2019 12:44:50 -0600
Subject: [PATCH 03/14] :bug: Refactor to use InitProcessPing
- Before this change, if ResolveDestination was not set, we did not use
the method to get the hop address string.
- After this change, the routerName and thus Destination field will
always be set.
---
.../commands/management/TestConnectionCommand.cs | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 1a7a22c3a6a..6609ef63544 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -389,8 +389,8 @@ private void ProcessTraceroute(string targetNameOrAddress)
{
try
{
-#if !UNIX
- if (ResolveDestination.IsPresent && routerName == string.Empty)
+ if (routerName == string.Empty
+ || ResolveDestination.IsPresent && routerName == hopAddressString)
{
try
{
@@ -401,7 +401,6 @@ private void ProcessTraceroute(string targetNameOrAddress)
// Swallow host resolve exceptions and just use the IP address.
}
}
-#endif
reply = SendCancellablePing(hopAddress, timeout, buffer, pingOptions, timer);
@@ -409,9 +408,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
{
var status = new PingStatus(
Source,
- routerName != string.Empty
- ? routerName
- : hopAddressString,
+ routerName,
reply,
reply.Status == IPStatus.Success
? reply.RoundtripTime
From 0304d01d37c5bf30fbb7c092f77293a3fdaf7100 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Fri, 13 Dec 2019 16:01:19 -0600
Subject: [PATCH 04/14] :fire: Remove unnecessary ToString() calls
---
.../commands/management/TestConnectionCommand.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 6609ef63544..a2e76d57f80 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -1024,8 +1024,8 @@ public string? Hostname
{
get
{
- if (_status.Address?.ToString() == IPAddress.Any.ToString()
- || _status.Address?.ToString() == IPAddress.IPv6Any.ToString())
+ if (_status.Address == IPAddress.Any
+ || _status.Address == IPAddress.IPv6Any)
{
// There was no response to the ping (TimedOut).
return null;
From 143b785d6aaa71be5ad8656bc20e3866d403a7b5 Mon Sep 17 00:00:00 2001
From: vexx32 <32407840+vexx32@users.noreply.github.com>
Date: Sat, 14 Dec 2019 23:48:42 -0500
Subject: [PATCH 05/14] :recycle: Refactor traceroute and tracestatus
- Call InitProcessPing() only once per hop.
- Set Hostname in TraceStatus constructor.
---
.../management/TestConnectionCommand.cs | 43 ++++++-------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index a2e76d57f80..c59bba2fdd2 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -351,8 +351,6 @@ private void ProcessTraceroute(string targetNameOrAddress)
IPAddress hopAddress;
do
{
- // Clear the stored router name for every hop
- string routerName = string.Empty;
pingOptions.Ttl = currentHop;
#if !UNIX
@@ -383,25 +381,14 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
+ InitProcessPing(hopAddressString, out string routerName, out _);
+
// In traceroutes we don't use 'Count' parameter.
// If we change 'DefaultTraceRoutePingCount' we should change 'ConsoleTraceRouteReply' resource string.
for (uint i = 1; i <= DefaultTraceRoutePingCount; i++)
{
try
{
- if (routerName == string.Empty
- || ResolveDestination.IsPresent && routerName == hopAddressString)
- {
- try
- {
- InitProcessPing(hopAddressString, out routerName, out _);
- }
- catch
- {
- // Swallow host resolve exceptions and just use the IP address.
- }
- }
-
reply = SendCancellablePing(hopAddress, timeout, buffer, pingOptions, timer);
if (!Quiet.IsPresent)
@@ -1007,6 +994,16 @@ internal TraceStatus(
Source = source;
Target = destination;
TargetAddress = destinationAddress;
+
+ if (_status.Address == IPAddress.Any
+ || _status.Address == IPAddress.IPv6Any)
+ {
+ Hostname = null;
+ }
+ else
+ {
+ Hostname = _status.Destination;
+ }
}
private readonly PingStatus _status;
@@ -1020,21 +1017,7 @@ internal TraceStatus(
/// Gets the hostname of the current hop point.
///
///
- public string? Hostname
- {
- get
- {
- if (_status.Address == IPAddress.Any
- || _status.Address == IPAddress.IPv6Any)
- {
- // There was no response to the ping (TimedOut).
- return null;
- }
-
- // We have a usable IP address from this ping reply.
- return _status.Destination;
- }
- }
+ public string? Hostname { get; }
///
/// Gets the sequence number of the ping in the sequence of pings to the hop point.
From 55e9f71e99673f97186680e470d5ca1369130c42 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Mon, 16 Dec 2019 16:49:41 -0600
Subject: [PATCH 06/14] :recycle: Add if/else for per-hop InitProcessPing
---
.../commands/management/TestConnectionCommand.cs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index c59bba2fdd2..431a9e70a8b 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -381,7 +381,11 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- InitProcessPing(hopAddressString, out string routerName, out _);
+ string routerName = null;
+ if (!InitProcessPing(hopAddressString, out routerName, out _))
+ {
+ routerName = hopAddressString;
+ }
// In traceroutes we don't use 'Count' parameter.
// If we change 'DefaultTraceRoutePingCount' we should change 'ConsoleTraceRouteReply' resource string.
From 72e9e8f4beba7bdce9445fbeac7d21f0e1d5f712 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Tue, 17 Dec 2019 11:13:33 -0600
Subject: [PATCH 07/14] :recycle: Fix null issue in syntax
---
.../commands/management/TestConnectionCommand.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 431a9e70a8b..b98f2c912fd 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -381,8 +381,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- string routerName = null;
- if (!InitProcessPing(hopAddressString, out routerName, out _))
+ if (!InitProcessPing(hopAddressString, out string routerName, out _))
{
routerName = hopAddressString;
}
From 8f305bbb85274f891dd5e63ccc81024bdfe25476 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Tue, 17 Dec 2019 16:25:30 -0600
Subject: [PATCH 08/14] :white_check_mark: Verify Destination works
---
.../Test-Connection.Tests.ps1 | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
index d3ec629f80f..175feebc806 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
@@ -275,6 +275,12 @@ Describe "Test-Connection" -tags "CI" {
It 'returns false without error if MaxHops is exceeded during -Traceroute -Quiet' {
Test-Connection 8.8.8.8 -Traceroute -MaxHops 2 -Quiet | Should -BeFalse
}
+
+ It 'has a non-null value for Destination for reachable hosts' {
+ $results = Test-Connection 127.0.0.1 -Traceroute
+
+ $results.Destination | Should -Not -BeNullOrEmpty
+ }
}
}
From c14da69089f4219e394fbc9b6fa17dbbfa32e411 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Tue, 17 Dec 2019 17:04:20 -0600
Subject: [PATCH 09/14] :white_check_mark: Fix test
---
.../Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
index 175feebc806..b7e90b9383b 100644
--- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
+++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1
@@ -279,7 +279,7 @@ Describe "Test-Connection" -tags "CI" {
It 'has a non-null value for Destination for reachable hosts' {
$results = Test-Connection 127.0.0.1 -Traceroute
- $results.Destination | Should -Not -BeNullOrEmpty
+ $results.Hostname | Should -Not -BeNullOrEmpty
}
}
}
From b1db89aa9abe6bcbc04fd381198823ef32e85114 Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Tue, 17 Dec 2019 17:04:28 -0600
Subject: [PATCH 10/14] :recycle: Rename InitProcessPing()
---
.../commands/management/TestConnectionCommand.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index b98f2c912fd..3bf811f0a97 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -285,7 +285,7 @@ protected override void StopProcessing()
private void ProcessConnectionByTCPPort(string targetNameOrAddress)
{
- if (!InitProcessPing(targetNameOrAddress, out _, out IPAddress? targetAddress))
+ if (!CanResolveNameOrAddress(targetNameOrAddress, out _, out IPAddress? targetAddress))
{
return;
}
@@ -336,7 +336,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
{
byte[] buffer = GetSendBuffer(BufferSize);
- if (!InitProcessPing(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -381,7 +381,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- if (!InitProcessPing(hopAddressString, out string routerName, out _))
+ if (!CanResolveNameOrAddress(hopAddressString, out string routerName, out _))
{
routerName = hopAddressString;
}
@@ -465,7 +465,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
private void ProcessMTUSize(string targetNameOrAddress)
{
PingReply? reply, replyResult = null;
- if (!InitProcessPing(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -568,7 +568,7 @@ private void ProcessMTUSize(string targetNameOrAddress)
private void ProcessPing(string targetNameOrAddress)
{
- if (!InitProcessPing(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -633,7 +633,7 @@ private void ProcessPing(string targetNameOrAddress)
#endregion PingTest
- private bool InitProcessPing(
+ private bool CanResolveNameOrAddress(
string targetNameOrAddress,
out string resolvedTargetName,
[NotNullWhen(true)]
From 6fa22473a70014fd4c68bc8be9f2c3417abebfc9 Mon Sep 17 00:00:00 2001
From: vexx32 <32407840+vexx32@users.noreply.github.com>
Date: Tue, 17 Dec 2019 20:53:00 -0500
Subject: [PATCH 11/14] :recycle: CanResolve..()->TryResolve..()
---
.../commands/management/TestConnectionCommand.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 3bf811f0a97..416f8e7dea6 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -285,7 +285,7 @@ protected override void StopProcessing()
private void ProcessConnectionByTCPPort(string targetNameOrAddress)
{
- if (!CanResolveNameOrAddress(targetNameOrAddress, out _, out IPAddress? targetAddress))
+ if (!TryResolveNameOrAddress(targetNameOrAddress, out _, out IPAddress? targetAddress))
{
return;
}
@@ -336,7 +336,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
{
byte[] buffer = GetSendBuffer(BufferSize);
- if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!TryResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -381,7 +381,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- if (!CanResolveNameOrAddress(hopAddressString, out string routerName, out _))
+ if (!TryResolveNameOrAddress(hopAddressString, out string routerName, out _))
{
routerName = hopAddressString;
}
@@ -465,7 +465,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
private void ProcessMTUSize(string targetNameOrAddress)
{
PingReply? reply, replyResult = null;
- if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!TryResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -568,7 +568,7 @@ private void ProcessMTUSize(string targetNameOrAddress)
private void ProcessPing(string targetNameOrAddress)
{
- if (!CanResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
+ if (!TryResolveNameOrAddress(targetNameOrAddress, out string resolvedTargetName, out IPAddress? targetAddress))
{
return;
}
@@ -633,7 +633,7 @@ private void ProcessPing(string targetNameOrAddress)
#endregion PingTest
- private bool CanResolveNameOrAddress(
+ private bool TryResolveNameOrAddress(
string targetNameOrAddress,
out string resolvedTargetName,
[NotNullWhen(true)]
From a351cb4280f29114ebbe0a97f40f9b97ec064d36 Mon Sep 17 00:00:00 2001
From: vexx32 <32407840+vexx32@users.noreply.github.com>
Date: Wed, 18 Dec 2019 01:23:07 -0500
Subject: [PATCH 12/14] :bug: Catch hostname resolve errors during trace
This resolves an issue where intermediate hops may not have DNS entries.
Retaining this behaviour means we acknowledge not all nodes in the
trace will necessarily be reachable. This is quite normal; many nodes
may block direct ICMP requests.
By catching any errors during hostname resolution, we get a more useful
experience for users.
---
.../commands/management/TestConnectionCommand.cs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index 416f8e7dea6..ad9768270a2 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -381,8 +381,16 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- if (!TryResolveNameOrAddress(hopAddressString, out string routerName, out _))
+ try
+ {
+ if (!TryResolveNameOrAddress(hopAddressString, out string routerName, out _))
+ {
+ routerName = hopAddressString;
+ }
+ }
+ catch
{
+ // Swallow hostname resolve exceptions and continue with traceroute
routerName = hopAddressString;
}
From 4fc9fb651a71eea470d4c145a4780a5b85430cfa Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Wed, 18 Dec 2019 08:43:27 -0600
Subject: [PATCH 13/14] :bug: Define routerName in proper context
---
.../commands/management/TestConnectionCommand.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index ad9768270a2..fd2de8edf75 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -381,9 +381,10 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
+ string routerName = null;
try
{
- if (!TryResolveNameOrAddress(hopAddressString, out string routerName, out _))
+ if (!TryResolveNameOrAddress(hopAddressString, out routerName, out _))
{
routerName = hopAddressString;
}
From 8e58e9ba77b77db9f8af069956f425ad196adbdf Mon Sep 17 00:00:00 2001
From: Joel Francis <32407840+vexx32@users.noreply.github.com>
Date: Wed, 18 Dec 2019 12:06:29 -0600
Subject: [PATCH 14/14] :bug: Fix non-nullable oops
---
.../commands/management/TestConnectionCommand.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
index fd2de8edf75..ab9c299b712 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs
@@ -381,7 +381,7 @@ private void ProcessTraceroute(string targetNameOrAddress)
#endif
var hopAddressString = discoveryReply.Address.ToString();
- string routerName = null;
+ string routerName = hopAddressString;
try
{
if (!TryResolveNameOrAddress(hopAddressString, out routerName, out _))
@@ -392,7 +392,6 @@ private void ProcessTraceroute(string targetNameOrAddress)
catch
{
// Swallow hostname resolve exceptions and continue with traceroute
- routerName = hopAddressString;
}
// In traceroutes we don't use 'Count' parameter.