Skip to content

Commit

Permalink
Remove cancellation token from new System.Data CloseAsync() (dotnet#3…
Browse files Browse the repository at this point in the history
…9070)

Affects DbDataReader and DbConnection, since these APIs are very likely
to be used for cleanup only, in which case a cancellation token is
an anti-pattern (similar to why DisposeAsync doesn't accept one).

See discussion here:
dotnet/standard#1283 (review)

Fixes #39069
  • Loading branch information
roji authored and wtgodbe committed Jul 2, 2019
1 parent 9e32789 commit 72e341c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ public virtual event System.Data.StateChangeEventHandler StateChange { add { } r
public abstract void ChangeDatabase(string databaseName);
public virtual System.Threading.Tasks.Task ChangeDatabaseAsync(string databaseName, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public abstract void Close();
public virtual System.Threading.Tasks.Task CloseAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
public System.Data.Common.DbCommand CreateCommand() { throw null; }
protected abstract System.Data.Common.DbCommand CreateDbCommand();
public virtual void EnlistTransaction(System.Transactions.Transaction transaction) { }
Expand Down Expand Up @@ -2062,7 +2062,7 @@ protected DbDataReader() { }
public abstract int RecordsAffected { get; }
public virtual int VisibleFieldCount { get { throw null; } }
public virtual void Close() { }
public virtual System.Threading.Tasks.Task CloseAsync(System.Threading.CancellationToken cancellationToken = default) { throw null; }
public virtual System.Threading.Tasks.Task CloseAsync() { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public void Dispose() { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,8 @@ public ValueTask<DbTransaction> BeginTransactionAsync(IsolationLevel isolationLe

public abstract void Close();

public virtual Task CloseAsync(CancellationToken cancellationToken = default)
public virtual Task CloseAsync()
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled(cancellationToken);
}

try
{
Close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ protected DbDataReader() : base() { }

public virtual void Close() { }

public virtual Task CloseAsync(CancellationToken cancellationToken = default)
public virtual Task CloseAsync()
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled(cancellationToken);
}

try
{
Close();
Expand Down

0 comments on commit 72e341c

Please sign in to comment.