Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -4,7 +4,6 @@
<!-- domain.c: mono_defaults.appdomain_class -->
<type fullname="System.AppDomain" preserve="fields">
<method name="DoDomainUnload" />
<!-- appdomain.c: mono_domain_try_type_resolve -->
<method name="DoTypeResolve" />
<!-- appdomain.c: mono_try_assembly_resolve -->
@@ -506,13 +505,6 @@
note: there's no fields (static type) but that will mark the type itself -->
<type fullname="System.Math" preserve="fields" />
<type fullname="System.Reflection.MonoAssembly">
<method name=".ctor" />
</type>
<type fullname="System.Reflection.MonoModule">
<method name=".ctor" />
</type>
<!-- appdomain.c: ves_icall_System_AppDomain_GetAssemblies -->
<type fullname="System.Reflection.Assembly" preserve="fields"/>
@@ -554,8 +546,12 @@
<type fullname="System.Reflection.MethodInfo" preserve="fields" />
<type fullname="System.Reflection.Module" preserve="fields" />
<type fullname="System.Reflection.MonoAssembly" preserve="fields" />
<type fullname="System.Reflection.MonoModule" preserve="fields" />
<type fullname="System.Reflection.MonoAssembly" preserve="fields" >
<method name=".ctor" />
</type>
<type fullname="System.Reflection.MonoModule" preserve="fields" >
<method name=".ctor" />
</type>
<type fullname="System.Reflection.MonoCMethod" preserve="fields" />
<type fullname="System.Reflection.MonoEvent" preserve="fields" />
<type fullname="System.Reflection.MonoEventInfo" preserve="fields" />
@@ -602,39 +598,39 @@
</type>
<type fullname="System.Reflection.Emit.AssemblyBuilder" preserve="fields" feature="sre">
<method name="AddPermissionRequests" />
<method name="AddModule" />
<method name="DefineIconResource" />
<method name="AddTypeForwarder" />
<method name="EmbedResourceFile" />
<method name="AddPermissionRequests" feature="sre" />
<method name="AddModule" feature="sre" />
<method name="DefineIconResource" feature="sre" />
<method name="AddTypeForwarder" feature="sre" />
<method name="EmbedResourceFile" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ConstructorBuilder" preserve="fields" feature="sre">
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.CustomAttributeBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.DynamicMethod" preserve="fields" />
<type fullname="System.Reflection.Emit.EnumBuilder" preserve="fields" />
<type fullname="System.Reflection.Emit.EventBuilder" preserve="fields" />
<type fullname="System.Reflection.Emit.FieldBuilder" preserve="fields" >
<method name="RuntimeResolve" />
<type fullname="System.Reflection.Emit.DynamicMethod" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.EnumBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.EventBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.FieldBuilder" preserve="fields" feature="sre" >
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.GenericTypeParameterBuilder" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ILExceptionBlock" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ILExceptionInfo" preserve="fields" />
<type fullname="System.Reflection.Emit.ILGenerator" preserve="fields">
<method name="Mono_GetCurrentOffset" />
<type fullname="System.Reflection.Emit.ILExceptionInfo" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ILGenerator" preserve="fields" feature="sre" >
<method name="Mono_GetCurrentOffset" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.LocalBuilder" preserve="fields" feature="sre" >
<method name="Mono_GetLocalIndex" />
<method name="Mono_GetLocalIndex" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.MethodBuilder" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ModuleBuilder" preserve="fields" feature="sre">
<method name="Mono_GetGuid" />
<method name="RuntimeResolve" />
<method name="Mono_GetGuid" feature="sre" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.MonoResource" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MonoWin32Resource" preserve="fields" feature="sre" />
@@ -642,34 +638,34 @@
<type fullname="System.Reflection.Emit.PropertyBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.SignatureHelper" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.TypeBuilder" preserve="fields" feature="sre">
<method name="SetCharSet" />
<method name="SetCharSet" feature="sre" />
<!-- reflection.c mono_reflection_call_is_assignable_to () -->
<method name="IsAssignableTo" />
<method name="IsAssignableTo" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.UnmanagedMarshal" preserve="fields" feature="sre" >
<method name="DefineCustom" />
<method name="DefineLPArrayInternal" />
<method name="DefineCustom" feature="sre" />
<method name="DefineLPArrayInternal" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.TypeBuilderInstantiation" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ArrayType" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ByRefType" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.PointerType" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.FieldOnTypeBuilderInst" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.MethodOnTypeBuilderInst" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ConstructorOnTypeBuilderInst" preserve="fields" feature="sre" >
<method name="RuntimeResolve" />
<method name="RuntimeResolve" feature="sre" />
</type>
<!-- domain.c: mono_defaults.internals_visible_class -->
@@ -726,13 +722,18 @@
<type fullname="System.Runtime.Remoting.Messaging.CallContext" feature="remoting" >
<method name="SetCurrentCallContext" />
</type>
<type fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" preserve="fields" feature="remoting" >
<!-- domain.c: mono_defaults.mono_method_message_class -->
<type fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" preserve="fields">
<!-- object.c: mono_message_init -->
<method name="InitMessage" />
</type>
<!-- domain.c: mono_defaults.real_proxy_class / removed with DISABLE_REMOTING -->
<type fullname="System.Runtime.Remoting.Proxies.RealProxy" preserve="fields" feature="remoting" >
<method name="PrivateInvoke" />
<method name="GetAppDomainTarget" />
</type>
<!-- domain.c: mono_defaults.transparent_proxy_class / removed with DISABLE_REMOTING -->
<type fullname="System.Runtime.Remoting.Proxies.TransparentProxy" preserve="fields" feature="remoting" >
<method name="LoadRemoteFieldNew" />
<method name="StoreRemoteField" />
@@ -743,18 +744,6 @@
<method name="SerializeExceptionData" />
</type>
<!-- domain.c: mono_defaults.mono_method_message_class -->
<type fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" preserve="fields">
<!-- object.c: mono_message_init -->
<method name="InitMessage" />
</type>
<!-- domain.c: mono_defaults.real_proxy_class / removed with DISABLE_REMOTING -->
<type fullname="System.Runtime.Remoting.Proxies.RealProxy" feature="remoting" />
<!-- domain.c: mono_defaults.transparent_proxy_class / removed with DISABLE_REMOTING -->
<type fullname="System.Runtime.Remoting.Proxies.TransparentProxy" feature="remoting" />
<!-- object.c: mono_object_new_specific_checked -->
<type fullname="System.Runtime.Remoting.Activation.ActivationServices" >
<method name="CreateProxyForType"/>

View File

@@ -32,6 +32,12 @@ RESX_RESOURCE_STRING = \
../../../external/corefx/src/System.Memory/src/Resources/Strings.resx \
../../../external/corefx/src/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx \
../../../external/corefx/src/System.Threading.Tasks.Parallel/src/Resources/Strings.resx \
../../../external/corefx/src/System.Collections/src/Resources/Strings.resx \
../../../external/corefx/src/System.Collections.NonGeneric/src/Resources/Strings.resx \
../../../external/corefx/src/System.Runtime.Extensions/src/Resources/Strings.resx \
../../../external/corefx/src/System.ObjectModel/src/Resources/Strings.resx \
../../../external/corefx/src/System.Numerics.Vectors/src/Resources/Strings.resx \
../../../external/corefx/src/System.Runtime.Numerics/src/Resources/Strings.resx
LIBRARY_COMPILE = $(BOOT_COMPILE)
LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
@@ -95,7 +101,7 @@ ifdef MONO_FEATURE_APPLE_X509
LIB_MCS_FLAGS += -d:MONO_FEATURE_APPLE_X509
endif
COREFX_FLAGS := -d:FEATURE_PORTABLE_SPAN
COREFX_FLAGS := -d:BIT64
WARNING_ABOUT_DISABLED_WARNING=1635
LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618,3001,3002,3003,$(WARNING_ABOUT_DISABLED_WARNING) -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS) $(COREFX_FLAGS)
@@ -103,7 +109,7 @@ DEFAULT_REFERENCES =
TEST_LIB_REFS = System.Core System
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Numerics.Vectors System.Runtime.CompilerServices.Unsafe
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Text.RegularExpressions System.Numerics System.Runtime.CompilerServices.Unsafe
XTEST_LIB_FLAGS = -d:netcoreapp -publicsign -keyfile:../mono.snk
ifndef AOT_FRIENDLY_PROFILE

View File

@@ -1,3 +1,12 @@
#if BIT64
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif
using System.Runtime.CompilerServices;
using System.Runtime;
namespace System
{
partial class Buffer
@@ -213,7 +222,28 @@ namespace System
internal static unsafe void Memmove (byte *dest, byte *src, uint len)
{
if (((nuint)dest - (nuint)src < len) || ((nuint)src - (nuint)dest < len))
goto PInvoke;
Memcpy (dest, src, (int) len);
return;
PInvoke:
RuntimeImports.Memmove(dest, src, len);
}
internal static void Memmove<T>(ref T destination, ref T source, nuint elementCount)
{
if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>()) {
unsafe {
fixed (byte* pDestination = &Unsafe.As<T, byte>(ref destination), pSource = &Unsafe.As<T, byte>(ref source))
Memmove(pDestination, pSource, (uint)elementCount * (uint)Unsafe.SizeOf<T>());
}
} else {
unsafe {
fixed (byte* pDestination = &Unsafe.As<T, byte>(ref destination), pSource = &Unsafe.As<T, byte>(ref source))
RuntimeImports.Memmove_wbarrier(pDestination, pSource, (uint)elementCount, typeof(T).TypeHandle.Value);
}
}
}
}
}

View File

@@ -34,11 +34,19 @@
//
//
#if BIT64
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif
using System.Runtime.CompilerServices;
using System.Text;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics.Private;
namespace System
{
@@ -51,15 +59,6 @@ namespace System
public static readonly String Empty;
public unsafe static implicit operator ReadOnlySpan<char> (String value)
{
if (value == null)
return default;
fixed (void* start = &value._firstChar)
return new ReadOnlySpan<char> (start, value.Length);
}
internal unsafe int IndexOfUnchecked (string value, int startIndex, int count)
{
int valueLen = value.Length;
@@ -202,7 +201,12 @@ namespace System
if (this.Length < value.Length || _firstChar != value._firstChar)
return false;
return value.Length == 1 ? true : StartsWithOrdinalHelper (this, value);
return value.Length == 1 ?
true :
SpanHelpers.SequenceEqual (
ref Unsafe.As<char, byte> (ref this.GetRawStringData ()),
ref Unsafe.As<char, byte> (ref value.GetRawStringData ()),
((nuint)value.Length) * 2);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]

View File

@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Globalization
{
@@ -198,7 +199,7 @@ namespace System.Globalization
return c;
}
static unsafe int InternalCompareStringOrdinalIgnoreCase (String strA, int indexA, String strB, int indexB, int lenA, int lenB)
internal static unsafe int InternalCompareStringOrdinalIgnoreCase (String strA, int indexA, String strB, int indexB, int lenA, int lenB)
{
if (strA == null) {
return strB == null ? 0 : -1;
@@ -229,6 +230,47 @@ namespace System.Globalization
return lengthA - lengthB;
}
}
internal void ToLowerAsciiInvariant (ReadOnlySpan<char> source, Span<char> destination)
{
for (int i = 0; i < source.Length; i++)
{
destination [i] = ToLowerAsciiInvariant (source [i]);
}
}
internal void ToUpperAsciiInvariant (ReadOnlySpan<char> source, Span<char> destination)
{
for (int i = 0; i < source.Length; i++)
{
destination [i] = ToUpperAsciiInvariant (source[i]);
}
}
internal unsafe void ChangeCase (ReadOnlySpan<char> source, Span<char> destination, bool toUpper)
{
if (source.IsEmpty)
return;
var ti = CultureInfo.CurrentCulture.TextInfo;
fixed (char* pSource = &MemoryMarshal.GetReference (source))
fixed (char* pResult = &MemoryMarshal.GetReference (destination)) {
int length = 0;
char* a = pSource, b = pResult;
if (toUpper) {
while (length < source.Length) {
*b++ = ti.ToUpper (*a++);
length++;
}
} else {
while (length < source.Length) {
*b++ = ti.ToLower (*a++);
length++;
}
}
}
}
}
static class TextInfoToUpperData

View File

@@ -38,6 +38,7 @@ namespace System.Diagnostics.Tracing
{
public IntPtr DataPointer { get; set; }
public int Size { get; set; }
internal int Reserved { get; set; }
}
protected EventSource ()
@@ -77,6 +78,11 @@ namespace System.Diagnostics.Tracing
{
}
internal EventSource (Guid eventSourceGuid, string eventSourceName)
: this (eventSourceName)
{
}
~EventSource ()
{
Dispose (false);

View File

@@ -28,6 +28,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
@@ -180,7 +181,15 @@ namespace System.Diagnostics {
[ComVisibleAttribute (false)]
public virtual StackFrame[] GetFrames ()
{
return frames;
if (captured_traces == null)
return frames;
var accum = new List<StackFrame> ();
foreach (var t in captured_traces)
accum.AddRange(t.GetFrames ());
accum.AddRange (frames);
return accum.ToArray ();
}
static bool isAotidSet;
@@ -197,15 +206,16 @@ namespace System.Diagnostics {
return aotid;
}
bool AddFrames (StringBuilder sb)
bool AddFrames (StringBuilder sb, bool separator, out bool isAsync)
{
isAsync = false;
bool any_frame = false;
for (int i = 0; i < FrameCount; i++) {
StackFrame frame = GetFrame (i);
if (frame.GetMethod () == null) {
if (any_frame)
if (any_frame || separator)
sb.Append (Environment.NewLine);
sb.Append (prefix);
@@ -215,7 +225,7 @@ namespace System.Diagnostics {
else
sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> <unknown method>", frame.GetMethodAddress (), frame.GetNativeOffset ());
} else {
GetFullNameForStackTrace (sb, frame.GetMethod (), any_frame, out var skipped);
GetFullNameForStackTrace (sb, frame.GetMethod (), any_frame || separator, out var skipped, out isAsync);
if (skipped)
continue;
@@ -247,9 +257,9 @@ namespace System.Diagnostics {
return any_frame;
}
void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi, bool needsNewLine, out bool skipped)
void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi, bool needsNewLine, out bool skipped, out bool isAsync)
{
var declaringType = mi.DeclaringType;
Type declaringType = mi.DeclaringType;
// Get generic definition
if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition) {
@@ -265,10 +275,15 @@ namespace System.Diagnostics {
}
}
skipped = mi.IsDefined (typeof(StackTraceHiddenAttribute)) || declaringType.IsDefined (typeof(StackTraceHiddenAttribute));
isAsync = typeof (IAsyncStateMachine).IsAssignableFrom (declaringType);
skipped = mi.IsDefined (typeof (StackTraceHiddenAttribute)) || declaringType.IsDefined (typeof (StackTraceHiddenAttribute));
if (skipped)
return;
if (isAsync) {
ConvertAsyncStateMachineMethod (ref mi, ref declaringType);
}
if (needsNewLine)
sb.Append (Environment.NewLine);
sb.Append (prefix);
@@ -310,6 +325,31 @@ namespace System.Diagnostics {
}
sb.Append (")");
}
static void ConvertAsyncStateMachineMethod (ref MethodBase method, ref Type declaringType)
{
Type parentType = declaringType.DeclaringType;
if (parentType == null)
return;
MethodInfo[] methods = parentType.GetMethods (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
if (methods == null)
return;
foreach (MethodInfo candidateMethod in methods) {
var attributes = candidateMethod.GetCustomAttributes<AsyncStateMachineAttribute> ();
if (attributes == null)
continue;
foreach (var attr in attributes) {
if (attr.StateMachineType == declaringType) {
method = candidateMethod;
declaringType = candidateMethod.DeclaringType;
return;
}
}
}
}
public override string ToString ()
{
@@ -318,18 +358,22 @@ namespace System.Diagnostics {
//
// Add traces captured using ExceptionDispatchInfo
//
bool has_frames = false;
if (captured_traces != null) {
foreach (var t in captured_traces) {
if (!t.AddFrames (sb))
has_frames = t.AddFrames (sb, has_frames, out var isAsync);
if (!has_frames)
continue;
sb.Append (Environment.NewLine);
sb.Append ("--- End of stack trace from previous location where exception was thrown ---");
sb.Append (Environment.NewLine);
if (!isAsync) {
sb.Append (Environment.NewLine);
sb.Append ("--- End of stack trace from previous location where exception was thrown ---");
sb.Append (Environment.NewLine);
}
}
}
AddFrames (sb);
AddFrames (sb, has_frames, out _);
return sb.ToString ();
}

View File

@@ -951,6 +951,26 @@ namespace System.IO {
return path1 + DirectorySeparatorCharAsString + path2;
return path1 + path2;
}
#endregion
#region Copied from corefx
public static ReadOnlySpan<char> GetFileName(ReadOnlySpan<char> path)
{
int root = GetPathRoot(new string (path)).Length;
// We don't want to cut off "C:\file.txt:stream" (i.e. should be "file.txt:stream")
// but we *do* want "C:Foo" => "Foo". This necessitates checking for the root.
for (int i = path.Length; --i >= 0;)
{
if (i < root || IsDirectorySeparator(path[i]))
return path.Slice(i + 1, path.Length - i - 1);
}
return path;
}
#endregion
}
}

View File

@@ -95,13 +95,8 @@ namespace System.Reflection.Emit {
public virtual void SetConstant (object defaultValue)
{
if (position > 0) {
Type t = methodb.GetParameterType (position - 1);
if (defaultValue != null && t != defaultValue.GetType ()) {
if(!t.IsEnum || t.UnderlyingSystemType != defaultValue.GetType ())
throw new ArgumentException ("Constant does not match the defined type.");
}
if (t.IsValueType && !t.IsPrimitive && !t.IsEnum && t != typeof (DateTime))
throw new ArgumentException ("" + t + " is not a supported constant type.");
TypeBuilder.SetConstantValue (methodb.GetParameterType (position - 1),
defaultValue, ref defaultValue);
}
def_value = defaultValue;

View File

@@ -1903,6 +1903,125 @@ namespace System.Reflection.Emit
{
return base.IsAssignableFrom (typeInfo);
}
internal static bool SetConstantValue (Type destType, Object value, ref Object destValue)
{
// Mono: This is based on the CoreCLR
// TypeBuilder.SetConstantValue except it writes to an
// out argument instead of doing an icall, and it uses
// TypeCode instead of CorElementType (like
// MonoTypeEnum) which we don't have in our corlib and
// our member fields are different.
// This is a helper function that is used by ParameterBuilder, PropertyBuilder,
// and FieldBuilder to validate a default value and save it in the meta-data.
if (value != null) {
Type type = value.GetType ();
// We should allow setting a constant value on a ByRef parameter
if (destType.IsByRef)
destType = destType.GetElementType ();
// Convert nullable types to their underlying type.
// This is necessary for nullable enum types to pass the IsEnum check that's coming next.
destType = Nullable.GetUnderlyingType (destType) ?? destType;
if (destType.IsEnum)
{
// | UnderlyingSystemType | Enum.GetUnderlyingType() | IsEnum
// ----------------------------------|---------------------------|---------------------------|---------
// runtime Enum Type | self | underlying type of enum | TRUE
// EnumBuilder | underlying type of enum | underlying type of enum* | TRUE
// TypeBuilder of enum types** | underlying type of enum | Exception | TRUE
// TypeBuilder of enum types (baked) | runtime enum type | Exception | TRUE
// *: the behavior of Enum.GetUnderlyingType(EnumBuilder) might change in the future
// so let's not depend on it.
// **: created with System.Enum as the parent type.
// The above behaviors might not be the most consistent but we have to live with them.
Type underlyingType;
EnumBuilder enumBldr;
TypeBuilder typeBldr;
if ((enumBldr = destType as EnumBuilder) != null) {
underlyingType = enumBldr.GetEnumUnderlyingType ();
// The constant value supplied should match either the baked enum type or its underlying type
// we don't need to compare it with the EnumBuilder itself because you can never have an object of that type
if (!((enumBldr.GetTypeBuilder ().is_created && type == enumBldr.GetTypeBuilder ().created) ||
type == underlyingType))
throw_argument_ConstantDoesntMatch ();
} else if ((typeBldr = destType as TypeBuilder) != null) {
underlyingType = typeBldr.underlying_type;
// The constant value supplied should match either the baked enum type or its underlying type
// typeBldr.m_enumUnderlyingType is null if the user hasn't created a "value__" field on the enum
if (underlyingType == null || (type != typeBldr.UnderlyingSystemType && type != underlyingType))
throw_argument_ConstantDoesntMatch ();
} else {
// must be a runtime Enum Type
// Debug.Assert(destType is RuntimeType, "destType is not a runtime type, an EnumBuilder, or a TypeBuilder.");
underlyingType = Enum.GetUnderlyingType (destType);
// The constant value supplied should match either the enum itself or its underlying type
if (type != destType && type != underlyingType)
throw_argument_ConstantDoesntMatch ();
}
type = underlyingType;
} else {
// Note that it is non CLS compliant if destType != type. But RefEmit never guarantees CLS-Compliance.
if (!destType.IsAssignableFrom (type))
throw_argument_ConstantDoesntMatch ();
}
TypeCode corType = Type.GetTypeCode (type);
switch (corType)
{
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Boolean:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Char:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Single:
case TypeCode.Int64:
case TypeCode.UInt64:
case TypeCode.Double:
destValue = value;
return true;
case TypeCode.String:
destValue = value;
return true;
case TypeCode.DateTime:
//date is a I8 representation
long ticks = ((DateTime)value).Ticks;
destValue = ticks;
return true;
default:
throw new ArgumentException(type.ToString() + " is not a supported constant type.");
}
} else {
// A null default value in metadata is permissible even for non-nullable value types.
// (See ECMA-335 II.15.4.1.4 "The .param directive" and II.22.9 "Constant" for details.)
// This is how the Roslyn compilers generally encode `default(TValueType)` default values.
destValue = null;
return true;
}
}
private static void throw_argument_ConstantDoesntMatch ()
{
throw new ArgumentException("Constant does not match the defined type.");
}
}
}
#endif

View File

@@ -531,6 +531,9 @@ namespace System.Reflection {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static Assembly LoadFrom (String assemblyFile, bool refonly);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static Assembly LoadFile_internal (String assemblyFile);
public static Assembly LoadFrom (String assemblyFile)
{
return LoadFrom (assemblyFile, false);
@@ -575,8 +578,11 @@ namespace System.Reflection {
throw new ArgumentNullException ("path");
if (path == String.Empty)
throw new ArgumentException ("Path can't be empty", "path");
// FIXME: Make this do the right thing
return LoadFrom (path, securityEvidence);
Assembly a = LoadFile_internal (path);
if (a != null && securityEvidence != null) {
throw new NotImplementedException ();
}
return a;
}
public static Assembly LoadFile (String path)

View File

@@ -63,23 +63,7 @@ namespace System.Reflection
protected ParameterInfo () {
}
public override string ToString() {
Type elementType = ClassImpl;
while (elementType.HasElementType) {
elementType = elementType.GetElementType();
}
bool useShort = elementType.IsPrimitive || ClassImpl == typeof(void)
|| ClassImpl.Namespace == MemberImpl.DeclaringType.Namespace;
string result = useShort
? ClassImpl.Name
: ClassImpl.FullName;
// MS.NET seems to skip this check and produce an extra space for return types
if (!IsRetval) {
result += ' ';
result += NameImpl;
}
return result;
}
public override string ToString() => ClassImpl.FormatTypeName() + " " + Name;
internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention, bool serialization)
{

View File

@@ -1,12 +1,10 @@
//
// System.Text.NormalizationForm.cs
// PreserveDependencyAttribute.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
// Copyright (C) 2018 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -15,10 +13,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -28,15 +26,15 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices {
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = true)]
/*public*/ sealed class PreserveDependencyAttribute : Attribute {
public PreserveDependencyAttribute (string metadataSignature)
{
}
namespace System.Text
{
[ComVisible (true)]
public enum NormalizationForm {
FormC = 1,
FormD = 2,
FormKC = 5,
FormKD = 6
public PreserveDependencyAttribute (string metadataSignature, string condition)
{
}
}
}
}

View File

@@ -141,8 +141,6 @@ namespace System.Runtime.CompilerServices
[MonoTODO("Currently a no-op")]
public static void PrepareDelegate (Delegate d)
{
if (d == null)
throw new ArgumentNullException ("d");
}
// extracted from ../../../../external/referencesource/mscorlib/system/runtime/compilerservices/runtimehelpers.cs

View File

@@ -26,6 +26,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if BIT64
using nuint = System.UInt64;
using nint = System.Int64;
#else
using nuint = System.UInt32;
using nint = System.Int32;
#endif
namespace System.Runtime.CompilerServices
{
static partial class Unsafe
@@ -60,7 +68,12 @@ namespace System.Runtime.CompilerServices
throw new NotImplementedException ();
}
public static ref TTo As<TFrom, TTo>(ref TFrom source)
public static ref TTo As<TFrom, TTo> (ref TFrom source)
{
throw new NotImplementedException ();
}
public unsafe static void* AsPointer<T> (ref T value)
{
throw new NotImplementedException ();
}
@@ -95,6 +108,11 @@ namespace System.Runtime.CompilerServices
throw new NotImplementedException ();
}
public unsafe static T ReadUnaligned<T> (void* source)
{
throw new NotImplementedException ();
}
public static T ReadUnaligned<T> (ref byte source)
{
throw new NotImplementedException ();
@@ -114,5 +132,12 @@ namespace System.Runtime.CompilerServices
{
throw new NotImplementedException ();
}
[MethodImpl (MethodImplOptions.AggressiveInlining)]
unsafe internal static ref T AddByteOffset<T> (ref T source, nuint byteOffset)
{
return ref AddByteOffset (ref source, (IntPtr)(void*)byteOffset);
}
}
}

View File

@@ -348,4 +348,21 @@
ret
}
.method public hidebysig static bool IsAddressGreaterThan<T>(!!T& left, !!T& right) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
cgt.un
ret
}
.method public hidebysig static bool IsAddressLessThan<T>(!!T& left, !!T& right) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
clt.un
ret
}
}

View File

@@ -30,6 +30,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
{
internal unsafe static class UnsafeNativeMethods
{
#if !DISABLE_COM
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern int WindowsCreateString(string sourceString, int length, IntPtr* hstring);
@@ -47,5 +48,30 @@ namespace System.Runtime.InteropServices.WindowsRuntime
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern IRestrictedErrorInfo GetRestrictedErrorInfo();
#else
public static int WindowsCreateString(string sourceString, int length, IntPtr* hstring) {
throw new NotImplementedException ();
}
public static int WindowsDeleteString(IntPtr hstring) {
throw new NotImplementedException ();
}
public static char* WindowsGetStringRawBuffer(IntPtr hstring, uint* length) {
throw new NotImplementedException ();
}
public static bool RoOriginateLanguageException(int error, string message, IntPtr languageException) {
throw new NotImplementedException ();
}
public static void RoReportUnhandledError(IRestrictedErrorInfo error) {
throw new NotImplementedException ();
}
public static IRestrictedErrorInfo GetRestrictedErrorInfo() {
throw new NotImplementedException ();
}
#endif
}
}
}

View File

@@ -34,7 +34,7 @@ namespace System.Runtime.InteropServices
{
[Obsolete]
[Flags, Serializable]
public enum LIBFLAGS
public enum LIBFLAGS : short
{
LIBFLAG_FRESTRICTED = 1,
LIBFLAG_FCONTROL = 2,

View File

@@ -179,5 +179,15 @@ namespace System.Threading
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms);
internal static int ToTimeoutMilliseconds(TimeSpan timeout)
{
var timeoutMilliseconds = (long)timeout.TotalMilliseconds;
if (timeoutMilliseconds < -1 || timeoutMilliseconds > int.MaxValue)
{
throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
}
return (int)timeoutMilliseconds;
}
}
}

View File

@@ -65,6 +65,21 @@ namespace System
return true;
}
// adapted to the Mono array layout
[StructLayout(LayoutKind.Sequential)]
private class RawData
{
public IntPtr Bounds;
public IntPtr Count;
public byte Data;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal ref byte GetRawSzArrayData()
{
return ref Unsafe.As<RawData>(this).Data;
}
internal IEnumerator<T> InternalArray__IEnumerable_GetEnumerator<T> ()
{
if (Length == 0)
@@ -571,26 +586,27 @@ namespace System
throw new ArgumentException ("length");
if (dest_pos > destinationArray.Length - length) {
string msg = "Destination array was not long enough. Check " +
"destIndex and length, and the array's lower bounds";
throw new ArgumentException (msg, string.Empty);
throw new ArgumentException ("Destination array was not long enough. Check destIndex and length, and the array's lower bounds", nameof (destinationArray));
}
Type src_type = sourceArray.GetType ().GetElementType ();
Type dst_type = destinationArray.GetType ().GetElementType ();
var dst_type_vt = dst_type.IsValueType;
if (!Object.ReferenceEquals (sourceArray, destinationArray) || source_pos > dest_pos) {
for (int i = 0; i < length; i++) {
Object srcval = sourceArray.GetValueImpl (source_pos + i);
if (srcval == null && dst_type_vt)
throw new InvalidCastException ();
try {
destinationArray.SetValueImpl (srcval, dest_pos + i);
} catch (ArgumentException) {
throw CreateArrayTypeMismatchException ();
} catch {
} catch (InvalidCastException) {
if (CanAssignArrayElement (src_type, dst_type))
throw;
throw CreateArrayTypeMismatchException ();
}
}
@@ -613,7 +629,7 @@ namespace System
}
}
static Exception CreateArrayTypeMismatchException ()
static ArrayTypeMismatchException CreateArrayTypeMismatchException ()
{
return new ArrayTypeMismatchException ();
}

Some files were not shown because too many files have changed in this diff Show More