From 2b6c59b289d5372470989abd169be64ddb2cca51 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 8 Mar 2025 16:44:54 +0100 Subject: [PATCH 1/2] `IPInterfaceProperties.GetIPv(4|6)Properties` never returns null (#11056) The null checking in the code samples is unnecessary and misleading so I'm proposing to delete it. Moreover, we should call out in the remarks section the necessity of a capability check so users avoid walking into an exception in case of missing protocol support. --- .../NCLNetInfo2/CPP/networkexamples.cpp | 5 ----- .../Overview/networkexamples.cs | 6 ------ .../VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb | 6 +----- xml/System.Net.NetworkInformation/IPInterfaceProperties.xml | 6 ++++-- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp index 2a2ee1dc16b..210b727cdc0 100644 --- a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp +++ b/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp @@ -836,11 +836,6 @@ void DisplayIPv4NetworkInterfaces() // Try to get the IPv4 interface properties. IPv4InterfaceProperties ^ p = adapterProperties->GetIPv4Properties(); - if ( !p ) - { - Console::WriteLine( "No IPv4 information is available for this interface." ); - continue; - } // Display the IPv4 specific data. Console::WriteLine( " Index ............................. : {0}", diff --git a/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs b/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs index 9c6b672328b..8cc9ce5ed92 100644 --- a/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs +++ b/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs @@ -796,12 +796,6 @@ public static void DisplayIPv4NetworkInterfaces() // Try to get the IPv4 interface properties. IPv4InterfaceProperties p = adapterProperties.GetIPv4Properties(); - if (p == null) - { - Console.WriteLine("No IPv4 information is available for this interface."); - Console.WriteLine(); - continue; - } // Display the IPv4 specific data. Console.WriteLine(" Index ............................. : {0}", p.Index); Console.WriteLine(" MTU ............................... : {0}", p.Mtu); diff --git a/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb b/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb index 30e67a10ba5..867a2dbadd4 100644 --- a/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb +++ b/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb @@ -695,11 +695,7 @@ Public Class NetworkingExample Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties() ' Try to get the IPv4 interface properties. Dim p As IPv4InterfaceProperties = adapterProperties.GetIPv4Properties() - - If p Is Nothing Then - Console.WriteLine("No IPv4 information is available for this interface.") - GoTo ContinueForEach1 - End If + ' Display the IPv4 specific data. Console.WriteLine(" Index ............................. : {0}", p.Index) Console.WriteLine(" MTU ............................... : {0}", p.Mtu) diff --git a/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml b/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml index e9d07e9b728..d85efc8d377 100644 --- a/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml +++ b/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml @@ -494,7 +494,8 @@ ## Remarks For a detailed description of the information available for an interface that supports IPv4, see the class documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. - + A is thrown if the interface does not support the IPv4 protocol, therefore it's recommended to check IPv4 support calling on the originating instance before querying the IPv4 properties. + ]]> The interface does not support the IPv4 protocol. @@ -544,7 +545,8 @@ ## Remarks For a detailed description of the information available for an interface that supports IPv6, see the documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. - + A is thrown if the interface does not support the IPv6 protocol, therefore it's recommended to check IPv6 support calling on the originating instance before querying the IPv6 properties. + ]]> The interface does not support the IPv6 protocol. From 17a1a93359457a3554b6e8a57c53710a68076ebf Mon Sep 17 00:00:00 2001 From: hawkeye101 Date: Mon, 10 Mar 2025 00:27:39 +0530 Subject: [PATCH 2/2] Corrected wording for ImportedFromTypeLibAttribute (#11067) --- .../ImportedFromTypeLibAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Runtime.InteropServices/ImportedFromTypeLibAttribute.xml b/xml/System.Runtime.InteropServices/ImportedFromTypeLibAttribute.xml index 63a2aee8e09..c1144eb82b3 100644 --- a/xml/System.Runtime.InteropServices/ImportedFromTypeLibAttribute.xml +++ b/xml/System.Runtime.InteropServices/ImportedFromTypeLibAttribute.xml @@ -60,7 +60,7 @@ , which specifies that an individual type is implemented in COM.