From ac2fb76ed0a01ca480abc0ca2e017dcd776761fd Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Mon, 25 Mar 2019 11:22:54 +0200 Subject: [PATCH] [netcore] Marshal.IsPinnable (#13628) Needed for MSBuild. Stream changes were copied from [CoreRT](https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/IO/Stream.CoreRT.cs). IsPinnable - perhaps it should be an icall/intrinsics for better perf? [CoreCLR impl for IsPinnable (InternalCall)](https://github.com/dotnet/coreclr/blob/1f3f474a13bdde1c5fecdf8cd9ce525dbe5df000/src/vm/marshalnative.cpp#L257) [CoreRT impl for IsPinnable](https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs#L114) (and [MightBeBlittable](https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InteropExtensions.cs#L60)) --- mcs/class/System.Private.CoreLib/System.IO/Stream.cs | 10 ++-------- .../System.Runtime.InteropServices/Marshal.cs | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mcs/class/System.Private.CoreLib/System.IO/Stream.cs b/mcs/class/System.Private.CoreLib/System.IO/Stream.cs index 9f5e08e9569..243fcba39da 100644 --- a/mcs/class/System.Private.CoreLib/System.IO/Stream.cs +++ b/mcs/class/System.Private.CoreLib/System.IO/Stream.cs @@ -2,14 +2,8 @@ namespace System.IO { partial class Stream { - private bool HasOverriddenBeginEndRead () - { - throw new NotImplementedException (); - } + bool HasOverriddenBeginEndRead () => true; - private bool HasOverriddenBeginEndWrite () - { - throw new NotImplementedException (); - } + bool HasOverriddenBeginEndWrite () => true; } } diff --git a/mcs/class/System.Private.CoreLib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/System.Private.CoreLib/System.Runtime.InteropServices/Marshal.cs index eca15521bbb..d0d18b8dad0 100644 --- a/mcs/class/System.Private.CoreLib/System.Runtime.InteropServices/Marshal.cs +++ b/mcs/class/System.Private.CoreLib/System.Runtime.InteropServices/Marshal.cs @@ -49,7 +49,7 @@ namespace System.Runtime.InteropServices internal static bool IsPinnable (object obj) { - throw new NotImplementedException (); + return obj == null || RuntimeTypeHandle.HasReferences (obj.GetType () as RuntimeType); } // TODO: Should be called from Windows only code @@ -420,4 +420,4 @@ namespace System public const int MSEE_E_ASSEMBLYLOADINPROGRESS = unchecked((int)0x80131016); public const int ERROR_FILE_INVALID = unchecked((int)0x800703EE); } -} \ No newline at end of file +} -- 2.11.4.GIT