Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -0,0 +1,22 @@
thisdir = class/System.Private.CoreLib
SUBDIRS =
include ../../build/rules.make
include ../../../netcore/roslyn.make
ROSLYN_PROPS_FILE := ../../../netcore/roslyn/packages/microsoft.net.compilers.toolset/$(ROSLYN_VERSION)/build/Microsoft.Net.Compilers.Toolset.props
dirs := $(dir $(wildcard */*))
files := $(wildcard */*.cs)
all-local: $(ROSLYN_PROPS_FILE)
dotnet build $(CORETARGETS) $(CORLIB_BUILD_FLAGS) -p:BuildArch=$(COREARCH) -p:OutputPath=bin/$(COREARCH) -p:RoslynPropsFile="$(ROSLYN_PROPS_FILE)" System.Private.CoreLib.csproj
$(ROSLYN_PROPS_FILE):
make -C ../../../netcore update-roslyn
dist-local:
mkdir -p $(distdir)
cp -a Makefile $(distdir)
cp -a *.csproj $(distdir)
for i in $(dirs); do mkdir -p $(distdir)/$$i; done
for i in $(files); do cp -a $$i $(distdir)/$$i; done

View File

@@ -0,0 +1,18 @@
using System;
using System.Threading;
using System.Runtime.CompilerServices;
namespace Microsoft.Win32.SafeHandles
{
partial class SafeWaitHandle
{
protected override bool ReleaseHandle ()
{
CloseEventInternal (handle);
return true;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void CloseEventInternal (IntPtr handle);
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Win32
{
static class UnsafeNativeMethods
{
internal static unsafe class ManifestEtw
{
internal unsafe delegate void EtwEnableCallback(
[In] ref Guid sourceId,
[In] int isEnabled,
[In] byte level,
[In] long matchAnyKeywords,
[In] long matchAllKeywords,
[In] EVENT_FILTER_DESCRIPTOR* filterData,
[In] void* callbackContext
);
[StructLayout(LayoutKind.Sequential)]
unsafe internal struct EVENT_FILTER_DESCRIPTOR
{
public long Ptr;
public int Size;
public int Type;
}
internal enum ActivityControl : uint
{
EVENT_ACTIVITY_CTRL_GET_ID = 1,
EVENT_ACTIVITY_CTRL_SET_ID = 2,
EVENT_ACTIVITY_CTRL_CREATE_ID = 3,
EVENT_ACTIVITY_CTRL_GET_SET_ID = 4,
EVENT_ACTIVITY_CTRL_CREATE_SET_ID = 5
}
internal const int ERROR_ARITHMETIC_OVERFLOW = 534;
internal const int ERROR_NOT_ENOUGH_MEMORY = 8;
internal const int ERROR_MORE_DATA = 0xEA;
internal const int EVENT_CONTROL_CODE_DISABLE_PROVIDER = 0;
internal const int EVENT_CONTROL_CODE_ENABLE_PROVIDER = 1;
internal const int EVENT_CONTROL_CODE_CAPTURE_STATE = 2;
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Mono
{
[StructLayout (LayoutKind.Sequential)]
internal sealed partial class MonoDomain
{
#pragma warning disable 169
#region Sync with object-internals.h
IntPtr _mono_app_domain;
#endregion
#pragma warning restore 169
public event AssemblyLoadEventHandler AssemblyLoad;
private void DoAssemblyLoad (Assembly assembly)
{
return; /* FIXME */
}
private Assembly? DoAssemblyResolve (string name, Assembly requestingAssembly, bool refonly)
{
return null;
}
internal Assembly? DoTypeResolve (string name)
{
return null;
}
internal Assembly? DoTypeBuilderResolve (System.Reflection.Emit.TypeBuilder tb)
{
return null;
}
public event UnhandledExceptionEventHandler UnhandledException;
public event EventHandler ProcessExit;
}
}

View File

@@ -0,0 +1,41 @@
#nullable disable
using System.Runtime.InteropServices;
namespace Mono
{
[StructLayout (LayoutKind.Sequential)]
internal sealed class MonoDomainSetup
{
#region Sync with object-internals.h
string application_base;
string application_name;
string cache_path;
string configuration_file;
string dynamic_base;
string license_file;
string private_bin_path;
string private_bin_path_probe;
string shadow_copy_directories;
string shadow_copy_files;
bool publisher_policy;
private bool path_changed;
private int loader_optimization;
bool disallow_binding_redirects;
bool disallow_code_downloads;
object _activationArguments;
object domain_initializer;
object application_trust;
string [] domain_initializer_args;
bool disallow_appbase_probe;
byte [] configuration_bytes;
byte [] serialized_non_primitives;
#endregion
public MonoDomainSetup ()
{
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Mono
{
// Internal type used by Mono runtime only
internal sealed class MonoListItem
{
public MonoListItem next;
public object data;
}
}

View File

@@ -0,0 +1,236 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Mono
{
unsafe struct RuntimeClassHandle
{
RuntimeStructs.MonoClass* value;
internal RuntimeClassHandle (RuntimeStructs.MonoClass* value)
{
this.value = value;
}
internal RuntimeClassHandle (IntPtr ptr)
{
this.value = (RuntimeStructs.MonoClass*) ptr;
}
internal RuntimeStructs.MonoClass* Value => value;
public override bool Equals (object? obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimeClassHandle)obj).Value;
}
public override int GetHashCode () => ((IntPtr)value).GetHashCode ();
public bool Equals (RuntimeClassHandle handle)
{
return value == handle.Value;
}
public static bool operator == (RuntimeClassHandle left, object? right)
{
return right != null && right is RuntimeClassHandle rch && left.Equals (rch);
}
public static bool operator != (RuntimeClassHandle left, object? right)
{
return !(left == right);
}
public static bool operator == (object? left, RuntimeClassHandle right)
{
return left != null && left is RuntimeClassHandle rch && rch.Equals (right);
}
public static bool operator != (object? left, RuntimeClassHandle right)
{
return !(left == right);
}
[MethodImpl (MethodImplOptions.InternalCall)]
internal unsafe extern static IntPtr GetTypeFromClass (RuntimeStructs.MonoClass *klass);
internal RuntimeTypeHandle GetTypeHandle () => new RuntimeTypeHandle (GetTypeFromClass (value));
}
unsafe struct RuntimeRemoteClassHandle
{
RuntimeStructs.RemoteClass* value;
internal RuntimeRemoteClassHandle (RuntimeStructs.RemoteClass* value)
{
this.value = value;
}
internal RuntimeClassHandle ProxyClass {
get {
return new RuntimeClassHandle (value->proxy_class);
}
}
}
unsafe struct RuntimeGenericParamInfoHandle
{
RuntimeStructs.GenericParamInfo* value;
internal RuntimeGenericParamInfoHandle (RuntimeStructs.GenericParamInfo* value)
{
this.value = value;
}
internal RuntimeGenericParamInfoHandle (IntPtr ptr)
{
this.value = (RuntimeStructs.GenericParamInfo*) ptr;
}
internal Type[] Constraints => GetConstraints ();
internal GenericParameterAttributes Attributes => (GenericParameterAttributes) value->flags;
Type[] GetConstraints ()
{
int n = GetConstraintsCount ();
var a = new Type [n];
for (int i = 0; i < n; i++) {
RuntimeClassHandle c = new RuntimeClassHandle (value->constraints[i]);
a[i] = Type.GetTypeFromHandle (c.GetTypeHandle ());
}
return a;
}
int GetConstraintsCount ()
{
int i = 0;
RuntimeStructs.MonoClass** p = value->constraints;
while (p != null && *p != null) {
p++; i++;
}
return i;
}
}
internal struct RuntimeEventHandle
{
IntPtr value;
internal RuntimeEventHandle (IntPtr v)
{
value = v;
}
public IntPtr Value => value;
public override bool Equals (object? obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimeEventHandle)obj).Value;
}
public bool Equals (RuntimeEventHandle handle)
{
return value == handle.Value;
}
public override int GetHashCode ()
{
return value.GetHashCode ();
}
public static bool operator == (RuntimeEventHandle left, RuntimeEventHandle right)
{
return left.Equals (right);
}
public static bool operator != (RuntimeEventHandle left, RuntimeEventHandle right)
{
return !left.Equals (right);
}
}
internal struct RuntimePropertyHandle
{
IntPtr value;
internal RuntimePropertyHandle (IntPtr v)
{
value = v;
}
public IntPtr Value => value;
public override bool Equals (object? obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimePropertyHandle)obj).Value;
}
public bool Equals (RuntimePropertyHandle handle)
{
return value == handle.Value;
}
public override int GetHashCode ()
{
return value.GetHashCode ();
}
public static bool operator == (RuntimePropertyHandle left, RuntimePropertyHandle right)
{
return left.Equals (right);
}
public static bool operator != (RuntimePropertyHandle left, RuntimePropertyHandle right)
{
return !left.Equals (right);
}
}
unsafe struct RuntimeGPtrArrayHandle
{
RuntimeStructs.GPtrArray* value;
internal RuntimeGPtrArrayHandle (RuntimeStructs.GPtrArray* value)
{
this.value = value;
}
internal RuntimeGPtrArrayHandle (IntPtr ptr)
{
this.value = (RuntimeStructs.GPtrArray*) ptr;
}
internal int Length => value->len;
internal IntPtr this [int i] => Lookup (i);
internal IntPtr Lookup (int i)
{
if (i >= 0 && i < Length) {
return value->data[i];
} else
throw new IndexOutOfRangeException ();
}
[MethodImpl(MethodImplOptions.InternalCall)]
extern static void GPtrArrayFree (RuntimeStructs.GPtrArray* value);
internal static void DestroyAndFree (ref RuntimeGPtrArrayHandle h)
{
GPtrArrayFree (h.value);
h.value = null;
}
}
}

View File

@@ -0,0 +1,38 @@
// 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;
static partial class SR
{
internal static string Format (string resourceFormat, object? p1)
{
return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1);
}
internal static string Format (string resourceFormat, object p1, object p2)
{
return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1, p2);
}
internal static string Format (CultureInfo ci, string resourceFormat, object p1, object p2)
{
return string.Format (ci, resourceFormat, p1, p2);
}
internal static string Format (string resourceFormat, object p1, object p2, object p3)
{
return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1, p2, p3);
}
internal static string Format (string resourceFormat, params object[] args)
{
if (args != null)
return string.Format (CultureInfo.InvariantCulture, resourceFormat, args);
return resourceFormat;
}
internal static string GetResourceString (string str) => str;
}

View File

@@ -0,0 +1 @@
094f35e5039cf1b08e6c12e35ab6f5120836bdf5

View File

@@ -0,0 +1,12 @@
namespace System.Collections.Generic
{
partial class ArraySortHelper<T>
{
public static ArraySortHelper<T> Default { get; } = new ArraySortHelper<T>();
}
partial class ArraySortHelper<TKey, TValue>
{
public static ArraySortHelper<TKey, TValue> Default { get; } = new ArraySortHelper<TKey, TValue>();
}
}

View File

@@ -0,0 +1,46 @@
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
{
partial class Comparer<T>
{
static volatile Comparer<T> defaultComparer;
public static Comparer<T> Default {
get {
Comparer<T> comparer = defaultComparer;
if (comparer == null) {
comparer = CreateComparer();
defaultComparer = comparer;
}
return comparer;
}
}
static Comparer<T> CreateComparer() {
RuntimeType t = (RuntimeType)typeof(T);
if (typeof(IComparable<T>).IsAssignableFrom(t))
return (Comparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(GenericComparer<>), t);
// If T is a Nullable<U> where U implements IComparable<U> return a NullableComparer<U>
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) {
RuntimeType u = (RuntimeType)t.GetGenericArguments()[0];
if (typeof(IComparable<>).MakeGenericType (u).IsAssignableFrom (u))
return (Comparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(NullableComparer<>), u);
}
if (t.IsEnum)
return (Comparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumComparer<>), t);
// Otherwise return an ObjectComparer<T>
return new ObjectComparer<T> ();
}
}
partial class EnumComparer<T>
{
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public override int Compare (T x, T y) => JitHelpers.EnumCompareTo (x, y);
}
}

View File

@@ -0,0 +1,79 @@
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
{
partial class EqualityComparer<T>
{
static volatile EqualityComparer<T> defaultComparer;
public static EqualityComparer<T> Default {
[MethodImplAttribute (MethodImplOptions.AggressiveInlining)]
get {
EqualityComparer<T> comparer = defaultComparer;
if (comparer == null) {
comparer = CreateComparer();
defaultComparer = comparer;
}
return comparer;
}
}
static EqualityComparer<T> CreateComparer ()
{
RuntimeType t = (RuntimeType)typeof(T);
if (t == typeof(byte)) {
return (EqualityComparer<T>)(object)(new ByteEqualityComparer());
}
/////////////////////////////////////////////////
// KEEP THIS IN SYNC WITH THE DEVIRT CODE
// IN METHOD-TO-IR.C
/////////////////////////////////////////////////
if (typeof(IEquatable<T>).IsAssignableFrom(t)) {
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(GenericEqualityComparer<>), t);
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) {
RuntimeType u = (RuntimeType)t.GetGenericArguments()[0];
if (typeof(IEquatable<>).MakeGenericType(u).IsAssignableFrom(u)) {
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(NullableEqualityComparer<>), u);
}
}
if (t.IsEnum) {
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumEqualityComparer<>), t);
}
return new ObjectEqualityComparer<T>();
}
// MONOTODO: Add specialized versions
internal virtual int IndexOf (T[] array, T value, int startIndex, int count)
{
int endIndex = startIndex + count;
for (int i = startIndex; i < endIndex; i++) {
if (Equals (array[i], value))
return i;
}
return -1;
}
internal virtual int LastIndexOf (T[] array, T value, int startIndex, int count)
{
int endIndex = startIndex - count + 1;
for (int i = startIndex; i >= endIndex; i--) {
if (Equals (array[i], value))
return i;
}
return -1;
}
}
partial class EnumEqualityComparer<T>
{
[MethodImpl (MethodImplOptions.AggressiveInlining)]
public override bool Equals (T x, T y) => JitHelpers.EnumEquals (x, y);
}
}

View File

@@ -0,0 +1,34 @@
using System.Runtime.CompilerServices;
namespace System.Diagnostics
{
public static class Debugger
{
public static readonly string DefaultCategory = "";
public static bool IsAttached => IsAttached_internal ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern static bool IsAttached_internal ();
public static void Break ()
{
// The JIT inserts a breakpoint on the caller.
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool IsLogging();
public static bool Launch ()
{
throw new NotImplementedException ();
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern void Log (int level, string category, string message);
public static void NotifyOfCrossThreadDependency ()
{
}
}
}

View File

@@ -0,0 +1,50 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
namespace System.Diagnostics
{
partial class StackFrame
{
internal StackFrame (MonoStackFrame monoStackFrame, bool needFileInfo)
{
_method = monoStackFrame.methodBase;
_nativeOffset = monoStackFrame.nativeOffset;
_ilOffset = monoStackFrame.ilOffset;
if (needFileInfo) {
_fileName = monoStackFrame.fileName;
_lineNumber = monoStackFrame.lineNumber;
_columnNumber = monoStackFrame.columnNumber;
}
_isLastFrameFromForeignExceptionStackTrace = monoStackFrame.isLastFrameFromForeignException;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
void BuildStackFrame (int skipFrames, bool needFileInfo)
{
const int SystemDiagnosticsStackDepth = 3;
if (skipFrames + SystemDiagnosticsStackDepth < 0 || !get_frame_info (skipFrames + SystemDiagnosticsStackDepth, needFileInfo, out var method, out var ilOffset, out var nativeOffset, out var fileName, out var line, out var column))
return;
_method = method;
_ilOffset = ilOffset;
_nativeOffset = nativeOffset;
if (needFileInfo) {
_fileName = fileName;
_lineNumber = line;
_columnNumber = column;
}
}
bool AppendStackFrameWithoutMethodBase (StringBuilder sb) => false;
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern bool get_frame_info (int skipFrames, bool needFileInfo,
out MethodBase method, out int ilOffset, out int nativeOffset, out string file, out int line, out int column);
}
}

View File

@@ -0,0 +1,82 @@
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Diagnostics
{
// Need our own stackframe class since the shared version has its own fields
[StructLayout (LayoutKind.Sequential)]
class MonoStackFrame
{
#region Keep in sync with object-internals.h
internal int ilOffset;
internal int nativeOffset;
// Unused
internal long methodAddress;
// Unused
internal uint methodIndex;
internal MethodBase methodBase;
internal string fileName;
internal int lineNumber;
internal int columnNumber;
// Unused
internal string internalMethodName;
#endregion
internal bool isLastFrameFromForeignException;
}
partial class StackTrace
{
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern MonoStackFrame[] get_trace (Exception e, int skipFrames, bool needFileInfo);
[MethodImplAttribute (MethodImplOptions.NoInlining)]
void InitializeForCurrentThread (int skipFrames, bool needFileInfo)
{
skipFrames += 2; // Current method + parent ctor
StackFrame sf;
var frames = new List<StackFrame> ();
while (skipFrames >= 0) {
sf = new StackFrame (skipFrames, needFileInfo);
if (sf.GetMethod () == null) {
break;
}
frames.Add (sf);
skipFrames++;
}
_stackFrames = frames.ToArray ();
_numOfFrames = _stackFrames.Length;
}
void InitializeForException (Exception e, int skipFrames, bool needFileInfo)
{
var frames = get_trace (e, skipFrames, needFileInfo);
_numOfFrames = frames.Length;
int foreignFrames;
MonoStackFrame[] foreignExceptions = e.foreignExceptionsFrames;
if (foreignExceptions != null) {
foreignFrames = foreignExceptions.Length;
_numOfFrames += foreignFrames;
_stackFrames = new StackFrame [_numOfFrames];
for (int i = 0; i < foreignExceptions.Length; ++i) {
_stackFrames [i] = new StackFrame (foreignExceptions [i], needFileInfo);
}
} else {
_stackFrames = new StackFrame [_numOfFrames];
foreignFrames = 0;
}
for (int i = 0; i < frames.Length; ++i) {
_stackFrames [foreignFrames + i] = new StackFrame (frames [i], needFileInfo);
}
}
}
}

View File

@@ -0,0 +1,33 @@
// 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.Runtime.CompilerServices;
namespace System.Globalization
{
partial class GlobalizationMode
{
static bool GetGlobalizationInvariantMode ()
{
bool invariantEnabled = GetInvariantSwitchValue ();
if (invariantEnabled)
return true;
LoadICU ();
return false;
}
// Keep this in a separate method to avoid loading the native lib in invariant mode
[MethodImplAttribute (MethodImplOptions.NoInlining)]
static void LoadICU ()
{
int res = Interop.Globalization.LoadICU ();
if (res == 0) {
string message = "Couldn't find a valid ICU package installed on the system. " +
"Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.";
Environment.FailFast (message);
}
}
}
}

View File

@@ -0,0 +1,13 @@
// 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.Globalization
{
partial class GlobalizationMode
{
static bool GetGlobalizationInvariantMode () {
return GetInvariantSwitchValue ();
}
}
}

View File

@@ -0,0 +1,20 @@
// 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.Runtime.CompilerServices;
namespace System.Globalization
{
internal static partial class GlobalizationMode
{
internal static bool Invariant { get; } = GetGlobalizationInvariantMode ();
static bool GetInvariantSwitchValue ()
{
var val = Environment.GetEnvironmentVariable ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
if (val != null)
return Boolean.IsTrueStringIgnoreCase (val) || val.Equals ("1");
return false;
}
}
}

View File

@@ -0,0 +1,10 @@
namespace System.IO
{
partial class FileLoadException
{
internal static string FormatFileLoadExceptionMessage (string fileName, int hResult)
{
return "";
}
}
}

View File

@@ -0,0 +1,9 @@
namespace System.IO
{
partial class Stream
{
bool HasOverriddenBeginEndRead () => true;
bool HasOverriddenBeginEndWrite () => true;
}
}

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