From f486c5247a62ad67dd7ff53363251b4544b77cc1 Mon Sep 17 00:00:00 2001 From: "Stephen A. Imhoff" Date: Tue, 3 Jan 2017 16:43:59 -0800 Subject: [PATCH] Redo some argument name corrections (dotnet/coreclr#8727) * TraceLogging * SignatureHelper * RuntimeReflectionExtensions * RuntimeHandles - Public * SemaphoreSlim - Public * Directory - Public * ModuleBuilder - Public * EncoderFallback - Public - Test Failures * StringBuilder - Public - Test Failures Commit migrated from https://github.com/dotnet/coreclr/commit/0bf7fe6df4abbdedc6b1fb80add919fa7ab9cb1a --- .../Eventing/TraceLogging/TraceLoggingTypeInfo.cs | 2 +- src/coreclr/src/mscorlib/src/System/IO/Directory.cs | 2 +- .../src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs | 2 +- .../mscorlib/src/System/Reflection/Emit/SignatureHelper.cs | 8 ++++---- .../src/System/Reflection/RuntimeReflectionExtensions.cs | 12 ++++++------ 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 +- .../mscorlib/src/System/Text/EncoderReplacementFallback.cs | 2 +- src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs | 8 ++++---- .../src/mscorlib/src/System/Threading/SemaphoreSlim.cs | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs b/src/coreclr/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs index 0cc17e0..d68e106 100644 --- a/src/coreclr/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs +++ b/src/coreclr/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingTypeInfo.cs @@ -61,7 +61,7 @@ namespace System.Diagnostics.Tracing if (name == null) { - throw new ArgumentNullException("eventName"); + throw new ArgumentNullException(nameof(name)); } Contract.EndContractBlock(); diff --git a/src/coreclr/src/mscorlib/src/System/IO/Directory.cs b/src/coreclr/src/mscorlib/src/System/IO/Directory.cs index 7c9992e..d07d1f0c 100644 --- a/src/coreclr/src/mscorlib/src/System/IO/Directory.cs +++ b/src/coreclr/src/mscorlib/src/System/IO/Directory.cs @@ -127,7 +127,7 @@ namespace System.IO public static void SetCurrentDirectory(String path) { if (path==null) - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(path)); if (path.Length==0) throw new ArgumentException(Environment.GetResourceString("Argument_PathEmpty")); if (path.Length >= Path.MaxPath) diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs index 6884f50..00ca23f 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -1689,7 +1689,7 @@ namespace System.Reflection.Emit private FieldToken GetFieldTokenNoLock(FieldInfo field) { if (field == null) { - throw new ArgumentNullException("con"); + throw new ArgumentNullException(nameof(field)); } Contract.EndContractBlock(); diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs index c40035b..5128576 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs @@ -186,15 +186,15 @@ namespace System.Reflection.Emit return sigHelp; } - internal static SignatureHelper GetTypeSigToken(Module mod, Type type) + internal static SignatureHelper GetTypeSigToken(Module module, Type type) { - if (mod == null) - throw new ArgumentNullException("module"); + if (module == null) + throw new ArgumentNullException(nameof(module)); if (type == null) throw new ArgumentNullException(nameof(type)); - return new SignatureHelper(mod, type); + return new SignatureHelper(module, type); } #endregion diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs b/src/coreclr/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs index 00ab975..4926263 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs @@ -10,16 +10,16 @@ namespace System.Reflection { private const BindingFlags everything = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - private static void CheckAndThrow(Type t) + private static void CheckAndThrow(Type type) { - if (t == null) throw new ArgumentNullException("type"); - if (!(t is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + if (type == null) throw new ArgumentNullException(nameof(type)); + if (!(type is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } - private static void CheckAndThrow(MethodInfo m) + private static void CheckAndThrow(MethodInfo method) { - if (m == null) throw new ArgumentNullException("method"); - if (!(m is RuntimeMethodInfo)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo")); + if (method == null) throw new ArgumentNullException(nameof(method)); + if (!(method is RuntimeMethodInfo)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo")); } public static IEnumerable GetRuntimeProperties(this Type type) diff --git a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs index 127da1e..a47ebc3 100644 --- a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs +++ b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs @@ -1546,7 +1546,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; @@ -1600,7 +1600,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) @@ -1628,7 +1628,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 c5f82a2..9be095b 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs @@ -123,7 +123,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 604cddf..b0657ff 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs @@ -153,7 +153,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 f20146f..9d221ce 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/StringBuilder.cs @@ -593,7 +593,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(); @@ -605,7 +605,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) { @@ -848,7 +848,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(); @@ -1205,7 +1205,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 92d760d..29b8f79 100644 --- a/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs +++ b/src/coreclr/src/mscorlib/src/System/Threading/SemaphoreSlim.cs @@ -315,7 +315,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(); @@ -609,7 +609,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