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 1bd75631ba1e484fd2f17955f1308bb64a007551..b317b13e5499a45be699507d3ad85257db10176f 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 9e07f911a6639a6f06fb34a864a8505f3ad8913e..3afd1b9ed232e9a0402c4f24eadce4e75ed2de11 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 -->
              Link="Common\Interop\Windows\Interop.GetStdHandle.cs" />
   </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" />