Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add EnumeratorCancellationAttribute#37064

Merged
stephentoub merged 3 commits intodotnet:masterfrom
stephentoub:enumerationcancellation
Apr 20, 2019
Merged

Add EnumeratorCancellationAttribute#37064
stephentoub merged 3 commits intodotnet:masterfrom
stephentoub:enumerationcancellation

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Apr 20, 2019

Adds the new EnumeratorCancellationAttribute to System.Runtime. Eventually we may want to push the implementation down to corelib if/when it's needed for APIs in corelib, but for now we can just have it in corefx.

Also updates the new ChannelReader.ReadAllAsync method to use the attribute and revised pattern.

I'd like to get this merged asap.

cc: @terrajobst, @jcouv, @tarekgh, @bartonjs
Fixes https://github.com/dotnet/corefx/issues/37012

public abstract partial class ChannelReader<T>
{
public virtual System.Collections.Generic.IAsyncEnumerable<T> ReadAllAsync() { throw null; }
public virtual System.Collections.Generic.IAsyncEnumerable<T> ReadAllAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It seems ok to put the attribute there, as a form of documentation, but it won't do anything. The attribute must be placed on implementations to generate the desired GetAsyncEnumerator code.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 2)

@jcouv jcouv self-assigned this Apr 20, 2019
@stephentoub stephentoub merged commit 13cd961 into dotnet:master Apr 20, 2019
@stephentoub stephentoub deleted the enumerationcancellation branch April 20, 2019 20:08
@terrajobst
Copy link

Excellent. The corresponding PR in .NET Standard is also available now.

@karelz karelz added this to the 3.0 milestone May 4, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Update ChannelReader.ReadAllAsync for EnumeratorCancellationAttribute

* Add EnumeratorCancellationAttribute

* Address PR feedback


Commit migrated from dotnet/corefx@13cd961
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: DefaultCancellationAttribute

5 participants