Skip to content

Commit c85894d

Browse files
authored
fix various issues in response to UUF feedback (#10138)
1 parent d1f05ab commit c85894d

File tree

10 files changed

+142
-129
lines changed

10 files changed

+142
-129
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<StartupObject>Example1</StartupObject>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// <Snippet1>
2-
using System;
1+
using System;
32
using System.Text.RegularExpressions;
43

5-
public class Example
4+
public class Example1
65
{
7-
public static void Main()
8-
{
9-
string[] partNumbers= { "1298-673-4192", "A08Z-931-468A",
10-
"_A90-123-129X", "12345-KKA-1230",
11-
"0919-2893-1256" };
12-
string pattern = @"^[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$";
13-
foreach (string partNumber in partNumbers)
14-
Console.WriteLine("{0} {1} a valid part number.",
15-
partNumber,
16-
Regex.IsMatch(partNumber, pattern) ? "is" : "is not");
17-
}
6+
public static void Main()
7+
{
8+
// <Snippet1>
9+
string[] partNumbers = [ "1298-673-4192", "A08Z-931-468A",
10+
"_A90-123-129X", "12345-KKA-1230",
11+
"0919-2893-1256" ];
12+
string pattern = @"^[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$";
13+
foreach (string partNumber in partNumbers)
14+
Console.WriteLine($"{partNumber} {(Regex.IsMatch(partNumber, pattern) ? "is" : "is not")} " +
15+
$"a valid part number.");
16+
17+
// The example displays the following output:
18+
// 1298-673-4192 is a valid part number.
19+
// A08Z-931-468A is a valid part number.
20+
// _A90-123-129X is not a valid part number.
21+
// 12345-KKA-1230 is not a valid part number.
22+
// 0919-2893-1256 is not a valid part number.
23+
// </Snippet1>
24+
}
1825
}
19-
// The example displays the following output:
20-
// 1298-673-4192 is a valid part number.
21-
// A08Z-931-468A is a valid part number.
22-
// _A90-123-129X is not a valid part number.
23-
// 12345-KKA-1230 is not a valid part number.
24-
// 0919-2893-1256 is not a valid part number.
25-
// </Snippet1>
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// <Snippet2>
2-
using System;
1+
using System;
32
using System.Text.RegularExpressions;
43

5-
public class Example
4+
public class Example2
65
{
7-
public static void Main()
8-
{
9-
string[] partNumbers= { "1298-673-4192", "A08Z-931-468A",
10-
"_A90-123-129X", "12345-KKA-1230",
11-
"0919-2893-1256" };
12-
Regex rgx = new Regex(@"^[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$");
13-
foreach (string partNumber in partNumbers)
14-
Console.WriteLine("{0} {1} a valid part number.",
15-
partNumber,
16-
rgx.IsMatch(partNumber) ? "is" : "is not");
17-
}
6+
public static void Main()
7+
{
8+
// <Snippet2>
9+
string[] partNumbers = [ "1298-673-4192", "A08Z-931-468A",
10+
"_A90-123-129X", "12345-KKA-1230",
11+
"0919-2893-1256" ];
12+
Regex rgx = new Regex(@"^[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$");
13+
foreach (string partNumber in partNumbers)
14+
Console.WriteLine($"{partNumber} {(rgx.IsMatch(partNumber) ? "is" : "is not")} a valid part number.");
15+
16+
// The example displays the following output:
17+
// 1298-673-4192 is a valid part number.
18+
// A08Z-931-468A is a valid part number.
19+
// _A90-123-129X is not a valid part number.
20+
// 12345-KKA-1230 is not a valid part number.
21+
// 0919-2893-1256 is not a valid part number.
22+
// </Snippet2>
23+
}
1824
}
19-
// The example displays the following output:
20-
// 1298-673-4192 is a valid part number.
21-
// A08Z-931-468A is a valid part number.
22-
// _A90-123-129X is not a valid part number.
23-
// 12345-KKA-1230 is not a valid part number.
24-
// 0919-2893-1256 is not a valid part number.
25-
// </Snippet2>
25+
Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
1-
// <Snippet3>
1+

22
using System;
33
using System.Text.RegularExpressions;
44

5-
public class Example
5+
public partial class Example3
66
{
7-
public static void Main()
8-
{
9-
string[] partNumbers= { "Part Number: 1298-673-4192", "Part No: A08Z-931-468A",
10-
"_A90-123-129X", "123K-000-1230",
11-
"SKU: 0919-2893-1256" };
12-
Regex rgx = new Regex(@"[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$");
13-
foreach (string partNumber in partNumbers)
14-
{
15-
int start = partNumber.IndexOf(':');
16-
if (start >= 0)
17-
{
18-
Console.WriteLine("{0} {1} a valid part number.",
19-
partNumber,
20-
rgx.IsMatch(partNumber, start) ? "is" : "is not");
21-
}
22-
else
23-
{
24-
Console.WriteLine("Cannot find starting position in {0}.", partNumber);
25-
}
26-
}
27-
}
7+
public static void Main()
8+
{
9+
// <Snippet3>
10+
string[] partNumbers = [ "Part Number: 1298-673-4192", "Part No: A08Z-931-468A",
11+
"_A90-123-129X", "123K-000-1230",
12+
"SKU: 0919-2893-1256" ];
13+
Regex rgx = MyRegex();
14+
foreach (string partNumber in partNumbers)
15+
{
16+
int start = partNumber.IndexOf(':');
17+
if (start >= 0)
18+
{
19+
Console.WriteLine($"{partNumber} {(rgx.IsMatch(partNumber, start) ? "is" : "is not")} a valid part number.");
20+
}
21+
else
22+
{
23+
Console.WriteLine("Cannot find starting position in {0}.", partNumber);
24+
}
25+
}
26+
27+
// The example displays the following output:
28+
// Part Number: 1298-673-4192 is a valid part number.
29+
// Part No: A08Z-931-468A is a valid part number.
30+
// Cannot find starting position in _A90-123-129X.
31+
// Cannot find starting position in 123K-000-1230.
32+
// SKU: 0919-2893-1256 is not a valid part number.
33+
// </Snippet3>
34+
}
35+
36+
[GeneratedRegex(@"[a-zA-Z0-9]\d{2}[a-zA-Z0-9](-\d{3}){2}[A-Za-z0-9]$")]
37+
private static partial Regex MyRegex();
2838
}
29-
// The example displays the following output:
30-
// Part Number: 1298-673-4192 is a valid part number.
31-
// Part No: A08Z-931-468A is a valid part number.
32-
// Cannot find starting position in _A90-123-129X.
33-
// Cannot find starting position in 123K-000-1230.
34-
// SKU: 0919-2893-1256 is not a valid part number.
35-
// </Snippet3>
39+
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
// <Snippet4>
2-
using System;
1+
using System;
32
using System.Text.RegularExpressions;
43

5-
public class Example
4+
public class Example4
65
{
7-
public static void Main()
8-
{
9-
string[] partNumbers= { "1298-673-4192", "A08Z-931-468a",
10-
"_A90-123-129X", "12345-KKA-1230",
11-
"0919-2893-1256" };
12-
string pattern = @"^[A-Z0-9]\d{2}[A-Z0-9](-\d{3}){2}[A-Z0-9]$";
13-
foreach (string partNumber in partNumbers)
14-
Console.WriteLine("{0} {1} a valid part number.",
15-
partNumber,
16-
Regex.IsMatch(partNumber, pattern, RegexOptions.IgnoreCase)
17-
? "is" : "is not");
18-
}
6+
public static void Main()
7+
{
8+
// <Snippet4>
9+
string[] partNumbers = [ "1298-673-4192", "A08Z-931-468a",
10+
"_A90-123-129X", "12345-KKA-1230",
11+
"0919-2893-1256" ];
12+
string pattern = @"^[A-Z0-9]\d{2}[A-Z0-9](-\d{3}){2}[A-Z0-9]$";
13+
foreach (string partNumber in partNumbers)
14+
Console.WriteLine("{0} {1} a valid part number.",
15+
partNumber,
16+
Regex.IsMatch(partNumber, pattern, RegexOptions.IgnoreCase) ? "is" : "is not");
17+
18+
// The example displays the following output:
19+
// 1298-673-4192 is a valid part number.
20+
// A08Z-931-468a is a valid part number.
21+
// _A90-123-129X is not a valid part number.
22+
// 12345-KKA-1230 is not a valid part number.
23+
// 0919-2893-1256 is not a valid part number.
24+
// </Snippet4>
25+
}
1926
}
20-
// The example displays the following output:
21-
// 1298-673-4192 is a valid part number.
22-
// A08Z-931-468a is a valid part number.
23-
// _A90-123-129X is not a valid part number.
24-
// 12345-KKA-1230 is not a valid part number.
25-
// 0919-2893-1256 is not a valid part number.
26-
// </Snippet4>
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
// <Snippet5>
2-
using System;
1+
using System;
32
using System.Text.RegularExpressions;
43

5-
public class Example
4+
public class Example5
65
{
7-
public static void Main()
8-
{
9-
string[] partNumbers= { "1298-673-4192", "A08Z-931-468a",
10-
"_A90-123-129X", "12345-KKA-1230",
11-
"0919-2893-1256" };
12-
string pattern = @"^[A-Z0-9]\d{2}[A-Z0-9](-\d{3}){2}[A-Z0-9]$";
13-
foreach (string partNumber in partNumbers)
14-
try {
15-
Console.WriteLine("{0} {1} a valid part number.",
16-
partNumber,
17-
Regex.IsMatch(partNumber, pattern, RegexOptions.IgnoreCase)
18-
? "is" : "is not", TimeSpan.FromMilliseconds(500));
19-
}
20-
catch (RegexMatchTimeoutException e) {
21-
Console.WriteLine("Timeout after {0} seconds matching {1}.",
22-
e.MatchTimeout, e.Input);
23-
}
24-
}
6+
public static void Main()
7+
{
8+
// <Snippet5>
9+
string[] partNumbers = [ "1298-673-4192", "A08Z-931-468a",
10+
"_A90-123-129X", "12345-KKA-1230",
11+
"0919-2893-1256" ];
12+
string pattern = @"^[A-Z0-9]\d{2}[A-Z0-9](-\d{3}){2}[A-Z0-9]$";
13+
foreach (string partNumber in partNumbers)
14+
try
15+
{
16+
bool isMatch = Regex.IsMatch(partNumber, pattern, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(500));
17+
Console.WriteLine($"{partNumber} {(isMatch ? "is" : "is not")} a valid part number.");
18+
}
19+
catch (RegexMatchTimeoutException e)
20+
{
21+
Console.WriteLine($"Timeout after {e.MatchTimeout} seconds matching {e.Input}.");
22+
}
23+
24+
// The example displays the following output:
25+
// 1298-673-4192 is a valid part number.
26+
// A08Z-931-468a is a valid part number.
27+
// _A90-123-129X is not a valid part number.
28+
// 12345-KKA-1230 is not a valid part number.
29+
// 0919-2893-1256 is not a valid part number.
30+
// </Snippet5>
31+
}
2532
}
26-
// The example displays the following output:
27-
// 1298-673-4192 is a valid part number.
28-
// A08Z-931-468a is a valid part number.
29-
// _A90-123-129X is not a valid part number.
30-
// 12345-KKA-1230 is not a valid part number.
31-
// 0919-2893-1256 is not a valid part number.
32-
// </Snippet5>
33+

xml/System.Net/HttpWebRequest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ Both <xref:System.Net.HttpWebRequest> constructors are obsolete and should not b
25792579
</ReturnValue>
25802580
<Docs>
25812581
<summary>Gets or sets the default maximum length of an HTTP error response.</summary>
2582-
<value>The default maximum length of an HTTP error response.</value>
2582+
<value>The default maximum length, in kilobytes (1024 bytes), of an HTTP error response.</value>
25832583
<remarks>To be added.</remarks>
25842584
<exception cref="T:System.ArgumentOutOfRangeException">The value is less than 0 and is not equal to -1.</exception>
25852585
</Docs>

xml/System.Windows.Forms/DataGridView.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3594,7 +3594,7 @@ The <xref:System.Windows.Forms.DataGridView> control replaces and extends the <x
35943594
<ReturnType>System.Windows.Forms.QuestionEventHandler</ReturnType>
35953595
</ReturnValue>
35963596
<Docs>
3597-
<summary>Occurs when the <see cref="P:System.Windows.Forms.DataGridView.VirtualMode" /> property of a <see cref="T:System.Windows.Forms.DataGridView" /> control is <see langword="true" /> and the cancels edits in a row.</summary>
3597+
<summary>Occurs when the <see cref="P:System.Windows.Forms.DataGridView.VirtualMode" /> property of a <see cref="T:System.Windows.Forms.DataGridView" /> control is <see langword="true" /> and the user cancels edits in a row.</summary>
35983598
<remarks>
35993599
<format type="text/markdown"><![CDATA[
36003600

xml/System/Char.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,8 +1631,7 @@ This determines whether the character is in the range 'a' through 'z', inclusive
16311631

16321632
## Remarks
16331633

1634-
This determines whether the character is in the range 'A' through 'Z', inclusive,
1635-
'a' through 'z', inclusive, or '0' through '9', inclusive.
1634+
This determines whether the character is in the range 'A' through 'Z', inclusive, 'a' through 'z', inclusive, or '0' through '9', inclusive.
16361635

16371636
]]></format>
16381637
</remarks>
@@ -1668,13 +1667,13 @@ This determines whether the character is in the range 'A' through 'Z', inclusive
16681667
<param name="c">The character to evaluate.</param>
16691668
<summary>Indicates whether a character is categorized as an uppercase ASCII letter.</summary>
16701669
<returns>
1671-
<see langword="true" /> if <paramref name="c" /> is a lowercase ASCII letter; otherwise, <see langword="false" />.</returns>
1670+
<see langword="true" /> if <paramref name="c" /> is an uppercase ASCII letter; otherwise, <see langword="false" />.</returns>
16721671
<remarks>
16731672
<format type="text/markdown"><![CDATA[
16741673

16751674
## Remarks
16761675

1677-
This determines whether the character is in the range 'a' through 'z', inclusive.
1676+
This determines whether the character is in the range 'A' through 'Z', inclusive.
16781677

16791678
]]></format>
16801679
</remarks>

xml/System/Decimal.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7133,7 +7133,7 @@ It is recommended that a function return `1`, `0`, and `-1`, respectively.
71337133
<Docs>
71347134
<param name="d1">The minuend.</param>
71357135
<param name="d2">The subtrahend.</param>
7136-
<summary>Subtracts one specified <see cref="T:System.Decimal" /> value from another.</summary>
7136+
<summary>Subtracts a specified <see cref="T:System.Decimal" /> value from another.</summary>
71377137
<returns>The result of subtracting <paramref name="d2" /> from <paramref name="d1" />.</returns>
71387138
<remarks>
71397139
<format type="text/markdown"><![CDATA[

0 commit comments

Comments
 (0)