From e55808fed0a39ca8f61ea2f7d5f759e91767c7af Mon Sep 17 00:00:00 2001 From: Jon Hanna Date: Tue, 25 Aug 2015 00:55:29 +0100 Subject: [PATCH] Consistently Throw NotSupportedException on Enumerator Reset Fixes dotnet/corefx#2879 Have Enumerable.Iterator's implementation of IEnumerator.Reset throw NotSupportedException instead of NotImplementedException as both more appropriate in itself, and more consistent with other IEnumerator.Reset implementations. Commit migrated from https://github.com/dotnet/corefx/commit/4ae66173c49d5d83cfa6a7abf466c73ea9fddf09 --- src/libraries/System.Linq/src/System.Linq.csproj | 3 --- src/libraries/System.Linq/src/System/Linq/Enumerable.cs | 2 +- src/libraries/System.Linq/tests/SelectTests.cs | 2 +- src/libraries/System.Linq/tests/WhereTests.cs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index 2568fd99fb6c1..eee54eff87b8a 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -16,9 +16,6 @@ - - Common\System\NotImplemented.cs - diff --git a/src/libraries/System.Linq/src/System/Linq/Enumerable.cs b/src/libraries/System.Linq/src/System/Linq/Enumerable.cs index 49f3905e188d6..191a7c03b0606 100644 --- a/src/libraries/System.Linq/src/System/Linq/Enumerable.cs +++ b/src/libraries/System.Linq/src/System/Linq/Enumerable.cs @@ -139,7 +139,7 @@ IEnumerator IEnumerable.GetEnumerator() void IEnumerator.Reset() { - throw NotImplemented.ByDesign; + throw Error.NotSupported(); } } diff --git a/src/libraries/System.Linq/tests/SelectTests.cs b/src/libraries/System.Linq/tests/SelectTests.cs index b583fb8c476a6..9f5e4457ab4e7 100644 --- a/src/libraries/System.Linq/tests/SelectTests.cs +++ b/src/libraries/System.Linq/tests/SelectTests.cs @@ -658,7 +658,7 @@ public void Select_ResetCalledOnEnumerator_ExceptionThrown() var result = source.Select(selector); var enumerator = result.GetEnumerator(); - Assert.Throws(() => enumerator.Reset()); + Assert.Throws(() => enumerator.Reset()); } } } diff --git a/src/libraries/System.Linq/tests/WhereTests.cs b/src/libraries/System.Linq/tests/WhereTests.cs index cb515c1f373e5..4fde9c7eccbc1 100644 --- a/src/libraries/System.Linq/tests/WhereTests.cs +++ b/src/libraries/System.Linq/tests/WhereTests.cs @@ -831,7 +831,7 @@ public void Select_SourceThrowsOnReset() var enumerator = source.Where(value => true).GetEnumerator(); - Assert.Throws(() => enumerator.Reset()); + Assert.Throws(() => enumerator.Reset()); } [Fact]