<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" />
{
}
- public override bool IsInvalid => handle.IsNull() || handle == new IntPtr(-1);
+ public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
}
}
<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'" />
--- /dev/null
+// 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;
+ }
+ }
+}
// 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
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)
EnumCalendarsData data = new EnumCalendarsData();
data.userOverride = 0;
- data.calendars = new IntList();
+ data.calendars = new List<int>();
// First call GetLocaleInfo if necessary
if (useUserOverride)
private class EnumData
{
public string userOverride;
- public StringList strings;
+ public List<string> strings;
}
// EnumCalendarInfoExEx callback itself.
{
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.
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)]
--- /dev/null
+// 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);
+ }
+ }
+}
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.
public TaskCanceledException(Task task) :
base(SR.TaskCanceledException_ctor_DefaultMessage, task != null ? task.CancellationToken : new CancellationToken())
{
- m_canceledTask = task;
+ _canceledTask = task;
}
/// <summary>
/// <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;
}
}
/// 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>
/// </exception>
public TaskCompletionSource(object state, TaskCreationOptions creationOptions)
{
- m_task = new Task<TResult>(state, creationOptions);
+ _task = new Task<TResult>(state, creationOptions);
}
/// 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>
{
// Spin wait until the completion is finalized by another thread.
var sw = new SpinWait();
- while (!m_task.IsCompleted)
+ while (!_task.IsCompleted)
sw.SpinOnce();
}
{
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;
}
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;
}
/// <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;
}
// 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;
}
// 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;
{
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;
}
unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
- {
throw new ArgumentNullException(nameof(info));
- }
+
info.AddValue("value", (ulong)_value);
}
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()
#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);
+ }
}
}
-
-
{
// 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);
}
// 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)
}
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
// 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();
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
internal virtual Object GetTarget()
{
- return (_methodPtrAux.IsNull()) ? _target : null;
+ return (_methodPtrAux == IntPtr.Zero) ? _target : null;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// 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));
+++ /dev/null
-// 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();
- }
- }
-}
+++ /dev/null
-// 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;
- }
- }
-}
-
-
~LoaderAllocatorScout()
{
- if (m_nativeLoaderAllocator.IsNull())
+ if (m_nativeLoaderAllocator == IntPtr.Zero)
return;
// Assemblies and LoaderAllocators will be cleaned up during AppDomain shutdown in
{
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);
}
}
// 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.
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();
}
internal bool IsNullHandle()
{
- return m_handle.IsNull();
+ return m_handle == IntPtr.Zero;
}
internal IntPtr Value
{
internal bool IsNullHandle()
{
- return m_handle.IsNull();
+ return m_handle == IntPtr.Zero;
}
internal IntPtr Value
}
finally
{
- if (!oldItemsIP.IsNull())
+ if (oldItemsIP != IntPtr.Zero)
Marshal.Release(oldItemsIP);
- if (!newItemsIP.IsNull())
+ if (newItemsIP != IntPtr.Zero)
Marshal.Release(newItemsIP);
}
}
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);
}
unsafe internal NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData)
{
- if (!m_pinSelf.IsNull())
+ if (m_pinSelf != IntPtr.Zero)
{
throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
}
// 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);
{
get
{
- return Value.IsNull() && Type.IsNull();
+ return Value == IntPtr.Zero && Type == IntPtr.Zero;
}
}