@@ -9,7 +9,8 @@ namespace KZDev.PerfUtils.Helpers;
99
1010//################################################################################
1111/// <summary>
12- /// Helper class for throwing exceptions.
12+ /// Centralizes throwing common argument, state, and I/O exceptions using localized
13+ /// messages from <see cref="Strings"/>.
1314/// </summary>
1415[ ExcludeFromCodeCoverage ]
1516internal static class ThrowHelper
@@ -18,7 +19,7 @@ internal static class ThrowHelper
1819
1920 //--------------------------------------------------------------------------------
2021 /// <summary>
21- /// Throws an argument out of range exception with the message for a non-negative number.
22+ /// Throws an ArgumentOutOfRangeException with the message for a non-negative number.
2223 /// </summary>
2324 /// <param name="argumentName">The name of the invalid argument.</param>
2425 /// <exception cref="ArgumentOutOfRangeException">
@@ -28,7 +29,7 @@ internal static void ThrowArgumentOutOfRangeException_NeedNonNegNum (string argu
2829 throw new ArgumentOutOfRangeException ( argumentName , string . Format ( Strings . Arg_OutOfRangeNonNegNum , argumentName ) ) ;
2930 //--------------------------------------------------------------------------------
3031 /// <summary>
31- /// Throws an argument out of range exception with the message for a number required
32+ /// Throws an ArgumentOutOfRangeException with the message for a number required
3233 /// to be between two values.
3334 /// </summary>
3435 /// <param name="argumentName">
@@ -48,7 +49,7 @@ internal static void ThrowArgumentOutOfRangeException_NeedBetween (string argume
4849 throw new ArgumentOutOfRangeException ( argumentName , string . Format ( Strings . Arg_OutOfRangeNeedBetween , argumentName , minimumValue , maximumValue ) ) ;
4950 //--------------------------------------------------------------------------------
5051 /// <summary>
51- /// Throws an argument out of range exception with the message for a number required
52+ /// Throws an ArgumentOutOfRangeException with the message for a number required
5253 /// to be greater than or equal to a minimum value.
5354 /// </summary>
5455 /// <param name="argumentName">
@@ -65,7 +66,7 @@ internal static void ThrowArgumentOutOfRangeException_NeedMinValue (string argum
6566 throw new ArgumentOutOfRangeException ( argumentName , string . Format ( Strings . Arg_OutOfRangeMinValue , argumentName , minimumValue ) ) ;
6667 //--------------------------------------------------------------------------------
6768 /// <summary>
68- /// Throws an argument out of range exception with the message for a number required
69+ /// Throws an ArgumentOutOfRangeException with the message for a number required
6970 /// to be less than the size of the collection.
7071 /// </summary>
7172 /// <param name="argumentName">
@@ -77,7 +78,7 @@ internal static void ThrowArgumentOutOfRange_IndexMustBeLessException (string ar
7778 throw new ArgumentOutOfRangeException ( argumentName , Strings . Arg_IndexMustBeLessException ) ;
7879 //--------------------------------------------------------------------------------
7980 /// <summary>
80- /// Throws an argument out of range exception with the message for a number required
81+ /// Throws an ArgumentOutOfRangeException with the message for a number required
8182 /// to be less than or equal to the size of the collection.
8283 /// </summary>
8384 /// <param name="argumentName">
@@ -90,7 +91,7 @@ internal static void ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException (st
9091 throw new ArgumentOutOfRangeException ( argumentName , Strings . Arg_IndexMustBeLessOrEqualException ) ;
9192 //--------------------------------------------------------------------------------
9293 /// <summary>
93- /// Throws an argument exception with the message for an invalid Stream seek origin
94+ /// Throws an ArgumentException with the message for an invalid Stream seek origin
9495 /// value.
9596 /// </summary>
9697 /// <param name="argumentName">
@@ -103,7 +104,7 @@ internal static void ThrowArgumentException_InvalidSeekOrigin (string argumentNa
103104 throw new ArgumentException ( Strings . Arg_InvalidSeekOrigin , argumentName ) ;
104105 //--------------------------------------------------------------------------------
105106 /// <summary>
106- /// Throws an argument with the message for an invalid array segment offset
107+ /// Throws an ArgumentException with the message for an invalid array segment offset
107108 /// and length.
108109 /// </summary>
109110 /// <exception cref="ArgumentException">
@@ -113,7 +114,7 @@ internal static void ThrowArgumentException_InvalidOffsetLength () =>
113114 throw new ArgumentException ( Strings . Arg_InvalidOffsetLength ) ;
114115 //--------------------------------------------------------------------------------
115116 /// <summary>
116- /// Throws an argument with the message for copy destination that is too short
117+ /// Throws an ArgumentException with the message for copy destination that is too short
117118 /// and length.
118119 /// </summary>
119120 /// <param name="argumentName">
@@ -126,7 +127,7 @@ internal static void ThrowArgumentException_DestinationTooShort (string argument
126127 throw new ArgumentException ( Strings . Arg_DestinationTooShort , argumentName ) ;
127128 //--------------------------------------------------------------------------------
128129 /// <summary>
129- /// Throws an argument with the message for a source stream that is not readable
130+ /// Throws an ArgumentException with the message for a source stream that is not readable
130131 /// </summary>
131132 /// <param name="argumentName">
132133 /// The name of the invalid argument.
@@ -138,7 +139,7 @@ internal static void ThrowArgumentException_SourceStreamMustBeReadable (string a
138139 throw new ArgumentException ( Strings . Arg_SourceStreamMustBeReadable , argumentName ) ;
139140 //--------------------------------------------------------------------------------
140141 /// <summary>
141- /// Throws an argument with the message for a source stream that is not seekable
142+ /// Throws an ArgumentException with the message for a source stream that is not seekable
142143 /// </summary>
143144 /// <param name="argumentName">
144145 /// The name of the invalid argument.
@@ -150,7 +151,7 @@ internal static void ThrowArgumentException_SourceStreamMustBeSeekable (string a
150151 throw new ArgumentException ( Strings . Arg_SourceStreamMustBeSeekable , argumentName ) ;
151152 //--------------------------------------------------------------------------------
152153 /// <summary>
153- /// Throws an argument exception with the message for a contained value that is not comparable.
154+ /// Throws an ArgumentException with the message for a contained value that is not comparable.
154155 /// </summary>
155156 /// <param name="argumentName">
156157 /// The name of the invalid argument.
@@ -168,7 +169,7 @@ internal static void ThrowArgumentException_ContainedValueIsNotComparable (strin
168169
169170 //--------------------------------------------------------------------------------
170171 /// <summary>
171- /// Throws an invalid operation exception with the message for a closed stream.
172+ /// Throws an InvalidOperationException with the message for a closed stream.
172173 /// </summary>
173174 /// <exception cref="InvalidOperationException">
174175 /// </exception>
@@ -177,7 +178,7 @@ internal static void ThrowInvalidOperationException_StreamClosed () =>
177178 throw new InvalidOperationException ( Strings . InvalidOperation_StreamClosed ) ;
178179 //--------------------------------------------------------------------------------
179180 /// <summary>
180- /// Throws an object disposed exception with the message for a closed stream.
181+ /// Throws an ObjectDisposedException with the message for a closed stream.
181182 /// </summary>
182183 /// <param name="objectName">
183184 /// The name of the object that was disposed.
@@ -189,7 +190,7 @@ internal static void ThrowObjectDisposedException_StreamClosed (string objectNam
189190 throw new ObjectDisposedException ( objectName , Strings . InvalidOperation_StreamClosed ) ;
190191 //--------------------------------------------------------------------------------
191192 /// <summary>
192- /// Throws a not supported exception with the message for an unwritable stream.
193+ /// Throws a NotSupportedException with the message for an unwritable stream.
193194 /// </summary>
194195 /// <exception cref="NotSupportedException">
195196 /// </exception>
@@ -198,7 +199,7 @@ internal static void ThrowNotSupportedException_UnwritableStream () =>
198199 throw new NotSupportedException ( Strings . NotSupported_UnwritableStream ) ;
199200 //--------------------------------------------------------------------------------
200201 /// <summary>
201- /// Throws a not supported exception with the message for a feature not supported
202+ /// Throws a NotSupportedException with the message for a feature not supported
202203 /// in the specified stream mode.
203204 /// </summary>
204205 /// <param name="streamMode">
@@ -212,7 +213,7 @@ internal static void ThrowNotSupportedException_InvalidMemoryStreamSlimMode (Mem
212213 streamMode . GetString ( ) ) ) ;
213214 //--------------------------------------------------------------------------------
214215 /// <summary>
215- /// Throws a not supported exception with the message for a general feature not supported.
216+ /// Throws a NotSupportedException with the message for a general feature not supported.
216217 /// </summary>
217218 /// <exception cref="NotSupportedException">
218219 /// </exception>
@@ -221,7 +222,7 @@ internal static void ThrowNotSupportedException_FeatureNotSupported () =>
221222 throw new NotSupportedException ( Strings . NotSupported_FeatureNotAvailable ) ;
222223 //--------------------------------------------------------------------------------
223224 /// <summary>
224- /// Throws an argument out of range exception with the message for a small capacity.
225+ /// Throws an ArgumentOutOfRangeException with the message for a small capacity.
225226 /// </summary>
226227 /// <param name="argumentName">
227228 /// The name of the invalid argument.
@@ -233,7 +234,7 @@ internal static void ThrowArgumentOutOfRangeException_CapacitySmall (string argu
233234 throw new ArgumentOutOfRangeException ( argumentName , Strings . Arg_OutOfRangeSmallCapacity ) ;
234235 //--------------------------------------------------------------------------------
235236 /// <summary>
236- /// Throws an argument out of range exception with the message indicating that the
237+ /// Throws an ArgumentOutOfRangeException with the message indicating that the
237238 /// stream length would be invalid.
238239 /// </summary>
239240 /// <exception cref="ArgumentOutOfRangeException">
@@ -243,8 +244,8 @@ internal static void ThrowArgumentOutOfRangeException_StreamLength (string argum
243244 throw new ArgumentOutOfRangeException ( argumentName , Strings . Arg_OutOfRangeStreamLength ) ;
244245 //--------------------------------------------------------------------------------
245246 /// <summary>
246- /// Throws an argument out of range exception with the message indicating that the
247- /// stream length would be invalid .
247+ /// Throws an ArgumentOutOfRangeException with the message indicating that the
248+ /// requested size is too large for an array .
248249 /// </summary>
249250 /// <exception cref="ArgumentOutOfRangeException">
250251 /// </exception>
@@ -253,7 +254,7 @@ internal static void ThrowArgumentOutOfRangeException_TooLargeForArray(string ar
253254 throw new ArgumentOutOfRangeException ( argumentName , Strings . Arg_TooLargeForArray ) ;
254255 //--------------------------------------------------------------------------------
255256 /// <summary>
256- /// Throws an IO exception with the message for the stream being too long.
257+ /// Throws an IOException with the message for the stream being too long.
257258 /// </summary>
258259 /// <exception cref="IOException">
259260 /// </exception>
@@ -262,7 +263,7 @@ internal static void ThrowIOException_StreamTooLong () =>
262263 throw new IOException ( Strings . IO_StreamTooLong ) ;
263264 //--------------------------------------------------------------------------------
264265 /// <summary>
265- /// Throws an IO exception with the message for an attempt to move the position
266+ /// Throws an IOException with the message for an attempt to move the position
266267 /// before the beginning of the stream.
267268 /// </summary>
268269 /// <exception cref="IOException">
@@ -272,7 +273,7 @@ internal static void ThrowIOException_SeekBeforeBegin () =>
272273 throw new IOException ( Strings . IO_SeekBeforeBegin ) ;
273274 //--------------------------------------------------------------------------------
274275 /// <summary>
275- /// Throws an invalid operation exception with the message for an integer overflow
276+ /// Throws an InvalidOperationException with the message for an integer overflow
276277 /// when calculating the new capacity or accessing the Int32 Capacity property of a stream.
277278 /// </summary>
278279 /// <exception cref="InvalidOperationException">
@@ -282,7 +283,7 @@ internal static void ThrowInvalidOperationException_IntOverflowCapacity () =>
282283 throw new InvalidOperationException ( Strings . InvalidOperation_IntOverflowCapacity ) ;
283284 //--------------------------------------------------------------------------------
284285 /// <summary>
285- /// Throws an invalid operation exception with the message for an attempt to copy
286+ /// Throws an InvalidOperationException with the message for an attempt to copy
286287 /// the stream into an array but the length of the stream is too large to fit in an array.
287288 /// </summary>
288289 /// <exception cref="InvalidOperationException">
@@ -296,7 +297,7 @@ internal static void ThrowInvalidOperationException_TooLargeToCopyToArray () =>
296297
297298 //--------------------------------------------------------------------------------
298299 /// <summary>
299- /// Throws an invalid operation exception with the message for a type of global settings
300+ /// Throws an InvalidOperationException with the message for a type of global settings
300301 /// that cannot be updated.
301302 /// </summary>
302303 /// <param name="classTypeName">
@@ -310,7 +311,7 @@ internal static void ThrowInvalidOperation_GlobalSettingsCantBeUpdated (string c
310311 classTypeName ) ) ;
311312 //--------------------------------------------------------------------------------
312313 /// <summary>
313- /// Throws an object disposed exception with the object name.
314+ /// Throws an ObjectDisposedException for the object identified by the specified name.
314315 /// </summary>
315316 /// <param name="objectName">
316317 /// The name of the object that was disposed.
0 commit comments