<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComTypes\ITypeInfo2.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComTypes\ITypeLib.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComTypes\ITypeLib2.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\CriticalHandle.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\CriticalHandle.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\CurrencyWrapper.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ErrorWrapper.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\Expando\IExpando.cs" />
--- /dev/null
+using System.Runtime.CompilerServices;
+using System.Runtime.ConstrainedExecution;
+
+namespace System.Runtime.InteropServices
+{
+ public abstract partial class CriticalHandle : CriticalFinalizerObject, IDisposable
+ {
+ void ReleaseHandleCore()
+ {
+ // Save last error from P/Invoke in case the implementation of
+ // ReleaseHandle trashes it (important because this ReleaseHandle could
+ // occur implicitly as part of unmarshaling another P/Invoke).
+ int lastError = Marshal.GetLastWin32Error();
+
+ if (!ReleaseHandle())
+ FireCustomerDebugProbe();
+
+ Marshal.SetLastWin32Error(lastError);
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern void FireCustomerDebugProbe();
+ }
+}
\ No newline at end of file
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\CallingConvention.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\CharSet.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ComVisibleAttribute.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\CriticalHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\DefaultCharSetAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\DefaultDllImportSearchPathsAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\DllImportAttribute.cs" />
namespace System.Runtime.InteropServices
{
// This class should not be serializable - it's a handle
- public abstract class CriticalHandle : CriticalFinalizerObject, IDisposable
+ public abstract partial class CriticalHandle : CriticalFinalizerObject, IDisposable
{
// ! Do not add or rearrange fields as the EE depends on this layout.
//------------------------------------------------------------------
protected CriticalHandle(IntPtr invalidHandleValue)
{
handle = invalidHandleValue;
- _isClosed = false;
}
~CriticalHandle()
if (IsInvalid)
return;
- // Save last error from P/Invoke in case the implementation of
- // ReleaseHandle trashes it (important because this ReleaseHandle could
- // occur implicitly as part of unmarshaling another P/Invoke).
- int lastError = Marshal.GetLastWin32Error();
-
- if (!ReleaseHandle())
- FireCustomerDebugProbe();
-
- Marshal.SetLastWin32Error(lastError);
-
+ ReleaseHandleCore();
GC.SuppressFinalize(this);
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void FireCustomerDebugProbe();
-
protected void SetHandle(IntPtr handle)
{
this.handle = handle;