Skip to content

Commit

Permalink
Revert the workaround for < .NET Core 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Dec 23, 2024
1 parent 506d029 commit c2b1675
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,12 @@ internal static CallTargetState OnMethodBegin<TTarget, TExchange, TRoutingKey, T
return BasicPublishAsyncIntegration.OnMethodBegin(instance, exchangeString, routingKeyString, mandatory, basicProperties, body, default);
}

#if NETCOREAPP3_1_OR_GREATER
// We don't support ValueTask in < .NET Core 3.1, which means this doesn't work and is never called
internal static TReturn? OnAsyncMethodEnd<TTarget, TReturn>(TTarget instance, TReturn? returnValue, Exception? exception, in CallTargetState state)
{
state.Scope.DisposeWithException(exception);
return returnValue;
}
#else
// If the method executes synchronously, then this works fine, but if it executes asynchronously we could miss the exception
// This is because the exception is thrown after the method returns, and we can't catch it here
// If/when we support handling ValueTask correctly in < .NET Core 3.1, we should remove this method
internal static CallTargetReturn<TReturn?> OnMethodEnd<TTarget, TReturn>(TTarget instance, TReturn? returnValue, Exception? exception, in CallTargetState state)
{
state.Scope.DisposeWithException(exception);
return new CallTargetReturn<TReturn?>(returnValue);
}
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,10 @@ internal static CallTargetState OnMethodBegin<TTarget, TBasicProperties, TBody>(
return new CallTargetState(scope);
}

#if NETCOREAPP3_1_OR_GREATER
// We don't support ValueTask in < .NET Core 3.1, which means this doesn't work and is never called
internal static TReturn? OnAsyncMethodEnd<TTarget, TReturn>(TTarget instance, TReturn? returnValue, Exception? exception, in CallTargetState state)
{
state.Scope.DisposeWithException(exception);
return returnValue;
}
#else
// If the method executes synchronously, then this works fine, but if it executes asynchronously we could miss the exception
// This is because the exception is thrown after the method returns, and we can't catch it here
// If/when we support handling ValueTask correctly in < .NET Core 3.1, we should remove this method
internal static CallTargetReturn<TReturn?> OnMethodEnd<TTarget, TReturn>(TTarget instance, TReturn? returnValue, Exception? exception, in CallTargetState state)
{
state.Scope.DisposeWithException(exception);
return new CallTargetReturn<TReturn?>(returnValue);
}
#endif
}

0 comments on commit c2b1675

Please sign in to comment.