Skip to content

Commit

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

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 dotnet/corefx#39069

Commit migrated from dotnet/corefx@539ed31
  • Loading branch information
roji authored and wtgodbe committed Jul 2, 2019
1 parent d5d04d6 commit 277fd3f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/libraries/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 277fd3f

Please sign in to comment.