Fix non-windows test failure on Microsoft.Extensions.Hosting.HostTests.CreateDefaultB...
authorMaryam Ariyan <maryam.ariyan@microsoft.com>
Thu, 16 Jul 2020 12:24:20 +0000 (05:24 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Jul 2020 12:24:20 +0000 (14:24 +0200)
* ifdefing SuppressGCTransition out of Logging.Console

Fixes #39404

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs
src/libraries/Microsoft.Extensions.Logging.Console/src/Microsoft.Extensions.Logging.Console.csproj

index 1bd7563..b317b13 100644 (file)
@@ -9,7 +9,9 @@ internal static partial class Interop
     internal static partial class Kernel32
     {
         [DllImport(Libraries.Kernel32)]
+#if !NO_SUPPRESS_GC_TRANSITION
         [SuppressGCTransition]
+#endif
         internal static extern IntPtr GetStdHandle(int nStdHandle);  // param is NOT a handle, but it returns one!
     }
 }
index 9e07f91..3afd1b9 100644 (file)
@@ -5,6 +5,7 @@
     <ExcludeCurrentFullFrameworkFromPackage>true</ExcludeCurrentFullFrameworkFromPackage>
     <EnableDefaultItems>true</EnableDefaultItems>
     <Nullable>annotations</Nullable>
+    <DefineConstants>$(DefineConstants);NO_SUPPRESS_GC_TRANSITION</DefineConstants>
   </PropertyGroup>
   <PropertyGroup>
     <!-- Ensure Assemblies are first resolved via targeting pack when targeting net461 -->
   </ItemGroup>
 
   <ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
-    <Compile Include="$(CommonPath)System\Runtime\InteropServices\SuppressGCTransitionAttribute.internal.cs"
-             Link="Common\System\Runtime\InteropServices\SuppressGCTransitionAttribute.internal.cs" />
-  </ItemGroup>
-
-  <ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
     <Reference Include="System.Buffers" />
     <Reference Include="Microsoft.Bcl.AsyncInterfaces" />
   </ItemGroup>