Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,24 @@
using System.Reflection;
using System.Security;
using System.Runtime.Versioning;
namespace System {
public partial class AppDomain
{
internal String GetTargetFrameworkName()
{
return ".NETFramework,Version=v4.5";
}
internal static bool IsAppXModel ()
{
return false;
}
internal static bool IsAppXDesignMode ()
{
return false;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace System
{
static class Array_ReferenceSources
{
internal const int MaxArrayLength = 0X7FEFFFFF;
}
}

View File

@@ -0,0 +1,45 @@
using System.Diagnostics;
namespace System
{
internal enum LogLevel {
Trace = 0,
Status = 20,
Warning= 40,
Error = 50,
Panic = 100,
}
static class BCLDebug
{
[Conditional("_DEBUG")]
static public void Assert(bool condition, string message)
{
}
[Conditional("_DEBUG")]
internal static void Correctness(bool expr, string msg)
{
}
[Conditional("_DEBUG")]
static public void Log (string message)
{
}
[Conditional("_DEBUG")]
static public void Log (string switchName, string message)
{
}
[Conditional("_DEBUG")]
public static void Log (string switchName, LogLevel level, params object[] messages)
{
}
[Conditional("_DEBUG")]
internal static void Perf (bool expr, string msg)
{
}
}
}

View File

@@ -0,0 +1,45 @@
///------------------------------------------------------------------------------
/// <copyright file="CLRConfig.cs" company="Microsoft">
/// Copyright (c) Microsoft Corporation. All rights reserved.
/// </copyright>
///
/// <owner>gpaperin</owner>
///------------------------------------------------------------------------------
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Runtime.InteropServices;
using System.Security;
namespace System {
/// <summary>
/// For now, this class should be the central point to collect all managed declarations
/// of native functions designed to expose config switches.
/// In Dev11 M2.2 we will redesign this class to expose CLRConfig from within the CLR
/// and refactor managed Fx code to access all compat switches through here.
/// </summary>
[FriendAccessAllowed]
internal class CLRConfig {
[FriendAccessAllowed]
[System.Security.SecurityCritical]
[ResourceExposure(ResourceScope.None)]
[SuppressUnmanagedCodeSecurity]
internal static bool CheckLegacyManagedDeflateStream()
{
return false;
}
[System.Security.SecurityCritical]
[ResourceExposure(ResourceScope.None)]
[SuppressUnmanagedCodeSecurity]
internal static bool CheckThrowUnobservedTaskExceptions()
{
return false;
}
} // internal class CLRConfig
} // namespace System
// file CLRConfig

View File

@@ -0,0 +1,52 @@
//
// CalendarData.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace System.Globalization
{
[StructLayout (LayoutKind.Sequential)]
partial class CalendarData
{
public static int nativeGetTwoDigitYearMax (int calID)
{
// -1 mean OS does not override default BCL max year
return -1;
}
static bool nativeGetCalendarData (CalendarData data, string localeName, int calendarId)
{
// TODO: Convert calendar-id to mono runtime calendar-id when it's used
return data.fill_calendar_data (localeName.ToLowerInvariant (), calendarId);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern bool fill_calendar_data (string localeName, int datetimeIndex);
}
}

View File

@@ -0,0 +1,36 @@
//
// CompatibilitySwitches.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System
{
static class CompatibilitySwitches
{
public const bool IsAppEarlierThanSilverlight4 = false;
public const bool IsAppEarlierThanWindowsPhone8 = false;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,123 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Globalization {
using System.Text;
using System.Runtime.Remoting;
using System;
using System.Security;
//
// Data item for EncodingTable. Along with EncodingTable, they are used by
// System.Text.Encoding.
//
// This class stores a pointer to the internal data and the index into that data
// where our required information is found. We load the code page, flags and uiFamilyCodePage
// immediately because they don't require creating an object. Creating any of the string
// names is delayed until somebody actually asks for them and the names are then cached.
[Serializable]
internal class CodePageDataItem
{
internal int m_dataIndex;
internal int m_uiFamilyCodePage;
internal String m_webName;
internal String m_headerName;
internal String m_bodyName;
internal uint m_flags;
[SecurityCritical]
unsafe internal CodePageDataItem(int dataIndex) {
m_dataIndex = dataIndex;
m_uiFamilyCodePage = EncodingTable.codePageDataPtr[dataIndex].uiFamilyCodePage;
m_flags = EncodingTable.codePageDataPtr[dataIndex].flags;
}
static readonly char [] sep = {'|'};
[System.Security.SecurityCritical]
unsafe internal static String CreateString(string pStrings, uint index)
{
if (pStrings[0] == '|') // |str1|str2|str3
{
return pStrings.Split (sep, StringSplitOptions.RemoveEmptyEntries) [index];
/*
int start = 1;
for (int i = 1; true; i ++)
{
sbyte ch = pStrings[i];
if ((ch == '|') || (ch == 0))
{
if (index == 0)
{
return new String(pStrings, start, i - start);
}
index --;
start = i + 1;
if (ch == 0)
{
break;
}
}
}
throw new ArgumentException("pStrings");
*/
}
else
{
return pStrings;
//return new String(pStrings);
}
}
unsafe public String WebName {
[System.Security.SecuritySafeCritical] // auto-generated
get {
if (m_webName==null) {
m_webName = CreateString(EncodingTable.codePageDataPtr[m_dataIndex].Names, 0);
}
return m_webName;
}
}
public virtual int UIFamilyCodePage {
get {
return m_uiFamilyCodePage;
}
}
unsafe public String HeaderName {
[System.Security.SecuritySafeCritical] // auto-generated
get {
if (m_headerName==null) {
m_headerName = CreateString(EncodingTable.codePageDataPtr[m_dataIndex].Names, 1);
}
return m_headerName;
}
}
unsafe public String BodyName {
[System.Security.SecuritySafeCritical] // auto-generated
get {
if (m_bodyName==null) {
m_bodyName = CreateString(EncodingTable.codePageDataPtr[m_dataIndex].Names, 2);
}
return m_bodyName;
}
}
unsafe public uint Flags {
get {
return (m_flags);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
using System.Globalization;
namespace System
{
partial class Environment
{
internal static string GetResourceString (string key)
{
return key;
}
internal static string GetResourceString (string key, CultureInfo culture)
{
return key;
}
internal static string GetResourceString (string key, params object[] values)
{
return string.Format (CultureInfo.InvariantCulture, key, values);
}
}
}

View File

@@ -0,0 +1,56 @@
using System.Security;
namespace System.Threading
{
partial class ExecutionContext
{
internal static ExecutionContext Capture (ref StackCrawlMark stackMark, CaptureOptions options)
{
return Capture ((options & CaptureOptions.IgnoreSyncCtx) == 0, false);
}
internal static ExecutionContext FastCapture()
{
return Capture ();
}
[Flags]
internal enum CaptureOptions
{
None = 0x00,
IgnoreSyncCtx = 0x01, //Don't flow SynchronizationContext
OptimizeDefaultCase = 0x02, //Faster in the typical case, but can't show the result to users
// because they could modify the shared default EC.
// Use this only if you won't be exposing the captured EC to users.
}
private static readonly ExecutionContext s_dummyDefaultEC = new ExecutionContext();
static internal ExecutionContext PreAllocatedDefault
{
[SecuritySafeCritical]
get {
return s_dummyDefaultEC;
}
}
internal bool IsPreAllocatedDefault
{
get
{
return this == s_dummyDefaultEC;
}
}
}
[Serializable]
internal enum StackCrawlMark
{
LookForMe = 0,
LookForMyCaller = 1,
LookForMyCallersCaller = 2,
LookForThread = 3
}
}

View File

@@ -0,0 +1,12 @@
namespace System.Collections.Concurrent
{
static class HashHelpers
{
// Reference source has broken ConcurrentDictionary code which depends
// on #if FEATURE_RANDOMIZED_STRING_HASHING this is a workaround not to require it
public static object GetEqualityComparerForSerialization (object comparer)
{
return comparer;
}
}
}

View File

@@ -0,0 +1,12 @@
namespace System.Runtime.CompilerServices {
[FriendAccessAllowed]
internal static class JitHelpers
{
static internal T UnsafeCast<T>(Object o) where T : class
{
return (T)o;
}
}
}

View File

@@ -0,0 +1,389 @@
//
// ParseNumbers.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Globalization;
using System.Text;
namespace System {
static class ParseNumbers
{
internal const int PrintAsI1=0x40;
internal const int PrintAsI2=0x80;
// internal const int PrintAsI4=0x100;
internal const int TreatAsUnsigned=0x200;
internal const int TreatAsI1=0x400;
internal const int TreatAsI2=0x800;
internal const int IsTight=0x1000;
internal const int NoSpace=0x2000;
public static int StringToInt (string value, int fromBase, int flags)
{
unsafe {
return StringToInt (value, fromBase, flags, null);
}
}
public unsafe static int StringToInt (string value, int fromBase, int flags, int* parsePos)
{
if ((flags & (IsTight | NoSpace)) == 0)
throw new NotImplementedException (flags.ToString ());
if (value == null)
return 0;
int chars = 0;
uint result = 0;
int digitValue;
int len = value.Length;
bool negative = false;
if (len == 0) {
// Mimic broken .net behaviour
throw new ArgumentOutOfRangeException ("Empty string");
}
int i = parsePos == null ? 0 : *parsePos;
//Check for a sign
if (value [i] == '-') {
if (fromBase != 10)
throw new ArgumentException ("String cannot contain a minus sign if the base is not 10.");
if ((flags & TreatAsUnsigned) != 0)
throw new OverflowException ("Negative number");
negative = true;
i++;
} else if (value [i] == '+') {
i++;
}
if (fromBase == 16 && i + 1 < len && value [i] =='0' && (value [i + 1] == 'x' || value [i + 1] == 'X')) {
i += 2;
}
uint max_value;
if ((flags & TreatAsI1) != 0) {
max_value = Byte.MaxValue;
} else if ((flags & TreatAsI2) != 0) {
max_value = UInt16.MaxValue;
} else {
max_value = UInt32.MaxValue;
}
while (i < len) {
char c = value [i];
if (Char.IsNumber (c)) {
digitValue = c - '0';
} else if (Char.IsLetter (c)) {
digitValue = Char.ToLowerInvariant (c) - 'a' + 10;
} else {
if (i == 0)
throw new FormatException ("Could not find any parsable digits.");
if ((flags & IsTight) != 0)
throw new FormatException ("Additional unparsable characters are at the end of the string.");
break;
}
if (digitValue >= fromBase) {
if (chars > 0) {
throw new FormatException ("Additional unparsable characters are at the end of the string.");
}
throw new FormatException ("Could not find any parsable digits.");
}
var res = (uint) fromBase * result + (uint) digitValue;
if (res < result || res > max_value)
throw new OverflowException ();
result = res;
chars++;
++i;
}
if (chars == 0)
throw new FormatException ("Could not find any parsable digits.");
if (parsePos != null)
*parsePos = i;
return negative ? -(int)result : (int)result;
}
public static string LongToString (long value, int toBase, int width, char paddingChar, int flags)
{
if (value == 0)
return "0";
if (toBase == 10)
return value.ToString ();
byte[] val = BitConverter.GetBytes (value);
switch (toBase) {
case 2:
return ConvertToBase2 (val).ToString ();
case 8:
return ConvertToBase8 (val).ToString ();
case 16:
return ConvertToBase16 (val).ToString ();
default:
throw new NotImplementedException ();
}
}
public static long StringToLong (string value, int fromBase, int flags)
{
unsafe {
return StringToLong (value, fromBase, flags, null);
}
}
public unsafe static long StringToLong (string value, int fromBase, int flags, int* parsePos)
{
if ((flags & (IsTight | NoSpace)) == 0)
throw new NotImplementedException (flags.ToString ());
if (value == null)
return 0;
int chars = 0;
int digitValue = -1;
long result = 0;
int len = value.Length;
bool negative = false;
if (len == 0) {
// Mimic broken .net behaviour
throw new ArgumentOutOfRangeException ("Empty string");
}
int i = parsePos == null ? 0 : *parsePos;
//Check for a sign
if (value [i] == '-') {
if (fromBase != 10)
throw new ArgumentException ("String cannot contain a minus sign if the base is not 10.");
if ((flags & TreatAsUnsigned) != 0)
throw new OverflowException ("Negative number");
negative = true;
i++;
} else if (value [i] == '+') {
i++;
}
if (fromBase == 16 && i + 1 < len && value [i] =='0' && (value [i + 1] == 'x' || value [i + 1] == 'X')) {
i += 2;
}
while (i < len) {
char c = value[i];
if (Char.IsNumber (c)) {
digitValue = c - '0';
} else if (Char.IsLetter (c)) {
digitValue = Char.ToLowerInvariant (c) - 'a' + 10;
} else {
if (i == 0)
throw new FormatException ("Could not find any parsable digits.");
if ((flags & IsTight) != 0)
throw new FormatException ("Additional unparsable characters are at the end of the string.");
break;
}
if (digitValue >= fromBase) {
if (chars > 0) {
throw new FormatException ("Additional unparsable "
+ "characters are at the end of the string.");
} else {
throw new FormatException ("Could not find any parsable"
+ " digits.");
}
}
result = fromBase * result + digitValue;
chars++;
++i;
}
if (chars == 0)
throw new FormatException ("Could not find any parsable digits.");
if (parsePos != null)
*parsePos = i;
return negative ? -result : result;
}
public static string IntToString (int value, int toBase, int width, char paddingChar, int flags)
{
StringBuilder sb;
if (value == 0) {
if (width <= 0)
return "0";
sb = new StringBuilder ("0", width);
} else if (toBase == 10)
sb = new StringBuilder (value.ToString ());
else {
byte[] val;
if ((flags & PrintAsI1) != 0) {
val = BitConverter.GetBytes ((byte) value);
} else if ((flags & PrintAsI2) != 0) {
val = BitConverter.GetBytes ((short) value);
} else {
val = BitConverter.GetBytes (value);
}
switch (toBase) {
case 2:
sb = ConvertToBase2 (val);
break;
case 8:
sb = ConvertToBase8 (val);
break;
case 16:
sb = ConvertToBase16 (val);
break;
default:
throw new NotImplementedException ();
}
}
var padding = width - sb.Length;
while (padding > 0) {
sb.Insert (0, paddingChar);
--padding;
}
return sb.ToString ();
}
static void EndianSwap (ref byte[] value)
{
byte[] buf = new byte[value.Length];
for (int i = 0; i < value.Length; i++)
buf[i] = value[value.Length-1-i];
value = buf;
}
static StringBuilder ConvertToBase2 (byte[] value)
{
if (!BitConverter.IsLittleEndian)
EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
byte b = value [i];
for (int j = 0; j < 8; j++) {
if ((b & 0x80) == 0x80) {
sb.Append ('1');
}
else {
if (sb.Length > 0)
sb.Append ('0');
}
b <<= 1;
}
}
return sb;
}
static StringBuilder ConvertToBase8 (byte[] value)
{
ulong l = 0;
switch (value.Length) {
case 1:
l = (ulong) value [0];
break;
case 2:
l = (ulong) BitConverter.ToUInt16 (value, 0);
break;
case 4:
l = (ulong) BitConverter.ToUInt32 (value, 0);
break;
case 8:
l = BitConverter.ToUInt64 (value, 0);
break;
default:
throw new ArgumentException ("value");
}
StringBuilder sb = new StringBuilder ();
for (int i = 21; i >= 0; i--) {
// 3 bits at the time
char val = (char) ((l >> i * 3) & 0x7);
if ((val != 0) || (sb.Length > 0)) {
val += '0';
sb.Append (val);
}
}
return sb;
}
static StringBuilder ConvertToBase16 (byte[] value)
{
if (!BitConverter.IsLittleEndian)
EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
char high = (char)((value[i] >> 4) & 0x0f);
if ((high != 0) || (sb.Length > 0)) {
if (high < 10)
high += '0';
else {
high -= (char) 10;
high += 'a';
}
sb.Append (high);
}
char low = (char)(value[i] & 0x0f);
if ((low != 0) || (sb.Length > 0)) {
if (low < 10)
low += '0';
else {
low -= (char) 10;
low += 'a';
}
sb.Append (low);
}
}
return sb;
}
}
}

View File

@@ -0,0 +1,8 @@
namespace System
{
[Flags]
internal enum TimeZoneInfoOptions {
None = 1,
NoThrowOnInvalidTime = 2
};
}

View File

@@ -0,0 +1,6 @@
namespace System.IO
{
sealed class __ConsoleStream
{
}
}