Skip to content

Commit 0041613

Browse files
Merge pull request #11491 from dotnet/main
Merge main into live
2 parents d041aec + 20a51c9 commit 0041613

File tree

16 files changed

+178
-69
lines changed

16 files changed

+178
-69
lines changed

.github/copilot-instructions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Code comments should end with a period.
2+
3+
When you add a code snippet to the XML remarks of an API, add the code as a separate code file (.cs file) and not as an inline (```) code block. Also add a .csproj file to compile the code if one doesn't already exist in the snippet folder.
4+
5+
Don't use the word "may". Use "might" to indicate possibility or "can" to indicate permission.
6+
7+
There should always be a comma before a clause that begins with "which".
8+
9+
Use a conversational tone with contractions.
10+
11+
Be concise.
12+
13+
Break up long sentences.
14+
15+
Use the present tense for instructions and descriptions. For example, "The method returns a value" instead of "The method will return a value."
16+
17+
Use the Oxford comma in lists of three or more items.

snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME
3232
ar ar ara ARA Arabic Arabic
3333
bg bg bul BGR Bulgarian Bulgarian
3434
ca ca cat CAT Catalan Catalan
35-
zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
3635
cs cs ces CSY Czech Czech
3736
da da dan DAN Danish Danish
3837
de de deu DEU German German
@@ -41,9 +40,10 @@ en en eng ENU English English
4140
es es spa ESP Spanish Spanish
4241
fi fi fin FIN Finnish Finnish
4342
zh zh zho CHS Chinese Chinese
44-
zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
45-
zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
46-
zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
43+
zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
44+
zh-Hant zh zho ZHH Chinese (Traditional) Chinese (Traditional)
45+
46+
Note: zh-Hant returns ZHH when using ICU (default). When NLS mode is enabled, it returns CHT.
4747
4848
*/
4949
// </snippet1>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="9.0.6" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Net;
3+
using System.Net.Http;
4+
using System.Net.Security;
5+
6+
class WinHttpHandler_SecureExample
7+
{
8+
static void Main()
9+
{
10+
if (!OperatingSystem.IsWindows())
11+
{
12+
Console.WriteLine("This example requires Windows.");
13+
return;
14+
}
15+
// <Snippet1>
16+
var handler = new WinHttpHandler();
17+
handler.ServerCertificateValidationCallback = (httpRequestMessage, certificate, chain, sslPolicyErrors) =>
18+
{
19+
if (sslPolicyErrors == SslPolicyErrors.None)
20+
{
21+
// TODO: Implement additional custom certificate validation logic here.
22+
return true;
23+
}
24+
// Do not allow this client to communicate with unauthenticated servers.
25+
return false;
26+
};
27+
// </Snippet1>
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Security.Cryptography.X509Certificates;
3+
4+
public class ChainElementsOrdering
5+
{
6+
public static void DemonstrateChainElementsOrdering(X509Certificate2 certificate)
7+
{
8+
//<SNIPPET6>
9+
using var chain = new X509Chain();
10+
chain.Build(certificate);
11+
12+
// chain.ChainElements[0] is the leaf (end-entity) certificate
13+
// chain.ChainElements[^1] is the root (trust anchor) certificate
14+
15+
Console.WriteLine("Certificate chain from leaf to root:");
16+
for (int i = 0; i < chain.ChainElements.Count; i++)
17+
{
18+
var cert = chain.ChainElements[i].Certificate;
19+
var role = i == 0 ? "Leaf" :
20+
i == chain.ChainElements.Count - 1 ? "Root" : "Intermediate";
21+
Console.WriteLine($"[{i}] {role}: {cert.Subject}");
22+
}
23+
//</SNIPPET6>
24+
}
25+
}

snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Module Module1
2929
'ar ar ara ARA Arabic Arabic
3030
'bg bg bul BGR Bulgarian Bulgarian
3131
'ca ca cat CAT Catalan Catalan
32-
'zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
3332
'cs cs ces CSY Czech Czech
3433
'da da dan DAN Danish Danish
3534
'de de deu DEU German German
@@ -38,9 +37,10 @@ Module Module1
3837
'es es spa ESP Spanish Spanish
3938
'fi fi fin FIN Finnish Finnish
4039
'zh zh zho CHS Chinese Chinese
41-
'zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional)
42-
'zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy
43-
'zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy
40+
'zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified)
41+
'zh-Hant zh zho ZHH Chinese (Traditional) Chinese (Traditional)
42+
'
43+
'Note: zh-Hant returns ZHH when using ICU (default). When NLS mode is enabled, it returns CHT.
4444

4545
End Module
4646
' </snippet1>

xml/System.Buffers.Text/Base64Url.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<Interfaces />
2828
<Docs>
2929
<summary>Converts between binary data and URL-safe ASCII encoded text that's represented in Base64Url characters.</summary>
30-
<remarks>To be added.</remarks>
30+
<remarks>Base64Url encoding uses the same alphabet as standard Base64 encoding, except that the characters '+' and '/' are replaced with '-' and '_' respectively to make the output URL-safe.</remarks>
3131
</Docs>
3232
<Members>
3333
<Member MemberName="DecodeFromChars">
@@ -373,7 +373,7 @@
373373
<param name="source">The input span which contains binary data that needs to be encoded.</param>
374374
<summary>Encodes the span of binary data into unicode ASCII chars represented as Base64Url.</summary>
375375
<returns>A char array which contains the result of the operation, i.e. the ASCII chars in Base64Url.</returns>
376-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
376+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
377377
</Docs>
378378
</Member>
379379
<Member MemberName="EncodeToChars">
@@ -406,7 +406,7 @@
406406
<param name="destination">The output span which contains the result of the operation, i.e. the ASCII chars in Base64Url.</param>
407407
<summary>Encodes the span of binary data into Unicode ASCII chars represented as Base64Url.</summary>
408408
<returns>The number of bytes written into the destination span. This can be used to slice the output for subsequent calls, if necessary.</returns>
409-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
409+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
410410
<exception cref="T:System.ArgumentException">The buffer in <paramref name="destination" /> is too small to hold the encoded output.</exception>
411411
</Docs>
412412
</Member>
@@ -449,7 +449,7 @@
449449
</param>
450450
<summary>Encodes the span of binary data into unicode ASCII chars represented as Base64Url.</summary>
451451
<returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
452-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
452+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
453453
</Docs>
454454
</Member>
455455
<Member MemberName="EncodeToString">
@@ -486,7 +486,7 @@
486486
<param name="source">The input span that contains binary data that needs to be encoded.</param>
487487
<summary>Encodes the span of binary data into Unicode string represented as Base64Url ASCII chars.</summary>
488488
<returns>A string that contains the result of the operation, i.e. the ASCII string in Base64Url.</returns>
489-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
489+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
490490
</Docs>
491491
</Member>
492492
<Member MemberName="EncodeToUtf8">
@@ -523,7 +523,7 @@
523523
<param name="source">The input span which contains binary data that needs to be encoded.</param>
524524
<summary>Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.</summary>
525525
<returns>The output byte array which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.</returns>
526-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
526+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
527527
</Docs>
528528
</Member>
529529
<Member MemberName="EncodeToUtf8">
@@ -556,7 +556,7 @@
556556
<param name="destination">The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.</param>
557557
<summary>Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.</summary>
558558
<returns>The number of bytes written into the destination span. This can be used to slice the output for subsequent calls, if necessary.</returns>
559-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
559+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
560560
<exception cref="T:System.ArgumentException">The buffer in <paramref name="destination" /> is too small to hold the encoded output.</exception>
561561
</Docs>
562562
</Member>
@@ -599,7 +599,7 @@
599599
</param>
600600
<summary>Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.</summary>
601601
<returns>One of the enumeration values that indicates the success or failure of the operation.</returns>
602-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
602+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
603603
</Docs>
604604
</Member>
605605
<Member MemberName="GetEncodedLength">
@@ -926,7 +926,7 @@
926926
<summary>Encodes the span of binary data into Unicode ASCII chars represented as Base64Url.</summary>
927927
<returns>
928928
<see langword="true" /> if chars encoded successfully; <see langword="false" /> if <paramref name="destination" /> is too small.</returns>
929-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
929+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
930930
</Docs>
931931
</Member>
932932
<Member MemberName="TryEncodeToUtf8">
@@ -962,7 +962,7 @@
962962
<summary>Encodes the span of binary data into UTF-8 encoded chars represented as Base64Url.</summary>
963963
<returns>
964964
<see langword="true" /> if bytes encoded successfully; <see langword="false" /> if <paramref name="destination" /> is too small.</returns>
965-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
965+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
966966
</Docs>
967967
</Member>
968968
<Member MemberName="TryEncodeToUtf8InPlace">
@@ -1007,7 +1007,7 @@
10071007
</summary>
10081008
<returns>
10091009
<see langword="true" /> if bytes encoded successfully; <see langword="false" /> if <paramref name="buffer" /> is too small to fit the result.</returns>
1010-
<remarks>This implementation of the base64url encoding omits the optional padding characters.</remarks>
1010+
<remarks>This implementation of the Base64Url encoding omits the optional padding characters. The encoding uses '-' and '_' instead of the '+' and '/' characters used in standard Base64 encoding.</remarks>
10111011
</Docs>
10121012
</Member>
10131013
</Members>

xml/System.Diagnostics/DebuggerDisplayAttribute.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class MyTable
212212
<format type="text/markdown"><![CDATA[
213213
214214
## Remarks
215-
The value can contain curly braces ({ and }). Text within a pair of braces is evaluated as the name of a field, property, or method.
215+
The value can contain curly braces ({ and }). Text within a pair of braces is evaluated as the name of a field, property, or method. You can also use format specifiers within the braces to control how values are displayed. For information about debugger format specifiers, see [Format Specifiers in C#](/visualstudio/debugger/format-specifiers-in-csharp).
216216
217217
218218
@@ -377,7 +377,14 @@ class MyTable
377377
<Docs>
378378
<summary>Gets or sets the string to display in the type column of the debugger variable windows.</summary>
379379
<value>The string to display in the type column of the debugger variable windows.</value>
380-
<remarks>To be added.</remarks>
380+
<remarks>
381+
<format type="text/markdown"><![CDATA[
382+
383+
## Remarks
384+
The value can contain curly braces ({ and }). Text within a pair of braces is evaluated as the name of a field, property, or method. You can also use format specifiers within the braces to control how values are displayed. For information about debugger format specifiers, see [Format Specifiers in C#](/visualstudio/debugger/format-specifiers-in-csharp).
385+
386+
]]></format>
387+
</remarks>
381388
</Docs>
382389
</Member>
383390
<Member MemberName="Value">
@@ -432,9 +439,11 @@ class MyTable
432439
<format type="text/markdown"><![CDATA[
433440
434441
## Remarks
435-
This property contains the string passed in by the `value` parameter of the constructor.
442+
This property contains the string passed in by the `value` parameter of the constructor.
436443
437-
]]></format>
444+
The value can contain curly braces ({ and }). Text within a pair of braces is evaluated as the name of a field, property, or method. You can also use format specifiers within the braces to control how values are displayed. For information about debugger format specifiers, see [Format Specifiers in C#](/visualstudio/debugger/format-specifiers-in-csharp).
445+
446+
]]></format>
438447
</remarks>
439448
</Docs>
440449
</Member>

xml/System.Globalization/CultureInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ The following code example shows that CultureInfo.Clone also clones the <xref:Sy
33783378
The following code example displays several properties of the neutral cultures.
33793379
33803380
> [!NOTE]
3381-
> The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of zh-CHS and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names.
3381+
> The `zh-Hans` and `zh-Hant` names represent the current standard for Chinese cultures. Older applications might reference the legacy `zh-CHS` and `zh-CHT` culture names, but these should be replaced with `zh-Hans` and `zh-Hant` respectively in modern applications.
33823382
33833383
:::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1":::
33843384
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1":::

xml/System.Net.Http/WinHttpHandler.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,20 @@ When this property is set to `true`, all HTTP redirect responses from the server
740740
</ReturnValue>
741741
<Docs>
742742
<summary>Gets or sets a callback method to validate the server certificate. This callback is part of the SSL handshake.</summary>
743-
<value>The callback should return <see langword="true" /> if the server certificate is considered valid and the request should be sent. Otherwise, return <see langword="false" />.</value>
743+
<value>The callback should return <see langword="true" /> if the server certificate is considered valid and the request should be sent. Otherwise, returns <see langword="false" />.</value>
744744
<remarks>
745745
<format type="text/markdown"><![CDATA[
746746
747747
## Remarks
748748
The default value is `null`. If this property is `null`, the server certificate is validated using standard well-known certificate authorities.
749749
750+
The delegate's `sslPolicyErrors` argument contains any certificate errors returned by SSPI while authenticating the server. The <xref:System.Boolean> value returned by this delegate determines whether the authentication is allowed to succeed.
751+
752+
## Examples
753+
754+
The following code example implements the callback. If there are validation errors, this method returns `false` preventing communication with the unauthenticated server. Otherwise, it allows for additional validation and return `true` if the certificate is valid.
755+
756+
:::code language="csharp" source="~/snippets/csharp/System.Net.Http/WinHttpHandler/program.cs" id="Snippet1":::
750757
]]></format>
751758
</remarks>
752759
</Docs>

0 commit comments

Comments
 (0)