Shorter ExecutionContext.Capture (dotnet/coreclr#21707)
authorBen Adams <thundercat@illyriad.co.uk>
Sun, 30 Dec 2018 16:54:44 +0000 (17:54 +0100)
committerJan Kotas <jkotas@microsoft.com>
Sun, 30 Dec 2018 16:54:44 +0000 (06:54 -1000)
Commit migrated from https://github.com/dotnet/coreclr/commit/c83821535b0bbc2f7e19e2e712c1d56aef4b9360

src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs

index 5c1d1a1..62b7521 100644 (file)
@@ -57,10 +57,16 @@ namespace System.Threading
         public static ExecutionContext Capture()
         {
             ExecutionContext executionContext = Thread.CurrentThread.ExecutionContext;
-            return
-                executionContext == null ? Default :
-                executionContext.m_isFlowSuppressed ? null :
-                executionContext;
+            if (executionContext == null)
+            {
+                executionContext = Default;
+            }
+            else if (executionContext.m_isFlowSuppressed)
+            {
+                executionContext = null;
+            }
+
+            return executionContext;
         }
 
         private ExecutionContext ShallowClone(bool isFlowSuppressed)