Skip to content

Commit b0dabad

Browse files
committed
Fix the build for VS2022 by altering the arguments to ArgumentException
Why: Currently this project does not build for users of VS2022 because of CA2208.
1 parent 550b183 commit b0dabad

File tree

1 file changed

+3
-2
lines changed
  • samples/snippets/core/testing/unit-testing-best-practices/csharp/unit-testing-best-practices

1 file changed

+3
-2
lines changed

samples/snippets/core/testing/unit-testing-best-practices/csharp/unit-testing-best-practices/StringCalculator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public int Add(string numbers)
1010
{
1111
if (numbers == null)
1212
{
13-
throw new ArgumentException(nameof(numbers));
13+
throw new ArgumentNullException(nameof(numbers));
1414
}
1515

1616
int result;
@@ -49,7 +49,8 @@ private static int HandleSingleNumber(string number)
4949
var result = int.TryParse(number, out var parsedNumber);
5050
if (result == false)
5151
{
52-
throw new ArgumentException(nameof(number));
52+
throw new ArgumentException(
53+
$"Unable to parse {nameof(number)} as an Int32.", nameof(number));
5354
}
5455

5556
return parsedNumber;

0 commit comments

Comments
 (0)