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

Intercepters: Don't return null for Async methods #16348

Merged
merged 1 commit into from
Jun 28, 2019
Merged
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
67 changes: 32 additions & 35 deletions src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
return interceptor.ReaderExecuting(command, eventData, null);
}
return interceptor?.ReaderExecuting(command, eventData, null);
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
}

return null;
Expand Down Expand Up @@ -127,10 +124,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
return interceptor.ScalarExecuting(command, eventData, null);
}
return interceptor?.ScalarExecuting(command, eventData, null);
}

return null;
Expand Down Expand Up @@ -176,10 +170,7 @@ public static class RelationalLoggerExtensions
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
return interceptor.NonQueryExecuting(command, eventData, null);
}
return interceptor?.NonQueryExecuting(command, eventData, null);
}

return null;
Expand Down Expand Up @@ -1006,7 +997,7 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
/// <param name="connection"> The connection. </param>
/// <param name="startTime"> The time that the operation was started. </param>
/// <returns> The result of execution, which may have been modified by an interceptor. </returns>
public static InterceptionResult? ConnectionOpening(
public static InterceptionResult? ConnectionOpening(
[NotNull] this IDiagnosticsLogger<DbLoggerCategory.Database.Connection> diagnostics,
[NotNull] IRelationalConnection connection,
DateTimeOffset startTime)
Expand All @@ -1029,10 +1020,7 @@ private static string CommandError(EventDefinitionBase definition, EventData pay
false,
diagnosticSourceEnabled);

if (interceptor != null)
{
return interceptor.ConnectionOpening(connection.DbConnection, eventData, null);
}
return interceptor?.ConnectionOpening(connection.DbConnection, eventData, null);
}

return null;
Expand Down Expand Up @@ -1418,10 +1406,7 @@ public static void ConnectionClosed(
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
interceptor.ConnectionClosed(connection.DbConnection, eventData);
}
interceptor?.ConnectionClosed(connection.DbConnection, eventData);
}
}

Expand Down Expand Up @@ -1559,10 +1544,7 @@ public static void ConnectionError(
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
interceptor.ConnectionFailed(connection.DbConnection, eventData);
}
interceptor?.ConnectionFailed(connection.DbConnection, eventData);
}
}

Expand Down Expand Up @@ -1706,10 +1688,7 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);

if (interceptor != null)
{
return interceptor.TransactionStarting(connection.DbConnection, eventData, null);
}
return interceptor?.TransactionStarting(connection.DbConnection, eventData, null);
}

return null;
Expand Down Expand Up @@ -1753,7 +1732,10 @@ private static string ConnectionError(EventDefinitionBase definition, EventData
definition,
diagnosticSourceEnabled);

return interceptor?.TransactionStartingAsync(connection.DbConnection, eventData, null, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionStartingAsync(connection.DbConnection, eventData, null, cancellationToken);
}
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
}

return Task.FromResult<InterceptionResult<DbTransaction>?>(null);
Expand Down Expand Up @@ -2183,7 +2165,10 @@ private static string TransactionUsed(EventDefinitionBase definition, EventData
true,
diagnosticSourceEnabled);

return interceptor?.TransactionCommittingAsync(transaction, eventData, null, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionCommittingAsync(transaction, eventData, null, cancellationToken);
}
}

return Task.FromResult<InterceptionResult?>(null);
Expand Down Expand Up @@ -2311,7 +2296,10 @@ public static Task TransactionCommittedAsync(
true,
diagnosticSourceEnabled);

return interceptor?.TransactionCommittedAsync(transaction, eventData, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionCommittedAsync(transaction, eventData, cancellationToken);
}
}

return Task.CompletedTask;
Expand Down Expand Up @@ -2441,7 +2429,10 @@ public static Task TransactionRolledBackAsync(
true,
diagnosticSourceEnabled);

return interceptor?.TransactionRolledBackAsync(transaction, eventData, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionRolledBackAsync(transaction, eventData, cancellationToken);
}
}

return Task.CompletedTask;
Expand Down Expand Up @@ -2568,7 +2559,10 @@ private static void LogTransactionRolledBack(
true,
diagnosticSourceEnabled);

return interceptor?.TransactionRollingBackAsync(transaction, eventData, null, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionRollingBackAsync(transaction, eventData, null, cancellationToken);
}
}

return Task.FromResult<InterceptionResult?>(null);
Expand Down Expand Up @@ -2747,7 +2741,10 @@ public static Task TransactionErrorAsync(
true,
diagnosticSourceEnabled);

return interceptor?.TransactionFailedAsync(transaction, eventData, cancellationToken);
if (interceptor != null)
{
return interceptor.TransactionFailedAsync(transaction, eventData, cancellationToken);
}
}

return Task.CompletedTask;
Expand Down