-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to obsolete IEnumerable.GetEnumerator
used through Linq
#103664
Comments
Tagging subscribers to this area: @dotnet/area-system-linq |
Would this be something fixed by dotnet/roslyn#73920 and #103430, at least for the |
IEnumerable.GetEnumerator
used through foreach/LinqIEnumerable.GetEnumerator
used through Linq
ha, indeed I see the warning in the build output but not in Rider. I'll redirect that issue to JetBrains (RIDER-113674).
In the expression But yes it would miss such case: IEnumerable<object> e = new MyDbReader();
_ = e.Select(x => x); |
It could, but like I said technically calling |
Hmm true.
With the introduction of |
My recommendation would be to use separate types for each of the interface implementations, or perhaps use a property or factory that explicitly gets the specific enumerator implementation public IEnumerable<T> AsEnumerable();
public IAsyncEnumerable<T> AsAsyncEnumerable(); |
Assume a class that reads rows from the network
the maintainer recently implemented IAsyncEnumerable after realizing that reading synchronously from the network using the
IEnumerable
was causing a thread pool starvation. They also added the Obsolete attribute on theGetEnumerator
hoping this would guide the users to useGetAsyncEnumerator
. Though, if used through a foreach or Linq, no warnings are emitted:When
GetEnumerator
is marked as obsolete, would it possible to generate warnings on foreach and Linq?The text was updated successfully, but these errors were encountered: