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

Re-work InterceptionResult per API review feedback #16661

Merged
merged 1 commit into from
Jul 19, 2019
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
121 changes: 61 additions & 60 deletions src/EFCore.Relational/Diagnostics/DbCommandInterceptor.cs

Large diffs are not rendered by default.

76 changes: 40 additions & 36 deletions src/EFCore.Relational/Diagnostics/DbConnectionInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ public abstract class DbConnectionInterceptor : IDbConnectionInterceptor
/// <param name="connection"> The connection. </param>
/// <param name="eventData"> Contextual information about the connection. </param>
/// <param name="result">
/// The current result, or null if no result yet exists.
/// This value will be non-null if some previous interceptor suppressed execution by returning a result from
/// its implementation of this method.
/// Represents the current result if one exists.
/// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous
/// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>.
/// This value is typically used as the return value for the implementation of this method.
/// </param>
/// <returns>
/// If null, then EF will open the connection as normal.
/// If non-null, then connection opening is suppressed.
/// 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.
/// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal.
/// If <see cref="InterceptionResult.IsSuppressed"/> is true, then EF will suppress the operation
/// it was about to perform.
/// 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 InterceptionResult? ConnectionOpening(
public virtual InterceptionResult ConnectionOpening(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult? result)
InterceptionResult result)
=> result;

/// <summary>
Expand All @@ -44,22 +45,23 @@ public abstract class DbConnectionInterceptor : IDbConnectionInterceptor
/// <param name="connection"> The connection. </param>
/// <param name="eventData"> Contextual information about the connection. </param>
/// <param name="result">
/// The current result, or null if no result yet exists.
/// This value will be non-null if some previous interceptor suppressed execution by returning a result from
/// its implementation of this method.
/// Represents the current result if one exists.
/// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous
/// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>.
/// This value is typically used as the return value for the implementation of this method.
/// </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <returns>
/// If the <see cref="Task" /> result is null, then EF will open the connection as normal.
/// If the <see cref="Task" /> result is non-null value, then connection opening is suppressed.
/// 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}" />
/// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal.
/// If <see cref="InterceptionResult.IsSuppressed"/> is true, then EF will suppress the operation
/// it was about to perform.
/// 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 Task<InterceptionResult> ConnectionOpeningAsync(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult? result,
InterceptionResult result,
CancellationToken cancellationToken = default)
=> Task.FromResult(result);

Expand Down Expand Up @@ -91,21 +93,22 @@ public virtual Task ConnectionOpenedAsync(
/// <param name="connection"> The connection. </param>
/// <param name="eventData"> Contextual information about the connection. </param>
/// <param name="result">
/// The current result, or null if no result yet exists.
/// This value will be non-null if some previous interceptor suppressed execution by returning a result from
/// its implementation of this method.
/// Represents the current result if one exists.
/// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous
/// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>.
/// This value is typically used as the return value for the implementation of this method.
/// </param>
/// <returns>
/// If null, then EF will close the connection as normal.
/// If non-null, then connection closing is suppressed.
/// 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.
/// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal.
/// If <see cref="InterceptionResult.IsSuppressed"/> is true, then EF will suppress the operation
/// it was about to perform.
/// 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 InterceptionResult? ConnectionClosing(
public virtual InterceptionResult ConnectionClosing(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult? result)
InterceptionResult result)
=> result;

/// <summary>
Expand All @@ -114,21 +117,22 @@ public virtual Task ConnectionOpenedAsync(
/// <param name="connection"> The connection. </param>
/// <param name="eventData"> Contextual information about the connection. </param>
/// <param name="result">
/// The current result, or null if no result yet exists.
/// This value will be non-null if some previous interceptor suppressed execution by returning a result from
/// its implementation of this method.
/// Represents the current result if one exists.
/// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous
/// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>.
/// This value is typically used as the return value for the implementation of this method.
/// </param>
/// <returns>
/// If the <see cref="Task" /> result is null, then EF will close the connection as normal.
/// If the <see cref="Task" /> result is non-null value, then connection closing is suppressed.
/// 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}" />
/// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal.
/// If <see cref="InterceptionResult.IsSuppressed"/> is true, then EF will suppress the operation
/// it was about to perform.
/// 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 Task<InterceptionResult> ConnectionClosingAsync(
DbConnection connection,
ConnectionEventData eventData,
InterceptionResult? result)
InterceptionResult result)
=> Task.FromResult(result);

/// <summary>
Expand Down
Loading