Commit 003e43b
committed
Add/use ArgumentException.ThrowIfNullOrEmpty
Adds ArgumentException.ThrowIfNullOrEmpty and then uses it in a bunch of places around the tree. Most of the replaced places used a resource string for the message, and I used it in places where it didn't feel like we were losing any meaningful information by centralizing on the single shared string, but I didn't use it in places where the resource string message used in the empty case conveyed something that seemed useful, e.g. a recommendation on what to use instead of an empty string.
There are a few places where I allowed for order of exception throws to change in the case where there were multiple user errors and the validation for a single argument was split, e.g. I changed a few cases of:
```C#
if (arg1 is null) throw new ArgumentNullException(...);
if (arg2 is null) throw new ArgumentNullException(...);
if (arg1.Length == 0) throw new ArgumentException(...);
if (arg2.Length == 0) throw new ArgumentException(...);
```
to:
```C#
ArgumentException.ThrowIfNullOrEmpty(arg1);
ArgumentException.ThrowIfNullOrEmpty(arg2);
```
even though it'll produce a different exception for `M("", null)` than it would previously. Technically a breaking change, but given this is a case of multiple usage errors and all the exceptions are ArgumentException-based, I think it's acceptable.
I wanted to get this in before we do the massive !! conversion, as I expect !! auto-fixes will make it a bit harder to roll this out. I explicitly did not do anything to roll out use of ArgumentNullException.ThrowIfNull, except in cases where I was modifying a method to use ArgumentException.ThrowIfNullOrEmpty, in which case for consistency I changed anything else in the function that could have been using ThrowIfNull to do so.1 parent 1092617 commit 003e43b
136 files changed
Lines changed: 553 additions & 1462 deletions
File tree
- src
- coreclr/System.Private.CoreLib/src/System
- Reflection/Emit
- libraries
- Common
- src/System/Security/Cryptography
- tests/System/Security/Cryptography/AlgorithmImplementations
- DSA
- ECDsa
- RSA
- System.ComponentModel.TypeConverter/src
- Resources
- System/ComponentModel
- System.Diagnostics.Process
- src
- Resources
- System/Diagnostics
- tests
- System.Diagnostics.TextWriterTraceListener
- src
- Resources
- System/Diagnostics
- tests
- System.Diagnostics.TraceSource/src
- Resources
- System/Diagnostics
- System.IO.FileSystem.AccessControl/src
- Resources
- System/IO
- System.IO.IsolatedStorage/src
- Resources
- System/IO/IsolatedStorage
- System.IO.MemoryMappedFiles
- src
- Resources
- System/IO/MemoryMappedFiles
- tests
- System.IO.Pipes
- src
- Resources
- System/IO/Pipes
- tests/NamedPipeTests
- System.IO/tests
- StreamReader
- StreamWriter
- System.Net.Mail/src
- Resources
- System/Net
- Mail
- Mime
- System.Net.Primitives
- src/System/Net
- tests/FunctionalTests
- System.Net.Security
- src
- Resources
- System/Security/Authentication/ExtendedProtection
- tests/FunctionalTests
- System.Net.WebHeaderCollection/src
- Resources
- System/Net
- System.Private.CoreLib/src
- Resources
- System
- Globalization
- IO
- Strategies
- Runtime
- InteropServices
- Loader
- Versioning
- Text
- Threading
- System.Private.Xml.Linq
- src
- Resources
- System/Xml/Linq
- tests
- SDMSample
- Streaming
- axes
- System.Private.Xml/src
- Resources
- System/Xml/Core
- System.Reflection/tests
- System.Runtime
- ref
- tests/System
- System.Security.Cryptography.Cng/src
- Resources
- System/Security/Cryptography
- System.Security.Cryptography.Csp/src
- Resources
- System/Security/Cryptography
- System.Security.Cryptography.OpenSsl/src/Resources
- System.Security.Cryptography.X509Certificates
- src
- Resources
- System/Security/Cryptography/X509Certificates
- tests/CertificateCreation
- System.Security.Cryptography
- src/System/Security/Cryptography
- tests
- System.Security.Principal.Windows/src
- Resources
- System/Security/Principal
- System.Text.RegularExpressions/src/System/Text/RegularExpressions
- mono/System.Private.CoreLib/src/System/Reflection
- Emit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 317 | + | |
325 | 318 | | |
326 | 319 | | |
327 | 320 | | |
| |||
467 | 460 | | |
468 | 461 | | |
469 | 462 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 463 | + | |
478 | 464 | | |
479 | 465 | | |
480 | 466 | | |
| |||
Lines changed: 2 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 23 | + | |
28 | 24 | | |
29 | 25 | | |
30 | 26 | | |
31 | 27 | | |
32 | | - | |
33 | | - | |
| 28 | + | |
34 | 29 | | |
35 | 30 | | |
36 | 31 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
| 1276 | + | |
1281 | 1277 | | |
1282 | 1278 | | |
1283 | 1279 | | |
| |||
Lines changed: 3 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 64 | + | |
69 | 65 | | |
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
73 | | - | |
74 | | - | |
| 69 | + | |
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
80 | | - | |
81 | | - | |
| 75 | + | |
82 | 76 | | |
83 | 77 | | |
84 | 78 | | |
| |||
Lines changed: 3 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
948 | 948 | | |
949 | 949 | | |
950 | 950 | | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
| 951 | + | |
959 | 952 | | |
960 | 953 | | |
961 | 954 | | |
| |||
1352 | 1345 | | |
1353 | 1346 | | |
1354 | 1347 | | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | | - | |
| 1348 | + | |
| 1349 | + | |
1367 | 1350 | | |
1368 | 1351 | | |
1369 | 1352 | | |
| |||
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 37 | + | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
| |||
Lines changed: 8 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
| 483 | + | |
488 | 484 | | |
489 | 485 | | |
490 | 486 | | |
| |||
581 | 577 | | |
582 | 578 | | |
583 | 579 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 580 | + | |
589 | 581 | | |
590 | 582 | | |
591 | 583 | | |
| |||
1282 | 1274 | | |
1283 | 1275 | | |
1284 | 1276 | | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
| 1277 | + | |
1290 | 1278 | | |
1291 | 1279 | | |
1292 | 1280 | | |
| |||
1374 | 1362 | | |
1375 | 1363 | | |
1376 | 1364 | | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
1392 | | - | |
1393 | | - | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
1394 | 1368 | | |
1395 | 1369 | | |
1396 | 1370 | | |
| |||
1792 | 1766 | | |
1793 | 1767 | | |
1794 | 1768 | | |
1795 | | - | |
1796 | | - | |
1797 | | - | |
1798 | | - | |
| 1769 | + | |
1799 | 1770 | | |
1800 | 1771 | | |
1801 | 1772 | | |
| |||
1847 | 1818 | | |
1848 | 1819 | | |
1849 | 1820 | | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
| 1821 | + | |
1854 | 1822 | | |
1855 | 1823 | | |
1856 | 1824 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
562 | | - | |
| 561 | + | |
563 | 562 | | |
564 | 563 | | |
565 | 564 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
| 27 | + | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
| |||
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
| 80 | + | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
| |||
99 | 97 | | |
100 | 98 | | |
101 | 99 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 100 | + | |
| 101 | + | |
106 | 102 | | |
107 | 103 | | |
108 | 104 | | |
| |||
0 commit comments