Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2017-05-11 00:33:38 +0300
committerGitHub <noreply@github.com>2017-05-11 00:33:38 +0300
commita29e79e8dac01846c5fe4bdb533e466188760f02 (patch)
tree175c8f0ded070a60739fa4512398d283c3c955bd /src/System.Private.CoreLib
parentd41bf46f2b32c68ee423334190caa6e616aafeb5 (diff)
parentabacb02d80c1aba107d342c83b469b616b8a7f49 (diff)
Merge pull request #3575 from dotnet/nmirror
Merge nmirror to master
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/src/System/Activator.cs23
-rw-r--r--src/System.Private.CoreLib/src/System/Array.CoreRT.cs9
-rw-r--r--src/System.Private.CoreLib/src/System/Attribute.cs24
-rw-r--r--src/System.Private.CoreLib/src/System/Enum.cs31
4 files changed, 75 insertions, 12 deletions
diff --git a/src/System.Private.CoreLib/src/System/Activator.cs b/src/System.Private.CoreLib/src/System/Activator.cs
index 4085f0f31..e77006e0a 100644
--- a/src/System.Private.CoreLib/src/System/Activator.cs
+++ b/src/System.Private.CoreLib/src/System/Activator.cs
@@ -7,8 +7,9 @@
// methods for late bound support.
//
-using System.Reflection;
+using System.Diagnostics;
using System.Globalization;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime;
@@ -25,6 +26,7 @@ namespace System
// a default constructor. (Those result in running the ClassWithMissingConstructor's .ctor, which flips the magic
// thread static to cause the CreateInstance<T> method to throw the right exception.)
//
+ [DebuggerGuidedStepThrough]
public static T CreateInstance<T>()
{
T t = default(T);
@@ -53,6 +55,7 @@ namespace System
try
{
t = CreateInstanceIntrinsic<T>();
+ System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
catch (Exception e)
{
@@ -78,6 +81,7 @@ namespace System
}
[Intrinsic]
+ [DebuggerGuidedStepThrough]
private static T CreateInstanceIntrinsic<T>()
{
// Fallback implementation for codegens that don't support this intrinsic.
@@ -93,6 +97,7 @@ namespace System
{
object o = null;
TypeLoaderExports.ActivatorCreateInstanceAny(ref o, eetype.RawValue);
+ System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
return (T)o;
}
@@ -113,12 +118,28 @@ namespace System
}
}
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type) => CreateInstance(type, nonPublic: false);
+
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type, bool nonPublic) => ReflectionAugments.ReflectionCoreCallbacks.ActivatorCreateInstance(type, nonPublic);
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type, params object[] args) => CreateInstance(type, ConstructorDefault, null, args, null, null);
+
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type, object[] args, object[] activationAttributes) => CreateInstance(type, ConstructorDefault, null, args, null, activationAttributes);
+
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture) => CreateInstance(type, bindingAttr, binder, args, culture, null);
+
+ [DebuggerHidden]
+ [DebuggerStepThrough]
public static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
{
return ReflectionAugments.ReflectionCoreCallbacks.ActivatorCreateInstance(type, bindingAttr, binder, args, culture, activationAttributes);
diff --git a/src/System.Private.CoreLib/src/System/Array.CoreRT.cs b/src/System.Private.CoreLib/src/System/Array.CoreRT.cs
index 885b6a89b..f93d8fb8d 100644
--- a/src/System.Private.CoreLib/src/System/Array.CoreRT.cs
+++ b/src/System.Private.CoreLib/src/System/Array.CoreRT.cs
@@ -14,6 +14,7 @@ using System.Diagnostics.Contracts;
using Internal.Runtime.Augments;
using Internal.Reflection.Core.NonPortable;
+using EEType = Internal.Runtime.EEType;
#if BIT64
using nuint = System.UInt64;
@@ -64,6 +65,14 @@ namespace System
}
}
+ // This is the classlib-provided "get array eetype" function that will be invoked whenever the runtime
+ // needs to know the base type of an array.
+ [RuntimeExport("GetSystemArrayEEType")]
+ private static unsafe EEType* GetSystemArrayEEType()
+ {
+ return EETypePtr.EETypePtrOf<Array>().ToPointer();
+ }
+
public static Array CreateInstance(Type elementType, int length)
{
if ((object)elementType == null)
diff --git a/src/System.Private.CoreLib/src/System/Attribute.cs b/src/System.Private.CoreLib/src/System/Attribute.cs
index 34d9b6b77..5445ffbd0 100644
--- a/src/System.Private.CoreLib/src/System/Attribute.cs
+++ b/src/System.Private.CoreLib/src/System/Attribute.cs
@@ -11,6 +11,13 @@ namespace System
{
protected Attribute() { }
+ //
+ // Compat note: .NET Core changed the behavior of Equals() relative to the full framework:
+ //
+ // (https://github.com/dotnet/coreclr/pull/6240)
+ //
+ // This implementation implements the .NET Core behavior.
+ //
public override bool Equals(Object obj)
{
if (obj == null)
@@ -124,7 +131,7 @@ namespace System
// This non-contract method is known to the IL transformer. See comments around _ILT_ReadFields() for more detail.
//
[CLSCompliant(false)]
- protected virtual int _ILT_GetNumFields(bool inBaseClass)
+ protected virtual int _ILT_GetNumFields()
{
return 0;
}
@@ -133,20 +140,15 @@ namespace System
// This non-contract method is known to the IL transformer. The IL transformer generates an override of this for each specific Attribute class.
// Together with _ILT_GetNumFields(), it fetches the same field values that the desktop would have for comparison.
//
- // The desktop uses "GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)" to determine the list of fields
- // used for comparison. Unfortunately, this list can include fields that the "this" class has no right to access (e.g. "internal"
+ // .NET Core uses "GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)" to
+ // determine the list of fields used for comparison. Unfortunately, this list can include fields that the "this" class has no right to access (e.g. "internal"
// fields in base classes defined in another assembly.) Thus, the IL Transformer cannot simply generate a method to walk the fields and
// be done with it. Instead, _ILT_ReadFields() directly fetches only the directly declared fields and reinvokes itself non-virtually on its
// base class to get any inherited fields. To simplify the IL generation, the generated method only writes the results into a specified
// offset inside a caller-supplied array. Attribute.ReadFields() calls _ILT_GetNumFields() to figure out how large an array is needed.
//
- // The "inBaseClass" determines whether the "this" is the "this" that Equals/GetHashCode was actually called or one of its base types.
- // That's because the list of fields includes directly declared private fields but not inherited private fields. (This can in turn
- // cause weird effects like the derived type returning "true" for Equals() while it's base type's Equal() returns "false" - but that's
- // backward compat for you.)
- //
[CLSCompliant(false)]
- protected virtual void _ILT_ReadFields(Object[] destination, int offset, bool inBaseClass)
+ protected virtual void _ILT_ReadFields(Object[] destination, int offset)
{
}
@@ -156,9 +158,9 @@ namespace System
//
private Object[] ReadFields()
{
- int numFields = _ILT_GetNumFields(inBaseClass: false);
+ int numFields = _ILT_GetNumFields();
Object[] fieldValues = new Object[numFields];
- _ILT_ReadFields(fieldValues, 0, inBaseClass: false);
+ _ILT_ReadFields(fieldValues, 0);
return fieldValues;
}
}
diff --git a/src/System.Private.CoreLib/src/System/Enum.cs b/src/System.Private.CoreLib/src/System/Enum.cs
index d25cca112..5e4adf1b5 100644
--- a/src/System.Private.CoreLib/src/System/Enum.cs
+++ b/src/System.Private.CoreLib/src/System/Enum.cs
@@ -1003,6 +1003,12 @@ namespace System
if (TryParseAsInteger(enumEEType, value, firstNonWhitespaceIndex, out result))
return true;
+ if (StillLooksLikeInteger(value, firstNonWhitespaceIndex))
+ {
+ exception = new OverflowException();
+ return false;
+ }
+
// Parse as string. Now (and only now) do we look for metadata information.
EnumInfo enumInfo = RuntimeAugments.Callbacks.GetEnumInfoIfAvailable(enumType);
if (enumInfo == null)
@@ -1175,6 +1181,31 @@ namespace System
}
}
+ private static bool StillLooksLikeInteger(String value, int index)
+ {
+ if (index != value.Length && (value[index] == '-' || value[index] == '+'))
+ {
+ index++;
+ }
+
+ if (index == value.Length || !char.IsDigit(value[index]))
+ return false;
+
+ index++;
+
+ while (index != value.Length && char.IsDigit(value[index]))
+ {
+ index++;
+ }
+
+ while (index != value.Length && char.IsWhiteSpace(value[index]))
+ {
+ index++;
+ }
+
+ return index == value.Length;
+ }
+
[Conditional("BIGENDIAN")]
private static unsafe void AdjustForEndianness(ref byte* pValue, EETypePtr enumEEType)
{