ThrowHelper.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. // This file defines an internal class used to throw exceptions in BCL code.
  5. // The main purpose is to reduce code size.
  6. //
  7. // The old way to throw an exception generates quite a lot IL code and assembly code.
  8. // Following is an example:
  9. // C# source
  10. // throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
  11. // IL code:
  12. // IL_0003: ldstr "key"
  13. // IL_0008: ldstr "ArgumentNull_Key"
  14. // IL_000d: call string System.Environment::GetResourceString(string)
  15. // IL_0012: newobj instance void System.ArgumentNullException::.ctor(string,string)
  16. // IL_0017: throw
  17. // which is 21bytes in IL.
  18. //
  19. // So we want to get rid of the ldstr and call to Environment.GetResource in IL.
  20. // In order to do that, I created two enums: ExceptionResource, ExceptionArgument to represent the
  21. // argument name and resource name in a small integer. The source code will be changed to
  22. // ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key, ExceptionResource.ArgumentNull_Key);
  23. //
  24. // The IL code will be 7 bytes.
  25. // IL_0008: ldc.i4.4
  26. // IL_0009: ldc.i4.4
  27. // IL_000a: call void System.ThrowHelper::ThrowArgumentNullException(valuetype System.ExceptionArgument)
  28. // IL_000f: ldarg.0
  29. //
  30. // This will also reduce the Jitted code size a lot.
  31. //
  32. // It is very important we do this for generic classes because we can easily generate the same code
  33. // multiple times for different instantiation.
  34. //
  35. using System.Buffers;
  36. using System.Collections.Generic;
  37. using System.Diagnostics;
  38. using System.Runtime.CompilerServices;
  39. using System.Runtime.Serialization;
  40. namespace System
  41. {
  42. [StackTraceHidden]
  43. internal static class ThrowHelper
  44. {
  45. internal static void ThrowArrayTypeMismatchException()
  46. {
  47. throw new ArrayTypeMismatchException();
  48. }
  49. internal static void ThrowInvalidTypeWithPointersNotSupported(Type targetType)
  50. {
  51. throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeWithPointersNotSupported, targetType));
  52. }
  53. internal static void ThrowIndexOutOfRangeException()
  54. {
  55. throw new IndexOutOfRangeException();
  56. }
  57. internal static void ThrowArgumentOutOfRangeException()
  58. {
  59. throw new ArgumentOutOfRangeException();
  60. }
  61. internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument)
  62. {
  63. throw new ArgumentOutOfRangeException(GetArgumentName(argument));
  64. }
  65. private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
  66. {
  67. return new ArgumentOutOfRangeException(GetArgumentName(argument), GetResourceString(resource));
  68. }
  69. internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
  70. {
  71. throw GetArgumentOutOfRangeException(argument, resource);
  72. }
  73. internal static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index()
  74. {
  75. throw GetArgumentOutOfRangeException(ExceptionArgument.startIndex,
  76. ExceptionResource.ArgumentOutOfRange_Index);
  77. }
  78. internal static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
  79. {
  80. throw GetArgumentOutOfRangeException(ExceptionArgument.count,
  81. ExceptionResource.ArgumentOutOfRange_Count);
  82. }
  83. internal static void ThrowArgumentException_DestinationTooShort()
  84. {
  85. throw new ArgumentException(SR.Argument_DestinationTooShort);
  86. }
  87. internal static void ThrowArgumentException_OverlapAlignmentMismatch()
  88. {
  89. throw new ArgumentException(SR.Argument_OverlapAlignmentMismatch);
  90. }
  91. internal static void ThrowArgumentException_CannotExtractScalar(ExceptionArgument argument)
  92. {
  93. throw GetArgumentException(ExceptionResource.Argument_CannotExtractScalar, argument);
  94. }
  95. internal static void ThrowArgumentOutOfRange_IndexException()
  96. {
  97. throw GetArgumentOutOfRangeException(ExceptionArgument.index,
  98. ExceptionResource.ArgumentOutOfRange_Index);
  99. }
  100. internal static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
  101. {
  102. throw GetArgumentOutOfRangeException(ExceptionArgument.index,
  103. ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
  104. }
  105. internal static void ThrowValueArgumentOutOfRange_NeedNonNegNumException()
  106. {
  107. throw GetArgumentOutOfRangeException(ExceptionArgument.value,
  108. ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
  109. }
  110. private static ArgumentException GetWrongKeyTypeArgumentException(object key, Type targetType)
  111. {
  112. return new ArgumentException(SR.Format(SR.Arg_WrongType, key, targetType), nameof(key));
  113. }
  114. internal static void ThrowWrongKeyTypeArgumentException(object key, Type targetType)
  115. {
  116. throw GetWrongKeyTypeArgumentException(key, targetType);
  117. }
  118. private static ArgumentException GetWrongValueTypeArgumentException(object value, Type targetType)
  119. {
  120. return new ArgumentException(SR.Format(SR.Arg_WrongType, value, targetType), nameof(value));
  121. }
  122. internal static void ThrowWrongValueTypeArgumentException(object value, Type targetType)
  123. {
  124. throw GetWrongValueTypeArgumentException(value, targetType);
  125. }
  126. private static ArgumentException GetAddingDuplicateWithKeyArgumentException(object key)
  127. {
  128. return new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
  129. }
  130. internal static void ThrowAddingDuplicateWithKeyArgumentException(object key)
  131. {
  132. throw GetAddingDuplicateWithKeyArgumentException(key);
  133. }
  134. private static KeyNotFoundException GetKeyNotFoundException(object key)
  135. {
  136. throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
  137. }
  138. internal static void ThrowKeyNotFoundException(object key)
  139. {
  140. throw GetKeyNotFoundException(key);
  141. }
  142. internal static void ThrowArgumentException(ExceptionResource resource)
  143. {
  144. throw new ArgumentException(GetResourceString(resource));
  145. }
  146. private static ArgumentException GetArgumentException(ExceptionResource resource, ExceptionArgument argument)
  147. {
  148. return new ArgumentException(GetResourceString(resource), GetArgumentName(argument));
  149. }
  150. internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
  151. {
  152. throw GetArgumentException(resource, argument);
  153. }
  154. internal static void ThrowAggregateException(List<Exception> exceptions)
  155. {
  156. throw new AggregateException(exceptions);
  157. }
  158. internal static void ThrowArgumentException_Argument_InvalidArrayType()
  159. {
  160. throw new ArgumentException(SR.Argument_InvalidArrayType);
  161. }
  162. internal static void ThrowArgumentNullException(ExceptionArgument argument)
  163. {
  164. throw new ArgumentNullException(GetArgumentName(argument));
  165. }
  166. internal static void ThrowInvalidOperationException(ExceptionResource resource)
  167. {
  168. throw new InvalidOperationException(GetResourceString(resource));
  169. }
  170. internal static void ThrowInvalidOperationException_OutstandingReferences()
  171. {
  172. throw new InvalidOperationException(SR.Memory_OutstandingReferences);
  173. }
  174. internal static void ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
  175. {
  176. throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
  177. }
  178. internal static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
  179. {
  180. throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
  181. }
  182. internal static void ThrowInvalidOperationException_InvalidOperation_EnumNotStarted()
  183. {
  184. throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
  185. }
  186. internal static void ThrowInvalidOperationException_InvalidOperation_EnumEnded()
  187. {
  188. throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
  189. }
  190. internal static void ThrowInvalidOperationException_InvalidOperation_NoValue()
  191. {
  192. throw new InvalidOperationException(SR.InvalidOperation_NoValue);
  193. }
  194. internal static void ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
  195. {
  196. throw new InvalidOperationException(SR.InvalidOperation_ConcurrentOperationsNotSupported);
  197. }
  198. internal static void ThrowSerializationException(ExceptionResource resource)
  199. {
  200. throw new SerializationException(GetResourceString(resource));
  201. }
  202. internal static void ThrowObjectDisposedException(ExceptionResource resource)
  203. {
  204. throw new ObjectDisposedException(null, GetResourceString(resource));
  205. }
  206. internal static void ThrowNotSupportedException()
  207. {
  208. throw new NotSupportedException();
  209. }
  210. internal static void ThrowNotSupportedException(ExceptionResource resource)
  211. {
  212. throw new NotSupportedException(GetResourceString(resource));
  213. }
  214. private static Exception GetArraySegmentCtorValidationFailedException(Array array, int offset, int count)
  215. {
  216. if (array == null)
  217. return new ArgumentNullException(nameof(array));
  218. if (offset < 0)
  219. return new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
  220. if (count < 0)
  221. return new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
  222. Debug.Assert(array.Length - offset < count);
  223. return new ArgumentException(SR.Argument_InvalidOffLen);
  224. }
  225. internal static void ThrowArraySegmentCtorValidationFailedExceptions(Array array, int offset, int count)
  226. {
  227. throw GetArraySegmentCtorValidationFailedException(array, offset, count);
  228. }
  229. internal static void ThrowFormatException_BadFormatSpecifier()
  230. {
  231. throw new FormatException(SR.Argument_BadFormatSpecifier);
  232. }
  233. internal static void ThrowArgumentOutOfRangeException_PrecisionTooLarge()
  234. {
  235. throw new ArgumentOutOfRangeException("precision", SR.Format(SR.Argument_PrecisionTooLarge, StandardFormat.MaxPrecision));
  236. }
  237. internal static void ThrowArgumentOutOfRangeException_SymbolDoesNotFit()
  238. {
  239. throw new ArgumentOutOfRangeException("symbol", SR.Argument_BadFormatSpecifier);
  240. }
  241. // Allow nulls for reference types and Nullable<U>, but not for value types.
  242. // Aggressively inline so the jit evaluates the if in place and either drops the call altogether
  243. // Or just leaves null test and call to the Non-returning ThrowHelper.ThrowArgumentNullException
  244. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  245. internal static void IfNullAndNullsAreIllegalThenThrow<T>(object value, ExceptionArgument argName)
  246. {
  247. // Note that default(T) is not equal to null for value types except when T is Nullable<U>.
  248. if (!(default(T) == null) && value == null)
  249. ThrowHelper.ThrowArgumentNullException(argName);
  250. }
  251. private static string GetArgumentName(ExceptionArgument argument)
  252. {
  253. switch (argument)
  254. {
  255. case ExceptionArgument.obj:
  256. return "obj";
  257. case ExceptionArgument.dictionary:
  258. return "dictionary";
  259. case ExceptionArgument.array:
  260. return "array";
  261. case ExceptionArgument.info:
  262. return "info";
  263. case ExceptionArgument.key:
  264. return "key";
  265. case ExceptionArgument.text:
  266. return "text";
  267. case ExceptionArgument.values:
  268. return "values";
  269. case ExceptionArgument.value:
  270. return "value";
  271. case ExceptionArgument.startIndex:
  272. return "startIndex";
  273. case ExceptionArgument.task:
  274. return "task";
  275. case ExceptionArgument.ch:
  276. return "ch";
  277. case ExceptionArgument.s:
  278. return "s";
  279. case ExceptionArgument.input:
  280. return "input";
  281. case ExceptionArgument.ownedMemory:
  282. return "ownedMemory";
  283. case ExceptionArgument.list:
  284. return "list";
  285. case ExceptionArgument.index:
  286. return "index";
  287. case ExceptionArgument.capacity:
  288. return "capacity";
  289. case ExceptionArgument.collection:
  290. return "collection";
  291. case ExceptionArgument.item:
  292. return "item";
  293. case ExceptionArgument.converter:
  294. return "converter";
  295. case ExceptionArgument.match:
  296. return "match";
  297. case ExceptionArgument.count:
  298. return "count";
  299. case ExceptionArgument.action:
  300. return "action";
  301. case ExceptionArgument.comparison:
  302. return "comparison";
  303. case ExceptionArgument.exceptions:
  304. return "exceptions";
  305. case ExceptionArgument.exception:
  306. return "exception";
  307. case ExceptionArgument.pointer:
  308. return "pointer";
  309. case ExceptionArgument.start:
  310. return "start";
  311. case ExceptionArgument.format:
  312. return "format";
  313. case ExceptionArgument.culture:
  314. return "culture";
  315. case ExceptionArgument.comparer:
  316. return "comparer";
  317. case ExceptionArgument.comparable:
  318. return "comparable";
  319. case ExceptionArgument.source:
  320. return "source";
  321. case ExceptionArgument.state:
  322. return "state";
  323. case ExceptionArgument.length:
  324. return "length";
  325. case ExceptionArgument.comparisonType:
  326. return "comparisonType";
  327. case ExceptionArgument.manager:
  328. return "manager";
  329. case ExceptionArgument.sourceBytesToCopy:
  330. return "sourceBytesToCopy";
  331. case ExceptionArgument.callBack:
  332. return "callBack";
  333. case ExceptionArgument.creationOptions:
  334. return "creationOptions";
  335. case ExceptionArgument.function:
  336. return "function";
  337. case ExceptionArgument.scheduler:
  338. return "scheduler";
  339. case ExceptionArgument.continuationAction:
  340. return "continuationAction";
  341. case ExceptionArgument.continuationFunction:
  342. return "continuationFunction";
  343. case ExceptionArgument.tasks:
  344. return "tasks";
  345. case ExceptionArgument.asyncResult:
  346. return "asyncResult";
  347. case ExceptionArgument.beginMethod:
  348. return "beginMethod";
  349. case ExceptionArgument.endMethod:
  350. return "endMethod";
  351. case ExceptionArgument.endFunction:
  352. return "endFunction";
  353. case ExceptionArgument.cancellationToken:
  354. return "cancellationToken";
  355. case ExceptionArgument.continuationOptions:
  356. return "continuationOptions";
  357. case ExceptionArgument.delay:
  358. return "delay";
  359. case ExceptionArgument.millisecondsDelay:
  360. return "millisecondsDelay";
  361. case ExceptionArgument.millisecondsTimeout:
  362. return "millisecondsTimeout";
  363. case ExceptionArgument.stateMachine:
  364. return "stateMachine";
  365. case ExceptionArgument.timeout:
  366. return "timeout";
  367. default:
  368. Debug.Fail("The enum value is not defined, please check the ExceptionArgument Enum.");
  369. return "";
  370. }
  371. }
  372. private static string GetResourceString(ExceptionResource resource)
  373. {
  374. switch (resource)
  375. {
  376. case ExceptionResource.Argument_InvalidArgumentForComparison:
  377. return SR.Argument_InvalidArgumentForComparison;
  378. case ExceptionResource.ArgumentOutOfRange_Index:
  379. return SR.ArgumentOutOfRange_Index;
  380. case ExceptionResource.ArgumentOutOfRange_Count:
  381. return SR.ArgumentOutOfRange_Count;
  382. case ExceptionResource.Arg_ArrayPlusOffTooSmall:
  383. return SR.Arg_ArrayPlusOffTooSmall;
  384. case ExceptionResource.NotSupported_ReadOnlyCollection:
  385. return SR.NotSupported_ReadOnlyCollection;
  386. case ExceptionResource.Arg_RankMultiDimNotSupported:
  387. return SR.Arg_RankMultiDimNotSupported;
  388. case ExceptionResource.Arg_NonZeroLowerBound:
  389. return SR.Arg_NonZeroLowerBound;
  390. case ExceptionResource.ArgumentOutOfRange_ListInsert:
  391. return SR.ArgumentOutOfRange_ListInsert;
  392. case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
  393. return SR.ArgumentOutOfRange_NeedNonNegNum;
  394. case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
  395. return SR.ArgumentOutOfRange_SmallCapacity;
  396. case ExceptionResource.Argument_InvalidOffLen:
  397. return SR.Argument_InvalidOffLen;
  398. case ExceptionResource.Argument_CannotExtractScalar:
  399. return SR.Argument_CannotExtractScalar;
  400. case ExceptionResource.ArgumentOutOfRange_BiggerThanCollection:
  401. return SR.ArgumentOutOfRange_BiggerThanCollection;
  402. case ExceptionResource.Serialization_MissingKeys:
  403. return SR.Serialization_MissingKeys;
  404. case ExceptionResource.Serialization_NullKey:
  405. return SR.Serialization_NullKey;
  406. case ExceptionResource.NotSupported_KeyCollectionSet:
  407. return SR.NotSupported_KeyCollectionSet;
  408. case ExceptionResource.NotSupported_ValueCollectionSet:
  409. return SR.NotSupported_ValueCollectionSet;
  410. case ExceptionResource.InvalidOperation_NullArray:
  411. return SR.InvalidOperation_NullArray;
  412. case ExceptionResource.TaskT_TransitionToFinal_AlreadyCompleted:
  413. return SR.TaskT_TransitionToFinal_AlreadyCompleted;
  414. case ExceptionResource.TaskCompletionSourceT_TrySetException_NullException:
  415. return SR.TaskCompletionSourceT_TrySetException_NullException;
  416. case ExceptionResource.TaskCompletionSourceT_TrySetException_NoExceptions:
  417. return SR.TaskCompletionSourceT_TrySetException_NoExceptions;
  418. case ExceptionResource.NotSupported_StringComparison:
  419. return SR.NotSupported_StringComparison;
  420. case ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported:
  421. return SR.ConcurrentCollection_SyncRoot_NotSupported;
  422. case ExceptionResource.Task_MultiTaskContinuation_NullTask:
  423. return SR.Task_MultiTaskContinuation_NullTask;
  424. case ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple:
  425. return SR.InvalidOperation_WrongAsyncResultOrEndCalledMultiple;
  426. case ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList:
  427. return SR.Task_MultiTaskContinuation_EmptyTaskList;
  428. case ExceptionResource.Task_Start_TaskCompleted:
  429. return SR.Task_Start_TaskCompleted;
  430. case ExceptionResource.Task_Start_Promise:
  431. return SR.Task_Start_Promise;
  432. case ExceptionResource.Task_Start_ContinuationTask:
  433. return SR.Task_Start_ContinuationTask;
  434. case ExceptionResource.Task_Start_AlreadyStarted:
  435. return SR.Task_Start_AlreadyStarted;
  436. case ExceptionResource.Task_RunSynchronously_Continuation:
  437. return SR.Task_RunSynchronously_Continuation;
  438. case ExceptionResource.Task_RunSynchronously_Promise:
  439. return SR.Task_RunSynchronously_Promise;
  440. case ExceptionResource.Task_RunSynchronously_TaskCompleted:
  441. return SR.Task_RunSynchronously_TaskCompleted;
  442. case ExceptionResource.Task_RunSynchronously_AlreadyStarted:
  443. return SR.Task_RunSynchronously_AlreadyStarted;
  444. case ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized:
  445. return SR.AsyncMethodBuilder_InstanceNotInitialized;
  446. case ExceptionResource.Task_ContinueWith_ESandLR:
  447. return SR.Task_ContinueWith_ESandLR;
  448. case ExceptionResource.Task_ContinueWith_NotOnAnything:
  449. return SR.Task_ContinueWith_NotOnAnything;
  450. case ExceptionResource.Task_Delay_InvalidDelay:
  451. return SR.Task_Delay_InvalidDelay;
  452. case ExceptionResource.Task_Delay_InvalidMillisecondsDelay:
  453. return SR.Task_Delay_InvalidMillisecondsDelay;
  454. case ExceptionResource.Task_Dispose_NotCompleted:
  455. return SR.Task_Dispose_NotCompleted;
  456. case ExceptionResource.Task_ThrowIfDisposed:
  457. return SR.Task_ThrowIfDisposed;
  458. case ExceptionResource.Task_WaitMulti_NullTask:
  459. return SR.Task_WaitMulti_NullTask;
  460. default:
  461. Debug.Assert(false,
  462. "The enum value is not defined, please check the ExceptionResource Enum.");
  463. return "";
  464. }
  465. }
  466. }
  467. //
  468. // The convention for this enum is using the argument name as the enum name
  469. //
  470. internal enum ExceptionArgument
  471. {
  472. obj,
  473. dictionary,
  474. array,
  475. info,
  476. key,
  477. text,
  478. values,
  479. value,
  480. startIndex,
  481. task,
  482. ch,
  483. s,
  484. input,
  485. ownedMemory,
  486. list,
  487. index,
  488. capacity,
  489. collection,
  490. item,
  491. converter,
  492. match,
  493. count,
  494. action,
  495. comparison,
  496. exceptions,
  497. exception,
  498. pointer,
  499. start,
  500. format,
  501. culture,
  502. comparer,
  503. comparable,
  504. source,
  505. state,
  506. length,
  507. comparisonType,
  508. manager,
  509. sourceBytesToCopy,
  510. callBack,
  511. creationOptions,
  512. function,
  513. scheduler,
  514. continuationAction,
  515. continuationFunction,
  516. tasks,
  517. asyncResult,
  518. beginMethod,
  519. endMethod,
  520. endFunction,
  521. cancellationToken,
  522. continuationOptions,
  523. delay,
  524. millisecondsDelay,
  525. millisecondsTimeout,
  526. stateMachine,
  527. timeout,
  528. }
  529. //
  530. // The convention for this enum is using the resource name as the enum name
  531. //
  532. internal enum ExceptionResource
  533. {
  534. Argument_InvalidArgumentForComparison,
  535. ArgumentOutOfRange_Index,
  536. ArgumentOutOfRange_Count,
  537. Arg_ArrayPlusOffTooSmall,
  538. NotSupported_ReadOnlyCollection,
  539. Arg_RankMultiDimNotSupported,
  540. Arg_NonZeroLowerBound,
  541. ArgumentOutOfRange_ListInsert,
  542. ArgumentOutOfRange_NeedNonNegNum,
  543. ArgumentOutOfRange_SmallCapacity,
  544. Argument_InvalidOffLen,
  545. Argument_CannotExtractScalar,
  546. ArgumentOutOfRange_BiggerThanCollection,
  547. Serialization_MissingKeys,
  548. Serialization_NullKey,
  549. NotSupported_KeyCollectionSet,
  550. NotSupported_ValueCollectionSet,
  551. InvalidOperation_NullArray,
  552. TaskT_TransitionToFinal_AlreadyCompleted,
  553. TaskCompletionSourceT_TrySetException_NullException,
  554. TaskCompletionSourceT_TrySetException_NoExceptions,
  555. NotSupported_StringComparison,
  556. ConcurrentCollection_SyncRoot_NotSupported,
  557. Task_MultiTaskContinuation_NullTask,
  558. InvalidOperation_WrongAsyncResultOrEndCalledMultiple,
  559. Task_MultiTaskContinuation_EmptyTaskList,
  560. Task_Start_TaskCompleted,
  561. Task_Start_Promise,
  562. Task_Start_ContinuationTask,
  563. Task_Start_AlreadyStarted,
  564. Task_RunSynchronously_Continuation,
  565. Task_RunSynchronously_Promise,
  566. Task_RunSynchronously_TaskCompleted,
  567. Task_RunSynchronously_AlreadyStarted,
  568. AsyncMethodBuilder_InstanceNotInitialized,
  569. Task_ContinueWith_ESandLR,
  570. Task_ContinueWith_NotOnAnything,
  571. Task_Delay_InvalidDelay,
  572. Task_Delay_InvalidMillisecondsDelay,
  573. Task_Dispose_NotCompleted,
  574. Task_ThrowIfDisposed,
  575. Task_WaitMulti_NullTask,
  576. }
  577. }