Move ArraySegment and a few other files to shared CoreLib partition (#15158)
authorJan Kotas <jkotas@microsoft.com>
Wed, 22 Nov 2017 07:27:12 +0000 (23:27 -0800)
committerGitHub <noreply@github.com>
Wed, 22 Nov 2017 07:27:12 +0000 (23:27 -0800)
27 files changed:
src/mscorlib/System.Private.CoreLib.csproj
src/mscorlib/shared/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs
src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/mscorlib/shared/System/ArraySegment.cs [moved from src/mscorlib/src/System/ArraySegment.cs with 100% similarity]
src/mscorlib/shared/System/Empty.cs [new file with mode: 0644]
src/mscorlib/shared/System/Globalization/BidiCategory.cs [moved from src/mscorlib/src/System/Globalization/BidiCategory.cs with 86% similarity]
src/mscorlib/shared/System/Globalization/CalendarData.Windows.cs [moved from src/mscorlib/src/System/Globalization/CalendarData.Windows.cs with 98% similarity]
src/mscorlib/shared/System/Globalization/CharUnicodeInfo.cs [moved from src/mscorlib/src/System/Globalization/CharUnicodeInfo.cs with 100% similarity]
src/mscorlib/shared/System/Globalization/IdnMapping.cs [moved from src/mscorlib/src/System/Globalization/IdnMapping.cs with 100% similarity]
src/mscorlib/shared/System/Globalization/RegionInfo.cs [moved from src/mscorlib/src/System/Globalization/RegionInfo.cs with 100% similarity]
src/mscorlib/shared/System/IntPtr.cs [new file with mode: 0644]
src/mscorlib/shared/System/Threading/Tasks/TaskCanceledException.cs
src/mscorlib/shared/System/Threading/Tasks/TaskCompletionSource.cs
src/mscorlib/shared/System/UIntPtr.cs [moved from src/mscorlib/src/System/UIntPtr.cs with 57% similarity]
src/mscorlib/src/System/AppDomain.cs
src/mscorlib/src/System/Delegate.cs
src/mscorlib/src/System/Diagnostics/Stacktrace.cs
src/mscorlib/src/System/Empty.cs [deleted file]
src/mscorlib/src/System/IntPtr.cs [deleted file]
src/mscorlib/src/System/Reflection/LoaderAllocator.cs
src/mscorlib/src/System/RtType.cs
src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs
src/mscorlib/src/System/RuntimeHandles.cs
src/mscorlib/src/System/StubHelpers.cs
src/mscorlib/src/System/Threading/Overlapped.cs
src/mscorlib/src/System/Threading/Thread.cs
src/mscorlib/src/System/TypedReference.cs

index 6fa4900..443a6bd 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\CurrentSystemTimeZone.Cache.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Object.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Array.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\ArraySegment.cs" />
     <Compile Include="$(BclSourcesRoot)\System\ThrowHelper.cs" />
     <Compile Include="$(BclSourcesRoot)\System\String.cs" />
     <Compile Include="$(BclSourcesRoot)\System\String.Comparison.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Decimal.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Decimal.DecCalc.cs" />
     <Compile Include="$(BclSourcesRoot)\System\DefaultBinder.CanConvert.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Empty.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Enum.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Environment.cs" />
     <Compile Include="$(BclSourcesRoot)\System\GC.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Guid.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\InsufficientMemoryException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\IntPtr.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Internal.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Math.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\MathF.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\TypeNameParser.cs" />
     <Compile Include="$(BclSourcesRoot)\System\TypedReference.cs" />
     <Compile Include="$(BclSourcesRoot)\System\TypeLoadException.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\UIntPtr.cs" />
     <Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
     <Compile Include="$(BclSourcesRoot)\System\WeakReference.cs" />
     <Compile Include="$(BclSourcesRoot)\System\WeakReferenceOfT.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Metadata\AssemblyExtensions.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="$(BclSourcesRoot)\System\Globalization\BidiCategory.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Globalization\CharUnicodeInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CharUnicodeInfoData.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureData.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Globalization\IdnMapping.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Globalization\RegionInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\TextInfo.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(FeatureCoreFxGlobalization)' != 'true'">
     <Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Idna.cs" />
     <Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Normalization.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Diagnostics\Debug.Windows.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Globalization\CalendarData.Windows.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CompareInfo.Windows.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureData.Windows.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.Windows.cs" />
index 195e48d..28d0219 100644 (file)
@@ -15,6 +15,6 @@ namespace Microsoft.Win32.SafeHandles
         {
         }
 
-        public override bool IsInvalid => handle.IsNull() || handle == new IntPtr(-1);
+        public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
     }
 }
index f1eeb04..0c2b677 100644 (file)
@@ -31,6 +31,7 @@
     <Compile Include="$(MSBuildThisFileDirectory)System\ArgumentNullException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\ArgumentOutOfRangeException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\ArithmeticException.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\ArraySegment.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\ArrayTypeMismatchException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\AssemblyLoadEventArgs.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\AssemblyLoadEventHandler.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\DllNotFoundException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Double.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\DuplicateWaitObjectException.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Empty.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\EntryPointNotFoundException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\EventArgs.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\EventHandler.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\FlagsAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\FormatException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\FormattableString.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\BidiCategory.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\Calendar.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarAlgorithmType.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarWeekRule.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendricalCalculationsHelper.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CharUnicodeInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\ChineseLunisolarCalendar.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Invariant.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HebrewCalendar.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HebrewNumber.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\IdnMapping.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\InternalGlobalizationHelper.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\JapaneseCalendar.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\JapaneseLunisolarCalendar.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\NumberFormatInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\NumberStyles.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\PersianCalendar.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\RegionInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\SortKey.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\SortVersion.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\StringInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Int16.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Int32.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Int64.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\IntPtr.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Lazy.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Math.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\MathF.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UInt16.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UInt32.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UInt64.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\UIntPtr.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UnauthorizedAccessException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UnhandledExceptionEventArgs.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\UnhandledExceptionEventHandler.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysFreeString.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysStringLen.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Windows.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Windows.cs" Condition="'$(EnableDummyGlobalizationImplementation)' != 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.Win32.cs" Condition="'$(EnableWinRT)' != 'true' and '$(EnableDummyGlobalizationImplementation)' != 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\HijriCalendar.WinRT.cs" Condition="'$(EnableWinRT)' == 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Globalization\JapaneseCalendar.Win32.cs" Condition="'$(EnableWinRT)' != 'true' and '$(EnableDummyGlobalizationImplementation)' != 'true'" />
diff --git a/src/mscorlib/shared/System/Empty.cs b/src/mscorlib/shared/System/Empty.cs
new file mode 100644 (file)
index 0000000..00fab0f
--- /dev/null
@@ -0,0 +1,25 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System
+{
+#if CORERT
+    public // Needs to be public so that Reflection.Core can see it.
+#else
+    internal
+#endif
+    sealed class Empty
+    {
+        private Empty()
+        {
+        }
+
+        public static readonly Empty Value = new Empty();
+
+        public override String ToString()
+        {
+            return String.Empty;
+        }
+    }
+}
@@ -2,14 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-**
-** Purpose:
-**
-**
-============================================================*/
-
 namespace System.Globalization
 {
     internal enum BidiCategory
@@ -10,14 +10,6 @@ using System.Collections.Generic;
 
 namespace System.Globalization
 {
-#if CORECLR
-    using IntList = List<int>;
-    using StringList = List<string>;
-#else
-    using IntList = LowLevelList<int>;
-    using StringList = LowLevelList<string>;
-#endif 
-    
     internal partial class CalendarData
     {
         private bool LoadCalendarDataFromSystem(String localeName, CalendarId calendarId)
@@ -140,7 +132,7 @@ namespace System.Globalization
 
             EnumCalendarsData data = new EnumCalendarsData();
             data.userOverride = 0;
-            data.calendars = new IntList();
+            data.calendars = new List<int>();
 
             // First call GetLocaleInfo if necessary
             if (useUserOverride)
@@ -284,7 +276,7 @@ namespace System.Globalization
         private class EnumData
         {
             public string userOverride;
-            public StringList strings;
+            public List<string> strings;
         }
 
         // EnumCalendarInfoExEx callback itself.
@@ -312,7 +304,7 @@ namespace System.Globalization
         {
             EnumData context = new EnumData();
             context.userOverride = null;
-            context.strings = new StringList();
+            context.strings = new List<string>();
             // First call GetLocaleInfo if necessary
             if (((lcType != 0) && ((lcType & CAL_NOUSEROVERRIDE) == 0)) &&
                 // Get user locale, see if it matches localeName.
@@ -437,7 +429,7 @@ namespace System.Globalization
         private class EnumCalendarsData
         {
             public int userOverride;   // user override value (if found)
-            public IntList calendars;      // list of calendars found so far
+            public List<int> calendars;      // list of calendars found so far
         }
 
         // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
diff --git a/src/mscorlib/shared/System/IntPtr.cs b/src/mscorlib/shared/System/IntPtr.cs
new file mode 100644 (file)
index 0000000..8626b56
--- /dev/null
@@ -0,0 +1,235 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.Serialization;
+using System.Runtime.Versioning;
+
+#if BIT64
+using nint = System.Int64;
+#else
+using nint = System.Int32;
+#endif
+
+namespace System
+{
+    [Serializable]
+    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+    public struct IntPtr : IEquatable<IntPtr>, ISerializable
+    {
+        // WARNING: We allow diagnostic tools to directly inspect this member (_value). 
+        // See https://github.com/dotnet/corert/blob/master/Documentation/design-docs/diagnostics/diagnostics-tools-contract.md for more details. 
+        // Please do not change the type, the name, or the semantic usage of this member without understanding the implication for tools. 
+        // Get in touch with the diagnostics team if you have questions.
+        unsafe private void* _value; // Do not rename (binary serialization)
+
+        [Intrinsic]
+        public static readonly IntPtr Zero;
+
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe IntPtr(int value)
+        {
+            _value = (void*)value;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe IntPtr(long value)
+        {
+#if BIT64
+            _value = (void*)value;
+#else
+            _value = (void*)checked((int)value);
+#endif
+        }
+
+        [CLSCompliant(false)]
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe IntPtr(void* value)
+        {
+            _value = value;
+        }
+
+        private unsafe IntPtr(SerializationInfo info, StreamingContext context)
+        {
+            long l = info.GetInt64("value");
+
+            if (Size == 4 && (l > int.MaxValue || l < int.MinValue))
+                throw new ArgumentException(SR.Serialization_InvalidPtrValue);
+
+            _value = (void*)l;
+        }
+
+        unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            if (info == null)
+                throw new ArgumentNullException(nameof(info));
+
+            info.AddValue("value", ToInt64());
+        }
+
+        public unsafe override bool Equals(Object obj)
+        {
+            if (obj is IntPtr)
+            {
+                return (_value == ((IntPtr)obj)._value);
+            }
+            return false;
+        }
+
+        unsafe bool IEquatable<IntPtr>.Equals(IntPtr value)
+        {
+            return _value == value._value;
+        }
+
+        public unsafe override int GetHashCode()
+        {
+#if BIT64
+            long l = (long)_value;
+            return (unchecked((int)l) ^ (int)(l >> 32));
+#else
+            return unchecked((int)_value);
+#endif
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe int ToInt32()
+        {
+#if BIT64
+            long l = (long)_value;
+            return checked((int)l);
+#else
+            return (int)_value;
+#endif
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe long ToInt64()
+        {
+            return (nint)_value;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator IntPtr(int value)
+        {
+            return new IntPtr(value);
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator IntPtr(long value)
+        {
+            return new IntPtr(value);
+        }
+
+        [CLSCompliant(false)]
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator IntPtr(void* value)
+        {
+            return new IntPtr(value);
+        }
+
+        [CLSCompliant(false)]
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator void* (IntPtr value)
+        {
+            return value._value;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator int(IntPtr value)
+        {
+#if BIT64
+            long l = (long)value._value;
+            return checked((int)l);
+#else
+            return (int)value._value;
+#endif
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator long(IntPtr value)
+        {
+            return (nint)value._value;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe bool operator ==(IntPtr value1, IntPtr value2)
+        {
+            return value1._value == value2._value;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe bool operator !=(IntPtr value1, IntPtr value2)
+        {
+            return value1._value != value2._value;
+        }
+
+        [NonVersionable]
+        public static IntPtr Add(IntPtr pointer, int offset)
+        {
+            return pointer + offset;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe IntPtr operator +(IntPtr pointer, int offset)
+        {
+            return new IntPtr((nint)pointer._value + offset);
+        }
+
+        [NonVersionable]
+        public static IntPtr Subtract(IntPtr pointer, int offset)
+        {
+            return pointer - offset;
+        }
+
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe IntPtr operator -(IntPtr pointer, int offset)
+        {
+            return new IntPtr((nint)pointer._value - offset);
+        }
+
+        public static int Size
+        {
+            [Intrinsic]
+            [NonVersionable]
+            get
+            {
+                return sizeof(nint);
+            }
+        }
+
+        [CLSCompliant(false)]
+        [Intrinsic]
+        [NonVersionable]
+        public unsafe void* ToPointer()
+        {
+            return _value;
+        }
+
+        public unsafe override String ToString()
+        {
+            return ((nint)_value).ToString(CultureInfo.InvariantCulture);
+        }
+
+        public unsafe String ToString(String format)
+        {
+            return ((nint)_value).ToString(format, CultureInfo.InvariantCulture);
+        }
+    }
+}
index 6f7fc68..a6ec030 100644 (file)
@@ -24,7 +24,7 @@ namespace System.Threading.Tasks
     public class TaskCanceledException : OperationCanceledException
     {
         [NonSerialized]
-        private Task m_canceledTask; // The task which has been canceled.
+        private readonly Task _canceledTask; // The task which has been canceled.
 
         /// <summary>
         /// Initializes a new instance of the <see cref="T:System.Threading.Tasks.TaskCanceledException"/> class.
@@ -61,7 +61,7 @@ namespace System.Threading.Tasks
         public TaskCanceledException(Task task) :
             base(SR.TaskCanceledException_ctor_DefaultMessage, task != null ? task.CancellationToken : new CancellationToken())
         {
-            m_canceledTask = task;
+            _canceledTask = task;
         }
 
         /// <summary>
@@ -82,9 +82,6 @@ namespace System.Threading.Tasks
         /// <see cref="T:System.Threading.Tasks.TaskCanceledException"/>, in which case
         /// this property will return null.
         /// </remarks>
-        public Task Task
-        {
-            get { return m_canceledTask; }
-        }
+        public Task Task => _canceledTask;
     }
 }
index dc59caf..992e9db 100644 (file)
@@ -48,14 +48,14 @@ namespace System.Threading.Tasks
     /// cref="TaskCompletionSource{TResult}"/>.</typeparam>
     public class TaskCompletionSource<TResult>
     {
-        private readonly Task<TResult> m_task;
+        private readonly Task<TResult> _task;
 
         /// <summary>
         /// Creates a <see cref="TaskCompletionSource{TResult}"/>.
         /// </summary>
         public TaskCompletionSource()
         {
-            m_task = new Task<TResult>();
+            _task = new Task<TResult>();
         }
 
         /// <summary>
@@ -103,7 +103,7 @@ namespace System.Threading.Tasks
         /// </exception>
         public TaskCompletionSource(object state, TaskCreationOptions creationOptions)
         {
-            m_task = new Task<TResult>(state, creationOptions);
+            _task = new Task<TResult>(state, creationOptions);
         }
 
 
@@ -119,10 +119,7 @@ namespace System.Threading.Tasks
         /// methods (and their "Try" variants) on this instance all result in the relevant state
         /// transitions on this underlying Task.
         /// </remarks>
-        public Task<TResult> Task
-        {
-            get { return m_task; }
-        }
+        public Task<TResult> Task => _task;
 
         /// <summary>Spins until the underlying task is completed.</summary>
         /// <remarks>This should only be called if the task is in the process of being completed by another thread.</remarks>
@@ -130,7 +127,7 @@ namespace System.Threading.Tasks
         {
             // Spin wait until the completion is finalized by another thread.
             var sw = new SpinWait();
-            while (!m_task.IsCompleted)
+            while (!_task.IsCompleted)
                 sw.SpinOnce();
         }
 
@@ -156,8 +153,8 @@ namespace System.Threading.Tasks
         {
             if (exception == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception);
 
-            bool rval = m_task.TrySetException(exception);
-            if (!rval && !m_task.IsCompleted) SpinUntilCompleted();
+            bool rval = _task.TrySetException(exception);
+            if (!rval && !_task.IsCompleted) SpinUntilCompleted();
             return rval;
         }
 
@@ -196,8 +193,8 @@ namespace System.Threading.Tasks
             if (defensiveCopy.Count == 0)
                 ThrowHelper.ThrowArgumentException(ExceptionResource.TaskCompletionSourceT_TrySetException_NoExceptions, ExceptionArgument.exceptions);
 
-            bool rval = m_task.TrySetException(defensiveCopy);
-            if (!rval && !m_task.IsCompleted) SpinUntilCompleted();
+            bool rval = _task.TrySetException(defensiveCopy);
+            if (!rval && !_task.IsCompleted) SpinUntilCompleted();
             return rval;
         }
 
@@ -274,7 +271,7 @@ namespace System.Threading.Tasks
         /// <exception cref="T:System.ObjectDisposedException">The <see cref="Task"/> was disposed.</exception>
         public bool TrySetResult(TResult result)
         {
-            bool rval = m_task.TrySetResult(result);
+            bool rval = _task.TrySetResult(result);
             if (!rval) SpinUntilCompleted();
             return rval;
         }
@@ -324,8 +321,8 @@ namespace System.Threading.Tasks
         // Enables a token to be stored into the canceled task
         public bool TrySetCanceled(CancellationToken cancellationToken)
         {
-            bool rval = m_task.TrySetCanceled(cancellationToken);
-            if (!rval && !m_task.IsCompleted) SpinUntilCompleted();
+            bool rval = _task.TrySetCanceled(cancellationToken);
+            if (!rval && !_task.IsCompleted) SpinUntilCompleted();
             return rval;
         }
 
similarity index 57%
rename from src/mscorlib/src/System/UIntPtr.cs
rename to src/mscorlib/shared/System/UIntPtr.cs
index d0fe263..d31728b 100644 (file)
@@ -2,50 +2,49 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-/*============================================================
-**
-**
-**
-** Purpose: Platform independent integer
-**
-** 
-===========================================================*/
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.Serialization;
+using System.Runtime.Versioning;
+
+#if BIT64
+using nuint = System.UInt64;
+#else
+using nuint = System.UInt32;
+#endif
 
 namespace System
 {
-    using System;
-    using System.Globalization;
-    using System.Runtime.Serialization;
-    using System.Security;
-
     [Serializable]
     [CLSCompliant(false)]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] 
+    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public struct UIntPtr : IEquatable<UIntPtr>, ISerializable
     {
         unsafe private void* _value; // Do not rename (binary serialization)
 
+        [Intrinsic]
         public static readonly UIntPtr Zero;
 
-
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe UIntPtr(uint value)
         {
             _value = (void*)value;
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe UIntPtr(ulong value)
         {
 #if BIT64
             _value = (void*)value;
-#else // 32
+#else
             _value = (void*)checked((uint)value);
 #endif
         }
 
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe UIntPtr(void* value)
         {
             _value = value;
@@ -55,10 +54,8 @@ namespace System
         {
             ulong l = info.GetUInt64("value");
 
-            if (Size == 4 && l > UInt32.MaxValue)
-            {
+            if (Size == 4 && l > uint.MaxValue)
                 throw new ArgumentException(SR.Serialization_InvalidPtrValue);
-            }
 
             _value = (void*)l;
         }
@@ -66,9 +63,8 @@ namespace System
         unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
         {
             if (info == null)
-            {
                 throw new ArgumentNullException(nameof(info));
-            }
+
             info.AddValue("value", (ulong)_value);
         }
 
@@ -81,9 +77,9 @@ namespace System
             return false;
         }
 
-        unsafe bool IEquatable<UIntPtr>.Equals(UIntPtr other)
+        unsafe bool IEquatable<UIntPtr>.Equals(UIntPtr value)
         {
-            return _value == other._value;
+            return _value == value._value;
         }
 
         public unsafe override int GetHashCode()
@@ -91,144 +87,135 @@ namespace System
 #if BIT64
             ulong l = (ulong)_value;
             return (unchecked((int)l) ^ (int)(l >> 32));
-#else // 32
+#else
             return unchecked((int)_value);
 #endif
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe uint ToUInt32()
         {
 #if BIT64
             return checked((uint)_value);
-#else // 32
+#else
             return (uint)_value;
 #endif
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe ulong ToUInt64()
         {
             return (ulong)_value;
         }
 
-        public unsafe override String ToString()
-        {
-#if BIT64
-            return ((ulong)_value).ToString(CultureInfo.InvariantCulture);
-#else // 32
-            return ((uint)_value).ToString(CultureInfo.InvariantCulture);
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public static explicit operator UIntPtr(uint value)
         {
             return new UIntPtr(value);
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public static explicit operator UIntPtr(ulong value)
         {
             return new UIntPtr(value);
         }
 
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static explicit operator uint(UIntPtr value)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator UIntPtr(void* value)
         {
-#if BIT64
-            return checked((uint)value._value);
-#else // 32
-            return (uint)value._value;
-#endif
+            return new UIntPtr(value);
         }
 
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static explicit operator ulong(UIntPtr value)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator void* (UIntPtr value)
         {
-            return (ulong)value._value;
+            return value._value;
         }
 
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
-        public static unsafe explicit operator UIntPtr(void* value)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator uint(UIntPtr value)
         {
-            return new UIntPtr(value);
+#if BIT64
+            return checked((uint)value._value);
+#else
+            return (uint)value._value;
+#endif
         }
 
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
-        public static unsafe explicit operator void* (UIntPtr value)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe explicit operator ulong(UIntPtr value)
         {
-            return value._value;
+            return (ulong)value._value;
         }
 
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static bool operator ==(UIntPtr value1, UIntPtr value2)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe bool operator ==(UIntPtr value1, UIntPtr value2)
         {
             return value1._value == value2._value;
         }
 
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static bool operator !=(UIntPtr value1, UIntPtr value2)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe bool operator !=(UIntPtr value1, UIntPtr value2)
         {
             return value1._value != value2._value;
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [NonVersionable]
         public static UIntPtr Add(UIntPtr pointer, int offset)
         {
             return pointer + offset;
         }
 
-        [System.Runtime.Versioning.NonVersionable]
-        public static UIntPtr operator +(UIntPtr pointer, int offset)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe UIntPtr operator +(UIntPtr pointer, int offset)
         {
-#if BIT64
-            return new UIntPtr(pointer.ToUInt64() + (ulong)offset);
-#else // 32
-                return new UIntPtr(pointer.ToUInt32() + (uint)offset);
-#endif
+            return new UIntPtr((nuint)pointer._value + (nuint)offset);
         }
 
-        [System.Runtime.Versioning.NonVersionable]
+        [NonVersionable]
         public static UIntPtr Subtract(UIntPtr pointer, int offset)
         {
             return pointer - offset;
         }
 
-        [System.Runtime.Versioning.NonVersionable]
-        public static UIntPtr operator -(UIntPtr pointer, int offset)
+        [Intrinsic]
+        [NonVersionable]
+        public static unsafe UIntPtr operator -(UIntPtr pointer, int offset)
         {
-#if BIT64
-            return new UIntPtr(pointer.ToUInt64() - (ulong)offset);
-#else // 32
-                return new UIntPtr(pointer.ToUInt32() - (uint)offset);
-#endif
+            return new UIntPtr((nuint)pointer._value - (nuint)offset);
         }
 
-        public static int Size
+        public static unsafe int Size
         {
-            [System.Runtime.Versioning.NonVersionable]
+            [Intrinsic]
+            [NonVersionable]
             get
             {
-#if BIT64
-                return 8;
-#else // 32
-                return 4;
-#endif
+                return sizeof(nuint);
             }
         }
 
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
+        [Intrinsic]
+        [NonVersionable]
         public unsafe void* ToPointer()
         {
             return _value;
         }
+
+        public unsafe override String ToString()
+        {
+            return ((nuint)_value).ToString(CultureInfo.InvariantCulture);
+        }
     }
 }
-
-
index 813b2b5..f69e836 100644 (file)
@@ -174,7 +174,7 @@ namespace System
         {
             // This should never happen under normal circumstances. However, there ar ways to create an
             // uninitialized object through remoting, etc.
-            if (_pDomain.IsNull())
+            if (_pDomain == IntPtr.Zero)
             {
                 throw new InvalidOperationException(SR.Argument_InvalidHandle);
             }
index 7258614..ddbeb0c 100644 (file)
@@ -130,9 +130,9 @@ namespace System
             // It may also happen that the method pointer was not jitted when creating one delegate and jitted in the other 
             // if that's the case the delegates may still be equals but we need to make a more complicated check
 
-            if (_methodPtrAux.IsNull())
+            if (_methodPtrAux == IntPtr.Zero)
             {
-                if (!d._methodPtrAux.IsNull())
+                if (d._methodPtrAux != IntPtr.Zero)
                     return false; // different delegate kind
                 // they are both closed over the first arg
                 if (_target != d._target)
@@ -141,7 +141,7 @@ namespace System
             }
             else
             {
-                if (d._methodPtrAux.IsNull())
+                if (d._methodPtrAux == IntPtr.Zero)
                     return false; // different delegate kind
 
                 // Ignore the target as it will be the delegate instance, though it may be a different one
@@ -170,12 +170,12 @@ namespace System
             // in that case the delegate is the same and Equals will return true but GetHashCode returns a
             // different hashcode which is not true.
             /*
-            if (_methodPtrAux.IsNull())
+            if (_methodPtrAux == IntPtr.Zero)
                 return unchecked((int)((long)this._methodPtr));
             else
                 return unchecked((int)((long)this._methodPtrAux));
             */
-            if (_methodPtrAux.IsNull())
+            if (_methodPtrAux == IntPtr.Zero)
                 return ( _target != null ? RuntimeHelpers.GetHashCode(_target) * 33 : 0) + GetType().GetHashCode();
             else
                 return GetType().GetHashCode();
@@ -229,7 +229,7 @@ namespace System
                     bool isStatic = (RuntimeMethodHandle.GetAttributes(method) & MethodAttributes.Static) != (MethodAttributes)0;
                     if (!isStatic)
                     {
-                        if (_methodPtrAux == (IntPtr)0)
+                        if (_methodPtrAux == IntPtr.Zero)
                         {
                             // The target may be of a derived type that doesn't have visibility onto the
                             // target method. We don't want to call RuntimeType.GetMethodBase below with that
@@ -679,7 +679,7 @@ namespace System
 
         internal virtual Object GetTarget()
         {
-            return (_methodPtrAux.IsNull()) ? _target : null;
+            return (_methodPtrAux == IntPtr.Zero) ? _target : null;
         }
 
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
index 1db7358..cc6f000 100644 (file)
@@ -171,7 +171,7 @@ namespace System.Diagnostics
             // and then we fetch the proper MethodBase!!
             IntPtr mh = rgMethodHandle[i];
 
-            if (mh.IsNull())
+            if (mh == IntPtr.Zero)
                 return null;
 
             IRuntimeMethodInfo mhReal = RuntimeMethodHandle.GetTypicalMethodDefinition(new RuntimeMethodInfoStub(mh, this));
diff --git a/src/mscorlib/src/System/Empty.cs b/src/mscorlib/src/System/Empty.cs
deleted file mode 100644 (file)
index ac01fa6..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-////////////////////////////////////////////////////////////////////////////////
-// Empty
-//    This class represents an empty variant
-////////////////////////////////////////////////////////////////////////////////
-
-
-using System;
-using System.Runtime.Serialization;
-
-namespace System
-{
-    internal sealed class Empty : ISerializable
-    {
-        private Empty()
-        {
-        }
-
-        public static readonly Empty Value = new Empty();
-
-        public override String ToString()
-        {
-            return String.Empty;
-        }
-
-        public void GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            throw new PlatformNotSupportedException();
-        }
-    }
-}
diff --git a/src/mscorlib/src/System/IntPtr.cs b/src/mscorlib/src/System/IntPtr.cs
deleted file mode 100644 (file)
index 76a8ea9..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** Purpose: Platform independent integer
-**
-** 
-===========================================================*/
-
-namespace System
-{
-    using System;
-    using System.Globalization;
-    using System.Runtime;
-    using System.Runtime.Serialization;
-    using System.Runtime.CompilerServices;
-    using System.Runtime.ConstrainedExecution;
-    using System.Security;
-
-    [Serializable]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
-    public struct IntPtr : IEquatable<IntPtr>, ISerializable
-    {
-        unsafe private void* _value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior. Do not rename (binary serialization)
-
-        public static readonly IntPtr Zero;
-
-        // fast way to compare IntPtr to (IntPtr)0 while IntPtr.Zero doesn't work due to slow statics access
-        internal unsafe bool IsNull()
-        {
-            return (_value == null);
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe IntPtr(int value)
-        {
-#if BIT64
-            _value = (void*)(long)value;
-#else // !BIT64 (32)
-                _value = (void *)value;
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe IntPtr(long value)
-        {
-#if BIT64
-            _value = (void*)value;
-#else // !BIT64 (32)
-                _value = (void *)checked((int)value);
-#endif
-        }
-
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe IntPtr(void* value)
-        {
-            _value = value;
-        }
-
-        private unsafe IntPtr(SerializationInfo info, StreamingContext context)
-        {
-            long l = info.GetInt64("value");
-
-            if (Size == 4 && (l > Int32.MaxValue || l < Int32.MinValue))
-            {
-                throw new ArgumentException(SR.Serialization_InvalidPtrValue);
-            }
-
-            _value = (void*)l;
-        }
-
-        unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            if (info == null)
-            {
-                throw new ArgumentNullException(nameof(info));
-            }
-#if BIT64
-            info.AddValue("value", (long)(_value));
-#else // !BIT64 (32)
-                info.AddValue("value", (long)((int)_value));
-#endif
-        }
-
-        public unsafe override bool Equals(Object obj)
-        {
-            if (obj is IntPtr)
-            {
-                return (_value == ((IntPtr)obj)._value);
-            }
-            return false;
-        }
-
-        unsafe bool IEquatable<IntPtr>.Equals(IntPtr other)
-        {
-            return _value == other._value;
-        }
-
-        public unsafe override int GetHashCode()
-        {
-#if BIT64
-            long l = (long)_value;
-            return (unchecked((int)l) ^ (int)(l >> 32));
-#else // !BIT64 (32)
-            return unchecked((int)_value);
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe int ToInt32()
-        {
-#if BIT64
-            long l = (long)_value;
-            return checked((int)l);
-#else // !BIT64 (32)
-                return (int)_value;
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe long ToInt64()
-        {
-#if BIT64
-            return (long)_value;
-#else // !BIT64 (32)
-                return (long)(int)_value;
-#endif
-        }
-
-        public unsafe override String ToString()
-        {
-#if BIT64
-            return ((long)_value).ToString(CultureInfo.InvariantCulture);
-#else // !BIT64 (32)
-                return ((int)_value).ToString(CultureInfo.InvariantCulture);
-#endif
-        }
-
-        public unsafe String ToString(String format)
-        {
-#if BIT64
-            return ((long)_value).ToString(format, CultureInfo.InvariantCulture);
-#else // !BIT64 (32)
-                return ((int)_value).ToString(format, CultureInfo.InvariantCulture);
-#endif
-        }
-
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static explicit operator IntPtr(int value)
-        {
-            return new IntPtr(value);
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static explicit operator IntPtr(long value)
-        {
-            return new IntPtr(value);
-        }
-
-        [CLSCompliant(false), ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)]
-        [System.Runtime.Versioning.NonVersionable]
-        public static unsafe explicit operator IntPtr(void* value)
-        {
-            return new IntPtr(value);
-        }
-
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
-        public static unsafe explicit operator void* (IntPtr value)
-        {
-            return value._value;
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static explicit operator int(IntPtr value)
-        {
-#if BIT64
-            long l = (long)value._value;
-            return checked((int)l);
-#else // !BIT64 (32)
-                return (int)value._value;
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static explicit operator long(IntPtr value)
-        {
-#if BIT64
-            return (long)value._value;
-#else // !BIT64 (32)
-                return (long)(int)value._value;
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static bool operator ==(IntPtr value1, IntPtr value2)
-        {
-            return value1._value == value2._value;
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe static bool operator !=(IntPtr value1, IntPtr value2)
-        {
-            return value1._value != value2._value;
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static IntPtr Add(IntPtr pointer, int offset)
-        {
-            return pointer + offset;
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static IntPtr operator +(IntPtr pointer, int offset)
-        {
-#if BIT64
-            return new IntPtr(pointer.ToInt64() + offset);
-#else // !BIT64 (32)
-                return new IntPtr(pointer.ToInt32() + offset);
-#endif
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static IntPtr Subtract(IntPtr pointer, int offset)
-        {
-            return pointer - offset;
-        }
-
-        [System.Runtime.Versioning.NonVersionable]
-        public static IntPtr operator -(IntPtr pointer, int offset)
-        {
-#if BIT64
-            return new IntPtr(pointer.ToInt64() - offset);
-#else // !BIT64 (32)
-                return new IntPtr(pointer.ToInt32() - offset);
-#endif
-        }
-
-        public static int Size
-        {
-            [System.Runtime.Versioning.NonVersionable]
-            get
-            {
-#if BIT64
-                return 8;
-#else // !BIT64 (32)
-                    return 4;
-#endif
-            }
-        }
-
-
-        [CLSCompliant(false)]
-        [System.Runtime.Versioning.NonVersionable]
-        public unsafe void* ToPointer()
-        {
-            return _value;
-        }
-    }
-}
-
-
index 7a34a15..5447773 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Reflection
 
         ~LoaderAllocatorScout()
         {
-            if (m_nativeLoaderAllocator.IsNull())
+            if (m_nativeLoaderAllocator == IntPtr.Zero)
                 return;
 
             // Assemblies and LoaderAllocators will be cleaned up during AppDomain shutdown in
index eff9291..9e78e82 100644 (file)
@@ -2453,13 +2453,13 @@ namespace System
         {
             get
             {
-                if (m_cache.IsNull())
+                if (m_cache == IntPtr.Zero)
                 {
                     IntPtr newgcHandle = new RuntimeTypeHandle(this).GetGCHandle(GCHandleType.WeakTrackResurrection);
-                    IntPtr gcHandle = Interlocked.CompareExchange(ref m_cache, newgcHandle, (IntPtr)0);
+                    IntPtr gcHandle = Interlocked.CompareExchange(ref m_cache, newgcHandle, IntPtr.Zero);
                     // Leak the handle if the type is collectible. It will be reclaimed when
                     // the type goes away.
-                    if (!gcHandle.IsNull() && !IsCollectible())
+                    if (gcHandle != IntPtr.Zero && !IsCollectible())
                         GCHandle.InternalFree(newgcHandle);
                 }
 
index 9b4670b..fe61af2 100644 (file)
@@ -145,7 +145,7 @@ namespace System.Runtime.InteropServices
         }
 
         // Determine whether this handle has been allocated or not.
-        public bool IsAllocated => !m_handle.IsNull();
+        public bool IsAllocated => m_handle != IntPtr.Zero;
 
         // Used to create a GCHandle from an int.  This is intended to
         // be used with the reverse conversion.
@@ -267,14 +267,14 @@ namespace System.Runtime.InteropServices
         private void ValidateHandle()
         {
             // Check if the handle was never initialized or was freed.
-            if (m_handle.IsNull())
+            if (m_handle == IntPtr.Zero)
                 ThrowInvalidOperationException_HandleIsNotInitialized();
         }
 
         private static void ValidateHandle(IntPtr handle)
         {
             // Check if the handle was never initialized or was freed.
-            if (handle.IsNull())
+            if (handle == IntPtr.Zero)
                 ThrowInvalidOperationException_HandleIsNotInitialized();
         }
 
index eda28c6..69ee4c2 100644 (file)
@@ -650,7 +650,7 @@ namespace System
 
         internal bool IsNullHandle()
         {
-            return m_handle.IsNull();
+            return m_handle == IntPtr.Zero;
         }
 
         internal IntPtr Value
@@ -1016,7 +1016,7 @@ namespace System
     {
         internal bool IsNullHandle()
         {
-            return m_handle.IsNull();
+            return m_handle == IntPtr.Zero;
         }
 
         internal IntPtr Value
index 888f25c..bf19c7f 100644 (file)
@@ -681,9 +681,9 @@ namespace System.StubHelpers
             }
             finally
             {
-                if (!oldItemsIP.IsNull())
+                if (oldItemsIP != IntPtr.Zero)
                     Marshal.Release(oldItemsIP);
-                if (!newItemsIP.IsNull())
+                if (newItemsIP != IntPtr.Zero)
                     Marshal.Release(newItemsIP);
             }
         }
index 2a9f1e2..44fe29c 100644 (file)
@@ -150,20 +150,20 @@ namespace System.Threading
             m_iocbHelper = null;
             m_overlapped = null;
             m_userObject = null;
-            Debug.Assert(m_pinSelf.IsNull(), "OverlappedData has not been freed: m_pinSelf");
-            m_pinSelf = (IntPtr)0;
-            m_userObjectInternal = (IntPtr)0;
+            Debug.Assert(m_pinSelf == IntPtr.Zero, "OverlappedData has not been freed: m_pinSelf");
+            m_pinSelf = IntPtr.Zero;
+            m_userObjectInternal = IntPtr.Zero;
             Debug.Assert(m_AppDomainId == 0 || m_AppDomainId == AppDomain.CurrentDomain.Id, "OverlappedData is not in the current domain");
             m_AppDomainId = 0;
-            m_nativeOverlapped.EventHandle = (IntPtr)0;
+            m_nativeOverlapped.EventHandle = IntPtr.Zero;
             m_isArray = 0;
-            m_nativeOverlapped.InternalLow = (IntPtr)0;
-            m_nativeOverlapped.InternalHigh = (IntPtr)0;
+            m_nativeOverlapped.InternalLow = IntPtr.Zero;
+            m_nativeOverlapped.InternalHigh = IntPtr.Zero;
         }
 
         unsafe internal NativeOverlapped* Pack(IOCompletionCallback iocb, Object userData)
         {
-            if (!m_pinSelf.IsNull())
+            if (m_pinSelf != IntPtr.Zero)
             {
                 throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
             }
@@ -195,7 +195,7 @@ namespace System.Threading
 
         unsafe internal NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData)
         {
-            if (!m_pinSelf.IsNull())
+            if (m_pinSelf != IntPtr.Zero)
             {
                 throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
             }
index a57b10f..c9ae3d8 100644 (file)
@@ -217,7 +217,7 @@ namespace System.Threading
             // This should never happen under normal circumstances. m_assembly is always assigned before it is handed out to the user.
             // There are ways how to create an unitialized objects through remoting, etc. Avoid AVing in the EE by throwing a nice
             // exception here.
-            if (thread.IsNull())
+            if (thread == IntPtr.Zero)
                 throw new ArgumentException(null, SR.Argument_InvalidHandle);
 
             return new ThreadHandle(thread);
index e29e880..f7c8779 100644 (file)
@@ -97,7 +97,7 @@ namespace System
         {
             get
             {
-                return Value.IsNull() && Type.IsNull();
+                return Value == IntPtr.Zero && Type == IntPtr.Zero;
             }
         }