Skip to content
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

Return ValueTask in loggers and interceptors (merge to preview6) #21158

Merged
merged 1 commit into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ public virtual InterceptionResult<int> NonQueryExecuting(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
public virtual ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<DbDataReader> result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult<DbDataReader>>(result);

/// <summary>
/// Called just before EF intends to call <see cref="DbCommand.ExecuteScalarAsync()" />.
Expand All @@ -176,12 +176,12 @@ public virtual Task<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<InterceptionResult<object>> ScalarExecutingAsync(
public virtual ValueTask<InterceptionResult<object>> ScalarExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<object> result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult<object>>(result);

/// <summary>
/// Called just before EF intends to call <see cref="DbCommand.ExecuteNonQueryAsync()" />.
Expand All @@ -202,12 +202,12 @@ public virtual Task<InterceptionResult<object>> ScalarExecutingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<InterceptionResult<int>> NonQueryExecutingAsync(
public virtual ValueTask<InterceptionResult<int>> NonQueryExecutingAsync(
DbCommand command,
CommandEventData eventData,
InterceptionResult<int> result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult<int>>(result);

/// <summary>
/// <para>
Expand Down Expand Up @@ -308,12 +308,12 @@ public virtual int NonQueryExecuted(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<DbDataReader> ReaderExecutedAsync(
public virtual ValueTask<DbDataReader> ReaderExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
DbDataReader result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<DbDataReader>(result);

/// <summary>
/// <para>
Expand All @@ -336,12 +336,12 @@ public virtual Task<DbDataReader> ReaderExecutedAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<object> ScalarExecutedAsync(
public virtual ValueTask<object> ScalarExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
object result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<object>(result);

/// <summary>
/// <para>
Expand All @@ -364,12 +364,12 @@ public virtual Task<object> ScalarExecutedAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<int> NonQueryExecutedAsync(
public virtual ValueTask<int> NonQueryExecutedAsync(
DbCommand command,
CommandExecutedEventData eventData,
int result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<int>(result);

/// <summary>
/// Called when execution of a command has failed with an exception.
Expand Down
8 changes: 4 additions & 4 deletions src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public virtual InterceptionResult ConnectionOpening(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
public virtual Task<InterceptionResult> ConnectionOpeningAsync(
public virtual ValueTask<InterceptionResult> ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult>(result);

/// <summary>
/// Called just after EF has called <see cref="DbConnection.Open()" />.
Expand Down Expand Up @@ -129,11 +129,11 @@ public virtual InterceptionResult ConnectionClosing(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
public virtual Task<InterceptionResult> ConnectionClosingAsync(
public virtual ValueTask<InterceptionResult> ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult result)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult>(result);

/// <summary>
/// Called just after EF has called <see cref="DbConnection.Close()" /> in an async context.
Expand Down
20 changes: 10 additions & 10 deletions src/EFCore.Relational/Diagnostics/DbTransactionInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public virtual DbTransaction TransactionStarted(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<InterceptionResult<DbTransaction>> TransactionStartingAsync(
public virtual ValueTask<InterceptionResult<DbTransaction>> TransactionStartingAsync(
DbConnection connection, TransactionStartingEventData eventData, InterceptionResult<DbTransaction> result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult<DbTransaction>>(result);

/// <summary>
/// <para>
Expand All @@ -114,9 +114,9 @@ public virtual Task<InterceptionResult<DbTransaction>> TransactionStartingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<DbTransaction> TransactionStartedAsync(
public virtual ValueTask<DbTransaction> TransactionStartedAsync(
DbConnection connection, TransactionEndEventData eventData, DbTransaction result, CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<DbTransaction>(result);

/// <summary>
/// <para>
Expand Down Expand Up @@ -158,12 +158,12 @@ public virtual DbTransaction TransactionUsed(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
public virtual Task<DbTransaction> TransactionUsedAsync(
public virtual ValueTask<DbTransaction> TransactionUsedAsync(
DbConnection connection,
TransactionEventData eventData,
DbTransaction result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<DbTransaction>(result);

/// <summary>
/// Called just before EF intends to call <see cref="DbTransaction.Commit" />.
Expand Down Expand Up @@ -220,12 +220,12 @@ public virtual void TransactionCommitted(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
public virtual Task<InterceptionResult> TransactionCommittingAsync(
public virtual ValueTask<InterceptionResult> TransactionCommittingAsync(
DbTransaction transaction,
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult>(result);

/// <summary>
/// Called immediately after EF calls <see cref="DbTransaction.CommitAsync" />.
Expand Down Expand Up @@ -295,12 +295,12 @@ public virtual void TransactionRolledBack(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
public virtual Task<InterceptionResult> TransactionRollingBackAsync(
public virtual ValueTask<InterceptionResult> TransactionRollingBackAsync(
DbTransaction transaction,
TransactionEventData eventData,
InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);
=> new ValueTask<InterceptionResult>(result);

/// <summary>
/// Called immediately after EF calls <see cref="DbTransaction.RollbackAsync" />.
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Relational/Diagnostics/IDbCommandInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ InterceptionResult<int> NonQueryExecuting(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
ValueTask<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
InterceptionResult<DbDataReader> result,
Expand All @@ -188,7 +188,7 @@ Task<InterceptionResult<DbDataReader>> ReaderExecutingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<InterceptionResult<object>> ScalarExecutingAsync(
ValueTask<InterceptionResult<object>> ScalarExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
InterceptionResult<object> result,
Expand All @@ -213,7 +213,7 @@ Task<InterceptionResult<object>> ScalarExecutingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<InterceptionResult<int>> NonQueryExecutingAsync(
ValueTask<InterceptionResult<int>> NonQueryExecutingAsync(
[NotNull] DbCommand command,
[NotNull] CommandEventData eventData,
InterceptionResult<int> result,
Expand Down Expand Up @@ -315,7 +315,7 @@ int NonQueryExecuted(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<DbDataReader> ReaderExecutedAsync(
ValueTask<DbDataReader> ReaderExecutedAsync(
[NotNull] DbCommand command,
[NotNull] CommandExecutedEventData eventData,
[NotNull] DbDataReader result,
Expand All @@ -342,7 +342,7 @@ Task<DbDataReader> ReaderExecutedAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<object> ScalarExecutedAsync(
ValueTask<object> ScalarExecutedAsync(
[NotNull] DbCommand command,
[NotNull] CommandExecutedEventData eventData,
[CanBeNull] object result,
Expand All @@ -369,7 +369,7 @@ Task<object> ScalarExecutedAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<int> NonQueryExecutedAsync(
ValueTask<int> NonQueryExecutedAsync(
[NotNull] DbCommand command,
[NotNull] CommandExecutedEventData eventData,
int result,
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ InterceptionResult ConnectionOpening(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
Task<InterceptionResult> ConnectionOpeningAsync(
ValueTask<InterceptionResult> ConnectionOpeningAsync(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
InterceptionResult result,
Expand Down Expand Up @@ -141,7 +141,7 @@ InterceptionResult ConnectionClosing(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
Task<InterceptionResult> ConnectionClosingAsync(
ValueTask<InterceptionResult> ConnectionClosingAsync(
[NotNull] DbConnection connection,
[NotNull] ConnectionEventData eventData,
InterceptionResult result);
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.Relational/Diagnostics/IDbTransactionInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ DbTransaction TransactionStarted(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<InterceptionResult<DbTransaction>> TransactionStartingAsync(
ValueTask<InterceptionResult<DbTransaction>> TransactionStartingAsync(
[NotNull] DbConnection connection,
[NotNull] TransactionStartingEventData eventData,
InterceptionResult<DbTransaction> result,
Expand Down Expand Up @@ -129,7 +129,7 @@ Task<InterceptionResult<DbTransaction>> TransactionStartingAsync(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<DbTransaction> TransactionStartedAsync(
ValueTask<DbTransaction> TransactionStartedAsync(
[NotNull] DbConnection connection,
[NotNull] TransactionEndEventData eventData,
[CanBeNull] DbTransaction result,
Expand Down Expand Up @@ -174,7 +174,7 @@ DbTransaction TransactionUsed(
/// A normal implementation of this method for any interceptor that is not attempting to change the result
/// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" />
/// </returns>
Task<DbTransaction> TransactionUsedAsync(
ValueTask<DbTransaction> TransactionUsedAsync(
[NotNull] DbConnection connection,
[NotNull] TransactionEventData eventData,
[CanBeNull] DbTransaction result,
Expand Down Expand Up @@ -232,7 +232,7 @@ void TransactionCommitted(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
Task<InterceptionResult> TransactionCommittingAsync(
ValueTask<InterceptionResult> TransactionCommittingAsync(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
InterceptionResult result,
Expand Down Expand Up @@ -302,7 +302,7 @@ void TransactionRolledBack(
/// A normal implementation of this method for any interceptor that is not attempting to suppress
/// the operation is to return the <paramref name="result" /> value passed in.
/// </returns>
Task<InterceptionResult> TransactionRollingBackAsync(
ValueTask<InterceptionResult> TransactionRollingBackAsync(
[NotNull] DbTransaction transaction,
[NotNull] TransactionEventData eventData,
InterceptionResult result,
Expand Down
Loading