Skip to content

Commit

Permalink
Re-work InterceptionResult per API review feedback
Browse files Browse the repository at this point in the history
Specifically, not using `Nullable` anymore and instead being explicit about suppression/result.
  • Loading branch information
ajcvickers committed Jul 19, 2019
1 parent 7d4b425 commit e8eb57b
Show file tree
Hide file tree
Showing 22 changed files with 720 additions and 583 deletions.
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

0 comments on commit e8eb57b

Please sign in to comment.