Skip to content

Commit 5e04197

Browse files
authored
Small fixes from post-merge code review. (#8489)
* Feedback from #8467 * Feedback from #8482 * Feedback from #8484 * Feedback from #8460 * More fixes
1 parent 67f69e6 commit 5e04197

File tree

7 files changed

+49
-51
lines changed

7 files changed

+49
-51
lines changed

snippets/csharp/System.Net.Sockets/TcpClient/Overview/tcpclient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void Connect(String server, String message)
6666
// combination.
6767
Int32 port = 13000;
6868

69-
// Prefer using declaration to ensure the instance is Disposed later.
69+
// Prefer a using declaration to ensure the instance is Disposed later.
7070
using TcpClient client = new TcpClient(server, port);
7171

7272
// Translate the passed message into ASCII and store it as a Byte array.

snippets/csharp/System.Net.Sockets/TcpListener/Overview/tcpserver.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public static void Main()
7474
stream.Write(msg, 0, msg.Length);
7575
Console.WriteLine("Sent: {0}", data);
7676
}
77-
78-
// Shutdown and end the connection
79-
client.Close();
8077
}
8178
}
8279
catch(SocketException e)

snippets/csharp/System.Net/HttpVersion/Overview/httpversion_version10.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,38 @@ The changed Version and the 'Version' of the response object are displayed.
1313

1414
class HttpVersion_Version10
1515
{
16-
public static void Main()
17-
{
18-
try
19-
{
20-
// <Snippet1>
21-
// HttpClient lifecycle management best practices:
22-
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
23-
HttpClient client = new HttpClient();
16+
public static void Main()
17+
{
18+
try
19+
{
20+
// <Snippet1>
21+
// HttpClient lifecycle management best practices:
22+
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
23+
using HttpClient client = new HttpClient();
2424

25-
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com");
26-
Console.WriteLine("Default HTTP request version is {0}", request.Version);
25+
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com");
26+
Console.WriteLine("Default HTTP request version is {0}", request.Version);
2727

28-
request.Version = HttpVersion.Version10;
29-
Console.WriteLine("Request version after assignment is {0}", request.Version);
28+
request.Version = HttpVersion.Version10;
29+
Console.WriteLine("Request version after assignment is {0}", request.Version);
3030

31-
HttpResponseMessage response = client.Send(request);
32-
Console.WriteLine("Response HTTP version {0}", response.Version);
33-
// </Snippet1>
34-
Console.WriteLine("\nPress 'Enter' Key to Continue..............");
35-
Console.Read();
36-
}
37-
catch(HttpRequestException e)
38-
{
39-
Console.WriteLine("HttpRequestException Caught!");
40-
Console.WriteLine("Message :{0} ",e.Message);
41-
Console.WriteLine("Source :{0} ",e.Source);
42-
}
43-
catch(Exception e)
44-
{
45-
Console.WriteLine("Exception Caught!");
46-
Console.WriteLine("Source :{0}" , e.Source);
47-
Console.WriteLine("Message :{0}" , e.Message);
48-
}
49-
}
31+
using HttpResponseMessage response = client.Send(request);
32+
Console.WriteLine("Response HTTP version {0}", response.Version);
33+
// </Snippet1>
34+
Console.WriteLine("\nPress 'Enter' Key to Continue..............");
35+
Console.Read();
36+
}
37+
catch (HttpRequestException e)
38+
{
39+
Console.WriteLine("HttpRequestException Caught!");
40+
Console.WriteLine("Message :{0} ", e.Message);
41+
Console.WriteLine("Source :{0} ", e.Source);
42+
}
43+
catch (Exception e)
44+
{
45+
Console.WriteLine("Exception Caught!");
46+
Console.WriteLine("Source :{0}", e.Source);
47+
Console.WriteLine("Message :{0}", e.Message);
48+
}
49+
}
5050
}

snippets/visualbasic/VS_Snippets_Remoting/HttpVersion_Version10/VB/httpversion_version10.vb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ Class HttpVersion_Version10
1717
' <Snippet1>
1818
' HttpClient lifecycle management best practices:
1919
' https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
20-
Dim client As New HttpClient()
20+
Using client As New HttpClient()
21+
Using request As New HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com")
22+
Console.WriteLine("Default HTTP request version is {0}", request.Version)
2123

22-
Dim request As New HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com")
23-
Console.WriteLine("Default HTTP request version is {0}", request.Version)
24+
request.Version = HttpVersion.Version10
25+
Console.WriteLine("Request version after assignment is {0}", request.Version)
2426

25-
request.Version = HttpVersion.Version10
26-
Console.WriteLine("Request version after assignment is {0}", request.Version)
27-
28-
Dim response As HttpResponseMessage = client.Send(request)
29-
Console.WriteLine("Response HTTP version {0}", response.Version)
27+
Using response As HttpResponseMessage = client.Send(request)
28+
Console.WriteLine("Response HTTP version {0}", response.Version)
29+
End Using
30+
End Using
31+
End Using
3032
' </Snippet1>
3133
Console.WriteLine(ControlChars.Cr + "Press 'Enter' Key to Continue..............")
3234
Console.Read()

xml/System.Net.Http/ByteArrayContent.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<format type="text/markdown"><![CDATA[
8484
8585
## Remarks
86-
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until the content is sent.
86+
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until after the content is sent.
8787
8888
]]></format>
8989
</remarks>
@@ -129,7 +129,7 @@ The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the p
129129
<format type="text/markdown"><![CDATA[
130130
131131
## Remarks
132-
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until the content is sent.
132+
The <xref:System.Net.Http.ByteArrayContent> class does not internally copy the provided byte array but keeps a reference to it instead. Callers should not modify the data in the array until after the content is sent.
133133
134134
Only the range specified by the `offset` parameter and the `count` parameter is used as content.
135135

xml/System.Net.NetworkInformation/Ping.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,10 +1775,7 @@
17751775
<format type="text/markdown"><![CDATA[
17761776
17771777
## Remarks
1778-
These methods do not cause your application's main thread to block. If you want to block while waiting for the ICMP echo reply message, use the <xref:System.Net.NetworkInformation.Ping.Send%2A> methods.
1779-
1780-
> [!NOTE]
1781-
> The IP address returned by any of the <xref:System.Net.NetworkInformation.Ping.SendPingAsync%2A> methods can originate from a malicious remote computer. Do not connect to the remote computer using this. Use DNS to determine the IP address of the machine to which you want to connect.
1778+
The IP address returned by any of the <xref:System.Net.NetworkInformation.Ping.SendPingAsync%2A> methods can originate from a malicious remote computer. Do not connect to the remote computer using this. Use DNS to determine the IP address of the machine to which you want to connect.
17821779
17831780
]]></format>
17841781
</remarks>

xml/System.Net/WebProxy.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
8181
8282
## Examples
83-
The following code example sets up <xref:System.Net.Http.HttpClient> instance with a <xref:System.Net.WebProxy> instance. The <xref:System.Net.Http.HttpClient> instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the <xref:System.Net.IWebProxyScript> class.)
83+
The following code example sets up an <xref:System.Net.Http.HttpClient> instance with a <xref:System.Net.WebProxy> instance. The <xref:System.Net.Http.HttpClient> instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the <xref:System.Net.IWebProxyScript> class.)
8484
8585
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp" id="Snippet1":::
8686
:::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Overview/source.cs" id="Snippet1":::
@@ -1147,7 +1147,8 @@
11471147
11481148
Applications should use the <xref:System.Net.Http.HttpClient.DefaultProxy?displayProperty=nameWithType> property instead of the <xref:System.Net.WebProxy.GetDefaultProxy%2A> method.
11491149
1150-
1150+
> [!NOTE]
1151+
> This property is not supported on .NET Core.
11511152
11521153
## Examples
11531154
The following code example demonstrates calling this method.
@@ -1157,6 +1158,7 @@
11571158
11581159
]]></format>
11591160
</remarks>
1161+
<exception cref="T:System.PlatformNotSupportedException">On .NET Core.</exception>
11601162
</Docs>
11611163
</Member>
11621164
<Member MemberName="GetObjectData">

0 commit comments

Comments
 (0)