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

@@ -31,10 +31,9 @@ using System.Runtime.CompilerServices;
namespace System
{
#if NET_4_0
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
#else
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public delegate void Action ();
@@ -43,21 +42,21 @@ namespace System
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
#else
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public delegate void Action <in T1, in T2> (T1 arg1, T2 arg2);
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
#else
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public delegate void Action <in T1, in T2, in T3> (T1 arg1, T2 arg2, T3 arg3);
#if MOBILE
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
#elif NET_4_0
#else
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
#endif
public delegate void Action <in T1, in T2, in T3, in T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
@@ -66,10 +65,4 @@ namespace System
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
#else
public delegate void Action <T> (T obj);
// Used internally
delegate void Action <T1, T2, T3> (T1 arg1, T2 arg2, T3 arg3);
#endif
}

View File

@@ -100,9 +100,7 @@ namespace System
activationAttributes, null);
}
#if NET_4_0
[Obsolete]
#endif
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object [] args,
CultureInfo culture, object [] activationAttributes,
@@ -137,9 +135,7 @@ namespace System
activationAttributes, null);
}
#if NET_4_0
[Obsolete]
#endif
public static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object [] args,
CultureInfo culture, object [] activationAttributes, Evidence securityInfo)
@@ -176,9 +172,7 @@ namespace System
}
#if NET_4_0
[Obsolete]
#endif
public static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName,
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
object [] args, CultureInfo culture,
@@ -198,9 +192,7 @@ namespace System
return domain.CreateInstance (assemblyName, typeName);
}
#if NET_4_0
[Obsolete]
#endif
public static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName,
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
object [] args, CultureInfo culture,
@@ -391,7 +383,6 @@ namespace System
throw new NotImplementedException ();
}
#if NET_4_0
public static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object [] args,
CultureInfo culture, object [] activationAttributes)
@@ -442,6 +433,5 @@ namespace System
return domain.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes);
}
#endif
}
}

View File

@@ -1,181 +0,0 @@
//
// AggregateException.cs
//
// Authors:
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (c) 2008 Jérémie "Garuma" Laval
// Copyright (C) 2013 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.
//
//
#if NET_4_0
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace System
{
[System.SerializableAttribute]
[System.Diagnostics.DebuggerDisplay ("Count = {InnerExceptions.Count}")]
public class AggregateException : Exception
{
List<Exception> innerExceptions = new List<Exception> ();
const string defaultMessage = "One or more errors occurred";
public AggregateException () : base (defaultMessage)
{
}
public AggregateException (string message): base (message)
{
}
public AggregateException (string message, Exception innerException): base (message, innerException)
{
if (innerException == null)
throw new ArgumentNullException ("innerException");
innerExceptions.Add (innerException);
}
protected AggregateException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
}
public AggregateException (params Exception[] innerExceptions)
: this (defaultMessage, innerExceptions)
{
}
public AggregateException (string message, params Exception[] innerExceptions)
: base (message, innerExceptions == null || innerExceptions.Length == 0 ? null : innerExceptions[0])
{
if (innerExceptions == null)
throw new ArgumentNullException ("innerExceptions");
foreach (var exception in innerExceptions)
if (exception == null)
throw new ArgumentException ("One of the inner exception is null", "innerExceptions");
this.innerExceptions.AddRange (innerExceptions);
}
public AggregateException (IEnumerable<Exception> innerExceptions)
: this (defaultMessage, innerExceptions)
{
}
public AggregateException (string message, IEnumerable<Exception> innerExceptions)
: this (message, new List<Exception> (innerExceptions).ToArray ())
{
}
public AggregateException Flatten ()
{
List<Exception> inner = new List<Exception> ();
foreach (Exception e in innerExceptions) {
AggregateException aggEx = e as AggregateException;
if (aggEx != null) {
inner.AddRange (aggEx.Flatten ().InnerExceptions);
} else {
inner.Add (e);
}
}
return new AggregateException (inner);
}
public void Handle (Func<Exception, bool> predicate)
{
if (predicate == null)
throw new ArgumentNullException ("predicate");
List<Exception> failed = new List<Exception> ();
foreach (var e in innerExceptions) {
if (!predicate (e))
failed.Add (e);
}
if (failed.Count > 0)
throw new AggregateException (failed);
}
public ReadOnlyCollection<Exception> InnerExceptions {
get {
return innerExceptions.AsReadOnly ();
}
}
internal void AddChildException (AggregateException childEx)
{
if (innerExceptions == null)
innerExceptions = new List<Exception> ();
if (childEx == null)
return;
innerExceptions.Add (childEx);
}
public override string ToString ()
{
System.Text.StringBuilder finalMessage = new System.Text.StringBuilder (base.ToString ());
int currentIndex = -1;
foreach (Exception e in innerExceptions) {
finalMessage.Append (Environment.NewLine);
finalMessage.Append (" --> (Inner exception ");
finalMessage.Append (++currentIndex);
finalMessage.Append (") ");
finalMessage.Append (e.ToString ());
finalMessage.Append (Environment.NewLine);
}
return finalMessage.ToString ();
}
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
if (info == null) {
throw new ArgumentNullException("info");
}
base.GetObjectData(info, context);
info.AddValue ("InnerExceptions", innerExceptions.ToArray(), typeof (Exception[]));
}
public override Exception GetBaseException ()
{
Exception inner = this;
for (var ae = this; ae.innerExceptions.Count == 1;) {
inner = ae.InnerExceptions [0];
var aei = inner as AggregateException;
if (aei == null)
break;
ae = aei;
}
return inner;
}
}
}
#endif

View File

@@ -41,6 +41,7 @@ using System.Reflection.Emit;
#endif
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
@@ -65,9 +66,9 @@ namespace System {
[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
public sealed class AppDomain : MarshalByRefObject {
public sealed partial class AppDomain : MarshalByRefObject {
#else
public sealed class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
public sealed partial class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
#endif
#pragma warning disable 169
#region Sync with object-internals.h
@@ -245,11 +246,9 @@ namespace System {
get { return (PermissionSet)_granted; }
}
#if NET_4_0
public PermissionSet PermissionSet {
get { return (PermissionSet)_granted ?? (PermissionSet)(_granted = new PermissionSet (PermissionState.Unrestricted)); }
}
#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern AppDomain getCurDomain ();
@@ -341,9 +340,7 @@ namespace System {
return Activator.CreateInstance (assemblyName, typeName, activationAttributes);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
Binder binder, object[] args, CultureInfo culture, object[] activationAttributes,
Evidence securityAttributes)
@@ -367,9 +364,7 @@ namespace System {
return (oh != null) ? oh.Unwrap () : null;
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public object CreateInstanceAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
object[] activationAttributes, Evidence securityAttributes)
@@ -379,7 +374,6 @@ namespace System {
return (oh != null) ? oh.Unwrap () : null;
}
#if NET_4_0
public ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr,
Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
{
@@ -418,7 +412,6 @@ namespace System {
return (oh != null) ? oh.Unwrap () : null;
}
#endif
public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
{
@@ -436,9 +429,7 @@ namespace System {
return Activator.CreateInstanceFrom (assemblyFile, typeName, activationAttributes);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
object[] activationAttributes, Evidence securityAttributes)
@@ -462,9 +453,7 @@ namespace System {
return (oh != null) ? oh.Unwrap () : null;
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args,
CultureInfo culture, object[] activationAttributes,
@@ -482,9 +471,7 @@ namespace System {
return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence)
{
return DefineDynamicAssembly (name, access, null, evidence, null, null, null, false);
@@ -495,18 +482,14 @@ namespace System {
return DefineDynamicAssembly (name, access, dir, null, null, null, null, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence)
{
return DefineDynamicAssembly (name, access, dir, evidence, null, null, null, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
@@ -516,9 +499,7 @@ namespace System {
refusedPermissions, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
@@ -528,9 +509,7 @@ namespace System {
refusedPermissions, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
PermissionSet requiredPermissions,
PermissionSet optionalPermissions,
@@ -540,9 +519,7 @@ namespace System {
refusedPermissions, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
@@ -553,9 +530,7 @@ namespace System {
refusedPermissions, false);
}
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
@@ -574,9 +549,7 @@ namespace System {
}
// NET 3.5 method
#if NET_4_0
[Obsolete ("Declarative security for assembly level is no longer enforced")]
#endif
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
Evidence evidence,
PermissionSet requiredPermissions,
@@ -597,7 +570,6 @@ namespace System {
return DefineDynamicAssembly (name, access, null, null, null, null, null, false, assemblyAttributes);
}
#if NET_4_0
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
{
return DefineDynamicAssembly (name, access, dir, null, null, null, null, isSynchronized, assemblyAttributes);
@@ -608,7 +580,6 @@ namespace System {
{
return DefineDynamicAssembly (name, access, assemblyAttributes);
}
#endif
internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
{
@@ -631,26 +602,20 @@ namespace System {
return ExecuteAssembly (assemblyFile, (Evidence)null, null);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity)
{
return ExecuteAssembly (assemblyFile, assemblySecurity, null);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args)
{
Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity);
return ExecuteAssemblyInternal (a, args);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
{
Assembly a = Assembly.LoadFrom (assemblyFile, assemblySecurity, hashValue, hashAlgorithm);
@@ -658,7 +623,6 @@ namespace System {
}
#if NET_4_0
public int ExecuteAssembly (string assemblyFile, string[] args)
{
Assembly a = Assembly.LoadFrom (assemblyFile, null);
@@ -670,7 +634,6 @@ namespace System {
Assembly a = Assembly.LoadFrom (assemblyFile, null, hashValue, hashAlgorithm);
return ExecuteAssemblyInternal (a, args);
}
#endif
int ExecuteAssemblyInternal (Assembly a, string[] args)
{
@@ -722,9 +685,7 @@ namespace System {
return result;
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
{
if (assemblyRef == null)
@@ -781,9 +742,7 @@ namespace System {
return Load (assemblyString, null, false);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public Assembly Load (string assemblyString, Evidence assemblySecurity)
{
return Load (assemblyString, assemblySecurity, false);
@@ -816,9 +775,7 @@ namespace System {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Assembly LoadAssemblyRaw (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence, bool refonly);
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
{
return Load (rawAssembly, rawSymbolStore, securityEvidence, false);
@@ -833,9 +790,7 @@ namespace System {
assembly.FromByteArray = true;
return assembly;
}
#if NET_4_0
[Obsolete ("AppDomain policy levels are obsolete")]
#endif
[SecurityPermission (SecurityAction.Demand, ControlPolicy = true)]
public void SetAppDomainPolicy (PolicyLevel domainPolicy)
{
@@ -1240,7 +1195,7 @@ namespace System {
AssemblyLoad (this, new AssemblyLoadEventArgs (assembly));
}
private Assembly DoAssemblyResolve (string name, bool refonly)
private Assembly DoAssemblyResolve (string name, Assembly requestingAssembly, bool refonly)
{
ResolveEventHandler del;
#if !NET_2_1
@@ -1279,7 +1234,7 @@ namespace System {
foreach (Delegate eh in invocation_list) {
ResolveEventHandler handler = (ResolveEventHandler) eh;
Assembly assembly = handler (this, new ResolveEventArgs (name));
Assembly assembly = handler (this, new ResolveEventArgs (name, requestingAssembly));
if (assembly != null)
return assembly;
}
@@ -1337,11 +1292,7 @@ namespace System {
foreach (Delegate eh in invocation_list) {
ResolveEventHandler handler = (ResolveEventHandler) eh;
#if NET_4_0
Assembly assembly = handler (this, new ResolveEventArgs (name, requesting));
#else
Assembly assembly = handler (this, new ResolveEventArgs (name));
#endif
if (assembly != null)
return assembly;
}
@@ -1410,11 +1361,8 @@ namespace System {
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
public event UnhandledExceptionEventHandler UnhandledException;
#if NET_4_5
public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException;
#endif
#if NET_4_0
[MonoTODO]
public bool IsHomogenous {
get { return true; }
@@ -1424,7 +1372,6 @@ namespace System {
public bool IsFullyTrusted {
get { return true; }
}
#endif
#pragma warning disable 649
#if !MOBILE
@@ -1499,17 +1446,13 @@ namespace System {
return ExecuteAssemblyByName (assemblyName, (Evidence)null, null);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity)
{
return ExecuteAssemblyByName (assemblyName, assemblySecurity, null);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssemblyByName (string assemblyName, Evidence assemblySecurity, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, assemblySecurity);
@@ -1517,9 +1460,7 @@ namespace System {
return ExecuteAssemblyInternal (a, args);
}
#if NET_4_0
[Obsolete ("Use an overload that does not take an Evidence parameter")]
#endif
public int ExecuteAssemblyByName (AssemblyName assemblyName, Evidence assemblySecurity, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, assemblySecurity);
@@ -1527,7 +1468,6 @@ namespace System {
return ExecuteAssemblyInternal (a, args);
}
#if NET_4_0
public int ExecuteAssemblyByName (string assemblyName, params string[] args)
{
Assembly a = Assembly.Load (assemblyName, null);
@@ -1541,7 +1481,6 @@ namespace System {
return ExecuteAssemblyInternal (a, args);
}
#endif
public bool IsDefaultAppDomain ()
{
@@ -1576,7 +1515,6 @@ namespace System {
}
#endif
#if NET_4_0
List<string> compatibility_switch;
public bool? IsCompatibilitySwitchSet (string value)
@@ -1620,6 +1558,5 @@ namespace System {
public TimeSpan MonitoringTotalProcessorTime {
get { throw new NotImplementedException (); }
}
#endif
}
}

View File

@@ -297,6 +297,8 @@ namespace System
}
}
public string TargetFrameworkName { get; set; }
public ActivationArguments ActivationArguments {
get {
if (_activationArguments != null)
@@ -390,11 +392,9 @@ namespace System
serialized_non_primitives = ms.ToArray ();
}
#if NET_4_0
[MonoTODO ("not implemented, does not throw because it's used in testing moonlight")]
public void SetCompatibilitySwitches (IEnumerable<string> switches)
{
}
#endif
}
}

View File

@@ -50,9 +50,7 @@ namespace System
[ComVisible (true)]
// FIXME: We are doing way to many double/triple exception checks for the overloaded functions"
public abstract class Array : ICloneable, ICollection, IList, IEnumerable
#if NET_4_0
, IStructuralComparable, IStructuralEquatable
#endif
{
// Constructor
private Array ()
@@ -142,7 +140,6 @@ namespace System
Copy (this, this.GetLowerBound (0), array, index, this.GetLength (0));
}
#if NET_4_5
internal T InternalArray__IReadOnlyList_get_Item<T> (int index)
{
if (unchecked ((uint) index) >= unchecked ((uint) Length))
@@ -157,7 +154,6 @@ namespace System
{
return Length;
}
#endif
internal void InternalArray__Insert<T> (int index, T item)
{
@@ -455,7 +451,6 @@ namespace System
return new SimpleEnumerator (this);
}
#if NET_4_0
int IStructuralComparable.CompareTo (object other, IComparer comparer)
{
if (other == null)
@@ -514,7 +509,6 @@ namespace System
hash = ((hash << 7) + hash) ^ comparer.GetHashCode (GetValueImpl (i));
return hash;
}
#endif
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
public int GetUpperBound (int dimension)
@@ -654,6 +648,11 @@ namespace System
SetValue (value, ind);
}
internal static Array UnsafeCreateInstance (Type elementType, int length)
{
return CreateInstance (elementType, length);
}
public static Array CreateInstance (Type elementType, int length)
{
int[] lengths = {length};
@@ -934,6 +933,9 @@ namespace System
int source_pos = sourceIndex - sourceArray.GetLowerBound (0);
int dest_pos = destinationIndex - destinationArray.GetLowerBound (0);
if (dest_pos < 0)
throw new ArgumentOutOfRangeException ("destinationIndex", "Index was less than the array's lower bound in the first dimension.");
// re-ordered to avoid possible integer overflow
if (source_pos > sourceArray.Length - length)
throw new ArgumentException ("length");
@@ -1005,7 +1007,7 @@ namespace System
[ReliabilityContractAttribute (Consistency.MayCorruptInstance, Cer.MayFail)]
public static void Copy (Array sourceArray, long sourceIndex, Array destinationArray,
long destinationIndex, long length)
long destinationIndex, long length)
{
if (sourceArray == null)
throw new ArgumentNullException ("sourceArray");
@@ -2727,7 +2729,7 @@ namespace System
public object Current {
get {
// Exception messages based on MS implementation
// Exception messages based on MS implementation
if (currentpos < 0 )
throw new InvalidOperationException (Locale.GetText (
"Enumeration has not started."));
@@ -3171,5 +3173,17 @@ namespace System
}
#endregion
internal sealed class FunctorComparer<T> : IComparer<T> {
Comparison<T> comparison;
public FunctorComparer(Comparison<T> comparison) {
this.comparison = comparison;
}
public int Compare(T x, T y) {
return comparison(x, y);
}
}
}
}

View File

@@ -1,204 +0,0 @@
//
// ArraySegment.cs
//
// Authors:
// Ben Maurer (bmaurer@ximian.com)
// Jensen Somers <jensen.somers@gmail.com>
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2004 Novell
// Copyright (C) 2012 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.Collections;
using System.Collections.Generic;
namespace System
{
[Serializable]
public struct ArraySegment<T>
#if NET_4_5
: IList<T>, IReadOnlyList<T>
#endif
{
T [] array;
readonly int offset, count;
public ArraySegment (T [] array, int offset, int count)
{
if (array == null)
throw new ArgumentNullException ("array");
if (offset < 0)
throw new ArgumentOutOfRangeException ("offset", "Non-negative number required.");
if (count < 0)
throw new ArgumentOutOfRangeException ("count", "Non-negative number required.");
if (offset > array.Length)
throw new ArgumentException ("out of bounds");
// now offset is valid, or just beyond the end.
// Check count -- do it this way to avoid overflow on 'offset + count'
if (array.Length - offset < count)
throw new ArgumentException ("out of bounds", "offset");
this.array = array;
this.offset = offset;
this.count = count;
}
public ArraySegment (T [] array)
{
if (array == null)
throw new ArgumentNullException ("array");
this.array = array;
this.offset = 0;
this.count = array.Length;
}
public T [] Array {
get { return array; }
}
public int Offset {
get { return offset; }
}
public int Count {
get { return count; }
}
public override bool Equals (Object obj)
{
if (obj is ArraySegment<T>) {
return this.Equals((ArraySegment<T>) obj);
}
return false;
}
public bool Equals (ArraySegment<T> obj)
{
if ((this.array == obj.Array) && (this.offset == obj.Offset) && (this.count == obj.Count))
return true;
return false;
}
public override int GetHashCode ()
{
return ((this.array.GetHashCode() ^ this.offset) ^ this.count);
}
public static bool operator ==(ArraySegment<T> a, ArraySegment<T> b)
{
return a.Equals(b);
}
public static bool operator !=(ArraySegment<T> a, ArraySegment<T> b)
{
return !(a.Equals(b));
}
#if NET_4_5
bool ICollection<T>.IsReadOnly {
get {
return true;
}
}
T IReadOnlyList<T>.this[int index] {
get {
return ((IList<T>) this)[index];
}
}
T IList<T>.this[int index] {
get {
if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
return array[offset + index];
}
set {
if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
array[offset + index] = value;
}
}
void ICollection<T>.Add (T item)
{
throw new NotSupportedException ();
}
void ICollection<T>.Clear ()
{
throw new NotSupportedException ();
}
bool ICollection<T>.Remove (T item)
{
throw new NotSupportedException ();
}
void IList<T>.Insert (int index, T item)
{
throw new NotSupportedException ();
}
void IList<T>.RemoveAt (int index)
{
throw new NotSupportedException ();
}
bool ICollection<T>.Contains (T item)
{
return System.Array.IndexOf (array, item, offset, count) >= 0;
}
void ICollection<T>.CopyTo (T[] array, int arrayIndex)
{
System.Array.Copy (this.array, offset, array, arrayIndex, count);
}
IEnumerator<T> IEnumerable<T>.GetEnumerator ()
{
for (int i = 0; i < count; ++i)
yield return array[offset + i];
}
IEnumerator IEnumerable.GetEnumerator ()
{
return ((IEnumerable<T>) this).GetEnumerator ();
}
int IList<T>.IndexOf (T item)
{
var res = System.Array.IndexOf (array, item, offset, count);
return res < 0 ? -1 : res - offset;
}
#endif
}
}

View File

@@ -1,38 +0,0 @@
//
// Base64FormattingOptions.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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
{
[Flags]
public enum Base64FormattingOptions
{
InsertLineBreaks = 0x1,
None = 0x0
}
}

View File

@@ -1,319 +0,0 @@
//
// System.BitConverter.cs
//
// Author:
// Matt Kimball (matt@kimball.net)
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.Text;
namespace System
{
public
static
class BitConverter
{
public static readonly bool IsLittleEndian = AmILittleEndian ();
static unsafe bool AmILittleEndian ()
{
// binary representations of 1.0:
// big endian: 3f f0 00 00 00 00 00 00
// little endian: 00 00 00 00 00 00 f0 3f
double d = 1.0;
byte *b = (byte*)&d;
return (b [0] == 0);
}
public unsafe static long DoubleToInt64Bits (double value)
{
return *(long *) &value;
}
public unsafe static double Int64BitsToDouble (long value)
{
return *(double *) &value;
}
unsafe static byte[] GetBytes (byte *ptr, int count)
{
byte [] ret = new byte [count];
for (int i = 0; i < count; i++) {
ret [i] = ptr [i];
}
return ret;
}
unsafe public static byte[] GetBytes (bool value)
{
return GetBytes ((byte *) &value, 1);
}
unsafe public static byte[] GetBytes (char value)
{
return GetBytes ((byte *) &value, 2);
}
unsafe public static byte[] GetBytes (short value)
{
return GetBytes ((byte *) &value, 2);
}
unsafe public static byte[] GetBytes (int value)
{
return GetBytes ((byte *) &value, 4);
}
unsafe public static byte[] GetBytes (long value)
{
return GetBytes ((byte *) &value, 8);
}
[CLSCompliant (false)]
unsafe public static byte[] GetBytes (ushort value)
{
return GetBytes ((byte *) &value, 2);
}
[CLSCompliant (false)]
unsafe public static byte[] GetBytes (uint value)
{
return GetBytes ((byte *) &value, 4);
}
[CLSCompliant (false)]
unsafe public static byte[] GetBytes (ulong value)
{
return GetBytes ((byte *) &value, 8);
}
unsafe public static byte[] GetBytes (float value)
{
return GetBytes ((byte *) &value, 4);
}
unsafe public static byte[] GetBytes (double value)
{
return GetBytes ((byte *) &value, 8);
}
unsafe static void PutBytes (byte *dst, byte[] src, int start_index, int count)
{
if (src == null)
throw new ArgumentNullException ("value");
if (start_index < 0 || (start_index > src.Length - 1))
throw new ArgumentOutOfRangeException ("startIndex", "Index was"
+ " out of range. Must be non-negative and less than the"
+ " size of the collection.");
// avoid integer overflow (with large pos/neg start_index values)
if (src.Length - count < start_index)
throw new ArgumentException ("Destination array is not long"
+ " enough to copy all the items in the collection."
+ " Check array index and length.");
for (int i = 0; i < count; i++)
dst[i] = src[i + start_index];
}
unsafe public static bool ToBoolean (byte[] value, int startIndex)
{
if (value == null)
throw new ArgumentNullException ("value");
if (startIndex < 0 || (startIndex > value.Length - 1))
throw new ArgumentOutOfRangeException ("startIndex", "Index was"
+ " out of range. Must be non-negative and less than the"
+ " size of the collection.");
if (value [startIndex] != 0)
return true;
return false;
}
unsafe public static char ToChar (byte[] value, int startIndex)
{
char ret;
PutBytes ((byte *) &ret, value, startIndex, 2);
return ret;
}
unsafe public static short ToInt16 (byte[] value, int startIndex)
{
short ret;
PutBytes ((byte *) &ret, value, startIndex, 2);
return ret;
}
unsafe public static int ToInt32 (byte[] value, int startIndex)
{
int ret;
PutBytes ((byte *) &ret, value, startIndex, 4);
return ret;
}
unsafe public static long ToInt64 (byte[] value, int startIndex)
{
long ret;
PutBytes ((byte *) &ret, value, startIndex, 8);
return ret;
}
[CLSCompliant (false)]
unsafe public static ushort ToUInt16 (byte[] value, int startIndex)
{
ushort ret;
PutBytes ((byte *) &ret, value, startIndex, 2);
return ret;
}
[CLSCompliant (false)]
unsafe public static uint ToUInt32 (byte[] value, int startIndex)
{
uint ret;
PutBytes ((byte *) &ret, value, startIndex, 4);
return ret;
}
[CLSCompliant (false)]
unsafe public static ulong ToUInt64 (byte[] value, int startIndex)
{
ulong ret;
PutBytes ((byte *) &ret, value, startIndex, 8);
return ret;
}
unsafe public static float ToSingle (byte[] value, int startIndex)
{
float ret;
PutBytes ((byte *) &ret, value, startIndex, 4);
return ret;
}
unsafe public static double ToDouble (byte[] value, int startIndex)
{
double ret;
PutBytes ((byte *) &ret, value, startIndex, 8);
return ret;
}
public static string ToString (byte[] value)
{
if (value == null)
throw new ArgumentNullException ("value");
return ToString (value, 0, value.Length);
}
public static string ToString (byte[] value, int startIndex)
{
if (value == null)
throw new ArgumentNullException ("value");
return ToString (value, startIndex, value.Length - startIndex);
}
public static string ToString (byte[] value, int startIndex, int length)
{
if (value == null)
throw new ArgumentNullException ("byteArray");
// The 4th and last clause (start_index >= value.Length)
// was added as a small fix to a very obscure bug.
// It makes a small difference when start_index is
// outside the range and length==0.
if (startIndex < 0 || startIndex >= value.Length) {
// special (but valid) case (e.g. new byte [0])
if ((startIndex == 0) && (value.Length == 0))
return String.Empty;
throw new ArgumentOutOfRangeException ("startIndex", "Index was"
+ " out of range. Must be non-negative and less than the"
+ " size of the collection.");
}
if (length < 0)
throw new ArgumentOutOfRangeException ("length",
"Value must be positive.");
// note: re-ordered to avoid possible integer overflow
if (startIndex > value.Length - length)
throw new ArgumentException ("startIndex + length > value.Length");
if (length == 0)
return string.Empty;
StringBuilder builder = new StringBuilder(length * 3 - 1);
int end = startIndex + length;
for (int i = startIndex; i < end; i++) {
if (i > startIndex)
builder.Append('-');
char high = (char)((value[i] >> 4) & 0x0f);
char low = (char)(value[i] & 0x0f);
if (high < 10)
high += '0';
else {
high -= (char) 10;
high += 'A';
}
if (low < 10)
low += '0';
else {
low -= (char) 10;
low += 'A';
}
builder.Append(high);
builder.Append(low);
}
return builder.ToString ();
}
}
}

View File

@@ -1,304 +0,0 @@
//
// System.Boolean.cs
//
// Author:
// Derek Holden (dholden@draper.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
//
// Testing SVN
//
// I guess this is the Boolean class. This was written word for word
// off the Library specification for System.Boolean in the ECMA
// TC39 TG2 and TG3 working documents.
//
// The XML style documentation isn't that elegant, but it seems to
// be the standard way according to the poorly documented C#
// Programmer's Reference section on XML Documentation.
//
using System.Globalization;
using System.Runtime.InteropServices;
namespace System
{
/// <summary>
/// Represents the boolean values of logical true and false.
/// </summary>
[Serializable]
[ComVisible (true)]
public struct Boolean : IComparable, IConvertible, IComparable <bool>, IEquatable <bool>
{
/// <value>
/// The String representation of Boolean False
/// </value>
public static readonly string FalseString = "False";
/// <value>
/// The String representation of Boolean True
/// </value>
public static readonly string TrueString = "True";
internal bool m_value;
/// <summary>
/// Compares the current Boolean instance against another object.
/// </summary>
/// <remarks>
/// Throws an ArgumentException if <c>obj</c> isn't null or
/// a Boolean.
/// </remarks>
/// <param name="obj">
/// The object to compare against
/// </param>
/// <returns>
/// An int reflecting the sort order of this instance as
/// compared to <c>obj</c>
/// -1 if this instance is false and <c>obj</c> is true
/// 0 if this instance is equal to <c>obj</c>
/// 1 if this instance is true and <c>obj</c> is false,
/// or <c>obj</c> is null
/// </returns>
public int CompareTo (object obj)
{
if (obj == null)
return 1;
if (!(obj is System.Boolean))
throw new ArgumentException (Locale.GetText (
"Object is not a Boolean."));
bool value = (bool) obj;
// for case #3
if (m_value && !value)
return 1;
// for case #2, else it's #1
return (m_value == value) ? 0 : -1;
}
/// <summary>
/// Determines whether this instance and another object represent the
/// same type and value.
/// </summary>
/// <param name="obj">
/// The object to check against
/// </param>
/// <returns>
/// true if this instnace and <c>obj</c> are same value,
/// otherwise false if it is not or null
/// </returns>
public override bool Equals (Object obj)
{
if (obj == null || !(obj is System.Boolean))
return false;
bool value = (bool) obj;
return m_value ? value : !value;
}
public int CompareTo (bool value)
{
if (m_value == value)
return 0;
return !m_value ? -1 : 1;
}
public bool Equals (bool obj)
{
return m_value == obj;
}
/// <summary>
/// Generates a hashcode for this object.
/// </summary>
/// <returns>
/// An Int32 value holding the hash code
/// </returns>
public override int GetHashCode ()
{
// Guess there's not too many ways to hash a Boolean
return m_value ? 1 : 0;
}
/// <summary>
/// Returns a given string as a boolean value. The string must be
/// equivalent to either TrueString or FalseString, with leading and/or
/// trailing spaces, and is parsed case-insensitively.
/// </summary>
/// <remarks>
/// Throws an ArgumentNullException if <c>val</c> is null, or a
/// FormatException if <c>val</c> doesn't match <c>TrueString</c>
/// or <c>FalseString</c>
/// </remarks>
/// <param name="val">
/// The string value to parse
/// </param>
/// <returns>
/// true if <c>val</c> is equivalent to TrueString,
/// otherwise false
/// </returns>
public static bool Parse (string value)
{
if (value == null)
throw new ArgumentNullException ("value");
value = value.Trim ();
if (string.CompareOrdinalCaseInsensitiveUnchecked (value, TrueString) == 0)
return true;
if (string.CompareOrdinalCaseInsensitiveUnchecked (value, FalseString) == 0)
return false;
throw new FormatException (Locale.GetText (
"Value is not equivalent to either TrueString or FalseString."));
}
public static bool TryParse (string value, out bool result)
{
result = false;
if (value == null)
return false;
value = value.Trim ();
if (string.CompareOrdinalCaseInsensitiveUnchecked (value, TrueString) == 0) {
result = true;
return true;
}
if (string.CompareOrdinalCaseInsensitiveUnchecked (value, FalseString) == 0) {
// result = false; // already set at false by default
return true;
}
return false;
}
/// <summary>
/// Returns a string representation of this Boolean object.
/// </summary>
/// <returns>
/// <c>FalseString</c> if the instance value is false, otherwise
/// <c>TrueString</c>
/// </returns>
public override string ToString ()
{
return m_value ? TrueString : FalseString;
}
// =========== IConvertible Methods =========== //
public TypeCode GetTypeCode ()
{
return TypeCode.Boolean;
}
object IConvertible.ToType (Type targetType, IFormatProvider provider)
{
if (targetType == null)
throw new ArgumentNullException ("targetType");
return System.Convert.ToType (m_value, targetType, provider, false);
}
bool IConvertible.ToBoolean (IFormatProvider provider)
{
return m_value;
}
byte IConvertible.ToByte (IFormatProvider provider)
{
return System.Convert.ToByte (m_value);
}
char IConvertible.ToChar (IFormatProvider provider)
{
throw new InvalidCastException ();
}
DateTime IConvertible.ToDateTime (IFormatProvider provider)
{
throw new InvalidCastException ();
}
decimal IConvertible.ToDecimal (IFormatProvider provider)
{
return System.Convert.ToDecimal (m_value);
}
double IConvertible.ToDouble (IFormatProvider provider)
{
return System.Convert.ToDouble (m_value);
}
short IConvertible.ToInt16 (IFormatProvider provider)
{
return System.Convert.ToInt16 (m_value);
}
int IConvertible.ToInt32 (IFormatProvider provider)
{
return System.Convert.ToInt32 (m_value);
}
long IConvertible.ToInt64 (IFormatProvider provider)
{
return System.Convert.ToInt64 (m_value);
}
sbyte IConvertible.ToSByte (IFormatProvider provider)
{
return System.Convert.ToSByte (m_value);
}
float IConvertible.ToSingle (IFormatProvider provider)
{
return System.Convert.ToSingle (m_value);
}
public string ToString (IFormatProvider provider)
{
return ToString ();
}
ushort IConvertible.ToUInt16 (IFormatProvider provider)
{
return System.Convert.ToUInt16 (m_value);
}
uint IConvertible.ToUInt32 (IFormatProvider provider)
{
return System.Convert.ToUInt32 (m_value);
}
ulong IConvertible.ToUInt64 (IFormatProvider provider)
{
return System.Convert.ToUInt64 (m_value);
}
}
}

View File

@@ -114,5 +114,10 @@ namespace System {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static bool BlockCopyInternal (Array src, int src_offset, Array dest, int dest_offset, int count);
internal static bool InternalBlockCopy (Array src, int src_offset, Array dest, int dest_offset, int count)
{
return BlockCopyInternal (src, src_offset, dest, dest_offset, count);
}
}
}

View File

@@ -1,227 +0,0 @@
//
// System.Byte.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.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;
namespace System
{
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public struct Byte : IFormattable, IConvertible, IComparable, IComparable<Byte>, IEquatable <Byte>
{
public const byte MinValue = 0;
public const byte MaxValue = 255;
internal byte m_value;
public int CompareTo (object value)
{
if (value == null)
return 1;
if (!(value is System.Byte))
throw new ArgumentException (Locale.GetText ("Value is not a System.Byte."));
return CompareTo ((byte) value);
}
public override bool Equals (object obj)
{
if (!(obj is System.Byte))
return false;
return ((byte) obj) == m_value;
}
public override int GetHashCode ()
{
return m_value;
}
public int CompareTo (byte value)
{
return m_value - value;
}
public bool Equals (byte obj)
{
return m_value == obj;
}
public static byte Parse (string s, IFormatProvider provider)
{
return Parse (s, NumberStyles.Integer, provider);
}
public static byte Parse (string s, NumberStyles style)
{
return Parse (s, style, null);
}
public static byte Parse (string s, NumberStyles style, IFormatProvider provider)
{
uint tmpResult = UInt32.Parse (s, style, provider);
if (tmpResult > Byte.MaxValue)
throw new OverflowException (Locale.GetText ("Value too large."));
return (byte) tmpResult;
}
public static byte Parse (string s)
{
return Parse (s, NumberStyles.Integer, null);
}
public static bool TryParse (string s, out byte result)
{
return TryParse (s, NumberStyles.Integer, null, out result);
}
public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out byte result)
{
uint tmpResult;
result = 0;
if (!UInt32.TryParse (s, style, provider, out tmpResult))
return false;
if (tmpResult > Byte.MaxValue)
return false;
result = (byte)tmpResult;
return true;
}
public override string ToString ()
{
return NumberFormatter.NumberToString (m_value, null);
}
public string ToString (string format)
{
return ToString (format, null);
}
public string ToString (IFormatProvider provider)
{
return NumberFormatter.NumberToString (m_value, provider);
}
public string ToString (string format, IFormatProvider provider)
{
return NumberFormatter.NumberToString (format, m_value, provider);
}
// =========== IConvertible Methods =========== //
public TypeCode GetTypeCode ()
{
return TypeCode.Byte;
}
object IConvertible.ToType (Type targetType, IFormatProvider provider)
{
if (targetType == null)
throw new ArgumentNullException ("targetType");
return System.Convert.ToType (m_value, targetType, provider, false);
}
bool IConvertible.ToBoolean (IFormatProvider provider)
{
return System.Convert.ToBoolean (m_value);
}
byte IConvertible.ToByte (IFormatProvider provider)
{
return m_value;
}
char IConvertible.ToChar (IFormatProvider provider)
{
return System.Convert.ToChar (m_value);
}
DateTime IConvertible.ToDateTime (IFormatProvider provider)
{
throw new InvalidCastException ();
}
decimal IConvertible.ToDecimal (IFormatProvider provider)
{
return System.Convert.ToDecimal (m_value);
}
double IConvertible.ToDouble (IFormatProvider provider)
{
return System.Convert.ToDouble (m_value);
}
short IConvertible.ToInt16 (IFormatProvider provider)
{
return System.Convert.ToInt16 (m_value);
}
int IConvertible.ToInt32 (IFormatProvider provider)
{
return System.Convert.ToInt32 (m_value);
}
long IConvertible.ToInt64 (IFormatProvider provider)
{
return System.Convert.ToInt64 (m_value);
}
sbyte IConvertible.ToSByte (IFormatProvider provider)
{
return System.Convert.ToSByte (m_value);
}
float IConvertible.ToSingle (IFormatProvider provider)
{
return System.Convert.ToSingle (m_value);
}
ushort IConvertible.ToUInt16 (IFormatProvider provider)
{
return System.Convert.ToUInt16 (m_value);
}
uint IConvertible.ToUInt32 (IFormatProvider provider)
{
return System.Convert.ToUInt32 (m_value);
}
ulong IConvertible.ToUInt64 (IFormatProvider provider)
{
return System.Convert.ToUInt64 (m_value);
}
}
}

View File

@@ -39,8 +39,8 @@ namespace System.IO {
class CStreamWriter : StreamWriter {
TermInfoDriver driver;
public CStreamWriter (Stream stream, Encoding encoding)
: base (stream, encoding)
public CStreamWriter (Stream stream, Encoding encoding, bool leaveOpen)
: base (stream, encoding, DefaultBufferSize, leaveOpen)
{
driver = (TermInfoDriver) ConsoleDriver.driver;
}

File diff suppressed because it is too large Load Diff

View File

@@ -70,11 +70,7 @@ namespace System
}
}
#if NET_4_0
public void Dispose ()
#else
void IDisposable.Dispose ()
#endif
{
// nop
}

View File

@@ -29,10 +29,6 @@
namespace System
{
#if NET_4_0
public delegate int Comparison <in T> (T x, T y);
#else
public delegate int Comparison <T> (T x, T y);
#endif
}

View File

@@ -125,11 +125,11 @@ namespace System
// UTF-8 ZWNBSP (zero-width non-breaking space).
//
int code_page = 0;
Encoding.InternalCodePage (ref code_page);
EncodingHelper.InternalCodePage (ref code_page);
if (code_page != -1 && ((code_page & 0x0fffffff) == 3 // UTF8Encoding.UTF8_CODE_PAGE
|| ((code_page & 0x10000000) != 0)))
inputEncoding = outputEncoding = Encoding.UTF8Unmarked;
inputEncoding = outputEncoding = EncodingHelper.UTF8Unmarked;
else
inputEncoding = outputEncoding = Encoding.Default;
}
@@ -141,13 +141,13 @@ namespace System
{
#if !NET_2_1
if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
w.AutoFlush = true;
stdout = TextWriter.Synchronized (w, true);
stdout = TextWriter.Synchronized (w);
w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
w.AutoFlush = true;
stderr = TextWriter.Synchronized (w, true);
stderr = TextWriter.Synchronized (w);
stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
} else {
@@ -161,7 +161,7 @@ namespace System
stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
((StreamWriter)stdout).AutoFlush = true;
#endif
stdout = TextWriter.Synchronized (stdout, true);
stdout = TextWriter.Synchronized (stdout);
#if MONOTOUCH && FULL_AOT_RUNTIME
stderr = new NSLogWriter ();
@@ -169,7 +169,7 @@ namespace System
stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding);
((StreamWriter)stderr).AutoFlush = true;
#endif
stderr = TextWriter.Synchronized (stderr, true);
stderr = TextWriter.Synchronized (stderr);
stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
stdin = TextReader.Synchronized (stdin);
@@ -212,7 +212,7 @@ namespace System
try {
return new FileStream (handle, access, false, bufferSize, false, bufferSize == 0);
} catch (IOException) {
return new NullStream ();
return Stream.Null;
}
}
@@ -661,7 +661,6 @@ namespace System
set { ConsoleDriver.WindowWidth = value; }
}
#if NET_4_5
public static bool IsErrorRedirected {
get {
return ConsoleDriver.IsErrorRedirected;
@@ -679,7 +678,6 @@ namespace System
return ConsoleDriver.IsInputRedirected;
}
}
#endif
public static void Beep ()
{

View File

@@ -80,6 +80,17 @@ namespace System {
catch (Exception) {
}
}
/* Called from TextWriter:WriteLine(string) */
public override void Write(char[] buffer, int index, int count) {
try {
sb.Append (buffer);
if (buffer != null && buffer.Length >= CoreNewLine.Length && EndsWithNewLine (buffer))
Flush ();
}
catch (Exception) {
}
}
bool EndsWithNewLine (string value)
{
@@ -90,6 +101,16 @@ namespace System {
return true;
}
bool EndsWithNewLine (char[] value)
{
for (int i = 0, v = value.Length - CoreNewLine.Length; i < CoreNewLine.Length; ++i, ++v) {
if (value [v] != CoreNewLine [i])
return false;
}
return true;
}
public override void WriteLine ()
{

View File

@@ -38,9 +38,6 @@ namespace System
{
[Serializable]
[ComVisible (true)]
#if !NET_4_0
[Obsolete ("this type is obsoleted in 2.0 profile")]
#endif
public class ContextMarshalException : SystemException
{
const int Result = unchecked ((int)0x80131504);

File diff suppressed because it is too large Load Diff

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