Skip to content

Commit 8587a5c

Browse files
committed
Only capture execution context if needed
1 parent 46fe1fb commit 8587a5c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

samples/LocalizationPlayground/CultureEnvironmentCommandLineExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ internal static CommandLineBuilder UseCultureEnvironment(
1717
!string.IsNullOrEmpty(culture))
1818
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
1919

20-
var execCtx = ExecutionContext.Capture();
21-
2220
await next(context).ConfigureAwait(false);
2321

24-
if (context.InvocationResult is { } innerResult)
22+
if (context.InvocationResult is IInvocationResult innerResult)
23+
{
24+
var execCtx = ExecutionContext.Capture();
2525
context.InvocationResult = new ExecutionContextRestoringInvocationResult(execCtx, innerResult);
26+
}
2627
}, MiddlewareOrder.ExceptionHandler);
2728
}
2829
}

0 commit comments

Comments
 (0)