Rollback parameter name change to fix failing corefx tests (dotnet/coreclr#8985)
authorJan Kotas <jkotas@microsoft.com>
Wed, 18 Jan 2017 16:58:03 +0000 (08:58 -0800)
committerGitHub <noreply@github.com>
Wed, 18 Jan 2017 16:58:03 +0000 (08:58 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/d3c7ce0c11eb79e33195ab9c1bee94bfe2f6738e

src/coreclr/src/mscorlib/src/System/DateTime.cs

index 7216047..2834825 100644 (file)
@@ -461,7 +461,12 @@ namespace System {
         // 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(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadYears"));
+            if (value < -10000 || value > 10000)
+            {
+                // DateTimeOffset.AddYears(int years) is implemented on top of DateTime.AddYears(int value). Use the more appropriate
+                // parameter name out of the two for the exception.
+                throw new ArgumentOutOfRangeException("years", Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadYears"));
+            }
             Contract.EndContractBlock();
             return AddMonths(value * 12);
         }