Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -1,34 +0,0 @@
//
// AppContext.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
{
public static class AppContext
{
}
}

View File

@@ -1 +0,0 @@
be02e0743ab07038577df7229d90569ba40cd378

View File

@@ -136,45 +136,29 @@ namespace System
{
#if !NET_2_1
if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
w.AutoFlush = true;
stdout = TextWriter.Synchronized (w);
w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
w.AutoFlush = true;
stderr = TextWriter.Synchronized (w);
stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
} else {
stdout = TextWriter.Synchronized (new CStreamWriter (OpenStandardOutput (0), outputEncoding, true) { AutoFlush = true });
stderr = TextWriter.Synchronized (new CStreamWriter (OpenStandardError (0), outputEncoding, true) { AutoFlush = true });
} else
#endif
{
stdin = TextReader.Synchronized (new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding));
#if MONOTOUCH
stdout = new NSLogWriter ();
#else
stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
((StreamWriter)stdout).AutoFlush = true;
#endif
stdout = TextWriter.Synchronized (stdout);
#if MONOTOUCH
stderr = new NSLogWriter ();
#else
stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding);
((StreamWriter)stderr).AutoFlush = true;
#endif
stderr = TextWriter.Synchronized (stderr);
stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
stdin = TextReader.Synchronized (stdin);
#if !NET_2_1
}
#endif
stdout = TextWriter.Synchronized (new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding) { AutoFlush = true });
stderr = TextWriter.Synchronized (new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding) { AutoFlush = true });
#if MONODROID
if (LogcatTextWriter.IsRunningOnAndroid ()) {
stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
if (LogcatTextWriter.IsRunningOnAndroid ()) {
stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
}
#endif // MONODROID
#endif // MONOTOUCH
}
#endif // MONODROID
GC.SuppressFinalize (stdout);
GC.SuppressFinalize (stderr);

View File

@@ -534,6 +534,12 @@ namespace System
if (a == null)
return b;
if (b == null)
return a;
if (a.GetType () != b.GetType ())
throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types. First is {0} second is {1}.", a.GetType ().FullName, b.GetType ().FullName));
return a.CombineImpl (b);
}

View File

@@ -57,7 +57,7 @@ namespace System {
* of icalls, do not require an increment.
*/
#pragma warning disable 169
private const int mono_corlib_version = 140;
private const int mono_corlib_version = 149;
#pragma warning restore 169
[ComVisible (true)]
@@ -736,10 +736,6 @@ namespace System {
return String.Empty;
// This is where data common to all users goes
case SpecialFolder.CommonApplicationData:
Version v = CreateVersionFromString (GetOSVersionString ());
if (Platform == PlatformID.MacOSX && v >= new Version(15, 0)) {
return "/usr/local/share";
}
return "/usr/share";
default:
throw new ArgumentException ("Invalid SpecialFolder");
@@ -900,8 +896,11 @@ namespace System {
throw new NotImplementedException ();
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern static bool GetIs64BitOperatingSystem ();
public static bool Is64BitOperatingSystem {
get { return IntPtr.Size == 8; } // FIXME: is this good enough?
get { return GetIs64BitOperatingSystem (); }
}
public static int SystemPageSize {
@@ -986,6 +985,19 @@ namespace System {
{
}
// Copied from referencesource Environment
internal static String GetStackTrace(Exception e, bool needFileInfo)
{
System.Diagnostics.StackTrace st;
if (e == null)
st = new System.Diagnostics.StackTrace(needFileInfo);
else
st = new System.Diagnostics.StackTrace(e, needFileInfo);
// Do not include a trailing newline for backwards compatibility
return st.ToString( System.Diagnostics.StackTrace.TraceFormat.Normal );
}
}
}

View File

@@ -0,0 +1,148 @@
// Copyright 2014 Xamarin Inc.
// note: or older hack to give the Documents (or Library) directories
using System.IO;
using System.Runtime.InteropServices;
namespace System {
public static partial class Environment {
static string ns_document;
static string ns_library;
[DllImport ("__Internal")]
extern static string xamarin_GetFolderPath (int folder);
static string NSDocumentDirectory {
get {
if (ns_document == null) {
#if MONOTOUCH_TV
// The "normal" NSDocumentDirectory is a read-only directory on tvOS
// and that breaks a lot of assumptions in the runtime and the BCL
// to avoid this we relocate the Documents directory under Caches
ns_document = Path.Combine (NSLibraryDirectory, "Caches", "Documents");
if (!Directory.Exists (ns_document))
Directory.CreateDirectory (ns_document);
#else
ns_document = xamarin_GetFolderPath (/* NSDocumentDirectory */ 9);
#endif
}
return ns_document;
}
}
// Various user-visible documentation, support, and configuration files
static string NSLibraryDirectory {
get {
if (ns_library == null)
ns_library = xamarin_GetFolderPath (/* NSLibraryDirectory */ 5);
return ns_library;
}
}
public static string GetFolderPath (SpecialFolder folder, SpecialFolderOption option)
{
return UnixGetFolderPath (folder, option);
}
// needed by our BCL, e.g. IsolatedStorageFile.cs
internal static string UnixGetFolderPath (SpecialFolder folder, SpecialFolderOption option)
{
var dir = iOSGetFolderPath (folder);
if ((option == SpecialFolderOption.Create) && !Directory.Exists (dir))
Directory.CreateDirectory (dir);
return dir;
}
internal static string iOSGetFolderPath (SpecialFolder folder)
{
switch (folder) {
case SpecialFolder.MyComputer:
case SpecialFolder.Programs:
case SpecialFolder.SendTo:
case SpecialFolder.StartMenu:
case SpecialFolder.Startup:
case SpecialFolder.Cookies:
case SpecialFolder.History:
case SpecialFolder.Recent:
case SpecialFolder.CommonProgramFiles:
case SpecialFolder.System:
case SpecialFolder.NetworkShortcuts:
case SpecialFolder.CommonStartMenu:
case SpecialFolder.CommonPrograms:
case SpecialFolder.CommonStartup:
case SpecialFolder.CommonDesktopDirectory:
case SpecialFolder.PrinterShortcuts:
case SpecialFolder.Windows:
case SpecialFolder.SystemX86:
case SpecialFolder.ProgramFilesX86:
case SpecialFolder.CommonProgramFilesX86:
case SpecialFolder.CommonDocuments:
case SpecialFolder.CommonAdminTools:
case SpecialFolder.AdminTools:
case SpecialFolder.CommonMusic:
case SpecialFolder.CommonPictures:
case SpecialFolder.CommonVideos:
case SpecialFolder.LocalizedResources:
case SpecialFolder.CommonOemLinks:
case SpecialFolder.CDBurning:
return String.Empty;
// personal == ~
case SpecialFolder.Personal:
case SpecialFolder.LocalApplicationData:
return NSDocumentDirectory;
case SpecialFolder.ApplicationData:
// note: at first glance that looked like a good place to return NSLibraryDirectory
// but it would break isolated storage for existing applications
return Path.Combine (NSDocumentDirectory, ".config");
case SpecialFolder.Resources:
return NSLibraryDirectory; // older (8.2 and previous) would return String.Empty
case SpecialFolder.Desktop:
case SpecialFolder.DesktopDirectory:
return Path.Combine (NSDocumentDirectory, "Desktop");
case SpecialFolder.MyMusic:
return Path.Combine (NSDocumentDirectory, "Music");
case SpecialFolder.MyPictures:
return Path.Combine (NSDocumentDirectory, "Pictures");
case SpecialFolder.Templates:
return Path.Combine (NSDocumentDirectory, "Templates");
case SpecialFolder.MyVideos:
return Path.Combine (NSDocumentDirectory, "Videos");
case SpecialFolder.CommonTemplates:
return "/usr/share/templates";
case SpecialFolder.Fonts:
return Path.Combine (NSDocumentDirectory, ".fonts");
case SpecialFolder.Favorites:
return Path.Combine (NSLibraryDirectory, "Favorites");
case SpecialFolder.ProgramFiles:
return "/Applications";
case SpecialFolder.InternetCache:
return Path.Combine (NSLibraryDirectory, "Caches");
case SpecialFolder.UserProfile:
return internalGetHome ();
case SpecialFolder.CommonApplicationData:
return "/usr/share";
default:
throw new ArgumentException ("Invalid SpecialFolder");
}
}
}
}

View File

@@ -1,336 +0,0 @@
//
// System.Exception.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
// Patrik Torstensson
//
// (C) Ximian, Inc. http://www.ximian.com
// 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.
//
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace System
{
[Serializable]
[ComVisible(true)]
[ComDefaultInterface (typeof (_Exception))]
[ClassInterface (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
public class Exception : ISerializable
#else
public class Exception : ISerializable, _Exception
#endif
{
#pragma warning disable 169, 649
#region Sync with object-internals.h
/* Stores the IPs and the generic sharing infos
(vtable/MRGCTX) of the frames. */
IntPtr [] trace_ips;
Exception inner_exception;
internal string _message;
string help_link;
string class_name;
string stack_trace;
// formerly known as remote_stack_trace (see #425512):
string _remoteStackTraceString;
int remote_stack_index;
internal int hresult = -2146233088;
string source;
IDictionary _data;
internal StackTrace[] captured_traces;
IntPtr[] native_trace_ips;
object dynamic_methods;
#endregion
#pragma warning restore 169, 649
/* Don't add fields here, the runtime depends on the layout of subclasses */
public Exception ()
{
}
public Exception (string message)
{
this._message = message;
}
protected Exception (SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException ("info");
class_name = info.GetString ("ClassName");
_message = info.GetString ("Message");
help_link = info.GetString ("HelpURL");
stack_trace = info.GetString ("StackTraceString");
_remoteStackTraceString = info.GetString ("RemoteStackTraceString");
remote_stack_index = info.GetInt32 ("RemoteStackIndex");
hresult = info.GetInt32 ("HResult");
source = info.GetString ("Source");
inner_exception = (Exception) info.GetValue ("InnerException", typeof (Exception));
try {
_data = (IDictionary) info.GetValue ("Data", typeof (IDictionary));
} catch (SerializationException) {
// member did not exist in .NET 1.x
}
}
public Exception (string message, Exception innerException)
{
inner_exception = innerException;
this._message = message;
}
public Exception InnerException {
get { return inner_exception; }
}
public virtual string HelpLink {
get { return help_link; }
set { help_link = value; }
}
public int HResult {
get { return hresult; }
protected set { hresult = value; }
}
internal void SetErrorCode(int hr)
{
HResult = hr;
}
internal void SetMessage (string s)
{
_message = s;
}
internal void SetStackTrace (string s)
{
stack_trace = s;
}
string ClassName {
get {
if (class_name == null)
class_name = GetType ().ToString ();
return class_name;
}
}
public virtual string Message {
get {
if (_message == null)
_message = string.Format (Locale.GetText ("Exception of type '{0}' was thrown."),
ClassName);
return _message;
}
}
[MonoTODO]
protected event EventHandler<SafeSerializationEventArgs> SerializeObjectState {
add {
}
remove {
}
}
public virtual string Source {
get {
if (source == null) {
StackTrace st = new StackTrace (this, true);
if (st.FrameCount > 0) {
StackFrame sf = st.GetFrame (0);
if (st != null) {
MethodBase method = sf.GetMethod ();
if (method != null) {
source = method.DeclaringType.Assembly.UnprotectedGetName ().Name;
}
}
}
}
// source can be null
return source;
}
set {
source = value;
}
}
public virtual string StackTrace {
get {
if (stack_trace != null)
return stack_trace;
if (trace_ips == null)
/* Not thrown yet */
return null;
StackTrace st = new StackTrace (this, 0, true);
return stack_trace = st.ToString ();
}
}
public MethodBase TargetSite {
get {
StackTrace st = new StackTrace (this, true);
if (st.FrameCount > 0)
return st.GetFrame (0).GetMethod ();
return null;
}
}
public virtual IDictionary Data {
get {
if (_data == null) {
// default to empty dictionary
_data = new Dictionary<object, object> ();
}
return _data;
}
}
public virtual Exception GetBaseException ()
{
Exception inner = inner_exception;
while (inner != null)
{
if (inner.InnerException != null)
inner = inner.InnerException;
else
return inner;
}
return this;
}
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException ("info");
info.AddValue ("ClassName", ClassName);
info.AddValue ("Message", _message);
info.AddValue ("InnerException", inner_exception, typeof (Exception));
info.AddValue ("HelpURL", help_link);
info.AddValue ("StackTraceString", StackTrace);
info.AddValue ("RemoteStackTraceString", _remoteStackTraceString);
info.AddValue ("RemoteStackIndex", remote_stack_index);
info.AddValue ("HResult", hresult);
info.AddValue ("Source", Source);
info.AddValue ("ExceptionMethod", null);
info.AddValue ("Data", _data, typeof (IDictionary));
}
public override string ToString ()
{
System.Text.StringBuilder result = new System.Text.StringBuilder (ClassName);
result.Append (": ").Append (Message);
if (null != _remoteStackTraceString)
result.Append (_remoteStackTraceString);
if (inner_exception != null)
{
result.Append (" ---> ").Append (inner_exception.ToString ());
result.Append (Environment.NewLine);
result.Append (Locale.GetText (" --- End of inner exception stack trace ---"));
}
if (StackTrace != null)
result.Append (Environment.NewLine).Append (StackTrace);
return result.ToString();
}
internal Exception FixRemotingException ()
{
string message = (0 == remote_stack_index) ?
Locale.GetText ("{0}{0}Server stack trace: {0}{1}{0}{0}Exception rethrown at [{2}]: {0}") :
Locale.GetText ("{1}{0}{0}Exception rethrown at [{2}]: {0}");
string tmp = String.Format (message, Environment.NewLine, StackTrace, remote_stack_index);
_remoteStackTraceString = tmp;
remote_stack_index++;
stack_trace = null;
return this;
}
// For ExceptionDispatchInfo
internal void RestoreExceptionDispatchInfo (System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
{
captured_traces = (StackTrace[]) exceptionDispatchInfo.BinaryStackTraceArray;
trace_ips = null;
stack_trace = null;
}
//
// The documentation states that this is available in 1.x,
// but it was not available (MemberRefing this would fail)
// and it states the signature is `override sealed', but the
// correct value is `newslot'
//
public new Type GetType ()
{
return base.GetType ();
}
internal enum ExceptionMessageKind
{
ThreadAbort = 1,
ThreadInterrupted = 2,
OutOfMemory = 3
}
internal static String GetMessageFromNativeResources (ExceptionMessageKind kind)
{
switch (kind) {
case ExceptionMessageKind.ThreadAbort:
return "";
case ExceptionMessageKind.ThreadInterrupted:
return "";
case ExceptionMessageKind.OutOfMemory:
return "Out of memory";
}
return "";
}
}
}

View File

@@ -49,14 +49,14 @@ namespace System
[ThreadStatic]
static Dictionary<Type, AttributeUsageAttribute> usage_cache;
/* Treat as user types all corlib types extending System.Type that are not MonoType and TypeBuilder */
/* Treat as user types all corlib types extending System.Type that are not RuntimeType and TypeBuilder */
static bool IsUserCattrProvider (object obj)
{
Type type = obj as Type;
#if !FULL_AOT_RUNTIME
if ((type is MonoType) || (type is TypeBuilder))
if ((type is RuntimeType) || (type is TypeBuilder))
#else
if (type is MonoType)
if (type is RuntimeType)
#endif
return false;
if ((obj is Type))

View File

@@ -32,126 +32,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Security;
using System.Diagnostics.Contracts;
using System.Threading;
using System.Diagnostics;
using System.Security.Permissions;
using System.Runtime.Remoting.Activation;
using System.Runtime;
namespace System
{
// Contains information about the type which is expensive to compute
[StructLayout (LayoutKind.Sequential)]
internal class MonoTypeInfo {
// this is the displayed form: special characters
// ,+*&*[]\ in the identifier portions of the names
// have been escaped with a leading backslash (\)
public string full_name;
public MonoCMethod default_ctor;
}
[Serializable]
[StructLayout (LayoutKind.Sequential)]
class MonoType : RuntimeType, ISerializable
// Dummy type kept because lots of external code uses
// this to check whenever it is running on mono.
sealed class MonoType : RuntimeType
{
[NonSerialized]
MonoTypeInfo type_info;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void type_from_obj (MonoType type, Object obj);
internal MonoType (Object obj)
private MonoType ()
{
// this should not be used - lupus
type_from_obj (this, obj);
throw new NotImplementedException ();
}
internal override MonoCMethod GetDefaultConstructor ()
{
MonoCMethod ctor = null;
if (type_info == null)
type_info = new MonoTypeInfo ();
else
ctor = type_info.default_ctor;
if (ctor == null) {
var ctors = GetConstructors (BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
for (int i = 0; i < ctors.Length; ++i) {
if (ctors [i].GetParametersCount () == 0) {
type_info.default_ctor = ctor = (MonoCMethod) ctors [i];
break;
}
}
}
return ctor;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern MethodInfo GetCorrespondingInflatedMethod (MethodInfo generic);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern ConstructorInfo GetCorrespondingInflatedConstructor (ConstructorInfo generic);
internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
{
if (fromNoninstanciated == null)
throw new ArgumentNullException ("fromNoninstanciated");
return GetCorrespondingInflatedMethod (fromNoninstanciated);
}
internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
{
if (fromNoninstanciated == null)
throw new ArgumentNullException ("fromNoninstanciated");
return GetCorrespondingInflatedConstructor (fromNoninstanciated);
}
internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
{
/* create sensible flags from given FieldInfo */
BindingFlags flags = fromNoninstanciated.IsStatic ? BindingFlags.Static : BindingFlags.Instance;
flags |= fromNoninstanciated.IsPublic ? BindingFlags.Public : BindingFlags.NonPublic;
return GetField (fromNoninstanciated.Name, flags);
}
public override int GetHashCode()
{
Type t = UnderlyingSystemType;
if (t != null && t != this)
return t.GetHashCode ();
return (int)_impl.Value;
}
public override string FullName {
get {
string fullName;
// This doesn't need locking
if (type_info == null)
type_info = new MonoTypeInfo ();
if ((fullName = type_info.full_name) == null)
fullName = type_info.full_name = getFullName (true, false);
return fullName;
}
}
internal override bool IsUserType {
get {
return false;
}
}
}
}

View File

@@ -0,0 +1,13 @@
namespace System {
public partial class NotSupportedException {
// Avoid having the linker generate this method for every linked build
// It also fix #30075 where --linkskip=mscorlib means that method could not be added
// but still referenced from other assemblies
internal static Exception LinkedAway ()
{
return new NotSupportedException ("Linked Away");
}
}
}

View File

@@ -62,7 +62,7 @@ namespace System
if (info == null)
throw new ArgumentNullException ("info");
MonoType mt = ((MonoType) info.GetValue ("TypeObj", typeof (MonoType)));
RuntimeType mt = ((RuntimeType) info.GetValue ("TypeObj", typeof (RuntimeType)));
value = mt.TypeHandle.Value;
if (value == IntPtr.Zero)
throw new SerializationException (Locale.GetText ("Insufficient state."));
@@ -82,7 +82,7 @@ namespace System
if (value == IntPtr.Zero)
throw new SerializationException ("Object fields may not be properly initialized");
info.AddValue ("TypeObj", Type.GetTypeHandle (this), typeof (MonoType));
info.AddValue ("TypeObj", Type.GetTypeHandle (this), typeof (RuntimeType));
}
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]

View File

@@ -90,14 +90,14 @@ namespace System
*/
private List<KeyValuePair<DateTime, TimeType>> transitions;
private static bool libcNotFound;
private static bool readlinkNotFound;
[DllImport ("libc")]
private static extern int readlink (string path, byte[] buffer, int buflen);
private static string readlink (string path)
{
if (libcNotFound)
if (readlinkNotFound)
return null;
byte[] buf = new byte [512];
@@ -106,7 +106,10 @@ namespace System
try {
ret = readlink (path, buf, buf.Length);
} catch (DllNotFoundException e) {
libcNotFound = true;
readlinkNotFound = true;
return null;
} catch (EntryPointNotFoundException e) {
readlinkNotFound = true;
return null;
}
@@ -120,8 +123,12 @@ namespace System
{
name = null;
var linkPath = readlink (path);
if (linkPath != null)
path = linkPath;
if (linkPath != null) {
if (Path.IsPathRooted(linkPath))
path = linkPath;
else
path = Path.Combine(Path.GetDirectoryName(path), linkPath);
}
path = Path.GetFullPath (path);
@@ -730,7 +737,8 @@ namespace System
public TimeSpan GetUtcOffset (DateTimeOffset dateTimeOffset)
{
throw new NotImplementedException ();
bool isDST;
return GetUtcOffset (dateTimeOffset.UtcDateTime, out isDST);
}
private TimeSpan GetUtcOffset (DateTime dateTime, out bool isDST)
@@ -865,7 +873,7 @@ namespace System
return true;
// We might be in the dateTime previous year's DST period
return IsInDSTForYear (rule, dateTime, dateTime.Year - 1);
return dateTime.Year > 1 && IsInDSTForYear (rule, dateTime, dateTime.Year - 1);
}
bool IsInDSTForYear (AdjustmentRule rule, DateTime dateTime, int year)
@@ -1213,8 +1221,10 @@ namespace System
try {
return ParseTZBuffer (id, buffer, length);
} catch (InvalidTimeZoneException) {
throw;
} catch (Exception e) {
throw new InvalidTimeZoneException (e.Message);
throw new InvalidTimeZoneException ("Time zone information file contains invalid data", e);
}
}
@@ -1271,7 +1281,7 @@ namespace System
if (time_types.Count == 0)
throw new InvalidTimeZoneException ();
if (time_types.Count == 1 && ((TimeType)time_types[0]).IsDst)
if (time_types.Count == 1 && time_types[0].IsDst)
throw new InvalidTimeZoneException ();
TimeSpan baseUtcOffset = new TimeSpan (0);
@@ -1352,8 +1362,8 @@ namespace System
TimeZoneInfo tz;
if (adjustmentRules.Count == 0 && !storeTransition) {
TimeType t = (TimeType)time_types [0];
if (standardDisplayName == null) {
var t = time_types [0];
standardDisplayName = t.Name;
baseUtcOffset = new TimeSpan (0, 0, t.Offset);
}
@@ -1397,6 +1407,20 @@ namespace System
var types = new Dictionary<int, TimeType> (count);
for (int i = 0; i < count; i++) {
int offset = ReadBigEndianInt32 (buffer, index + 6 * i);
//
// The official tz database contains timezone with GMT offsets
// not only in whole hours/minutes but in seconds. This happens for years
// before 1901. For example
//
// NAME GMTOFF RULES FORMAT UNTIL
// Europe/Madrid -0:14:44 - LMT 1901 Jan 1 0:00s
//
// .NET as of 4.6.2 cannot handle that and uses hours/minutes only, so
// we remove seconds to not crash later
//
offset = (offset / 60) * 60;
byte is_dst = buffer [index + 6 * i + 4];
byte abbrev = buffer [index + 6 * i + 5];
types.Add (i, new TimeType (offset, (is_dst != 0), abbreviations [(int)abbrev]));
@@ -1452,7 +1476,7 @@ namespace System
#endregion
}
struct TimeType {
class TimeType {
public readonly int Offset;
public readonly bool IsDst;
public string Name;

View File

@@ -104,7 +104,7 @@ namespace System
public override string ToString ()
{
return ((uint) _pointer).ToString();
return UIntPtr.Size < 8 ? ((uint) _pointer).ToString() : ((ulong) _pointer).ToString();
}
// Interface ISerializable

View File

@@ -63,6 +63,9 @@ namespace System
#endregion
#pragma warning restore 169
// keep a reference to the proxy so it doesn't get garbage collected before the RCW
ComInteropProxy proxy;
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern __ComObject CreateRCW (Type t);
@@ -71,10 +74,13 @@ namespace System
~__ComObject ()
{
if (synchronization_context != null)
synchronization_context.Post ((state) => ReleaseInterfaces (), this);
else
ReleaseInterfaces ();
if (hash_table != IntPtr.Zero) {
if (synchronization_context != null)
synchronization_context.Post ((state) => ReleaseInterfaces (), this);
else
ReleaseInterfaces ();
}
proxy = null;
}
public __ComObject ()
@@ -86,14 +92,22 @@ namespace System
Initialize (t);
}
internal __ComObject (IntPtr pItf)
internal __ComObject (IntPtr pItf, ComInteropProxy p)
{
proxy = p;
InitializeApartmentDetails ();
Guid iid = IID_IUnknown;
int hr = Marshal.QueryInterface (pItf, ref iid, out iunknown);
Marshal.ThrowExceptionForHR (hr);
}
internal void Initialize (IntPtr pUnk, ComInteropProxy p)
{
proxy = p;
InitializeApartmentDetails ();
iunknown = pUnk;
}
internal void Initialize (Type t)
{
InitializeApartmentDetails ();
@@ -101,8 +115,14 @@ namespace System
if (iunknown != IntPtr.Zero)
return;
iunknown = CreateIUnknown (t);
}
internal static IntPtr CreateIUnknown(Type t)
{
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (t.TypeHandle);
IntPtr iunknown;
ObjectCreationDelegate ocd = ExtensibleClassFactory.GetObjectCreationCallback (t);
if (ocd != null) {
iunknown = ocd (IntPtr.Zero);
@@ -113,6 +133,8 @@ namespace System
int hr = CoCreateInstance (GetCLSID (t), IntPtr.Zero, 0x1 | 0x4 | 0x10, IID_IUnknown, out iunknown);
Marshal.ThrowExceptionForHR (hr);
}
return iunknown;
}
private void InitializeApartmentDetails ()
@@ -230,4 +252,16 @@ namespace System
out IntPtr pUnk);
}
}
#else
namespace System
{
// this is a shim class so we can AOT during mobile_static build without --enable-minimal=com
internal class __ComObject
{
__ComObject ()
{
throw new NotSupportedException ();
}
}
}
#endif