From b1ae3b8c98d65bc3a0be50bce3b887682bd6dd7f Mon Sep 17 00:00:00 2001 From: "Stephen A. Imhoff" Date: Wed, 26 Oct 2016 13:45:44 -0700 Subject: [PATCH] Correct parameter names. Commit migrated from https://github.com/dotnet/coreclr/commit/a212082aa4cea8529b4c78844e2a7408ff6f7969 --- src/coreclr/src/mscorlib/src/System/DateTime.cs | 6 +++--- src/coreclr/src/mscorlib/src/System/GC.cs | 2 +- src/coreclr/src/mscorlib/src/System/Globalization/IdnMapping.cs | 2 +- src/coreclr/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs | 2 +- src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs | 6 +++--- .../src/mscorlib/src/System/Text/EncoderBestFitFallback.cs | 2 +- .../src/mscorlib/src/System/Text/EncoderExceptionFallback.cs | 2 +- .../src/mscorlib/src/System/Text/EncoderReplacementFallback.cs | 2 +- src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs | 8 ++++---- src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/DateTime.cs b/src/coreclr/src/mscorlib/src/System/DateTime.cs index 18e7053..788f1ca 100644 --- a/src/coreclr/src/mscorlib/src/System/DateTime.cs +++ b/src/coreclr/src/mscorlib/src/System/DateTime.cs @@ -460,10 +460,10 @@ namespace System { // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day // parts of the result are the same as those of this DateTime. // - public DateTime AddYears(int value) { - if (value < -10000 || value > 10000) throw new ArgumentOutOfRangeException("years", Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadYears")); + public DateTime AddYears(int years) { + if (years < -10000 || years > 10000) throw new ArgumentOutOfRangeException(nameof(years), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadYears")); Contract.EndContractBlock(); - return AddMonths(value * 12); + return AddMonths(years * 12); } // Compares two DateTime values, returning an integer that indicates diff --git a/src/coreclr/src/mscorlib/src/System/GC.cs b/src/coreclr/src/mscorlib/src/System/GC.cs index 93c3bbd..9b6ef39 100644 --- a/src/coreclr/src/mscorlib/src/System/GC.cs +++ b/src/coreclr/src/mscorlib/src/System/GC.cs @@ -132,7 +132,7 @@ namespace System { } if( (4 == IntPtr.Size) && (bytesAllocated > Int32.MaxValue) ) { - throw new ArgumentOutOfRangeException("pressure", + throw new ArgumentOutOfRangeException(nameof(bytesAllocated), Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegInt32")); } Contract.EndContractBlock(); diff --git a/src/coreclr/src/mscorlib/src/System/Globalization/IdnMapping.cs b/src/coreclr/src/mscorlib/src/System/Globalization/IdnMapping.cs index 842315e..556841e 100644 --- a/src/coreclr/src/mscorlib/src/System/Globalization/IdnMapping.cs +++ b/src/coreclr/src/mscorlib/src/System/Globalization/IdnMapping.cs @@ -261,7 +261,7 @@ namespace System.Globalization throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (index > ascii.Length) - throw new ArgumentOutOfRangeException("byteIndex", + throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); if (index > ascii.Length - count) throw new ArgumentOutOfRangeException(nameof(ascii), diff --git a/src/coreclr/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs b/src/coreclr/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs index 3d9a7ac..4a4f140 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs @@ -540,7 +540,7 @@ namespace System.IO { [System.Security.SecuritySafeCritical] // auto-generated public override void SetLength(long value) { if (value < 0) - throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); Contract.EndContractBlock(); if (_buffer != null) throw new NotSupportedException(Environment.GetResourceString("NotSupported_UmsSafeBuffer")); diff --git a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs index 4aa4af4..86f4beb 100644 --- a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs +++ b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs @@ -1775,7 +1775,7 @@ namespace System { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module).IsValidToken(typeToken)) - throw new ArgumentOutOfRangeException("metadataToken", + throw new ArgumentOutOfRangeException(nameof(typeToken), Environment.GetResourceString("Argument_InvalidToken", typeToken, new ModuleHandle(module))); int typeInstCount, methodInstCount; @@ -1832,7 +1832,7 @@ namespace System { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken)) - throw new ArgumentOutOfRangeException("metadataToken", + throw new ArgumentOutOfRangeException(nameof(methodToken), Environment.GetResourceString("Argument_InvalidToken", methodToken, new ModuleHandle(module))); fixed (IntPtr* typeInstArgs = typeInstantiationContext, methodInstArgs = methodInstantiationContext) @@ -1862,7 +1862,7 @@ namespace System { ValidateModulePointer(module); if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken)) - throw new ArgumentOutOfRangeException("metadataToken", + throw new ArgumentOutOfRangeException(nameof(fieldToken), Environment.GetResourceString("Argument_InvalidToken", fieldToken, new ModuleHandle(module))); // defensive copy to be sure array is not mutated from the outside during processing diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs b/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs index 92eff37..a2cb2ec 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs @@ -122,7 +122,7 @@ namespace System.Text 0xD800, 0xDBFF)); if (!Char.IsLowSurrogate(charUnknownLow)) - throw new ArgumentOutOfRangeException("CharUnknownLow", + throw new ArgumentOutOfRangeException(nameof(charUnknownLow), Environment.GetResourceString("ArgumentOutOfRange_Range", 0xDC00, 0xDFFF)); Contract.EndContractBlock(); diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs b/src/coreclr/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs index 051f50a..6735e7a 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs @@ -68,7 +68,7 @@ namespace System.Text } if (!Char.IsLowSurrogate(charUnknownLow)) { - throw new ArgumentOutOfRangeException("CharUnknownLow", + throw new ArgumentOutOfRangeException(nameof(charUnknownLow), Environment.GetResourceString("ArgumentOutOfRange_Range", 0xDC00, 0xDFFF)); } diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs b/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs index c9e0c6c..026a642 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs @@ -152,7 +152,7 @@ namespace System.Text 0xD800, 0xDBFF)); if (!Char.IsLowSurrogate(charUnknownLow)) - throw new ArgumentOutOfRangeException("CharUnknownLow", + throw new ArgumentOutOfRangeException(nameof(charUnknownLow), Environment.GetResourceString("ArgumentOutOfRange_Range", 0xDC00, 0xDFFF)); Contract.EndContractBlock(); diff --git a/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs b/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs index a90d60c..b1ae902 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs @@ -597,7 +597,7 @@ namespace System.Text { throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); } if (charCount<0) { - throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -609,7 +609,7 @@ namespace System.Text { throw new ArgumentNullException(nameof(value)); } if (charCount > value.Length - startIndex) { - throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_Index")); } if (charCount==0) { @@ -859,7 +859,7 @@ namespace System.Text { } if (length > Length - startIndex) { - throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_Index")); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1138,7 +1138,7 @@ namespace System.Text { } if (charCount < 0) { - throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); } if (startIndex > value.Length - charCount) { diff --git a/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs b/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs index c47ca02..d2cce03 100644 --- a/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs +++ b/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs @@ -318,7 +318,7 @@ namespace System.Threading if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException( - "totalMilliSeconds", millisecondsTimeout, GetResourceString("SemaphoreSlim_Wait_TimeoutWrong")); + nameof(millisecondsTimeout), millisecondsTimeout, GetResourceString("SemaphoreSlim_Wait_TimeoutWrong")); } cancellationToken.ThrowIfCancellationRequested(); @@ -612,7 +612,7 @@ namespace System.Threading if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException( - "totalMilliSeconds", millisecondsTimeout, GetResourceString("SemaphoreSlim_Wait_TimeoutWrong")); + nameof(millisecondsTimeout), millisecondsTimeout, GetResourceString("SemaphoreSlim_Wait_TimeoutWrong")); } // Bail early for cancellation -- 2.7.4