diff --git a/src/Microsoft.ML.Core/ComponentModel/ComponentCatalog.cs b/src/Microsoft.ML.Core/ComponentModel/ComponentCatalog.cs index fcddce4cc9..77604fb439 100644 --- a/src/Microsoft.ML.Core/ComponentModel/ComponentCatalog.cs +++ b/src/Microsoft.ML.Core/ComponentModel/ComponentCatalog.cs @@ -30,7 +30,7 @@ internal static AccessModifier Accessmodifier(this MethodInfo methodInfo) return AccessModifier.Internal; if (methodInfo.IsPublic) return AccessModifier.Public; - throw new ArgumentException("Did not find access modifier", "methodInfo"); + throw new ArgumentException("Did not find access modifier", nameof(methodInfo)); } internal static AccessModifier Accessmodifier(this ConstructorInfo constructorInfo) @@ -47,7 +47,7 @@ internal static AccessModifier Accessmodifier(this ConstructorInfo constructorIn return AccessModifier.Internal; if (constructorInfo.IsPublic) return AccessModifier.Public; - throw new ArgumentException("Did not find access modifier", "constructorInfo"); + throw new ArgumentException("Did not find access modifier", nameof(constructorInfo)); } internal enum AccessModifier diff --git a/src/Microsoft.ML.TorchSharp/Utils/Index.cs b/src/Microsoft.ML.TorchSharp/Utils/Index.cs index a36095690d..20f59a2e50 100644 --- a/src/Microsoft.ML.TorchSharp/Utils/Index.cs +++ b/src/Microsoft.ML.TorchSharp/Utils/Index.cs @@ -29,7 +29,7 @@ public Index(int value, bool fromEnd = false) { if (value < 0) { - throw new ArgumentOutOfRangeException("value", "Non-negative number required."); + throw new ArgumentOutOfRangeException(nameof(value), "Non-negative number required."); } if (fromEnd) @@ -57,7 +57,7 @@ public static Index FromStart(int value) { if (value < 0) { - throw new ArgumentOutOfRangeException("value", "Non-negative number required."); + throw new ArgumentOutOfRangeException(nameof(value), "Non-negative number required."); } return new Index(value); @@ -70,7 +70,7 @@ public static Index FromEnd(int value) { if (value < 0) { - throw new ArgumentOutOfRangeException("value", "Non-negative number required."); + throw new ArgumentOutOfRangeException(nameof(value), "Non-negative number required."); } return new Index(~value); diff --git a/src/Microsoft.ML.TorchSharp/Utils/Range.cs b/src/Microsoft.ML.TorchSharp/Utils/Range.cs index f7802ac074..7299998ca8 100644 --- a/src/Microsoft.ML.TorchSharp/Utils/Range.cs +++ b/src/Microsoft.ML.TorchSharp/Utils/Range.cs @@ -122,7 +122,7 @@ public override string ToString() if ((uint)end > (uint)length || (uint)start > (uint)end) { - throw new ArgumentOutOfRangeException("length"); + throw new ArgumentOutOfRangeException(nameof(length)); } return (start, end - start); diff --git a/test/Microsoft.ML.IntegrationTests/Datasets/TypeTestData.cs b/test/Microsoft.ML.IntegrationTests/Datasets/TypeTestData.cs index 7b218ad10b..cdc9b021e2 100644 --- a/test/Microsoft.ML.IntegrationTests/Datasets/TypeTestData.cs +++ b/test/Microsoft.ML.IntegrationTests/Datasets/TypeTestData.cs @@ -123,7 +123,7 @@ public static IEnumerable GenerateDataset(int numExamples = 5, int public static TypeTestData GetRandomInstance(Random rng) { if (rng == null) - throw new ArgumentNullException("rng"); + throw new ArgumentNullException(nameof(rng)); return new TypeTestData {