Use ArgumentOutOfRangeException.Throw helpers in more places (#79460)
authorStephen Toub <stoub@microsoft.com>
Sun, 11 Dec 2022 14:11:02 +0000 (09:11 -0500)
committerGitHub <noreply@github.com>
Sun, 11 Dec 2022 14:11:02 +0000 (09:11 -0500)
commit3689fbec921418e496962dc0ee252bdc9eafa3de
treee821347a13da2865b4c34e91472bdc4068095411
parent6407eae2c9cda49c725e744f9628bca65b6e71d2
Use ArgumentOutOfRangeException.Throw helpers in more places (#79460)

* Use ArgumentOutOfRangeException.Throw helpers in more places

* Fix a few issues

* Fix another test

* Apply suggestions from code review

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
213 files changed:
src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs
src/coreclr/System.Private.CoreLib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs
src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs
src/coreclr/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs
src/coreclr/System.Private.CoreLib/src/System/Threading/Monitor.CoreCLR.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/GC.NativeAot.cs
src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs
src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs
src/libraries/Common/src/Interop/OSX/Interop.libproc.cs
src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs
src/libraries/Common/src/System/Net/SocketAddress.cs
src/libraries/Common/src/System/Text/DBCSDecoder.cs
src/libraries/Common/src/System/Text/OSEncoder.cs
src/libraries/Common/src/System/Text/OSEncoding.Windows.cs
src/libraries/System.Collections.Concurrent/src/Resources/Strings.resx
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs
src/libraries/System.Collections.NonGeneric/src/Resources/Strings.resx
src/libraries/System.Collections.NonGeneric/src/System/Collections/Queue.cs
src/libraries/System.Collections.NonGeneric/src/System/Collections/SortedList.cs
src/libraries/System.Collections.NonGeneric/src/System/Collections/Stack.cs
src/libraries/System.Collections.Specialized/src/Resources/Strings.resx
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/BitVector32.cs
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/ListDictionary.cs
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs
src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs
src/libraries/System.Collections.Specialized/tests/BitVector32Tests.cs
src/libraries/System.Collections/src/Resources/Strings.resx
src/libraries/System.Collections/src/System/Collections/BitArray.cs
src/libraries/System.Collections/src/System/Collections/Generic/LinkedList.cs
src/libraries/System.Collections/src/System/Collections/Generic/PriorityQueue.cs
src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs
src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs
src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs
src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/Schema/ColumnAttribute.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/Serialization/ContextStack.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs
src/libraries/System.ComponentModel.TypeConverter/tests/ContextStackTests.cs
src/libraries/System.Console/src/Resources/Strings.resx
src/libraries/System.Console/src/System/Console.cs
src/libraries/System.Console/src/System/ConsolePal.Windows.cs
src/libraries/System.Console/src/System/IO/SyncTextReader.cs
src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs
src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs
src/libraries/System.Diagnostics.Process/src/Resources/Strings.resx
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.FreeBSD.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.OSX.cs
src/libraries/System.Formats.Tar/src/System/Formats/Tar/GnuTarEntry.cs
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
src/libraries/System.IO.Compression/src/Resources/Strings.resx
src/libraries/System.IO.IsolatedStorage/src/Resources/Strings.resx
src/libraries/System.IO.MemoryMappedFiles/src/Resources/Strings.resx
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.cs
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Unix.cs
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedViewStream.cs
src/libraries/System.IO.Pipes/src/Resources/Strings.resx
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.cs
src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/ContractUtils.cs
src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs
src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs
src/libraries/System.Net.Http/src/Resources/Strings.resx
src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentRangeHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs
src/libraries/System.Net.Http/src/System/Net/Http/StreamContent.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBuffer.cs
src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs
src/libraries/System.Net.Mail/src/System/Net/Mime/QuotedPrintableStream.cs
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/PingOptions.cs
src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs
src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs
src/libraries/System.Net.Primitives/src/System/Net/CredentialCache.cs
src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs
src/libraries/System.Net.Requests/src/System/Net/TimerThread.cs
src/libraries/System.Net.ServicePoint/src/System/Net/ServicePoint.cs
src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
src/libraries/System.Net.Sockets/src/Resources/Strings.resx
src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SendPacketsElement.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPListener.cs
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketReceiveResult.cs
src/libraries/System.ObjectModel/src/Resources/Strings.resx
src/libraries/System.ObjectModel/src/System/Collections/CollectionHelpers.cs
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Generic/HashSet.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ListDictionaryInternal.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/CollectionHelpers.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/EastAsianLunisolarCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/HebrewCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/HijriCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/JapaneseCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/JulianCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/KoreanCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/PersianCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/TaiwanCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/ThaiBuddhistCalendar.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/UmAlQuraCalendar.cs
src/libraries/System.Private.CoreLib/src/System/IO/BinaryReader.cs
src/libraries/System.Private.CoreLib/src/System/IO/BinaryWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/EnumerationOptions.cs
src/libraries/System.Private.CoreLib/src/System/IO/FileStreamOptions.cs
src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs
src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs
src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/StringReader.cs
src/libraries/System.Private.CoreLib/src/System/IO/StringWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/TextReader.cs
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryAccessor.cs
src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryStreamWrapper.cs
src/libraries/System.Private.CoreLib/src/System/Random.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs
src/libraries/System.Private.CoreLib/src/System/Security/SecureString.cs
src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs
src/libraries/System.Private.CoreLib/src/System/String.cs
src/libraries/System.Private.CoreLib/src/System/Text/ASCIIEncoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs
src/libraries/System.Private.CoreLib/src/System/Text/DecoderNLS.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs
src/libraries/System.Private.CoreLib/src/System/Text/EncoderNLS.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.cs
src/libraries/System.Private.CoreLib/src/System/Threading/SpinWait.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs
src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs
src/libraries/System.Private.CoreLib/src/System/Type.cs
src/libraries/System.Private.CoreLib/src/System/Version.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XNodeReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Base64Decoder.cs
src/libraries/System.Private.Xml/src/System/Xml/Base64Encoder.cs
src/libraries/System.Private.Xml/src/System/Xml/BinHexDecoder.cs
src/libraries/System.Private.Xml/src/System/Xml/BinHexEncoder.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/ReadContentAsBinaryHelper.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingWriterAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlSubtreeReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextEncoder.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriterAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlText.cs
src/libraries/System.Private.Xml/src/System/Xml/NameTable.cs
src/libraries/System.Private.Xml/src/System/Xml/Resolvers/XmlPreloadedResolver.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObjectTable.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdDuration.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XmlQuerySequence.cs
src/libraries/System.Runtime/tests/System/Reflection/SignatureTypes.cs
src/libraries/System.Security.AccessControl/src/Resources/Strings.resx
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACE.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/SecurityDescriptor.cs
src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptoStream.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HashAlgorithm.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HashProvider.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/IncrementalHash.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PasswordDeriveBytes.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PbeParameters.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/PemEncoding.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RandomNumberGenerator.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rfc2898DeriveBytes.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SymmetricAlgorithm.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/UniversalCryptoTransform.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRevocationListBuilder.Build.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509BasicConstraintsExtension.cs
src/libraries/System.Security.Principal.Windows/src/Resources/Strings.resx
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/SID.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionManager.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs
src/mono/System.Private.CoreLib/src/System/Array.Mono.cs
src/mono/System.Private.CoreLib/src/System/GC.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILInfo.cs
src/mono/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs