Merge pull request #3565 from vargaz/no-free-imt-thunks
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 16 Sep 2016 17:13:54 +0000 (10:13 -0700)
committerGitHub <noreply@github.com>
Fri, 16 Sep 2016 17:13:54 +0000 (10:13 -0700)
[runtime] Avoid freeing IMT thunks, some threads might still be execu…

104 files changed:
man/mcs.1
mcs/class/Facades/System.Net.Mail/TypeForwarders.cs
mcs/class/Makefile
mcs/class/System.Net.Http/System.Net.Http.Headers/HeaderInfo.cs
mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaderValueCollection.cs
mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs
mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeaderValueCollection.cs
mcs/class/System.Web/System.Web/HttpCookie.cs
mcs/class/System/System.Diagnostics/Win32EventLog.cs
mcs/class/System/Test/System.Net/DnsTest.cs
mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs [new file with mode: 0644]
mcs/class/corlib/ReferenceSources/CompatibilitySwitches.cs
mcs/class/corlib/ReferenceSources/RuntimeType.cs
mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs
mcs/class/corlib/System.Diagnostics/StackTrace.cs
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
mcs/class/corlib/System.Reflection/Assembly.cs
mcs/class/corlib/System.Runtime.Loader/AssemblyLoadContext.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
mcs/class/corlib/System.Security.AccessControl/NativeObjectSecurity.cs
mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs
mcs/class/corlib/System.Security/PermissionSet.cs
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/TimeZoneInfo.Android.cs
mcs/class/corlib/System/TimeZoneInfo.cs
mcs/class/corlib/Test/System.Threading/MutexTest.cs
mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs
mcs/class/corlib/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs
mcs/class/corlib/Test/System/TimeZoneTest.cs
mcs/class/corlib/Test/System/TypeTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/referencesource/mscorlib/system/boolean.cs
mcs/class/referencesource/mscorlib/system/collections/generic/list.cs
mcs/class/referencesource/mscorlib/system/convert.cs
mcs/class/referencesource/mscorlib/system/globalization/charunicodeinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/compareinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/datetimeformatinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/datetimeparse.cs
mcs/class/referencesource/mscorlib/system/globalization/japanesecalendar.cs
mcs/class/referencesource/mscorlib/system/globalization/sortversion.cs
mcs/class/referencesource/mscorlib/system/io/binaryreader.cs
mcs/class/referencesource/mscorlib/system/io/filesysteminfo.cs
mcs/class/referencesource/mscorlib/system/io/ioexception.cs
mcs/class/referencesource/mscorlib/system/io/streamwriter.cs
mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs
mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs
mcs/class/referencesource/mscorlib/system/rttype.cs
mcs/class/referencesource/mscorlib/system/runtime/compilerservices/typedependencyattribute.cs
mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarycommonclasses.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatterwriter.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarymethodmessage.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryutilclasses.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/serializationeventscache.cs
mcs/class/referencesource/mscorlib/system/security/claims/ClaimsIdentity.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/passwordderivebytes.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/rfc2898derivebytes.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/rsacryptoserviceprovider.cs
mcs/class/referencesource/mscorlib/system/text/stringbuilder.cs
mcs/class/referencesource/mscorlib/system/threading/CancellationTokenSource.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/Parallel.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/ParallelLoopState.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs
mcs/class/referencesource/mscorlib/system/threading/eventwaithandle.cs
mcs/class/referencesource/mscorlib/system/threading/threadpool.cs
mcs/class/referencesource/mscorlib/system/typedreference.cs
mcs/errors/cs0029-37.cs [new file with mode: 0644]
mcs/errors/cs0122-39.cs [new file with mode: 0644]
mcs/errors/cs0619-59.cs [new file with mode: 0644]
mcs/errors/cs1070-3.cs [new file with mode: 0644]
mcs/errors/cs1501-19.cs [new file with mode: 0644]
mcs/mcs/constant.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs
mcs/mcs/membercache.cs
mcs/mcs/typespec.cs
mcs/tests/gtest-639.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mono/io-layer/wait.c
mono/metadata/Makefile.am
mono/metadata/appdomain.c
mono/metadata/assembly.c
mono/metadata/class.c
mono/metadata/domain.c
mono/metadata/threads.c
mono/metadata/w32event-unix.c
mono/metadata/w32mutex-unix.c
mono/metadata/w32semaphore-unix.c
mono/mini/mini-amd64.c
mono/tests/Makefile.am
mono/tests/TestingReferenceAssembly.cs [deleted file]
mono/tests/TestingReferenceReferenceAssembly.cs [deleted file]
mono/tests/reference-loader.cs [deleted file]
mono/utils/mono-coop-mutex.h
mono/utils/mono-os-mutex.h
mono/utils/w32handle.c
mono/utils/w32handle.h

index ce7ff11c27aadf341a2ae73d3ddfdcb20ca329d3..377c445cb095c3479199002d4a1461bc3bdaf7d1 100644 (file)
--- a/man/mcs.1
+++ b/man/mcs.1
@@ -18,7 +18,8 @@ prepending the @ symbol to the response file name.
 The 
 .I mcs
 compiler is used to compile against the latest Mono Base Class Library
-version and fully implements C# 1.0, 2.0, 3.0 and 4.0 specifications.
+version and fully implements C# 1.0, 2.0, 3.0, 4.0, 5.0 and 6.0
+specifications.
 .PP
 See the section on packages for more information.
 .PP
@@ -163,7 +164,7 @@ The possible values are:
 .TP
 .I "Default"
 Instruct compiler to use the latest version. Equivalent is to omit the
-switch (this currently defaults to the C# 4.0 language specification).
+switch (this currently defaults to the C# 6.0 language specification).
 .TP
 .I "ISO-1"
 Restrict compiler to use only first ISO standardized features.
@@ -183,6 +184,14 @@ Restrict the compiler to use only the features available in C# 3.0
 Restrict the compiler to use only the features available in C# 4.0
 specification.
 .TP
+.I "5"
+Restrict the compiler to use only the features available in C# 5.0
+specification.
+.TP
+.I "6"
+Restrict the compiler to use only the features available in C# 6.0
+specification.
+.TP
 .I "experimental"
 Enables unstable features from upcoming versions of the language.
 .PP
@@ -510,7 +519,7 @@ the MIT X11.  Please read the accompanying `COPYING' file for details.
 Alternative licensing for the compiler is available from Xamarin.
 .PP
 .SH SEE ALSO
-csharp(1), mdb(1), mono(1), mopen(1), pkg-config(1), sn(1)
+csharp(1), mono(1), pkg-config(1), sn(1)
 .PP
 .SH BUGS
 To report bugs in the compiler, you must file them on our bug tracking
index 81e722e7d75a3f760188d4efed6d66f72ae8d360..a5009840f78876270fda7ca9a479dc9e786bbafe 100644 (file)
@@ -33,7 +33,9 @@
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.MailMessage))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.MailPriority))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpAccess))]
+#pragma warning disable 618
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpClient))]
+#pragma warning restore
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpDeliveryFormat))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpDeliveryMethod))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpException))]
index 8347d9f2d30e364ccbf759bc3a71e7916c62dd52..f9ff19f76daaef6fba55e1e370d13050e90cb521 100644 (file)
@@ -108,6 +108,7 @@ xammac_4_5_dirs := \
        System.ServiceModel.Internals   \
        SMDiagnostics   \
        System.Numerics \
+       System.Numerics.Vectors         \
        Mono.Data.Tds   \
        System.Transactions     \
        System.EnterpriseServices       \
index 9ca277dbbcd3ed5f92ef9a04e09fa3b6b5cade31..3da8be8c435ac602e3b50011669eaf5eccdaa244 100644 (file)
@@ -70,14 +70,21 @@ namespace System.Net.Http.Headers
                                        return null;
 
                                var c = (HttpHeaderValueCollection<U>) collection;
-                               if (c.Count == 0)
-                                       return null;
+                               if (c.Count == 0) {
+                                       if (c.InvalidValues == null)
+                                               return null;
+
+                                       return new List<string> (c.InvalidValues);
+                               }
 
                                var list = new List<string> ();
                                foreach (var item in c) {
                                        list.Add (item.ToString ());
                                }
 
+                               if (c.InvalidValues != null)
+                                       list.AddRange (c.InvalidValues);
+
                                return list;
                        }
 
index 72c4299e64ad4c8eb85239f9d849037435a10de0..35f8556bdc557ee733c41bd455f570010f8cdedc 100644 (file)
@@ -36,6 +36,7 @@ namespace System.Net.Http.Headers
                readonly List<T> list;
                readonly HttpHeaders headers;
                readonly HeaderInfo headerInfo;
+               List<string> invalidValues;
 
                internal HttpHeaderValueCollection (HttpHeaders headers, HeaderInfo headerInfo)
                {
@@ -50,6 +51,12 @@ namespace System.Net.Http.Headers
                        }
                }
 
+               internal List<string> InvalidValues {
+                       get {
+                               return invalidValues;
+                       }
+               }
+
                public bool IsReadOnly {
                        get {
                                return false;
@@ -66,9 +73,18 @@ namespace System.Net.Http.Headers
                        list.AddRange (values);
                }
 
+               internal void AddInvalidValue (string invalidValue)
+               {
+                       if (invalidValues == null)
+                               invalidValues = new List<string> ();
+
+                       invalidValues.Add (invalidValue);
+               }
+
                public void Clear ()
                {
                        list.Clear ();
+                       invalidValues = null;
                }
 
                public bool Contains (T item)
@@ -93,11 +109,12 @@ namespace System.Net.Http.Headers
 
                public override string ToString ()
                {
-                       // This implementation prints different values than
-                       // what .NET does when one of the values is invalid
-                       // But it better represents what is actually hold by
-                       // the collection
-                       return string.Join (headerInfo.Separator, list);
+                       var res = string.Join (headerInfo.Separator, list);
+
+                       if (invalidValues != null)
+                               res += string.Join (headerInfo.Separator, invalidValues);
+
+                       return res;
                }
 
                public bool TryParseAdd (string input)
index 05b5fe62681f3f981b067777d1cb7a7f9f32a03b..c22a6695593718e430899cf0ffd3dd20d11433a1 100644 (file)
@@ -481,23 +481,28 @@ namespace System.Net.Http.Headers
                                headers.Add (name, value);
                        }
 
+                       var col = (HttpHeaderValueCollection<T>) value.Parsed;
+
                        if (value.HasStringValues) {
                                var hinfo = known_headers[name];
-                               if (value.Parsed == null)
-                                       value.Parsed = hinfo.CreateCollection (this);
+                               if (col == null) {
+                                       value.Parsed = col = new HttpHeaderValueCollection<T> (this, hinfo);
+                               }
 
                                object pvalue;
                                for (int i = 0; i < value.Values.Count; ++i) {
-                                       if (!hinfo.TryParse (value.Values[i], out pvalue))
-                                               continue;
-
-                                       hinfo.AddToCollection (value.Parsed, pvalue);
-                                       value.Values.RemoveAt (i);
-                                       --i;
+                                       var svalue = value.Values[i];
+                                       if (!hinfo.TryParse (svalue, out pvalue)) {
+                                               col.AddInvalidValue (svalue);
+                                       } else {
+                                               hinfo.AddToCollection (col, pvalue);
+                                       }
                                }
+
+                               value.Values.Clear ();
                        }
 
-                       return (HttpHeaderValueCollection<T>) value.Parsed;
+                       return col;
                }
 
                internal void SetValue<T> (string name, T value, Func<object, string> toStringConverter = null)
index 50f8432f8ecb4ac99e1eb6ab1a7cd2c51bea74dc..0fd756037532eebca3f8ae890dbac52906503004 100644 (file)
@@ -91,5 +91,42 @@ namespace MonoTests.System.Net.Http.Headers
 
                        Assert.AreEqual ("kk, ttt", headers.Connection.ToString (), "#3");
                }
+
+               [Test]
+               public void AddInvalid ()
+               {
+                       HttpRequestMessage message = new HttpRequestMessage ();
+                       HttpRequestHeaders headers = message.Headers;
+
+                       headers.TryAddWithoutValidation ("User-Agent", "user,agent/1.0");
+
+                       Assert.AreEqual (0, headers.UserAgent.Count, "#1");
+                       Assert.AreEqual ("user,agent/1.0", headers.UserAgent.ToString (), "#2");
+
+                       Assert.AreEqual ("User-Agent: user,agent/1.0\r\n", headers.ToString (), "#3");
+
+                       headers.UserAgent.Clear ();
+                       Assert.AreEqual ("", headers.UserAgent.ToString (), "#4");
+                       Assert.AreEqual ("", headers.ToString (), "#5");
+               }
+
+               [Test]
+               public void AddInvalidAndValid ()
+               {
+                       HttpRequestMessage message = new HttpRequestMessage ();
+                       HttpRequestHeaders headers = message.Headers;
+
+                       headers.TryAddWithoutValidation ("User-Agent", "user,agent/1.0");
+                       headers.TryAddWithoutValidation("User-Agent", "agent2/2.0");
+
+                       Assert.AreEqual (1, headers.UserAgent.Count, "#1");
+                       Assert.AreEqual ("agent2/2.0user,agent/1.0", headers.UserAgent.ToString (), "#2");
+
+                       Assert.AreEqual ("User-Agent: agent2/2.0 user,agent/1.0\r\n", headers.ToString (), "#3");
+
+                       headers.UserAgent.Clear ();
+                       Assert.AreEqual ("", headers.UserAgent.ToString (), "#4");
+                       Assert.AreEqual ("", headers.ToString (), "#5");
+               }
        }
 }
index 2b4e68cf8ed8d8ad018ea72686d0fa9134cabaa0..a413f1140da720b97104bb309894793cbb9ac1cb 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //     Chris Toshok (toshok@novell.com)
+//     Katharina Bogad (bogad@cs.tum.edu)
 //
 
 //
@@ -31,6 +32,7 @@
 using System.Text;
 using System.Collections.Specialized;
 using System.Security.Permissions;
+using System.Web.Configuration;
 
 namespace System.Web
 {
@@ -66,6 +68,17 @@ namespace System.Web
                        this.name = name;
                        values = new CookieNVC();
                        Value = "";
+
+                       HttpCookiesSection cookieConfig = (HttpCookiesSection) WebConfigurationManager.GetSection ("system.web/httpCookies");
+
+                       if(!string.IsNullOrWhiteSpace(cookieConfig.Domain))
+                               domain = cookieConfig.Domain;
+
+                       if(cookieConfig.HttpOnlyCookies)
+                               flags |= CookieFlags.HttpOnly;
+
+                       if(cookieConfig.RequireSSL)
+                               flags |= CookieFlags.Secure;
                }
 
                public HttpCookie (string name, string value)
index 4002c3b7cdc4850dbe9490d4831005ed7024fc27..02e1e3d10009c8ba67b112e289c6f160184c1133 100644 (file)
@@ -7,7 +7,6 @@
 // Copyright (C) 2006 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,
@@ -48,7 +47,7 @@ namespace System.Diagnostics
                private IntPtr _readHandle;
                private Thread _notifyThread;
                private int _lastEntryWritten;
-               private bool _notifying;
+               private Object _eventLock = new object();
 
                public Win32EventLog (EventLog coreEventLog)
                        : base (coreEventLog)
@@ -68,9 +67,11 @@ namespace System.Diagnostics
 
                public override void Close ()
                {
-                       if (_readHandle != IntPtr.Zero) {
-                               CloseEventLog (_readHandle);
-                               _readHandle = IntPtr.Zero;
+                       lock (_eventLock) {
+                               if (_readHandle != IntPtr.Zero) {
+                                       CloseEventLog (_readHandle);
+                                       _readHandle = IntPtr.Zero;
+                               }
                        }
                }
 
@@ -703,45 +704,56 @@ namespace System.Diagnostics
 
                public override void DisableNotification ()
                {
-                       if (_notifyResetEvent != null) {
-                               _notifyResetEvent.Close ();
-                               _notifyResetEvent = null;
-                       }
-
-                       if (_notifyThread != null) {
-                               if (_notifyThread.ThreadState == System.Threading.ThreadState.Running)
-                                       _notifyThread.Abort ();
+                       lock (_eventLock) {
+                               if (_notifyResetEvent != null) {
+                                       _notifyResetEvent.Close ();
+                                       _notifyResetEvent = null;
+                               }
                                _notifyThread = null;
                        }
                }
 
                public override void EnableNotification ()
                {
-                       _notifyResetEvent = new ManualResetEvent (false);
-                       _lastEntryWritten = OldestEventLogEntry + EntryCount;
-                       if (PInvoke.NotifyChangeEventLog (ReadHandle, _notifyResetEvent.Handle) == 0)
-                               throw new InvalidOperationException (string.Format (
-                                       CultureInfo.InvariantCulture, "Unable to receive notifications"
-                                       + " for log '{0}' on computer '{1}'.", CoreEventLog.GetLogName (),
-                                       CoreEventLog.MachineName), new Win32Exception ());
-                       _notifyThread = new Thread (new ThreadStart (NotifyEventThread));
-                       _notifyThread.IsBackground = true;
-                       _notifyThread.Start ();
+                       lock (_eventLock) {
+                               if (_notifyResetEvent != null)
+                                       return;
+
+                               _notifyResetEvent = new ManualResetEvent (false);
+                               _lastEntryWritten = OldestEventLogEntry + EntryCount;
+                               if (PInvoke.NotifyChangeEventLog (ReadHandle, _notifyResetEvent.Handle) == 0)
+                                       throw new InvalidOperationException (string.Format (
+                                               CultureInfo.InvariantCulture, "Unable to receive notifications"
+                                               + " for log '{0}' on computer '{1}'.", CoreEventLog.GetLogName (),
+                                               CoreEventLog.MachineName), new Win32Exception ());
+                               _notifyThread = new Thread (() => NotifyEventThread(_notifyResetEvent));
+                               _notifyThread.IsBackground = true;
+                               _notifyThread.Start ();
+                       }
                }
 
-               private void NotifyEventThread ()
+               private void NotifyEventThread (ManualResetEvent resetEvent)
                {
                        while (true) {
-                               _notifyResetEvent.WaitOne ();
-                               lock (this) {
-                                       // after a clear, we something get notified
-                                       // twice for the same entry
-                                       if (_notifying)
-                                               return;
-                                       _notifying = true;
+                               try {
+                                       resetEvent.WaitOne ();
+                               } catch (ObjectDisposedException e) {
+                                       // Notifications have been disabled and event 
+                                       // has been closed but not yet nulled. End thread.
+                                       break;
                                }
 
-                               try {
+                               lock (_eventLock) {
+                                       if (resetEvent != _notifyResetEvent) {
+                                               // A new thread has started with another reset event instance
+                                               // or DisableNotifications has been called, setting
+                                               // _notifyResetEvent to null. In both cases end this thread.
+                                               break;
+                                       }
+
+                                       if (_readHandle == IntPtr.Zero)
+                                               break;
+
                                        int oldest_entry = OldestEventLogEntry;
                                        if (_lastEntryWritten < oldest_entry)
                                                _lastEntryWritten = oldest_entry;
@@ -752,9 +764,6 @@ namespace System.Diagnostics
                                                CoreEventLog.OnEntryWritten (entry);
                                        }
                                        _lastEntryWritten = last_entry;
-                               } finally {
-                                       lock (this)
-                                               _notifying = false;
                                }
                        }
                }
index dcc82f61678777cc202e1b94417d4b7a82c0d114..e06ca4bf5d6ae6e16ca43665f144953ba1d2b1c0 100644 (file)
@@ -32,28 +32,37 @@ namespace MonoTests.System.Net
                [Test]\r
                public void AsyncGetHostByName ()\r
                {\r
-                       IAsyncResult r;\r
-                       r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);\r
-\r
                        IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);\r
                        IPHostEntry entry = Dns.EndGetHostByName (async);\r
                        SubTestValidIPHostEntry (entry);\r
                        Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");\r
                }\r
 \r
-               void GetHostByNameCallback (IAsyncResult ar)\r
-               {\r
-                       IPHostEntry h;\r
-                       h = Dns.EndGetHostByName (ar);\r
-                       SubTestValidIPHostEntry (h);\r
+               [Test]\r
+               public void AsyncGetHostByNameCallback ()\r
+               {\r
+                       var evt = new ManualResetEvent (false);\r
+                       Exception ex = null;\r
+                       Dns.BeginGetHostByName (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+                       {\r
+                               try {\r
+                                       IPHostEntry h;\r
+                                       h = Dns.EndGetHostByName (ar);\r
+                                       SubTestValidIPHostEntry (h);\r
+                               } catch (Exception e) {\r
+                                       ex = e;\r
+                               } finally {\r
+                                       evt.Set ();\r
+                               }\r
+                       }), null);\r
+\r
+                       Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+                       Assert.IsNull (ex, "Exception");\r
                }\r
 \r
                [Test]\r
                public void AsyncResolve ()\r
                {\r
-                       IAsyncResult r;\r
-                       r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);\r
-\r
                        IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
                        IPHostEntry entry = Dns.EndResolve (async);\r
                        SubTestValidIPHostEntry (entry);\r
@@ -61,10 +70,25 @@ namespace MonoTests.System.Net
                        Assert.AreEqual (site1Dot, ip.ToString ());\r
                }\r
 \r
-               void ResolveCallback (IAsyncResult ar)\r
-               {\r
-                       IPHostEntry h = Dns.EndResolve (ar);\r
-                       SubTestValidIPHostEntry (h);\r
+               [Test]\r
+               public void AsyncResolveCallback ()\r
+               {\r
+                       var evt = new ManualResetEvent (false);\r
+                       Exception ex = null;\r
+                       Dns.BeginResolve (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+                       {\r
+                               try {\r
+                                       IPHostEntry h = Dns.EndResolve (ar);\r
+                                       SubTestValidIPHostEntry (h);\r
+                               } catch (Exception e) {\r
+                                       ex = e;\r
+                               } finally {\r
+                                       evt.Set ();\r
+                               }\r
+                       }), null);\r
+\r
+                       Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+                       Assert.IsNull (ex, "Exception");\r
                }\r
 \r
                [Test]\r
@@ -73,7 +97,7 @@ namespace MonoTests.System.Net
                        try {\r
                                Dns.BeginGetHostAddresses (\r
                                        (string) null,\r
-                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#1");\r
                        } catch (ArgumentNullException ex) {\r
@@ -91,7 +115,7 @@ namespace MonoTests.System.Net
                        try {\r
                                Dns.BeginGetHostAddresses (\r
                                        "0.0.0.0",\r
-                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#A1");\r
                        } catch (ArgumentException ex) {\r
@@ -108,7 +132,7 @@ namespace MonoTests.System.Net
                        try {\r
                                Dns.BeginGetHostAddresses (\r
                                        "::0",\r
-                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#B1");\r
                        } catch (ArgumentException ex) {\r
@@ -122,10 +146,9 @@ namespace MonoTests.System.Net
                        }\r
                }\r
 \r
-               void GetHostAddressesCallback (IAsyncResult ar)\r
+               void ShouldntBeCalled (IAsyncResult ar)\r
                {\r
-                       IPAddress [] addresses = Dns.EndGetHostAddresses (ar);\r
-                       Assert.IsNotNull (addresses);\r
+                       Assert.Fail ("Should not be called");\r
                }\r
 \r
                [Test]\r
@@ -317,7 +340,7 @@ namespace MonoTests.System.Net
                {\r
                        try {\r
                                Dns.BeginResolve ((string) null,\r
-                                       new AsyncCallback (ResolveCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#1");\r
                        } catch (ArgumentNullException ex) {\r
@@ -363,7 +386,7 @@ namespace MonoTests.System.Net
                        try {\r
                                Dns.BeginGetHostEntry (\r
                                        (IPAddress) null,\r
-                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#1");\r
                        } catch (ArgumentNullException ex) {\r
@@ -380,7 +403,7 @@ namespace MonoTests.System.Net
                        try {\r
                                Dns.BeginGetHostEntry (\r
                                        (string) null,\r
-                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       new AsyncCallback (ShouldntBeCalled),\r
                                        null);\r
                                Assert.Fail ("#1");\r
                        } catch (ArgumentNullException ex) {\r
diff --git a/mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs b/mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs
new file mode 100644 (file)
index 0000000..7735119
--- /dev/null
@@ -0,0 +1,8 @@
+namespace System.Runtime.Versioning
+{
+       static class BinaryCompatibility
+       {
+               public static readonly bool TargetsAtLeast_Desktop_V4_5 = true;
+               public static readonly bool TargetsAtLeast_Desktop_V4_5_1 = true;
+       }
+}
\ No newline at end of file
index ba5dba8e652eb1008f7f6b1745c06f540135ff1f..24ee1ee00f249ad9e06c1520a66961ab55447a02 100644 (file)
@@ -30,7 +30,7 @@ namespace System
 {
        static class CompatibilitySwitches
        {
-               public const bool IsAppEarlierThanSilverlight4 = false;
-               public const bool IsAppEarlierThanWindowsPhone8 = false;
+               public static readonly bool IsAppEarlierThanSilverlight4 = false;
+               public static readonly bool IsAppEarlierThanWindowsPhone8 = false;
        }
 }
\ No newline at end of file
index 8a49451936e5fd80e95e17913a2a3025084c5f7d..d0b1473c7cd6d77edfae7bebbae07c837c7f9b7a 100644 (file)
@@ -140,15 +140,15 @@ namespace System
 
                internal Object CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache, ref StackCrawlMark stackMark)
                {
-                       bool bNeedSecurityCheck = true;
-                       bool bCanBeCached = false;
-                       bool bSecurityCheckOff = false;
+                       //bool bNeedSecurityCheck = true;
+                       //bool bCanBeCached = false;
+                       //bool bSecurityCheckOff = false;
 
                        if (!skipCheckThis)
                                CreateInstanceCheckThis();
 
-                       if (!fillCache)
-                               bSecurityCheckOff = true;
+                       //if (!fillCache)
+                       //      bSecurityCheckOff = true;
 
                        return CreateInstanceMono (!publicOnly);
                }
index 312f0ccb166d6de88051a04b5670d7e828f0bb51..8397f4c2d2f4db3bcd383e583bf265b06d486137 100644 (file)
@@ -256,6 +256,7 @@ namespace System.Diagnostics.Tracing
                        WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
                }
 
+               [CLSCompliant (false)]
                protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
                {
                }
@@ -264,6 +265,7 @@ namespace System.Diagnostics.Tracing
                {
                }
 
+               [CLSCompliant (false)]
                protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
                {
                }
index b93808b89c4f6afa045a3f412642b90853dbb0e1..b528e4cdadcb5ff7e2aef43c0490a14e9fa7b16b 100644 (file)
@@ -59,9 +59,9 @@ namespace System.Diagnostics {
 
                private StackFrame[] frames;
                readonly StackTrace[] captured_traces;
+#pragma warning disable 414            
                private bool debug_info;
-
-               private static Dictionary<string, Func<StackTrace, string>> metadataHandlers;
+#pragma warning restore
 
                [MethodImplAttribute (MethodImplOptions.NoInlining)]
                public StackTrace ()
@@ -198,7 +198,6 @@ namespace System.Diagnostics {
 
                bool AddFrames (StringBuilder sb)
                {
-                       bool printOffset;
                        string debugInfo, indentation;
                        string unknown = Locale.GetText ("<unknown method>");
 
index 138163779f85793b7847b1fb3e82ff6333f28ece..5d63f271e607243398a6934082db61d9c17df0f8 100644 (file)
@@ -732,6 +732,7 @@ namespace System.IO {
                        else {
                                string ret = String.Join (DirectorySeparatorStr, dirs, 0, target);
                                if (Environment.IsRunningOnWindows) {
+#if !MOBILE                                    
                                        // append leading '\' of the UNC path that was lost in STEP 3.
                                        if (isUnc)
                                                ret = Path.DirectorySeparatorStr + ret;
@@ -757,6 +758,7 @@ namespace System.IO {
                                                else
                                                        return current + ret;
                                        }
+#endif
                                } else {
                                        if (root != "" && ret.Length > 0 && ret [0] != '/')
                                                ret = root + ret;
@@ -876,11 +878,13 @@ namespace System.IO {
                                throw new ArgumentException (Locale.GetText ("Path is empty"));
                        if (path.IndexOfAny (Path.InvalidPathChars) != -1)
                                throw new ArgumentException (Locale.GetText ("Path contains invalid chars"));
+#if !MOBILE                            
                        if (Environment.IsRunningOnWindows) {
                                int idx = path.IndexOf (':');
                                if (idx >= 0 && idx != 1)
                                        throw new ArgumentException (parameterName);
                        }
+#endif
                }
 
                internal static string DirectorySeparatorCharAsString {
index c098713ca97467dc23de1347023907bcf6062a09..9c257cb9a80542fc882eb52ddfd9c05c58c0b2ee 100644 (file)
@@ -466,6 +466,11 @@ namespace System.Reflection.Emit
                        return new AssemblyBuilder (name, null, access, false);
                }
 
+               public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
+               {
+                       throw new NotImplementedException ();
+               }
+
                public ModuleBuilder DefineDynamicModule (string name)
                {
                        return DefineDynamicModule (name, name, false, true);
index b5baac27ea0c69e17c2a6b18738bdd4e13b87e08..cba66c11840021f0404590a53fd2c5c2d81c6164 100644 (file)
@@ -162,6 +162,11 @@ namespace System.Reflection.Emit {
                        return res;
                }
 
+               public TypeInfo CreateTypeInfo()
+               {
+                       return _tb.CreateTypeInfo ();
+               }
+
                public override Type GetEnumUnderlyingType ()
                {
                        return _underlyingType;
index e9418c03393cd31d623a83f566b8f75ff06b945e..092ea767526688303dc675d67579d7a3cdbd4889 100644 (file)
@@ -63,7 +63,9 @@ namespace System.Reflection {
 
                internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
                {
+#pragma warning disable 414
                        Module module;
+#pragma warning restore
 
                        public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
                                : base (pointer, length)
index 1839144bcbcbec96b07322b7330268ff29a1a466..3297ac2342a84dd961e621ae968f04260d124739 100644 (file)
@@ -100,8 +100,10 @@ namespace System.Runtime.Loader
                {               
                }
 
+#pragma warning disable 67
                public event Func<AssemblyLoadContext, System.Reflection.AssemblyName, System.Reflection.Assembly> Resolving;
                public event Action<AssemblyLoadContext> Unloading;
+#pragma warning restore
        }
 }
 
index 0b267eed10646f58dc1e530c79fba21f2bb65464..b0eef4e4c0e4a72bd38995c925c2c1baf9038df2 100644 (file)
@@ -437,7 +437,9 @@ namespace System.Runtime.Remoting.Messaging {
        internal class CADMethodReturnMessage : CADMessageBase {
                object _returnValue;
                CADArgHolder _exception = null;
+#pragma warning disable 414
                Type [] _sig;
+#pragma warning restore
 
                static internal CADMethodReturnMessage Create (IMessage callMsg) {
                        IMethodReturnMessage msg = callMsg as IMethodReturnMessage;
index b951a8141d5d38927a3798202cdfae98f9751474..d97859f49db9d0164c155ad5d2e3e012338831ab 100644 (file)
@@ -38,7 +38,9 @@ namespace System.Security.AccessControl
        public abstract class NativeObjectSecurity : CommonObjectSecurity
        {
                ExceptionFromErrorCode exception_from_error_code;
+#if !MOBILE
                ResourceType resource_type;
+#endif
                
                protected internal delegate Exception ExceptionFromErrorCode (int errorCode,
                                                                              string name, SafeHandle handle,
@@ -47,7 +49,9 @@ namespace System.Security.AccessControl
                internal NativeObjectSecurity (CommonSecurityDescriptor securityDescriptor, ResourceType resourceType)
                        : base (securityDescriptor)
                {
+#if !MOBILE                    
                        resource_type = resourceType;
+#endif
                }
 
                protected NativeObjectSecurity (bool isContainer,
@@ -63,7 +67,9 @@ namespace System.Security.AccessControl
                        : base (isContainer)
                {
                        exception_from_error_code = exceptionFromErrorCode;
+#if !MOBILE                    
                        resource_type = resourceType;
+#endif
                }
                
                protected NativeObjectSecurity (bool isContainer,
index 4bed60fc3b93acbda77c62ddc51f284fc284254c..93c4c2d451a93713bdd13c0579d95aaa8fc6a277 100644 (file)
@@ -166,7 +166,7 @@ namespace System.Security.AccessControl
                        SetAuditRule((AuditRule)rule);
                }
                
-               protected void Persist (SafeHandle handle)
+               protected new void Persist (SafeHandle handle)
                {
                        WriteLock ();
                        try {
index 54cc0c1b3607e186cd7fa80511c13b32f6fb082f..ce855e490521ca652be5b91b18338e50a8e354a5 100644 (file)
@@ -227,8 +227,10 @@ namespace System.Security {
                // - SecurityManager.InternalDemand (declarative)
                internal void CasOnlyDemand (int skip)
                {
+#if !MONO
                        Assembly current = null;
                        AppDomain domain = null;
+#endif
 
                        if (_ignored == null) {
                                // special case when directly called from CodeAccessPermission.Demand
index 6a43f9cd8089fdb8cbb15eaf8569454e9877210c..c8afcf1ec60567a07a651d173cb5374147adde2e 100644 (file)
@@ -97,13 +97,10 @@ namespace System
                static Console ()
                {
                        if (Environment.IsRunningOnWindows) {
+#if !MOBILE                            
                                //
                                // On Windows, follow the Windows tradition
                                //
-#if MOBILE
-                               // should never happen since Moonlight does not run on windows
-                               inputEncoding = outputEncoding = Encoding.Default;
-#else                  
                                try {
                                        inputEncoding = Encoding.GetEncoding (WindowsConsole.GetInputCodePage ());
                                        outputEncoding = Encoding.GetEncoding (WindowsConsole.GetOutputCodePage ());
index 45475e910b5caebc26b28d8ce92b16e5b026b2ef..fa9f73a4dc68eea801f8bd30ccb0a5cee801e8b6 100644 (file)
@@ -553,11 +553,10 @@ namespace System {
                                        return sign * (hour * 60) * 60;
                        }
 
-                       static TimeZoneInfo defaultZone;
                        internal static TimeZoneInfo Local {
                                get {
                                        var id  = GetDefaultTimeZoneName ();
-                                       return defaultZone = GetTimeZone (id, id);
+                                       return GetTimeZone (id, id);
                                }
                        }
                        
index 96a1150368cb076b8b0c29edf6ce9575e6720eb6..f8e54b7fb85cbcd14606b9bc3db77ce7ddbfed80 100644 (file)
@@ -105,10 +105,10 @@ namespace System
 
                        try {
                                ret = readlink (path, buf, buf.Length);
-                       } catch (DllNotFoundException e) {
+                       } catch (DllNotFoundException) {
                                readlinkNotFound = true;
                                return null;
-                       } catch (EntryPointNotFoundException e) {
+                       } catch (EntryPointNotFoundException) {
                                readlinkNotFound = true;
                                return null;
                        }
@@ -965,12 +965,17 @@ namespace System
                        } else {
                                AdjustmentRule first = null, last = null;
 
+                               // Rule start/end dates are either very specific or very broad depending on the platform
+                               //   2015-10-04..2016-04-03 - Rule for a time zone in southern hemisphere on non-Windows platforms
+                               //   2016-03-27..2016-10-03 - Rule for a time zone in northern hemisphere on non-Windows platforms
+                               //   0001-01-01..9999-12-31 - Rule for a time zone on Windows
+
                                foreach (var rule in GetAdjustmentRules ()) {
-                                       if (rule.DateStart.Year != year && rule.DateEnd.Year != year)
+                                       if (rule.DateStart.Year > year || rule.DateEnd.Year < year)
                                                continue;
-                                       if (rule.DateStart.Year == year)
+                                       if (rule.DateStart.Year <= year && (first == null || rule.DateStart.Year > first.DateStart.Year))
                                                first = rule;
-                                       if (rule.DateEnd.Year == year)
+                                       if (rule.DateEnd.Year >= year && (last == null || rule.DateEnd.Year < last.DateEnd.Year))
                                                last = rule;
                                }
 
index 5149ece6900f034409ae09a0ef9558d292894388..ee3e58860494f861de1c6acc820572100cd83c4c 100644 (file)
@@ -20,6 +20,7 @@ namespace MonoTests.System.Threading
                {\r
                        public int id;\r
                        public Mutex mut;\r
+                       public bool abandoned_exception;\r
                        public ConcClass(int id,Mutex mut)\r
                        {\r
                                this.id = id;\r
@@ -63,7 +64,12 @@ namespace MonoTests.System.Threading
 \r
                        public void WaitAndForget()\r
                        {\r
-                               this.Wait();\r
+                               try {\r
+                                       this.Wait();\r
+                               } catch (AbandonedMutexException) {\r
+                                       this.abandoned_exception = true;\r
+                               }\r
+\r
                                this.marker = id;\r
                        }\r
                        public void WaitAndWait()\r
@@ -137,7 +143,7 @@ namespace MonoTests.System.Threading
                }\r
 \r
                [Test]\r
-               public void TestWaitAndFoget1()\r
+               public void TestWaitAndForget1()\r
                {\r
                        Mutex Sem = new Mutex(false);\r
                        ConcClassLoop class1 = new ConcClassLoop(1,Sem);\r
@@ -148,9 +154,11 @@ namespace MonoTests.System.Threading
                        try {\r
                                thread1.Start();\r
                                TestUtil.WaitForNotAlive (thread1, "t1");\r
+                               Assert.IsFalse (class1.abandoned_exception, "e1");\r
        \r
                                thread2.Start();\r
                                TestUtil.WaitForNotAlive (thread2, "t2");\r
+                               Assert.IsTrue (class2.abandoned_exception, "e2");\r
                        \r
                                Assert.AreEqual (class2.id, class2.marker);\r
                        } finally {\r
index 2fc0a6dd01d6963dfb8ae777ca494622d2dcee12..593edcf65c69780f331dae72e4e353651dbf87a2 100644 (file)
@@ -28,6 +28,7 @@
 
 
 using System;
+using System.Collections.Generic;
 using System.Threading;
 
 using NUnit.Framework;
@@ -395,6 +396,148 @@ namespace MonoTests.System.Threading {
                        }
                }
 
+               [Test]
+               public void WaitOneWithAbandonedMutex ()
+               {
+                       using (var m = new Mutex (false)) {
+                               var thread1 = new Thread (() => {
+                                       m.WaitOne ();
+                               });
+                               thread1.Start ();
+                               thread1.Join (1000);
+                               try {
+                                       m.WaitOne ();
+                                       Assert.Fail ("Expected AbandonedMutexException");
+                               } catch (AbandonedMutexException) {
+                               }
+                               // Current thread should own the Mutex now
+                               var signalled = false;
+                               var thread2 = new Thread (() => {
+                                       signalled = m.WaitOne (100);
+                               });
+                               thread2.Start ();
+                               thread2.Join (1000);
+                               Assert.IsFalse (signalled);
+
+                               // Since this thread owns the Mutex releasing it shouldn't fail
+                               m.ReleaseMutex ();
+                               // The Mutex should now be unowned
+                               try {
+                                       m.ReleaseMutex ();
+                                       Assert.Fail ("Expected ApplicationException");
+                               } catch (ApplicationException) {
+                               }
+                       }
+               }
+
+               [Test]
+               public void WaitOneWithAbandonedMutexAndMultipleThreads ()
+               {
+                       using (var m = new Mutex (true)) {
+                               var nonAbandoned = 0;
+                               var abandoned = 0;
+                               var n = 0;
+                               var threads = new List<Thread> ();
+                               for (int i = 0; i < 50; i++) {
+                                       var thread = new Thread (() => {
+                                               try {
+                                                       m.WaitOne ();
+                                                       nonAbandoned++;
+                                               } catch (AbandonedMutexException) {
+                                                       abandoned++;
+                                               }
+                                               if (((n++) % 5) != 0)
+                                                       m.ReleaseMutex ();
+                                       });
+                                       thread.Start ();
+                                       threads.Add (thread);
+                               }
+                               m.ReleaseMutex ();
+                               foreach (var thread in threads) {
+                                       if (!thread.Join (1000)) {
+                                               Assert.Fail ("Timed out");
+                                       }
+                               }
+                               Assert.AreEqual (40, nonAbandoned);
+                               Assert.AreEqual (10, abandoned);
+                       }
+               }
+
+               [Test]
+               public void WaitAnyWithSecondMutexAbandoned ()
+               {
+                       using (var m1 = new Mutex (false)) {
+                               using (var m2 = new Mutex (false)) {
+                                       var mainProceed = false;
+                                       var thread2Proceed = false;
+                                       var thread1 = new Thread (() => {
+                                               m2.WaitOne ();
+                                       });
+                                       var thread2 = new Thread (() => {
+                                               m1.WaitOne ();
+                                               mainProceed = true;
+                                               while (!thread2Proceed) {
+                                                       Thread.Sleep (10);
+                                               }
+                                               m1.ReleaseMutex ();
+                                       });
+                                       thread1.Start ();
+                                       thread1.Join (1000);
+                                       thread2.Start ();
+                                       while (!mainProceed) {
+                                               Thread.Sleep (10);
+                                       }
+                                       try {
+                                               WaitHandle.WaitAny (new WaitHandle [] { m1, m2 });
+                                               Assert.Fail ("Expected AbandonedMutexException");
+                                       } catch (AbandonedMutexException e) {
+                                               Assert.AreEqual (1, e.MutexIndex);
+                                               Assert.AreEqual (m2, e.Mutex);
+                                       } finally {
+                                               thread2Proceed = true;
+                                               thread2.Join (1000);
+                                       }
+
+                                       // Current thread should own the second Mutex now
+                                       var signalled = -1;
+                                       var thread3 = new Thread (() => {
+                                               signalled = WaitHandle.WaitAny (new WaitHandle [] { m1, m2 }, 0);
+                                       });
+                                       thread3.Start ();
+                                       thread3.Join (1000);
+                                       Assert.AreEqual (0, signalled);
+
+                                       // Since this thread owns the second Mutex releasing it shouldn't fail
+                                       m2.ReleaseMutex ();
+                                       // Second Mutex should now be unowned
+                                       try {
+                                               m2.ReleaseMutex ();
+                                               Assert.Fail ("Expected ApplicationException");
+                                       } catch (ApplicationException) {
+                                       }
+                                       // .NET allows the first Mutex which is now abandoned to be released multiple times by this thread
+                                       m1.ReleaseMutex ();
+                                       m1.ReleaseMutex ();
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (AbandonedMutexException))]
+               public void WaitAllWithOneAbandonedMutex ()
+               {
+                       using (var m1 = new Mutex (false)) {
+                               using (var m2 = new Mutex (false)) {
+                                       var thread = new Thread (() => {
+                                               m1.WaitOne ();
+                                       });
+                                       thread.Start ();
+                                       thread.Join (1000);
+                                       WaitHandle.WaitAll (new WaitHandle [] { m1, m2 });
+                               }
+                       }
+               }
+
 #if MONO_FEATURE_THREAD_SUSPEND_RESUME
                [Test]
                public void WaitOneWithTimeoutAndSpuriousWake ()
index 62ae67cfc814755576e69e8a862864bc5bc71e36..ed45adfb13775ec29015ce83e62cfed9d4503b36 100644 (file)
@@ -82,8 +82,6 @@ namespace MonoTests.System
                        [Test]
                        public void DeltaNotInSeconds ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       throw new ArgumentOutOfRangeException ();;
                                DateTime dateStart = new DateTime (2007,01,01);
                                DateTime dateEnd = new DateTime (2008,01,01);
                                TimeZoneInfo.TransitionTime daylightTransitionStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 03, 11);
index b124eb64a44647cdec7dad6c98895a5b314f38ca..27c167f04862d3d763272eb03a92d4e8c2bf5fa8 100644 (file)
@@ -43,6 +43,39 @@ namespace MonoTests.System
                static FieldInfo cachedDataField;
                static object localFieldObj;
 
+               public static string MapTimeZoneId (string id)
+               {
+                       if (Environment.OSVersion.Platform == PlatformID.Unix)
+                               return id;
+                       else {
+                               switch (id) {
+                               case "Pacific/Auckland":
+                                       return "New Zealand Standard Time";
+                               case "Europe/Athens":
+                                       return "GTB Standard Time";
+                               case "US/Eastern":
+                                       return "Eastern Standard Time";
+                               case "US/Pacific":
+                                       return "Pacific Standard Time";
+                               case "Australia/Sydney":
+                               case "Australia/Melbourne":
+                                       return "AUS Eastern Standard Time";
+                               case "Europe/Brussels":
+                                       return "Romance Standard Time";
+                               case "Africa/Kinshasa":
+                                       return "W. Central Africa Standard Time";
+                               case "Europe/Rome":
+                               case "Europe/Vatican":
+                                       return "W. Europe Standard Time";
+                               case "Canada/Eastern":
+                                       return "Eastern Standard Time";
+                               default:
+                                       Assert.Fail ($"No mapping defined for zone id '{id}'");
+                                       return null;
+                               }
+                       }
+               }
+
                public static void SetLocal (TimeZoneInfo val)
                {
                        if (localField == null) {
@@ -70,8 +103,6 @@ namespace MonoTests.System
                        [Test]
                        public void GetLocal ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                TimeZoneInfo local = TimeZoneInfo.Local;
                                Assert.IsNotNull (local);
                                Assert.IsTrue (true);
@@ -262,8 +293,6 @@ namespace MonoTests.System
                        [Test]
                        public void DSTInLondon ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                DateTime june01 = new DateTime (2007, 06, 01);
                                DateTime xmas = new DateTime (2007, 12, 25);
                                Assert.IsTrue (london.IsDaylightSavingTime (june01), "June 01 is DST in London");
@@ -273,8 +302,6 @@ namespace MonoTests.System
                        [Test]
                        public void DSTTransisions ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                DateTime beforeDST = new DateTime (2007, 03, 25, 0, 59, 59, DateTimeKind.Unspecified);
                                DateTime startDST = new DateTime (2007, 03, 25, 2, 0, 0, DateTimeKind.Unspecified);
                                DateTime endDST = new DateTime (2007, 10, 28, 1, 59, 59, DateTimeKind.Unspecified);
@@ -315,12 +342,7 @@ namespace MonoTests.System
                        [Test (Description="Description xambug #17155")]
                        public void AdjustmentRuleAfterNewYears ()
                        {
-                               TimeZoneInfo tz;
-                               if (Environment.OSVersion.Platform == PlatformID.Unix)
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("Pacific/Auckland"); // *nix
-                               else
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("New Zealand Standard Time"); // Windows
-
+                               TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland"));
                                // DST start: 9/29/2013 2:00:00 AM
                                // DST end: 4/6/2014 3:00:00 AM
                                DateTime dt = new DateTime (2014, 1, 9, 23, 0, 0, DateTimeKind.Utc);
@@ -354,7 +376,7 @@ namespace MonoTests.System
                        [Test] //Covers #25050
                        public void TestAthensDST ()
                        {
-                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
                                var date = new DateTime (2014, 3, 30 , 2, 0, 0);
                                Assert.IsFalse (tzi.IsDaylightSavingTime (date));
                                Assert.AreEqual (new TimeSpan (2,0,0), tzi.GetUtcOffset (date));
@@ -366,7 +388,7 @@ namespace MonoTests.System
                                // In .NET GetUtcOffset() returns the BaseUtcOffset for times within the hour
                                // lost when DST starts but IsDaylightSavingTime() returns true.
 
-                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
 
                                var date = new DateTime (2014, 3, 30 , 3, 0, 0);
                                Assert.IsTrue (tzi.IsDaylightSavingTime (date));
@@ -434,7 +456,7 @@ namespace MonoTests.System
                        [Test] //Covers #41349
                        public void TestIsDST_DateTimeOffset ()
                        {
-                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+                               TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
                                var date = new DateTime (2014, 3, 30 , 2, 0, 0);
                                var offset = tzi.GetUtcOffset (date);
                                var dateOffset = new DateTimeOffset (date, offset);
@@ -486,8 +508,6 @@ namespace MonoTests.System
                        [ExpectedException (typeof (ArgumentException))]
                        public void ConvertFromUtc_KindIsLocalException ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       throw new ArgumentException ();
                                TimeZoneInfo.ConvertTimeFromUtc (new DateTime (2007, 5, 3, 11, 8, 0, DateTimeKind.Local), TimeZoneInfo.Local);  
                        }
                
@@ -509,8 +529,6 @@ namespace MonoTests.System
                        [Test]
                        public void ConvertFromUTC_ConvertInWinter ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                DateTime utc = new DateTime (2007, 12, 25, 12, 0, 0);
                                DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
                                Assert.AreEqual (utc, converted);
@@ -519,8 +537,6 @@ namespace MonoTests.System
                        [Test]
                        public void ConvertFromUtc_ConvertInSummer ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                DateTime utc = new DateTime (2007, 06, 01, 12, 0, 0);
                                DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
                                Assert.AreEqual (utc + new TimeSpan (1,0,0), converted);
@@ -546,8 +562,6 @@ namespace MonoTests.System
                        [ExpectedException (typeof (ArgumentException))]
                        public void ConvertToUTC_KindIsLocalButSourceIsNot ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       throw new ArgumentException ();
                                TimeZoneInfo.ConvertTimeToUtc (new DateTime (2007, 5, 3, 12, 8, 0, DateTimeKind.Local), london);        
                        }
                
@@ -578,8 +592,6 @@ namespace MonoTests.System
                        [Test]
                        public void ConvertFromToUtc ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                DateTime utc = DateTime.UtcNow;
                                Assert.AreEqual (utc.Kind, DateTimeKind.Utc);
                                DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
@@ -628,10 +640,7 @@ namespace MonoTests.System
                        [Test]
                        public void ConvertToTimeZone ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-
-                               TimeZoneInfo.ConvertTime (DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Pacific/Auckland"));
+                               TimeZoneInfo.ConvertTime (DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland")));
                        }
 
                        [Test]
@@ -678,11 +687,7 @@ namespace MonoTests.System
                        [Test (Description="Fix for xambug https://bugzilla.xamarin.com/show_bug.cgi?id=17155")]
                        public void ConvertTime_AdjustmentRuleAfterNewYears ()
                        {
-                               TimeZoneInfo tz;
-                               if (Environment.OSVersion.Platform == PlatformID.Unix)
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("Pacific/Auckland"); // *nix
-                               else
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("New Zealand Standard Time"); // Windows
+                               TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland"));
 
                                // DST start: 9/29/2013 2:00:00 AM
                                // DST end: 4/6/2014 3:00:00 AM
@@ -721,19 +726,8 @@ namespace MonoTests.System
                        [Test (Description="Fix the bug https://bugzilla.xamarin.com/show_bug.cgi?id=1849")]
                        public void ConvertTime_AjustmentConvertTimeWithSourceTimeZone () {
                                
-                               TimeZoneInfo easternTimeZone;
-                               TimeZoneInfo pacificTimeZone;
-
-                               if (Environment.OSVersion.Platform == PlatformID.Unix) {
-                                       // *nix
-                                       easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("US/Eastern");
-                                       pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("US/Pacific");   
-                               }
-                               else {
-                                       // Windows
-                                       easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("Eastern Standard Time");
-                                       pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("Pacific Standard Time");
-                               }
+                               TimeZoneInfo easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("US/Eastern"));
+                               TimeZoneInfo pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("US/Pacific"));
 
                                DateTime lastMidnight = new DateTime (new DateTime (2012, 06, 13).Ticks, DateTimeKind.Unspecified);
                                DateTime lastMidnightAsEST = TimeZoneInfo.ConvertTime (lastMidnight, pacificTimeZone, easternTimeZone);
@@ -806,8 +800,6 @@ namespace MonoTests.System
                        [Test]
                        public void AmbiguousDates ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0)));
                                Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 1)));
                                Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 2, 0, 0)));
@@ -817,8 +809,6 @@ namespace MonoTests.System
                        [Test]
                        public void AmbiguousUTCDates ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 0, DateTimeKind.Utc)));
                                Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 1, DateTimeKind.Utc)));
                                Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 59, 59, DateTimeKind.Utc)));
@@ -848,8 +838,6 @@ namespace MonoTests.System
                        [Test]
                        public void NotEmpty ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> systemTZ = TimeZoneInfo.GetSystemTimeZones ();
                                Assert.IsNotNull(systemTZ, "SystemTZ is null");
                                Assert.IsFalse (systemTZ.Count == 0, "SystemTZ is empty");
@@ -858,11 +846,9 @@ namespace MonoTests.System
                        [Test]
                        public void ContainsBrussels ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
                                global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> systemTZ = TimeZoneInfo.GetSystemTimeZones ();
                                foreach (TimeZoneInfo tz in systemTZ) {
-                                       if (tz.Id == "Europe/Brussels")
+                                       if (tz.Id == MapTimeZoneId ("Europe/Brussels"))
                                                return;
                                }
                                Assert.Fail ("Europe/Brussels not found in SystemTZ");
@@ -903,72 +889,56 @@ namespace MonoTests.System
                        [ExpectedException (typeof (TimeZoneNotFoundException))]
                        public void NonSystemTimezone ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       throw new TimeZoneNotFoundException ();
                                TimeZoneInfo.FindSystemTimeZoneById ("Neverland/The_Lagoon");
                        }
                
                        [Test]
                        public void FindBrusselsTZ ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
                                Assert.IsNotNull (brussels);
                        }
                
                        [Test]
                        public void OffsetIsCorrectInKinshasa ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById ("Africa/Kinshasa");
+                               TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Africa/Kinshasa"));
                                Assert.AreEqual (new TimeSpan (1,0,0), kin.BaseUtcOffset, "BaseUtcOffset in Kinshasa is not +1h");
                        }
                
                        [Test]
                        public void OffsetIsCorrectInBrussels ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
                                Assert.AreEqual (new TimeSpan (1,0,0), brussels.BaseUtcOffset, "BaseUtcOffset for Brussels is not +1h");
                        }
                
                        [Test]
                        public void NoDSTInKinshasa ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById ("Africa/Kinshasa");
+                               TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Africa/Kinshasa"));
                                Assert.IsFalse (kin.SupportsDaylightSavingTime);
                        }
                
                        [Test]
                        public void BrusselsSupportsDST ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
                                Assert.IsTrue (brussels.SupportsDaylightSavingTime);
                        }
                
                        [Test]
                        public void MelbourneSupportsDST ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo melbourne = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Melbourne");
+                               TimeZoneInfo melbourne = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Australia/Melbourne"));
                                Assert.IsTrue (melbourne.SupportsDaylightSavingTime);
                        }
                
                        [Test]
                        public void RomeAndVaticanSharesTime ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo rome = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Rome");
-                               TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Vatican");
+                               TimeZoneInfo rome = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Rome"));
+                               TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Vatican"));
                                Assert.IsTrue (rome.HasSameRules (vatican));
                        }
 
@@ -1038,9 +1008,7 @@ namespace MonoTests.System
                        [ExpectedException (typeof(ArgumentException))]
                        public void DateIsNotAmbiguous ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       throw new ArgumentException ();
-                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
                                DateTime date = new DateTime (2007, 05, 11, 11, 40, 00);
                                brussels.GetAmbiguousTimeOffsets (date);
                        }
@@ -1048,9 +1016,7 @@ namespace MonoTests.System
                        [Test]
                        public void AmbiguousOffsets ()
                        {
-                               if (Environment.OSVersion.Platform != PlatformID.Unix)
-                                       Assert.Ignore ("Not running on Unix.");
-                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+                               TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
                                DateTime date = new DateTime (2007, 10, 28, 2, 30, 00);
                                Assert.IsTrue (brussels.IsAmbiguousTime (date));
                                Assert.AreEqual (2, brussels.GetAmbiguousTimeOffsets (date).Length);
@@ -1285,11 +1251,7 @@ namespace MonoTests.System
                        [Test]
                        public void TestSydneyDaylightChanges ()
                        {
-                               TimeZoneInfo tz;
-                               if (Environment.OSVersion.Platform == PlatformID.Unix)
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Sydney");
-                               else
-                                       tz = TimeZoneInfo.FindSystemTimeZoneById ("W. Australia Standard Time");
+                               TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Australia/Sydney"));
 
                                var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
 
@@ -1298,6 +1260,18 @@ namespace MonoTests.System
                                Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
                        }
 
+                       [Test]
+                       public void TestAthensDaylightChanges ()
+                       {
+                               TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
+
+                               var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
+
+                               Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
+                               Assert.AreEqual (new DateTime (2014, 3, 30, 3, 0, 0), changes.Start);
+                               Assert.AreEqual (new DateTime (2014, 10, 26, 4, 0, 0), changes.End);
+                       }
+
                        [Test]
                        public void AllTimeZonesDaylightChanges ()
                        {
index 409e62066b5f4a5a9cbd133ddff09a8a535fe598..d93258fbe1562310156d9ef0bfb2ecf62760b9e6 100644 (file)
@@ -23,8 +23,8 @@ public class TimeZoneTest {
 
        private void CET (TimeZone t1) 
        {
-               Assert.AreEqual("CET", t1.StandardName, "A01");
-               Assert.AreEqual("CEST", t1.DaylightName, "A02");
+               Assert.IsTrue("CET" == t1.StandardName || "W. Europe Standard Time" == t1.StandardName, "A01");
+               Assert.IsTrue("CEST" == t1.DaylightName || "W. Europe Daylight Time" == t1.DaylightName, "A02");
        
                DaylightTime d1 = t1.GetDaylightChanges (2002);
                Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "A03");
@@ -55,9 +55,8 @@ public class TimeZoneTest {
 
        private void EST (TimeZone t1) 
        {
-               // It could be EST though...
-               //Assert.AreEqual("Eastern Standard Time", t1.StandardName, "B01");
-               //Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02");
+               Assert.IsTrue("EST" == t1.StandardName || "Eastern Standard Time" == t1.StandardName, "B01");
+               Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02");
 
                DaylightTime d1 = t1.GetDaylightChanges (2002);
                Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
@@ -174,6 +173,7 @@ public class TimeZoneTest {
        {
                TimeZone t1 = TimeZone.CurrentTimeZone;
                switch (t1.StandardName) {
+                       case "W. Europe Standard Time":
                        case "CET":
                                CET (t1);
                                break;
@@ -320,9 +320,9 @@ public class TimeZoneTest {
                [Test]
                public void FindSystemTimeZoneById ()
                {
-                       TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Canada/Eastern");
-                       Assert.AreEqual ("EDT", tzi.DaylightName, "DaylightName");
-                       Assert.AreEqual ("EST", tzi.StandardName, "StandardName");
+                       TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfoTest.MapTimeZoneId ("Canada/Eastern"));
+                       Assert.IsTrue ("EDT" == tzi.DaylightName || "Eastern Daylight Time" == tzi.DaylightName, "DaylightName");
+                       Assert.IsTrue ("EST" == tzi.StandardName || "Eastern Standard Time" == tzi.StandardName, "StandardName");
                        Assert.IsTrue (tzi.SupportsDaylightSavingTime, "SupportsDaylightSavingTime");
                }
 
index 1e38f069af2b809045fa4e4cb2b686d035553a3f..1f408618bee270e7bb5c65ea1ace8861b925449e 100644 (file)
@@ -266,6 +266,7 @@ namespace MonoTests.System
 #endif
                const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
                static int typeIndexer = 0;
+               static bool isMono = Type.GetType ("Mono.Runtime", false) != null;
 
                [SetUp]
                public void SetUp ()
@@ -1834,8 +1835,8 @@ namespace MonoTests.System
 
                        Assert.AreEqual (t1.FullName, "System.__ComObject");
 
-                       if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
-                               Environment.OSVersion.Platform == PlatformID.Win32NT)
+                       if (!isMono && (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
+                               Environment.OSVersion.Platform == PlatformID.Win32NT))
                                Activator.CreateInstance(t1);
 
                        Assert.AreEqual (t2.FullName, "System.__ComObject");
index 6e253d6ff77128c7e034d704e67e2fde23434eb6..dab16f74fb90ea18cb75a58f8766c82d6d8913d7 100644 (file)
@@ -900,6 +900,7 @@ ReferenceSources/win32native.cs
 ReferenceSources/SharedStatics.cs
 ReferenceSources/SecurityContext.cs
 ReferenceSources/PathInternal.cs
+ReferenceSources/BinaryCompatibility.cs
 
 ../referencesource/mscorlib/system/__filters.cs
 ../referencesource/mscorlib/system/__hresults.cs
@@ -1557,7 +1558,6 @@ ReferenceSources/PathInternal.cs
 ../referencesource/mscorlib/system/runtime/serialization/formatters/soapfault.cs
 ../referencesource/mscorlib/system/runtime/serialization/formatters/soapmessage.cs
 
-../referencesource/mscorlib/system/runtime/versioning/binarycompatibility.cs
 ../referencesource/mscorlib/system/runtime/versioning/componentguaranteesattribute.cs
 ../referencesource/mscorlib/system/runtime/versioning/multitargetinghelpers.cs
 ../referencesource/mscorlib/system/runtime/versioning/NonVersionableAttribute.cs
index 1f90f34978a6b874579766d3f57d652cd191885e..6050d716ac1b6f0d5d7ae341bd679b88dd2fce82 100644 (file)
@@ -27,11 +27,12 @@ namespace System {
         , IComparable<Boolean>,  IEquatable<Boolean>
 #endif
     {
-    
+#pragma warning disable 649    
       //
       // Member Variables
       //
       private bool m_value;
+#pragma warning disable
 
       // The true value. 
       // 
index a5bb9e9c06df9057b61c7715ceade349c4481be1..c1a043d04b09ab8f2bd994096ab494bd266ef807 100644 (file)
@@ -910,7 +910,9 @@ namespace System.Collections.Generic {
             Contract.EndContractBlock();
     
             if (count > 0) {
+#if !MONO                
                 int i = _size;
+#endif
                 _size -= count;
                 if (index < _size) {
                     Array.Copy(_items, index + count, _items, index, _size - index);
index ce8bafab2deef044445d927a8898f6424e28abe6..4767195da3cf472f95631b2e33ccce96be7ddf11 100644 (file)
@@ -2445,9 +2445,8 @@ namespace System {
             Byte[] decodedBytes = new Byte[resultLength];
 
             // Convert Base64 chars into bytes:
-            Int32 actualResultLength;
             fixed (Byte* decodedBytesPtr = decodedBytes)
-                actualResultLength = FromBase64_Decode(inputPtr, inputLength, decodedBytesPtr, resultLength);
+                FromBase64_Decode(inputPtr, inputLength, decodedBytesPtr, resultLength);
 
             // Note that actualResultLength can differ from resultLength if the caller is modifying the array
             // as it is being converted. Silently ignore the failure.
index c8e2ce17d893a329aa26dfa2e106735ede65d767..77d17717ffdf52f9a1d9ce97e34fad32b141b0ff 100644 (file)
@@ -46,7 +46,9 @@ namespace System.Globalization {
         internal const int UNICODE_CATEGORY_OFFSET = 0;
         internal const int BIDI_CATEGORY_OFFSET = 1;
 
+#pragma warning disable 414
         static bool s_initialized = InitTable();
+#pragma warning restore
 
         // The native pointer to the 12:4:4 index table of the Unicode cateogry data.
         [SecurityCritical]
index 29c4cd43def3f451254fadfe32bc9b4d7cbb1dc4..147ef7382e1b349d631e9834a24caebff0d7bdb9 100644 (file)
@@ -103,11 +103,13 @@ namespace System.Globalization {
         [NonSerialized] 
         private String m_sortName; // The name that defines our behavior
 
+#if !MONO
         [NonSerialized]
         private IntPtr m_dataHandle;
 
         [NonSerialized]
         private IntPtr m_handleOrigin;
+#endif
 
         ////////////////////////////////////////////////////////////////////////
         //
@@ -258,8 +260,10 @@ namespace System.Globalization {
         // the following fields are defined to keep the compatibility with Whidbey.
         // don't change/remove the names/types of these fields.
 #if FEATURE_USE_LCID || MONO
+#pragma warning disable 169
                 [OptionalField(VersionAdded = 1)]
                 private int win32LCID;             // mapped sort culture id of this instance
+#pragma warning restore
                 private int culture;               // the culture ID used to create this instance.
 #endif
         [OnDeserializing]
@@ -1143,12 +1147,17 @@ namespace System.Globalization {
             {
                 throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");
             }
+
+#if !MONO            
             byte[] keyData = null;
+#endif
             // The OS doesn't have quite the same behavior so we have to test for empty inputs
             if (String.IsNullOrEmpty(source))
             {
+#if !MONO                
                 // Empty strings get an empty sort key
                 keyData = EmptyArray<Byte>.Value;
+#endif
                 // Fake value to test though so we can verify our flags
                 source = "\x0000";
             }
index cc6bc05d4d040352118265e0dea3270c9253a790..7c03df01a4c5f9072065355c954d3e1ae956b871 100644 (file)
@@ -398,6 +398,7 @@ namespace System.Globalization {
         [OptionalField(VersionAdded = 1)]
         private bool   m_useUserOverride;
 #if !FEATURE_CORECLR
+#pragma warning disable 169
         [OptionalField(VersionAdded = 1)]
         private bool bUseCalendarInfo;
         [OptionalField(VersionAdded = 1)]
@@ -406,6 +407,7 @@ namespace System.Globalization {
         internal bool m_isDefaultCalendar;                // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey)
         [OptionalField(VersionAdded = 2)]
         private static volatile Hashtable s_calendarNativeNames;   // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey)
+#pragma warning restore
 #endif // !FEATURE_CORECLR
 
         // This was synthesized by Whidbey so we knew what words might appear in the middle of a date string
@@ -1515,10 +1517,11 @@ namespace System.Globalization {
                 ClearTokenHashTable();
             }
         }
-
+#if !MONO
         // Whitespaces that we allow in the month names.
         // U+00a0 is non-breaking space.
         static char[] MonthSpaces = {' ', '\u00a0'};
+#endif
 
         internal bool HasSpacesInMonthNames {
             get {
index da422367d637dc6a26c15d3e0a8941355ac41088..991ac5117029a5071717bee473bbd049bed9c4e9 100644 (file)
@@ -4001,8 +4001,10 @@ new DS[] { DS.ERROR, DS.TX_NNN,  DS.TX_NNN,  DS.TX_NNN,  DS.ERROR,   DS.ERROR,
             parseInfo.fAllowInnerWhite = ((styles & DateTimeStyles.AllowInnerWhite) != 0);
             parseInfo.fAllowTrailingWhite = ((styles & DateTimeStyles.AllowTrailingWhite) != 0);
 
+#if !MONO
             // We need the original values of the following two below.
             String originalFormat = formatParam;
+#endif
 
             if (formatParam.Length == 1) {
                 if (((result.flags & ParseFlags.CaptureOffset) != 0) && formatParam[0] == 'U') {
index 911106e2022ccdab471cef916f02829a62370063..de0dc9b78b8374eae639732a62e331c55558e586 100644 (file)
@@ -164,10 +164,13 @@ namespace System.Globalization {
         [System.Security.SecuritySafeCritical]  // auto-generated
         private static EraInfo[] GetErasFromRegistry()
         {
+#if MONO
+            return null;
+#else
             // Look in the registry key and see if we can find any ranges
             int iFoundEras = 0;
             EraInfo[] registryEraRanges = null;
-#if !MONO            
+           
             try
             {
                 // Need to access registry
@@ -249,9 +252,10 @@ namespace System.Globalization {
                     registryEraRanges[i].maxEraYear = registryEraRanges[i-1].yearOffset + 1 - registryEraRanges[i].yearOffset;
                 }
             }
-#endif
+
             // Return our ranges
             return registryEraRanges;
+#endif            
         }
 
         //
index 577047c3f87ca0565f40c270fad581880d565eb9..b9069bba54a5b6f507238c76ba76b445d72da845 100644 (file)
@@ -30,7 +30,9 @@ namespace System.Globalization {
             m_NlsVersion = nlsVersion;
 
             if(customVersion == Guid.Empty) {
+#if !MONO                
                 byte[] b = BitConverter.GetBytes(effectiveId);
+#endif
                 byte b1 = (byte) ((uint) effectiveId >> 24);
                 byte b2 = (byte) ((effectiveId  & 0x00FF0000) >> 16);
                 byte b3 = (byte) ((effectiveId  & 0x0000FF00) >> 8);
index 3357589278655c7731f6f5c03311a88d15a26e31..bccfd3b510df28bd6b1779fbad2d36c9357d98de 100644 (file)
@@ -421,7 +421,7 @@ namespace System.IO {
             // put in InternalReadChars.   
             int charsRead = 0;
             int numBytes = 0;
-            long posSav = posSav = 0;
+            long posSav = 0;
             
             if (m_stream.CanSeek)
                 posSav = m_stream.Position;
index cf65efb2cf0e341e6f15f35d0b2f6dd804f88afd..aab4fe9497568f6ad79cd7d0ceb1a50f9d4f01e1 100644 (file)
@@ -97,7 +97,9 @@ namespace System.IO {
             [System.Security.SecuritySafeCritical]
             get 
             {
+#pragma warning disable 219
                 String demandDir;
+#pragma warning restore
                 if (this is DirectoryInfo)
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
@@ -119,7 +121,9 @@ namespace System.IO {
             [System.Security.SecurityCritical]
             get
             {
+#pragma warning disable 219
                 String demandDir;
+#pragma warning restore
                 if (this is DirectoryInfo)
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
index 699d4f7e76b50809826b31b0757c44337dbd318e..795ccabed01d42bd111e061f15b870270ec5352b 100644 (file)
@@ -32,8 +32,10 @@ namespace System.IO {
         // This information isn't guaranteed to be correct, but is our second 
         // best effort at a file or directory involved, after the exception 
         // message.
+#pragma warning disable 414
         [NonSerialized]
         private String _maybeFullPath;  // For debuggers on partial trust code
+#pragma warning restore
 
         public IOException() 
             : base(Environment.GetResourceString("Arg_IOException")) {
index f18a310acd80224e8e540dd7ca13ce167ad5fbf9..64f0dfcd349f7fcace0bfcd2fc6e6256883076d1 100644 (file)
@@ -240,9 +240,11 @@ namespace System.IO
                 // write any buffered data to those streams even during finalization, which 
                 // is generally the right thing to do.
                 if (stream != null) {
+#pragma warning disable 184
                     // Note: flush on the underlying stream can throw (ex., low disk space)
                     if (disposing || (LeaveOpen && stream is __ConsoleStream))
                     {
+#pragma warning restore
 #if FEATURE_ASYNC_IO
                         CheckAsyncTaskInProgress();
 #endif
index 6c65371dcd94feb4678c3f02a6b70b1148e720d1..df2870092b06d52b6e8283bfb1319c195fc2bdd0 100644 (file)
@@ -563,8 +563,9 @@ namespace System.Resources {
             // Jun 08: for cases other than ACCESS_DENIED, we'll assert instead of throw to give release builds more opportunity to fallback.
             // 
 
-
+#pragma warning disable 168
             catch (FileLoadException fle)
+#pragma warning restore
             {
 #if !MONO                
                 // Ignore cases where the loader gets an access
index 2a66d2394195194499a05d015fcc2ea52fceddfc..3e10b394fb9cda09834a5413fef128e7aa16d9ed 100644 (file)
@@ -202,10 +202,12 @@ namespace System.Resources {
 
         private bool UseManifest;  // Use Assembly manifest, or grovel disk.
 
+#pragma warning disable 414
         // unused! But need to keep for serialization
         [OptionalField(VersionAdded = 1)]
         private bool UseSatelliteAssem;  // Are all the .resources files in the 
                   // main assembly, or in satellite assemblies for each culture?
+#pragma warning restore
 #if RESOURCE_SATELLITE_CONFIG
         private static volatile Hashtable _installedSatelliteInfo;  // Give the user the option  
                // to prevent certain satellite assembly probes via a config file.
@@ -269,8 +271,9 @@ namespace System.Resources {
         // My private debugging aid.  Set to 5 or 6 for verbose output.  Set to 3
         // for summary level information.
         internal static readonly int DEBUG = 0; //Making this const causes C# to consider all of the code that it guards unreachable.
-        
+#if FEATURE_APPX        
         private static volatile bool s_IsAppXModel;
+#endif
         
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         private void Init()
index b1b8e3e48f4f9b142298c47a377a88da38130a6c..d5d396481fa7330478470230d46e206b923708f2 100644 (file)
@@ -4619,15 +4619,14 @@ namespace System
                     #region Non-TransparentProxy case
                     if (name == null)
                         throw new ArgumentNullException("name");
-
+#if MONO
+                    throw new NotImplementedException ();
+#else
                     bool[] isByRef = modifiers == null ? null : modifiers[0].IsByRefArray;
                     
                     // pass LCID_ENGLISH_US if no explicit culture is specified to match the behavior of VB
                     int lcid = (culture == null ? 0x0409 : culture.LCID);
 
-#if MONO
-                    throw new NotImplementedException ();
-#else
                     return InvokeDispMethod(name, bindingFlags, target, providedArgs, isByRef, lcid, namedParams);
 #endif
                     #endregion
@@ -4660,7 +4659,9 @@ namespace System
             if (binder == null)
                 binder = DefaultBinder;
 
+#if !MONO
             bool bDefaultBinder = (binder == DefaultBinder);
+#endif
             #endregion
             
             #region Delegate to Activator.CreateInstance
index 747c0245e5b75f786e5bd49121d664942ada174e..db143c04f522a1c5a65815c32d05261e8f0e995a 100644 (file)
@@ -13,8 +13,9 @@ namespace System.Runtime.CompilerServices
     [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
     internal sealed class TypeDependencyAttribute: Attribute    
     {
-
+#pragma warning disable 414
         private string typeName;
+#pragma warning restore
 
         public TypeDependencyAttribute (string typeName)        
         {
index dbb3f686c2fe185a215c610b8a0519e8c2c7fd09..2947f3877803657845293d4a296a558361472507 100644 (file)
@@ -32,11 +32,15 @@ namespace System.Runtime.ExceptionServices {
     {
         // Private members that will hold the relevant details.
         private Exception m_Exception;
+#if !MONO
         private string m_remoteStackTrace;
+#endif
         private object m_stackTrace;
+#if !MONO
         private object m_dynamicMethods;
         private UIntPtr m_IPForWatsonBuckets;
         private Object m_WatsonBuckets;
+#endif
         
         private ExceptionDispatchInfo(Exception exception)
         {
@@ -66,6 +70,7 @@ namespace System.Runtime.ExceptionServices {
 #endif
         }
 
+#if !MONO
         internal UIntPtr IPForWatsonBuckets
         {
             get
@@ -81,6 +86,7 @@ namespace System.Runtime.ExceptionServices {
                 return m_WatsonBuckets;   
             }
         }
+#endif
         
         internal object BinaryStackTraceArray
         {
@@ -90,6 +96,7 @@ namespace System.Runtime.ExceptionServices {
             }
         }
 
+#if !MONO
         internal object DynamicMethodArray
         {
             get
@@ -105,6 +112,7 @@ namespace System.Runtime.ExceptionServices {
                 return m_remoteStackTrace;
             }
         }
+#endif
 
         // This static method is used to create an instance of ExceptionDispatchInfo for
         // the specified exception object and save all the required details that maybe
index 396fe83d836a11f80f04a19e8cb743dc868d9523..852942e1bf743018df1c930f2981aa81dde27c87 100644 (file)
@@ -639,15 +639,23 @@ namespace System.Runtime.Serialization.Formatters.Binary{
 
     internal sealed class BinaryMethodCall
     {
+#if FEATURE_REMOTING
         String uri;
+#endif
         String methodName;
         String typeName;
+#if FEATURE_REMOTING
         Type[] instArgs;
+#endif
         Object[] args;
+#if FEATURE_REMOTING
         Object methodSignature;
+#endif
         Object callContext;
+#if FEATURE_REMOTING
         String scallContext;
         Object properties;
+#endif
         Type[] argTypes;
         bool bArgsPrimitive = true;
         MessageEnum messageEnum;
@@ -657,14 +665,22 @@ namespace System.Runtime.Serialization.Formatters.Binary{
         // if not the args are written out as a separate array
         internal Object[] WriteArray(String uri, String methodName, String typeName, Type[] instArgs, Object[] args, Object methodSignature, Object callContext, Object[] properties)
         {
+#if FEATURE_REMOTING            
             this.uri = uri;
+#endif
             this.methodName = methodName;
             this.typeName = typeName;
+#if FEATURE_REMOTING            
             this.instArgs = instArgs;
+#endif
             this.args = args;
+#if FEATURE_REMOTING            
             this.methodSignature = methodSignature;
+#endif
             this.callContext = callContext;
+#if FEATURE_REMOTING            
             this.properties = properties;
+#endif
 
             int arraySize = 0;
             if (args == null || args.Length == 0)
@@ -878,8 +894,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
                 {
                     if (callContext is String)
                         BinaryUtil.NVTraceI("callContext", (String)callContext);   
+#if FEATURE_REMOTING                        
                     else
                         BinaryUtil.NVTraceI("callContext", scallContext);   
+#endif
                 }
 
                 if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
@@ -900,10 +918,14 @@ namespace System.Runtime.Serialization.Formatters.Binary{
     {
         Object returnValue;
         Object[] args;
+#if FEATURE_REMOTING        
         Exception exception;
+#endif
         Object callContext;
+#if FEATURE_REMOTING
         String scallContext;
         Object properties;
+#endif
         Type[] argTypes;
         bool bArgsPrimitive = true;
         MessageEnum messageEnum;
@@ -928,9 +950,13 @@ namespace System.Runtime.Serialization.Formatters.Binary{
 
             this.returnValue = returnValue;
             this.args = args;
+#if FEATURE_REMOTING            
             this.exception = exception;
+#endif
             this.callContext = callContext;
+#if FEATURE_REMOTING
             this.properties = properties;
+#endif
 
             int arraySize = 0;
             if (args == null || args.Length == 0)
@@ -1159,8 +1185,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
                 {
                     if (callContext is String)
                         BinaryUtil.NVTraceI("callContext", (String)callContext);   
+#if FEATURE_REMOTING                        
                     else
                         BinaryUtil.NVTraceI("callContext", scallContext);   
+#endif
                 }
 
                 if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
index 28ef1f0810dac5a3ba328cc20085414c4e2d8dcf..2ae5aebb362803db1cd28bfb11606296a3ae4e4b 100644 (file)
@@ -319,7 +319,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         }
 
         internal BinaryObjectString binaryObjectString;
+#if !MONO
         internal BinaryCrossAppDomainString binaryCrossAppDomainString;
+#endif
 
         internal void WriteObjectString(int objectId, String value)
         {
@@ -397,7 +399,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         private void WriteArrayAsBytes(Array array, int typeLength)
         {
             InternalWriteItemNull();
+#if !MONO
             int byteLength = array.Length*typeLength;
+#endif
             int arrayOffset = 0;
             if (byteBuffer == null)
                 byteBuffer = new byte[chunkSize];
@@ -689,7 +693,9 @@ if (!BitConverter.IsLittleEndian) {
 
 
         internal BinaryAssembly binaryAssembly;
+#if !MONO        
         internal BinaryCrossAppDomainAssembly crossAppDomainAssembly;
+#endif
 
         internal void WriteAssembly(Type type, String assemblyString, int assemId, bool isNew)
         {
index 53c04ba771b242ac86b05659a736cb4264efd257..c62b865c9cdd51c32c7b6df831786144c0974036 100644 (file)
@@ -15,7 +15,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
     [Serializable]
     internal sealed class BinaryMethodCallMessage
     {
+#pragma warning disable 414
         Object[] _inargs = null;
+#pragma warning restore
         String _methodName = null;
         String _typeName = null;
         Object _methodSignature = null;
@@ -100,7 +102,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
     [Serializable]
     internal class BinaryMethodReturnMessage
     {
+#pragma warning disable 414
         Object[] _outargs = null;
+#pragma warning restore
         Exception _exception = null;
         Object _returnValue = null;
 
index fd5131e8e061f7980638fe85c32d454853210bfb..0205e307d156e8142e6fe431fbf3333a03b8ef4a 100644 (file)
@@ -50,7 +50,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         internal Object m_topObject;
         internal Header[] headers;
         internal HeaderHandler handler;
+#pragma warning disable 649
         internal SerObjectInfoInit serObjectInfoInit;
+#pragma warning restore
         internal IFormatterConverter m_formatterConverter;
 
         // Stack of Object ParseRecords
@@ -669,7 +671,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         {
             SerTrace.Log( this, "ParseArray Entry");
 
+#if !MONO
             long genId = pr.PRobjectId;
+#endif
 
             if (pr.PRarrayTypeEnum == InternalArrayTypeE.Base64)
             {
@@ -1055,9 +1059,11 @@ namespace System.Runtime.Serialization.Formatters.Binary {
 
 
             ParseRecord objectPr = (ParseRecord)stack.Peek();
+#if !MONO
             String objName = null;
             if (objectPr != null)
                 objName = objectPr.PRname;
+#endif
 
 #if _DEBUG                        
             SerTrace.Log( this, "ParseMember ",objectPr.PRobjectId," ",pr.PRname);
@@ -1523,7 +1529,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                     TypeInformation typeInfo = BinaryFormatter.GetTypeInformation(resolvedType);
                     if (typeInfo.HasTypeForwardedFrom)
                     {
+#pragma warning disable 219
                         Assembly typeFowardedFromAssembly = null;
+#pragma warning restore
                         try
                         {
                             // if this Assembly.Load failed, we still want to throw security exception
index 569c1a38bdc5080a6f234a09f8806e3e2c0b91b9..3da9e497a834f502438bcd52aad12c6aabaf9ad2 100644 (file)
@@ -354,8 +354,8 @@ namespace System.Runtime.Serialization.Formatters.Binary
         {
             for (int i=0; i<Count(); i++)
             {
+#if _DEBUG
                 Object obj = objects[i];
-#if _DEBUG                
                 SerTrace.Log(this, "Stack Dump ",stackId," "+((obj is ITrace)?((ITrace)obj).Trace():""));
 #endif
             }
index 8d53544a067c3226d3e56523efd38af48e0eeb47..8810cb8b1cab31e61b9b3beb2e252ea30f0e25e3 100644 (file)
@@ -44,7 +44,9 @@ namespace System.Runtime.Serialization {
         internal long               m_fixupCount;
         internal ISurrogateSelector m_selector;
         internal StreamingContext   m_context;
+#if !FEATURE_PAL        
         bool m_isCrossAppDomain;
+#endif
     
         [System.Security.SecuritySafeCritical]  // auto-generated
         public ObjectManager(ISurrogateSelector selector, StreamingContext context) : this(selector, context, true, false) {
@@ -60,7 +62,9 @@ namespace System.Runtime.Serialization {
             m_objects = new ObjectHolder[DefaultInitialSize];
             m_selector = selector;
             m_context = context;
+#if !FEATURE_PAL            
             m_isCrossAppDomain = isCrossAppDomain;
+#endif
         }
 
     
@@ -341,7 +345,9 @@ namespace System.Runtime.Serialization {
             int[] arrayIndex = null;
             ValueTypeFixupInfo currFixup=null;
             Object fixupObj=holder.ObjectValue;
+#if false
             ObjectHolder originalHolder = holder;
+#endif
 
             Contract.Assert(holder!=null, "[TypedReferenceBuilder.ctor]holder!=null");
             Contract.Assert(holder.RequiresValueTypeFixup, "[TypedReferenceBuilder.ctor]holder.RequiresValueTypeFixup");
index 194fc21f3b95696eb5f2dcbd68edb4d55d85b52b..1974926ac9a286bdcca8885e4c8f99a729823996 100644 (file)
@@ -36,7 +36,9 @@ using System.Diagnostics.Contracts;
             // Traverse the hierarchy to find all methods with the particular attribute
             while (baseType != null && baseType != typeof(Object))
             {
+#if !MONO
                 RuntimeType rt = (RuntimeType)baseType;
+#endif
                 // Get all methods which are declared on this type, instance and public or nonpublic
                 MethodInfo[] mis = baseType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
 #if _DEBUG                
@@ -97,7 +99,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnSerializingMethods
             if (m_OnSerializingMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnSerializingMethods)
                 {
@@ -116,7 +120,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnDeserializingMethods
             if (m_OnDeserializingMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnDeserializingMethods)
                 {
@@ -135,7 +141,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnDeserializingMethods
             if (m_OnDeserializedMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnDeserializedMethods)
                 {
index 5f3a25e79b72ee61df57ce06bf256a9e1dfc6ccb..68af0d6ef3f5691f82ce935adaa299861bfd3e8d 100644 (file)
@@ -1310,7 +1310,7 @@ namespace System.Security.Claims
                 switch (enumerator.Name)
                 {
                     case VersionKey:
-                        string version = info.GetString(VersionKey);
+                        info.GetString(VersionKey);
                         break;
 
                     case AuthenticationTypeKey:
index ba6b40ec0ef3f36d54b45b18e4d03bf402a13774..cb23f7bd7a91ad6dd1b17d35d2b6468ca46425c7 100644 (file)
@@ -31,8 +31,9 @@ namespace System.Security.Cryptography {
         private string          _hashName;
         private byte[]          _password;
         private HashAlgorithm   _hash;
+#if !MONO        
         private CspParameters   _cspParams;
-#if !MONO
+
         [System.Security.SecurityCritical] // auto-generated
         private SafeProvHandle _safeProvHandle = null;
         private SafeProvHandle ProvHandle {
@@ -83,7 +84,9 @@ namespace System.Security.Cryptography {
             this.Salt = salt;
             this.HashName = hashName;
             _password = password;
+#if !MONO
             _cspParams = cspParams;
+#endif
         }
 
         //
index 84d4a66edc37b5983b897a663213d58342c98c0e..804eeda9bdac32d93a1173972e7989b8989a6352 100644 (file)
@@ -30,7 +30,9 @@ namespace System.Security.Cryptography {
         private byte[] m_salt;
         private HMACSHA1 m_hmacsha1;  // The pseudo-random generator function used in PBKDF2
         private byte[] m_password;
+#if !MONO
         private CspParameters m_cspParams = new CspParameters();
+#endif
 
         private uint m_iterations;
         private uint m_block;
index 0954818455914214f4a21c807ed7d00eea61d89b..a1b0a7786981ae8a8efedf0f5106156a16c0571a 100644 (file)
@@ -24,6 +24,7 @@ namespace System.Security.Cryptography {
     using System.Security.Permissions;
     using System.Diagnostics.Contracts;
 
+#if !MONO
     // Object layout of the RSAParameters structure
     internal class RSACspObject {
         internal byte[] Exponent;
@@ -35,6 +36,7 @@ namespace System.Security.Cryptography {
         internal byte[] InverseQ;
         internal byte[] D;
     }
+#endif
 
     [System.Runtime.InteropServices.ComVisible(true)]
     public sealed partial class RSACryptoServiceProvider : RSA
index 46c377bdebae60fc7e70105d0cbd79f6cd76186b..c0fcae0e3d635a505539edb83a72d10b26e88ec5 100644 (file)
@@ -1338,8 +1338,10 @@ namespace System.Text {
             }
 
             while (true) {
+#if !MONO                
                 int p = pos;
                 int i = pos;
+#endif
                 while (pos < len) {
                     ch = format[pos];
 
@@ -1406,8 +1408,10 @@ namespace System.Text {
                 StringBuilder fmt = null;
                 if (ch == ':') {
                     pos++;
+#if !MONO
                     p = pos;
                     i = pos;
+#endif
                     while (true) {
                         if (pos == len) FormatError();
                         ch = format[pos];
@@ -1559,7 +1563,9 @@ namespace System.Text {
             if (newValue == null)
                 newValue = "";
 
+#if !MONO
             int deltaLength = newValue.Length - oldValue.Length;
+#endif
 
             int[] replacements = null;          // A list of replacement positions in a chunk to apply
             int replacementsCount = 0;
@@ -1597,7 +1603,9 @@ namespace System.Text {
                 {
                     // Replacing mutates the blocks, so we need to convert to logical index and back afterward. 
                     int index = indexInChunk + chunk.m_ChunkOffset;
+#if !MONO                    
                     int indexBeforeAdjustment = index;
+#endif
 
                     // See if we accumulated any replacements, if so apply them 
                     ReplaceAllInChunk(replacements, replacementsCount, chunk, oldValue.Length, newValue);
index 1a293330ac96feba2b9e58a6246db499fa2765db..3f2e5f608113287f596a479ec589ad0970155459 100644 (file)
@@ -1080,7 +1080,9 @@ namespace System.Threading
     /// <typeparam name="T">The kind of elements contained within.</typeparam>
     internal class SparselyPopulatedArray<T> where T : class
     {
+#if DEBUG        
         private readonly SparselyPopulatedArrayFragment<T> m_head;
+#endif
         private volatile SparselyPopulatedArrayFragment<T> m_tail;
 
         /// <summary>
@@ -1089,7 +1091,10 @@ namespace System.Threading
         /// <param name="initialSize">How many array slots to pre-allocate.</param>
         internal SparselyPopulatedArray(int initialSize)
         {
-            m_head = m_tail = new SparselyPopulatedArrayFragment<T>(initialSize);
+#if DEBUG            
+            m_head = 
+#endif
+            m_tail = new SparselyPopulatedArrayFragment<T>(initialSize);
         }
 
 #if DEBUG
index 4168909f0dd17449e19e6aed3039bce3e82ce073..21ec1d7b8346d780a4a059738ca4bb8f908e7f5c 100644 (file)
@@ -858,7 +858,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //This is the original 4.0 behaviour
-                    var asyncResult = beginMethod(iar =>
+                    beginMethod(iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -995,7 +995,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //quirk for previous versions
-                    var asyncResult = beginMethod(arg1, iar =>
+                    beginMethod(arg1, iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -1141,7 +1141,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //quirk for previous versions
-                    var asyncResult = beginMethod(arg1, arg2, iar =>
+                    beginMethod(arg1, arg2, iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -1294,7 +1294,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //quirk for previous versions
-                    var asyncResult = beginMethod(arg1, arg2, arg3, iar =>
+                    beginMethod(arg1, arg2, arg3, iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
index 2b64b423d8e28a317807644569681db96f0c3521..89ae7f7d20e98d27c2f40234107dd5d469f715c5 100644 (file)
@@ -122,8 +122,10 @@ namespace System.Threading.Tasks
             get { return m_cancellationToken; }
             set
             {
+#if !MONO                
                 if (value == null)
                     throw new ArgumentNullException("CancellationToken");
+#endif
                 m_cancellationToken = value;
             }
         }
@@ -245,10 +247,11 @@ namespace System.Threading.Tasks
                 }
             }
 
+#if !MONO
             // ETW event for Parallel Invoke Begin
             int forkJoinContextID = 0;
             Task callerTask = null;
-#if !MONO            
+           
             if (TplEtwProvider.Log.IsEnabled())
             {
                 forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
@@ -1095,10 +1098,11 @@ namespace System.Threading.Tasks
                 }, null);
             }
 
+#if !MONO
             // ETW event for Parallel For begin
             int forkJoinContextID = 0;
             Task callingTask = null;
-#if !MONO            
+            
             if (TplEtwProvider.Log.IsEnabled())
             {
                 forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
@@ -1418,10 +1422,11 @@ namespace System.Threading.Tasks
                 }, null);
             }
 
+#if !MONO
             // ETW event for Parallel For begin
             Task callerTask = null;
             int forkJoinContextID = 0;
-#if !MONO
+
             if (TplEtwProvider.Log.IsEnabled())
             {
                 forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
index 2ae0c8790457fb7f593ef9bdd4cc5f7bc0968664..d37a6e7c1b5c8162cb77167ebc2e76d7d8840bed 100644 (file)
@@ -412,7 +412,9 @@ namespace System.Threading.Tasks
     /// </summary>
     internal class ParallelLoopStateFlags
     {
+#pragma warning disable 649        
         internal static int PLS_NONE;
+#pragma warning restore
         internal static int PLS_EXCEPTIONAL = 1;
         internal static int PLS_BROKEN = 2;
         internal static int PLS_STOPPED = 4;
@@ -439,7 +441,9 @@ namespace System.Threading.Tasks
             {
                 oldState = m_LoopStateFlags;
                 if ((oldState & illegalStates) != 0) return false;
+#pragma warning disable 420
                 if (Interlocked.CompareExchange(ref m_LoopStateFlags, oldState | newState, oldState) == oldState)
+#pragma warning restore
                 {
                     return true;
                 }
index 522db85b2f0833793dbe86928b6b0c5769c3196c..6b11de5616f16f1cd2dddb2d6a42ef84945bad69 100644 (file)
@@ -550,7 +550,9 @@ namespace System.Threading.Tasks
         /// <summary>The action to invoke.</summary>
         protected readonly Action m_action;
 
+#if !MONO
         protected int m_continuationId;
+#endif
 
         /// <summary>Initializes the continuation.</summary>
         /// <param name="action">The action to invoke. Must not be null.</param>
index cf9bdf17b1b19f95123dc8b0e424c6d3c2aea8ce..2d602aac3439ccaa5b53eef75cbb317ae4008821 100644 (file)
@@ -122,8 +122,9 @@ namespace System.Threading
                 throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name));
             }
             Contract.EndContractBlock();
-            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
 #if !MONO
+            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
+
 #if FEATURE_MACL
             // For ACL's, get the security descriptor from the EventWaitHandleSecurity.
             if (eventSecurity != null) {
index 13e1e31a9767216974fb004458de09cd2d167fff..79ca731df46141499b85b059d03ae3ea729145e3 100644 (file)
@@ -579,7 +579,9 @@ namespace System.Threading
         // The head and tail of the queue.  We enqueue to the head, and dequeue from the tail.
         internal volatile QueueSegment queueHead;
         internal volatile QueueSegment queueTail;
+#if !MONO        
         internal bool loggingEnabled;
+#endif
 
         internal static SparseArray<WorkStealingQueue> allThreadQueues = new SparseArray<WorkStealingQueue>(16); //
 
index 8aad5bb3a61236af796230cbec40949294609e96..80bef5ab852b2b77947bdeca47d7f8ce38d1b0f0 100644 (file)
@@ -22,7 +22,9 @@ namespace System {
     public struct TypedReference
     {
 #if MONO
+#pragma warning disable 169
         RuntimeTypeHandle type;
+#pragma warning restore
 #endif
         private IntPtr Value;
         private IntPtr Type;
diff --git a/mcs/errors/cs0029-37.cs b/mcs/errors/cs0029-37.cs
new file mode 100644 (file)
index 0000000..80f8e8c
--- /dev/null
@@ -0,0 +1,24 @@
+// CS0029: Cannot implicitly convert type `string' to `int'
+// Line: 8
+
+class A<T> where T : CB, IA
+{
+       void Foo (T t)
+       {
+               t.Prop = "3";
+       }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+       public int Prop { get; set; }
+}
+
+interface IA
+{
+       string Prop { get; set; }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0122-39.cs b/mcs/errors/cs0122-39.cs
new file mode 100644 (file)
index 0000000..f7da1f9
--- /dev/null
@@ -0,0 +1,15 @@
+// CS0122: `A.Y' is inaccessible due to its protection level
+// Line: 8
+
+public class Test
+{
+       public static void Main ()
+       {
+               var x = nameof (A.Y);
+       }
+}
+        
+public class A
+{
+       private int Y { get; set; }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0619-59.cs b/mcs/errors/cs0619-59.cs
new file mode 100644 (file)
index 0000000..b703b0e
--- /dev/null
@@ -0,0 +1,18 @@
+// CS0619: `A.X' is obsolete: `'
+// Line: 10
+
+using System;
+
+public class Test
+{
+       public static void Main()
+       {
+               var m = nameof (A.X);
+       }
+}
+        
+public class A
+{
+       [Obsolete ("", true)]
+       public int X;
+}
diff --git a/mcs/errors/cs1070-3.cs b/mcs/errors/cs1070-3.cs
new file mode 100644 (file)
index 0000000..18811dc
--- /dev/null
@@ -0,0 +1,11 @@
+// CS1070: The type `C' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `CS1070-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
+// Line: 5
+// Compiler options: -r:CS1070-lib.dll
+
+public class D
+{
+       static void Main ()
+       {
+               new C ();
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs1501-19.cs b/mcs/errors/cs1501-19.cs
new file mode 100644 (file)
index 0000000..68095c1
--- /dev/null
@@ -0,0 +1,26 @@
+// CS1501: No overload for method `Call' takes `0' arguments
+// Line: 8
+
+class A<T> where T : CB, IA
+{
+       void Foo (T t)
+       {
+               t.Call ();
+       }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+       public void Call (int arg)
+       {
+       }
+}
+
+interface IA
+{
+       void Call (bool arg, int arg2);
+}
index a0ae78cdf518e42737b571c830e08a99adf00747..acec3be3588b60665439f60a90ff92f2e45f933a 100644 (file)
@@ -2149,11 +2149,6 @@ namespace Mono.CSharp {
                        this.name = name;
                }
 
-               static void Error_MethodGroupWithTypeArguments (ResolveContext rc, Location loc)
-               {
-                       rc.Report.Error (8084, loc, "An argument to nameof operator cannot be method group with type arguments");
-               }
-
                protected override Expression DoResolve (ResolveContext rc)
                {
                        throw new NotSupportedException ();
@@ -2169,9 +2164,9 @@ namespace Mono.CSharp {
                                        rc.Report.FeatureIsNotAvailable (rc.Module.Compiler, Location, "nameof operator");
 
                                var res = sn.LookupNameExpression (rc, MemberLookupRestrictions.IgnoreAmbiguity | MemberLookupRestrictions.NameOfExcluded);
-                               if (sn.HasTypeArguments && res is MethodGroupExpr) {
-                                       Error_MethodGroupWithTypeArguments (rc, expr.Location);
-                               }
+                               var me = res as MemberExpr;
+                               if (me != null)
+                                       me.ResolveNameOf (rc, sn);
 
                                return true;
                        }
@@ -2197,20 +2192,9 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               var mg = res as MethodGroupExpr;
-                               if (mg != null) {
-                                       var emg = res as ExtensionMethodGroupExpr;
-                                       if (emg != null && !emg.ResolveNameOf (rc, ma)) {
-                                               return true;
-                                       }
-
-                                       if (!mg.HasAccessibleCandidate (rc)) {
-                                               ErrorIsInaccesible (rc, ma.GetSignatureForError (), loc);
-                                       }
-
-                                       if (ma.HasTypeArguments) {
-                                               Error_MethodGroupWithTypeArguments (rc, ma.Location);
-                                       }
+                               var me = res as MemberExpr;
+                               if (me != null) {
+                                       me.ResolveNameOf (rc, ma);
                                }
 
                                //
index 42eba97ee475763eb15186ea8a25bbe36fc1fca9..edc860eca83b595e90b61975654147dbd691c4e9 100644 (file)
@@ -841,22 +841,29 @@ namespace Mono.CSharp {
                public static Expression MemberLookup (IMemberContext rc, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc)
                {
                        var members = MemberCache.FindMembers (queried_type, name, false);
-                       if (members == null)
-                               return null;
 
-                       Expression expr;
-                       do {
-                               expr = MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
-                               if (expr != null)
-                                       return expr;
+                       if (members != null) {
+                               Expression expr;
+                               do {
+                                       expr = MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
+                                       if (expr != null)
+                                               return expr;
 
-                               if (members [0].DeclaringType.BaseType == null)
-                                       members = null;
-                               else
-                                       members = MemberCache.FindMembers (members [0].DeclaringType.BaseType, name, false);
-                       } while (members != null);
+                                       if (members [0].DeclaringType.BaseType == null)
+                                               members = null;
+                                       else
+                                               members = MemberCache.FindMembers (members [0].DeclaringType.BaseType, name, false);
+                               } while (members != null);
+                       }
+
+                       var tps = queried_type as TypeParameterSpec;
+                       if (tps != null) {
+                               members = MemberCache.FindInterfaceMembers (tps, name);
+                               if (members != null)
+                                       return MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
+                       }
 
-                       return expr;
+                       return null;
                }
 
                public static Expression MemberLookupToExpression (IMemberContext rc, IList<MemberSpec> members, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc)
@@ -901,15 +908,6 @@ namespace Mono.CSharp {
 
                                if ((restrictions & MemberLookupRestrictions.InvocableOnly) != 0) {
                                        if (member is MethodSpec) {
-                                               //
-                                               // Interface members that are hidden by class members are removed from the set. This
-                                               // step only has an effect if T is a type parameter and T has both an effective base 
-                                               // class other than object and a non-empty effective interface set
-                                               //
-                                               var tps = queried_type as TypeParameterSpec;
-                                               if (tps != null && tps.HasTypeConstraint)
-                                                       members = RemoveHiddenTypeParameterMethods (members);
-
                                                return new MethodGroupExpr (members, queried_type, loc);
                                        }
 
@@ -959,57 +957,6 @@ namespace Mono.CSharp {
                        return null;
                }
 
-               static IList<MemberSpec> RemoveHiddenTypeParameterMethods (IList<MemberSpec> members)
-               {
-                       if (members.Count < 2)
-                               return members;
-
-                       //
-                       // If M is a method, then all non-method members declared in an interface declaration
-                       // are removed from the set, and all methods with the same signature as M declared in
-                       // an interface declaration are removed from the set
-                       //
-
-                       bool copied = false;
-                       for (int i = 0; i < members.Count; ++i) {
-                               var method = members[i] as MethodSpec;
-                               if (method == null) {
-                                       if (!copied) {
-                                               copied = true;
-                                               members = new List<MemberSpec> (members);
-                                       } 
-                                       
-                                       members.RemoveAt (i--);
-                                       continue;
-                               }
-
-                               if (!method.DeclaringType.IsInterface)
-                                       continue;
-
-                               for (int ii = 0; ii < members.Count; ++ii) {
-                                       var candidate = members[ii] as MethodSpec;
-                                       if (candidate == null || !candidate.DeclaringType.IsClass)
-                                               continue;
-
-                                       if (!TypeSpecComparer.Override.IsEqual (candidate.Parameters, method.Parameters))
-                                               continue;
-
-                                       if (!AParametersCollection.HasSameParameterDefaults (candidate.Parameters, method.Parameters))
-                                               continue;
-
-                                       if (!copied) {
-                                               copied = true;
-                                               members = new List<MemberSpec> (members);
-                                       }
-
-                                       members.RemoveAt (i--);
-                                       break;
-                               }
-                       }
-
-                       return members;
-               }
-
                protected static void Error_NamedArgument (NamedArgument na, Report Report)
                {
                        Report.Error (1742, na.Location, "An element access expression cannot use named argument");
@@ -3701,6 +3648,11 @@ namespace Mono.CSharp {
                        return this;
                }
 
+               public virtual void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+
+               }
+
                protected void EmitInstance (EmitContext ec, bool prepare_for_load)
                {
                        var inst = new InstanceEmitter (InstanceExpression, TypeSpec.IsValueType (InstanceExpression.Type));
@@ -3776,7 +3728,7 @@ namespace Mono.CSharp {
                // For extension methodgroup we are not looking for base members but parent
                // namespace extension methods
                //
-               public override IList<MemberSpec> GetBaseMembers (TypeSpec baseType)
+               public override IList<MemberSpec> GetBaseMembers (TypeSpec type)
                {
                        // TODO: candidates are null only when doing error reporting, that's
                        // incorrect. We have to discover same extension methods in error mode
@@ -3805,27 +3757,9 @@ namespace Mono.CSharp {
                                Convert.ImplicitBoxingConversion (null, argType, extensionType) != null;
                }
 
-               public bool ResolveNameOf (ResolveContext rc, MemberAccess ma)
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
                {
-                       rc.Report.Error (8093, ma.Location, "An argument to nameof operator cannot be extension method group");
-
-                       // Not included in C#6
-                       /*
-                       ExtensionExpression = ExtensionExpression.Resolve (rc);
-                       if (ExtensionExpression == null)
-                               return false;
-
-                       var argType = ExtensionExpression.Type;
-                       foreach (MethodSpec candidate in Candidates) {
-                               if (ExtensionMethodGroupExpr.IsExtensionTypeCompatible (argType, candidate.Parameters.ExtensionMethodType))
-                                       return true;
-                       }
-
-                       // TODO: Scan full hierarchy
-
-                       ma.Error_TypeDoesNotContainDefinition (rc, argType, ma.Name);
-                       */
-                       return false;
+                       rc.Report.Error (8093, expr.Location, "An argument to nameof operator cannot be extension method group");
                }
 
                public override MethodGroupExpr LookupExtensionMethod (ResolveContext rc)
@@ -4226,6 +4160,17 @@ namespace Mono.CSharp {
                        return base.ResolveMemberAccess (ec, left, original);
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       if (!HasAccessibleCandidate (rc)) {
+                               ErrorIsInaccesible (rc, expr.GetSignatureForError (), loc);
+                       }
+
+                       if (expr.HasTypeArguments) {
+                               rc.Report.Error (8084, expr.Location, "An argument to nameof operator cannot be method group with type arguments");
+                       }
+               }
+
                public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
                {
                        type_arguments = ta;
@@ -4233,9 +4178,19 @@ namespace Mono.CSharp {
 
                #region IBaseMembersProvider Members
 
-               public virtual IList<MemberSpec> GetBaseMembers (TypeSpec baseType)
+               public virtual IList<MemberSpec> GetBaseMembers (TypeSpec type)
                {
-                       return baseType == null ? null : MemberCache.FindMembers (baseType, Methods [0].Name, false);
+                       var baseType = type.BaseType;
+                       
+                       IList<MemberSpec> members = baseType == null ? null : MemberCache.FindMembers (baseType, Methods [0].Name, false);
+
+                       if (members == null && !type.IsInterface) {
+                               var tps = queried_type as TypeParameterSpec;
+                               if (tps != null)
+                                       members = MemberCache.FindInterfaceMembers (tps, Methods [0].Name);
+                       }
+
+                       return members;
                }
 
                public IParametersMember GetOverrideMemberParameters (MemberSpec member)
@@ -5632,7 +5587,7 @@ namespace Mono.CSharp {
                                                // Restore expanded arguments
                                                candidate_args = args;
                                        }
-                               } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null);
+                               } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType)) != null);
 
                                //
                                // We've found exact match
@@ -6196,6 +6151,11 @@ namespace Mono.CSharp {
                        return constant.GetSignatureForError ();
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       constant.CheckObsoleteness (rc, expr.Location);
+               }
+
                public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
                {
                        Error_TypeArgumentsCannotBeUsed (ec, "constant", GetSignatureForError (), loc);
@@ -6425,6 +6385,11 @@ namespace Mono.CSharp {
                        return this;
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       spec.CheckObsoleteness (rc, expr.Location);
+               }
+
                public void SetFieldAssigned (FlowAnalysisContext fc)
                {
                        if (!IsInstance)
@@ -7195,6 +7160,14 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       if (!best_candidate.IsAccessible (rc))
+                               ErrorIsInaccesible (rc, best_candidate.GetSignatureForError (), expr.Location);
+
+                       best_candidate.CheckObsoleteness (rc, expr.Location);
+               }
+
                public void SetBackingFieldAssigned (FlowAnalysisContext fc)
                {
                        if (backing_field != null) {
@@ -7616,6 +7589,11 @@ namespace Mono.CSharp {
                        return TypeManager.CSharpSignature (spec);
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       spec.CheckObsoleteness (rc, expr.Location);
+               }
+
                public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
                {
                        Error_TypeArgumentsCannotBeUsed (ec, "event", GetSignatureForError (), loc);
index db50ba39b8e9b2642e53e57951b1402edd637d4f..ae27eb24900d5eed8c6ee3ae36589ff54643b1cc 100644 (file)
@@ -10952,9 +10952,18 @@ namespace Mono.CSharp
 
                #region IBaseMembersProvider Members
 
-               IList<MemberSpec> OverloadResolver.IBaseMembersProvider.GetBaseMembers (TypeSpec baseType)
+               IList<MemberSpec> OverloadResolver.IBaseMembersProvider.GetBaseMembers (TypeSpec type)
                {
-                       return baseType == null ? null : MemberCache.FindMembers (baseType, MemberCache.IndexerNameAlias, false);
+                       var baseType = type.BaseType;
+                       var members = baseType == null ? null : MemberCache.FindMembers (baseType, MemberCache.IndexerNameAlias, false);
+
+                       if (members == null && !type.IsInterface) {
+                               var tps = queried_type as TypeParameterSpec;
+                               if (tps != null)
+                                       members = MemberCache.FindInterfaceMembers (tps, MemberCache.IndexerNameAlias);
+                       }
+
+                       return members;
                }
 
                IParametersMember OverloadResolver.IBaseMembersProvider.GetOverrideMemberParameters (MemberSpec member)
index b34f2dc1ec56dfbadb8ff468da7940d1f49b3ca4..48d2dc01b96c28e35cd2981830306cdbef1d0302 100644 (file)
@@ -773,6 +773,7 @@ namespace Mono.CSharp {
                TypeSpec[] targs;
                TypeSpec[] ifaces_defined;
                TypeSpec effective_base;
+               MemberCache interface_cache;
 
                //
                // Creates type owned type parameter
@@ -882,6 +883,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public MemberCache InterfaceCache {
+                       get {
+                               return interface_cache;
+                       }
+               }
+
                //
                // Unexpanded interfaces list
                //
@@ -1351,13 +1358,27 @@ namespace Mono.CSharp {
                        // For a type parameter the membercache is the union of the sets of members of the types
                        // specified as a primary constraint or secondary constraint
                        //
+                       bool has_user_base_type = false;
                        if (BaseType.BuiltinType != BuiltinTypeSpec.Type.Object && BaseType.BuiltinType != BuiltinTypeSpec.Type.ValueType) {
                                cache.AddBaseType (BaseType);
+                               has_user_base_type = true;
                        }
 
                        if (InterfacesDefined != null) {
+                               var icache = cache;
+                               if (has_user_base_type) {
+                                       //
+                                       // type-parameter lookup rules are more complicated that other types lookup rules.
+                                       // Effective base class and its base types member have priority over interface
+                                       // constraints which means we cannot lookup interface members before class members
+                                       // hence we setup secondary cache for such cases.
+                                       //
+                                       interface_cache = new MemberCache ();
+                                       icache = interface_cache;
+                               }
+
                                foreach (var iface_type in InterfacesDefined) {
-                                       cache.AddInterface (iface_type);
+                                       icache.AddInterface (iface_type);
                                }
                        }
 
@@ -1370,8 +1391,14 @@ namespace Mono.CSharp {
                                        var ifaces = tps == null ? ta.Interfaces : tps.InterfacesDefined;
 
                                        if (ifaces != null) {
+                                               var icache = cache;
+                                               if (has_user_base_type) {
+                                                       interface_cache = new MemberCache ();
+                                                       icache = interface_cache;
+                                               }
+
                                                foreach (var iface_type in ifaces) {
-                                                       cache.AddInterface (iface_type);
+                                                       icache.AddInterface (iface_type);
                                                }
                                        }
                                }
index 8ada0a97071a327cd2c8433a09eb654d904633bd..27b7f586932c7d01e355f5bc2745512d5cb07a1a 100644 (file)
@@ -406,8 +406,13 @@ namespace Mono.CSharp {
 
                public static MemberSpec FindMember (TypeSpec container, MemberFilter filter, BindingRestriction restrictions)
                {
+                       if (filter.Kind == MemberKind.Method && container.Kind == MemberKind.TypeParameter && filter.Parameters == null)
+                               throw new NotSupportedException ("type parameters methods cannot be lookup up due to two stage setup");
+
+                       IList<MemberSpec> applicable;
+                       var top_container = container;
+
                        do {
-                               IList<MemberSpec> applicable;
                                if (container.MemberCache.member_hash.TryGetValue (filter.Name, out applicable)) {
                                        // Start from the end because interface members are in reverse order
                                        for (int i = applicable.Count - 1; i >= 0; i--) {
@@ -438,6 +443,26 @@ namespace Mono.CSharp {
                                container = container.BaseType;
                        } while (container != null);
 
+                       var tps = top_container as TypeParameterSpec;
+                       if (tps != null && tps.InterfaceCache != null) {
+                               if (tps.InterfaceCache.member_hash.TryGetValue (filter.Name, out applicable)) {
+                                       for (int i = applicable.Count - 1; i >= 0; i--) {
+                                               var entry = applicable [i];
+
+                                               if ((restrictions & BindingRestriction.NoAccessors) != 0 && entry.IsAccessor)
+                                                       continue;
+
+                                               if ((restrictions & BindingRestriction.OverrideOnly) != 0 && (entry.Modifiers & Modifiers.OVERRIDE) == 0)
+                                                       continue;
+
+                                               if (!filter.Equals (entry))
+                                                       continue;
+
+                                               return entry;
+                                       }
+                               }
+                       }
+
                        return null;
                }
 
@@ -450,9 +475,9 @@ namespace Mono.CSharp {
                //
                public static IList<MemberSpec> FindMembers (TypeSpec container, string name, bool declaredOnlyClass)
                {
-                       IList<MemberSpec> applicable;
-
                        do {
+                               IList<MemberSpec> applicable;
+                               
                                if (container.MemberCache.member_hash.TryGetValue (name, out applicable) || declaredOnlyClass)
                                        return applicable;
 
@@ -462,6 +487,17 @@ namespace Mono.CSharp {
                        return null;
                }
 
+               public static IList<MemberSpec> FindInterfaceMembers (TypeParameterSpec typeParameter, string name)
+               {
+                       if (typeParameter.InterfaceCache != null) {
+                               IList<MemberSpec> applicable;
+                               typeParameter.InterfaceCache.member_hash.TryGetValue (name, out applicable);
+                               return applicable;
+                       }
+
+                       return null;
+               }
+
                //
                // Finds the nested type in container
                //
index fb02370dbb32cd2317827d323637b370d01e0048..696bde556c820ad00f9d206bac897e80c10ee470 100644 (file)
@@ -109,7 +109,6 @@ namespace Mono.CSharp
                                        var imported = MemberDefinition as ImportedTypeDefinition;
                                        if (imported != null && Kind != MemberKind.MissingType)
                                                imported.DefineInterfaces (this);
-
                                }
 
                                return ifaces;
@@ -1603,6 +1602,12 @@ namespace Mono.CSharp
 
                public TypeSpec Element { get; private set; }
 
+               public override IList<TypeSpec> Interfaces {
+                       set {
+                               throw new NotSupportedException ();
+                       }
+               }
+
                bool ITypeDefinition.IsComImport {
                        get {
                                return false;
@@ -1777,13 +1782,19 @@ namespace Mono.CSharp
                readonly int rank;
                readonly ModuleContainer module;
 
-               private ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
+               ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
                        : base (MemberKind.ArrayType, element, null)
                {
                        this.module = module;
                        this.rank = rank;
                }
 
+               public override IList<TypeSpec> Interfaces {
+                       get {
+                               return BaseType.Interfaces;
+                       }
+               }
+
                public int Rank {
                        get {
                                return rank;
@@ -1926,7 +1937,6 @@ namespace Mono.CSharp
                        if (!module.ArrayTypesCache.TryGetValue (key, out ac)) {
                                ac = new ArrayContainer (module, element, rank);
                                ac.BaseType = module.Compiler.BuiltinTypes.Array;
-                               ac.Interfaces = ac.BaseType.Interfaces;
 
                                module.ArrayTypesCache.Add (key, ac);
                        }
@@ -1942,11 +1952,17 @@ namespace Mono.CSharp
 
        class ReferenceContainer : ElementTypeSpec
        {
-               private ReferenceContainer (TypeSpec element)
+               ReferenceContainer (TypeSpec element)
                        : base (MemberKind.Class, element, null)        // TODO: Kind.Class is most likely wrong
                {
                }
 
+               public override IList<TypeSpec> Interfaces {
+                       get {
+                               return null;
+                       }
+               }
+
                public override MetaType GetMetaInfo ()
                {
                        if (info == null) {
@@ -1977,6 +1993,12 @@ namespace Mono.CSharp
                        state &= ~StateFlags.CLSCompliant_Undetected;
                }
 
+               public override IList<TypeSpec> Interfaces {
+                       get {
+                               return null;
+                       }
+               }
+
                public override MetaType GetMetaInfo ()
                {
                        if (info == null) {
diff --git a/mcs/tests/gtest-639.cs b/mcs/tests/gtest-639.cs
new file mode 100644 (file)
index 0000000..afc0b20
--- /dev/null
@@ -0,0 +1,47 @@
+class A<T> where T : CB, IA
+{
+       void Foo (T t)
+       {
+               t.Prop = 3;
+               long l = t.Prop2;
+               t["1"] = "2";
+       }
+}
+
+class A2<T, U> 
+       where T : CB, U
+       where U : IA
+{
+       void Foo (T t)
+       {
+               t.Prop = 3;
+               long l = t.Prop2;
+               t["1"] = "2";
+       }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+       public int Prop { get; set; }
+
+       public string this [byte b] { get { return ""; } }
+}
+
+interface IA
+{
+       string Prop { get; set; }
+       long Prop2 { get; }
+
+       string this [string b] { get; set; }
+}
+
+class X
+{
+       public static void Main ()
+       {
+       }
+}
\ No newline at end of file
index 5d65a14e47979efc27d2accaa0b8f36367c611c2..2ef20e19608c53fa53918153e1d01fa2feacff8b 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-639.cs">
+    <type name="A`1[T]">
+      <method name="Void Foo(T)" attrs="129">
+        <size>53</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="CB">
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="CA">
+      <method name="Int32 get_Prop()" attrs="2182">
+        <size>14</size>
+      </method>
+      <method name="Void set_Prop(Int32)" attrs="2182">
+        <size>8</size>
+      </method>
+      <method name="System.String get_Item(Byte)" attrs="2182">
+        <size>14</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X">
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="A2`2[T,U]">
+      <method name="Void Foo(T)" attrs="129">
+        <size>53</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-anontype-01.cs">
     <type name="Test">
       <method name="Int32 Main()" attrs="150">
index 448232dff9ca550e7c0f81a70e5b9b23dc2b1d55..aa58ea1614f76dde7cc51478b3cc0a73b7991b40 100644 (file)
@@ -42,6 +42,8 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout, gboolean alertab
        ret = mono_w32handle_wait_one (handle, timeout, alertable);
        if (ret == MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
                return WAIT_OBJECT_0;
+       else if (ret == MONO_W32HANDLE_WAIT_RET_ABANDONED_0)
+               return WAIT_ABANDONED_0;
        else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
                return WAIT_IO_COMPLETION;
        else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
@@ -96,6 +98,8 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
        ret = mono_w32handle_signal_and_wait (signal_handle, wait, timeout, alertable);
        if (ret == MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
                return WAIT_OBJECT_0;
+       else if (ret == MONO_W32HANDLE_WAIT_RET_ABANDONED_0)
+               return WAIT_ABANDONED_0;
        else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
                return WAIT_IO_COMPLETION;
        else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
@@ -143,8 +147,10 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
        MonoW32HandleWaitRet ret;
 
        ret = mono_w32handle_wait_multiple (handles, numobjects, waitall, timeout, alertable);
-       if (ret >= MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
+       if (ret >= MONO_W32HANDLE_WAIT_RET_SUCCESS_0 && ret <= MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + numobjects - 1)
                return WAIT_OBJECT_0 + (ret - MONO_W32HANDLE_WAIT_RET_SUCCESS_0);
+       else if (ret >= MONO_W32HANDLE_WAIT_RET_ABANDONED_0 && ret <= MONO_W32HANDLE_WAIT_RET_ABANDONED_0 + numobjects - 1)
+               return WAIT_ABANDONED_0 + (ret - MONO_W32HANDLE_WAIT_RET_ABANDONED_0);
        else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
                return WAIT_IO_COMPLETION;
        else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
index f19773b6a2ffa8e1c1bafb1ea9a866b3b7e049c2..3b8d92bb84dcb72359e34fdeece13d464bef01b4 100644 (file)
@@ -225,6 +225,7 @@ common_sources = \
        handle.c        \
        handle.h        \
        w32mutex.h      \
+       w32mutex-utils.h        \
        w32semaphore.h  \
        w32event.h      \
        w32handle-namespace.h   \
index 174b4c9f28b285009c4ef3e353d8ee56c370c8c7..789eb27977ddd0eb1456a3d00a6a1bdacf7fa5d0 100644 (file)
@@ -58,6 +58,7 @@
 #include <mono/metadata/tokentype.h>
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/abi-details.h>
 #include <mono/utils/mono-uri.h>
 #include <mono/utils/mono-logger-internals.h>
 #include <mono/utils/mono-path.h>
@@ -343,8 +344,14 @@ mono_check_corlib_version (void)
        int version = mono_get_corlib_version ();
        if (version != MONO_CORLIB_VERSION)
                return g_strdup_printf ("expected corlib version %d, found %d.", MONO_CORLIB_VERSION, version);
-       else
-               return NULL;
+
+       /* Check that the managed and unmanaged layout of MonoInternalThread matches */
+       guint32 native_offset = (guint32) MONO_STRUCT_OFFSET (MonoInternalThread, last);
+       guint32 managed_offset = mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last"));
+       if (native_offset != managed_offset)
+               return g_strdup_printf ("expected InternalThread.last field offset %u, found %u. See InternalThread.last comment", native_offset, managed_offset);
+
+       return NULL;
 }
 
 /**
@@ -1934,20 +1941,6 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
        return NULL;
 }
 
-static gboolean
-prevent_running_reference_assembly (MonoAssembly *ass, MonoError *error)
-{
-       mono_error_init (error);
-       gboolean refasm = mono_assembly_get_reference_assembly_attribute (ass, error);
-       if (!is_ok (error))
-               return TRUE;
-       if (refasm) {
-               mono_error_set_bad_image (error, ass->image, "Could not load file or assembly or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context.\n");
-               return TRUE;
-       }
-       return FALSE;
-}
-
 MonoReflectionAssembly *
 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean refOnly)
 {
@@ -1956,40 +1949,37 @@ ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean re
        MonoDomain *domain = mono_domain_get ();
        char *name, *filename;
        MonoImageOpenStatus status = MONO_IMAGE_OK;
-       MonoAssembly *ass = NULL;
-
-       name = NULL;
-       result = NULL;
-
-       mono_error_init (&error);
+       MonoAssembly *ass;
 
        if (fname == NULL) {
-               mono_error_set_argument_null (&error, "assemblyFile", "");
-               goto leave;
+               MonoException *exc = mono_get_exception_argument_null ("assemblyFile");
+               mono_set_pending_exception (exc);
+               return NULL;
        }
                
        name = filename = mono_string_to_utf8_checked (fname, &error);
-       if (!is_ok (&error))
-               goto leave;
+       if (mono_error_set_pending_exception (&error))
+               return NULL;
        
        ass = mono_assembly_open_full (filename, &status, refOnly);
        
        if (!ass) {
+               MonoException *exc;
+
                if (status == MONO_IMAGE_IMAGE_INVALID)
-                       mono_error_set_bad_image_name (&error, name, "");
+                       exc = mono_get_exception_bad_image_format2 (NULL, fname);
                else
-                       mono_error_set_exception_instance (&error, mono_get_exception_file_not_found2 (NULL, fname));
-               goto leave;
+                       exc = mono_get_exception_file_not_found2 (NULL, fname);
+               g_free (name);
+               mono_set_pending_exception (exc);
+               return NULL;
        }
 
-       if (!refOnly && prevent_running_reference_assembly (ass, &error))
-               goto leave;
+       g_free (name);
 
        result = mono_assembly_get_object_checked (domain, ass, &error);
-
-leave:
-       mono_error_set_pending_exception (&error);
-       g_free (name);
+       if (!result)
+               mono_error_set_pending_exception (&error);
        return result;
 }
 
@@ -2024,11 +2014,6 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
                return NULL; 
        }
 
-       if (!refonly && prevent_running_reference_assembly (ass, &error)) {
-               mono_error_set_pending_exception (&error);
-               return NULL;
-       }
-
        refass = mono_assembly_get_object_checked (domain, ass, &error);
        if (!refass)
                mono_error_set_pending_exception (&error);
@@ -2046,7 +2031,7 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *assRef,
        MonoAssembly *ass;
        MonoAssemblyName aname;
        MonoReflectionAssembly *refass = NULL;
-       gchar *name = NULL;
+       gchar *name;
        gboolean parsed;
 
        g_assert (assRef);
@@ -2055,13 +2040,16 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *assRef,
        if (mono_error_set_pending_exception (&error))
                return NULL;
        parsed = mono_assembly_name_parse (name, &aname);
+       g_free (name);
 
        if (!parsed) {
                /* This is a parse error... */
                if (!refOnly) {
                        refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
-                       if (!is_ok (&error))
-                               goto leave;
+                       if (!mono_error_ok (&error)) {
+                               mono_error_set_pending_exception (&error);
+                               return NULL;
+                       }
                }
                return refass;
        }
@@ -2073,31 +2061,25 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *assRef,
                /* MS.NET doesn't seem to call the assembly resolve handler for refonly assemblies */
                if (!refOnly) {
                        refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
-                       if (!is_ok (&error))
-                               goto leave;
+                       if (!mono_error_ok (&error)) {
+                               mono_error_set_pending_exception (&error);
+                               return NULL;
+                       }
                }
                else
                        refass = NULL;
-               if (!refass)
-                       goto leave;
-               ass = refass->assembly;
+               if (!refass) {
+                       return NULL;
+               }
        }
 
-       if (!refOnly && prevent_running_reference_assembly (ass, &error))
-               goto leave;
-
-       g_assert (ass);
-       if (refass == NULL) {
+       if (refass == NULL)
                refass = mono_assembly_get_object_checked (domain, ass, &error);
-               if (!is_ok (&error))
-                       goto leave;
-       }
 
-       MONO_OBJECT_SETREF (refass, evidence, evidence);
-
-leave:
-       g_free (name);
-       mono_error_set_pending_exception (&error);
+       if (refass == NULL)
+               mono_error_set_pending_exception (&error);
+       else
+               MONO_OBJECT_SETREF (refass, evidence, evidence);
        return refass;
 }
 
index 96025d9d06a775c5539634654ff4fedeb998bc18..2510a4a79d3e7d2664703f113f9dcc4b6401b8a8 100644 (file)
@@ -1191,23 +1191,6 @@ mono_assembly_load_reference (MonoImage *image, int index)
                                   aname.major, aname.minor, aname.build, aname.revision,
                                   strlen ((char*)aname.public_key_token) == 0 ? "(none)" : (char*)aname.public_key_token, extra_msg);
                g_free (extra_msg);
-
-       } else if (!image->assembly->ref_only) {
-               MonoError error;
-               if (mono_assembly_get_reference_assembly_attribute (reference, &error)) {
-                       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY, "The following reference assembly assembly referenced from %s was not loaded.  Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context:\n"
-                                   "     Assembly:   %s    (assemblyref_index=%d)\n"
-                                   "     Version:    %d.%d.%d.%d\n"
-                                   "     Public Key: %s\n",
-                                   image->name, aname.name, index,
-                                   aname.major, aname.minor, aname.build, aname.revision,
-                                   strlen ((char*)aname.public_key_token) == 0 ? "(none)" : (char*)aname.public_key_token);
-                       reference = NULL; /* don't load reference assemblies for execution */
-               }
-               if (!is_ok (&error)) {
-                       reference = NULL;
-                       mono_error_cleanup (&error);
-               }
        }
 
        mono_assemblies_lock ();
index 7ec6ee9186e119598af72817dfe7df1bfd7e203f..a419af381492313e250c7887c0217c26ea071269 100644 (file)
@@ -5591,7 +5591,6 @@ mono_class_setup_parent (MonoClass *klass, MonoClass *parent)
                        /* set the parent to something useful and safe, but mark the type as broken */
                        parent = mono_defaults.object_class;
                        mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
-                       g_assert (parent);
                }
 
                klass->parent = parent;
index 7be40e5cee773bdc08483ee625f7772f4067c978..bb40725ac1f401e085deccb0dc901a0b083a6ecd 100644 (file)
@@ -816,16 +816,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
 
        mono_profiler_appdomain_name (domain, domain->friendly_name);
 
-       /* Have to do this quite late so that we at least have System.Object */
-       MonoError custom_attr_error;
-       if (mono_assembly_get_reference_assembly_attribute (ass, &custom_attr_error)) {
-               char *corlib_file = g_build_filename (mono_assembly_getrootdir (), "mono", current_runtime->framework_version, "mscorlib.dll", NULL);
-               g_print ("Could not load file or assembly %s. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context.", corlib_file);
-               g_free (corlib_file);
-               exit (1);
-       }
-       mono_error_assert_ok (&custom_attr_error);
-
        return domain;
 }
 
index ab3a11ea5f15e329d54147c82839ff1f3909a639..8d8510f5fb0edca44e597ccf064b725d2ea02ffc 100644 (file)
@@ -1760,19 +1760,9 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
        THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") returning %d", __func__, mono_native_thread_id_get (), ret));
 
        mono_error_set_pending_exception (&error);
-       /*
-        * These need to be here.  See MSDN dos on WaitForMultipleObjects.
-        */
-       if (ret >= WAIT_OBJECT_0 && ret <= WAIT_OBJECT_0 + numhandles - 1) {
-               return map_native_wait_result_to_managed (ret - WAIT_OBJECT_0);
-       }
-       else if (ret >= WAIT_ABANDONED_0 && ret <= WAIT_ABANDONED_0 + numhandles - 1) {
-               return map_native_wait_result_to_managed (ret - WAIT_ABANDONED_0);
-       }
-       else {
-               /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
-               return map_native_wait_result_to_managed (ret);
-       }
+
+       /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+       return map_native_wait_result_to_managed (ret);
 }
 
 gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms)
@@ -2849,9 +2839,6 @@ void mono_thread_init (MonoThreadStartCB start_cb,
         * anything up.
         */
        GetCurrentProcess ();
-
-       /* Check that the managed and unmanaged layout of MonoInternalThread matches */
-       g_assert (MONO_STRUCT_OFFSET (MonoInternalThread, last) == mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last")));
 }
 
 void mono_thread_cleanup (void)
index 237ea0f7507a20362e889ab23bf84b1c60476aff..5644ce7d27b1eb708aa47933e1acca5b0be7b44d 100644 (file)
@@ -24,11 +24,13 @@ struct MonoW32HandleNamedEvent {
        MonoW32HandleNamespace sharedns;
 };
 
-static gboolean event_handle_own (gpointer handle, MonoW32HandleType type)
+static gboolean event_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
 {
        MonoW32HandleEvent *event_handle;
        gboolean ok;
 
+       *statuscode = WAIT_OBJECT_0;
+
        ok = mono_w32handle_lookup (handle, type, (gpointer *)&event_handle);
        if (!ok) {
                g_warning ("%s: error looking up %s handle %p",
@@ -55,9 +57,9 @@ static void event_signal(gpointer handle)
        ves_icall_System_Threading_Events_SetEvent_internal (handle);
 }
 
-static gboolean event_own (gpointer handle)
+static gboolean event_own (gpointer handle, guint32 *statuscode)
 {
-       return event_handle_own (handle, MONO_W32HANDLE_EVENT);
+       return event_handle_own (handle, MONO_W32HANDLE_EVENT, statuscode);
 }
 
 static void namedevent_signal (gpointer handle)
@@ -66,9 +68,9 @@ static void namedevent_signal (gpointer handle)
 }
 
 /* NB, always called with the shared handle lock held */
-static gboolean namedevent_own (gpointer handle)
+static gboolean namedevent_own (gpointer handle, guint32 *statuscode)
 {
-       return event_handle_own (handle, MONO_W32HANDLE_NAMEDEVENT);
+       return event_handle_own (handle, MONO_W32HANDLE_NAMEDEVENT, statuscode);
 }
 
 static void event_details (gpointer data)
index 16cddd000fd36a65ae5c0acd1f5febf29c9c93b7..5ffdda1af9403cbd99b089d174ae4c6058a73028 100644 (file)
@@ -21,6 +21,7 @@
 typedef struct {
        MonoNativeThreadId tid;
        guint32 recursion;
+       gboolean abandoned;
 } MonoW32HandleMutex;
 
 struct MonoW32HandleNamedMutex {
@@ -29,10 +30,12 @@ struct MonoW32HandleNamedMutex {
 };
 
 static gboolean
-mutex_handle_own (gpointer handle, MonoW32HandleType type)
+mutex_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
 {
        MonoW32HandleMutex *mutex_handle;
 
+       *statuscode = WAIT_OBJECT_0;
+
        if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
                g_warning ("%s: error looking up %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
                return FALSE;
@@ -45,6 +48,11 @@ mutex_handle_own (gpointer handle, MonoW32HandleType type)
 
        mutex_handle->tid = pthread_self ();
        mutex_handle->recursion++;
+       if (mutex_handle->abandoned) {
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p was abandoned", __func__, handle);
+               mutex_handle->abandoned = FALSE;
+               *statuscode = WAIT_ABANDONED_0;
+       }
 
        mono_w32handle_set_signal_state (handle, FALSE, FALSE);
 
@@ -80,9 +88,9 @@ static void mutex_signal(gpointer handle)
        ves_icall_System_Threading_Mutex_ReleaseMutex_internal (handle);
 }
 
-static gboolean mutex_own (gpointer handle)
+static gboolean mutex_own (gpointer handle, guint32 *statuscode)
 {
-       return mutex_handle_own (handle, MONO_W32HANDLE_MUTEX);
+       return mutex_handle_own (handle, MONO_W32HANDLE_MUTEX, statuscode);
 }
 
 static gboolean mutex_is_owned (gpointer handle)
@@ -97,9 +105,9 @@ static void namedmutex_signal (gpointer handle)
 }
 
 /* NB, always called with the shared handle lock held */
-static gboolean namedmutex_own (gpointer handle)
+static gboolean namedmutex_own (gpointer handle, guint32 *statuscode)
 {
-       return mutex_handle_own (handle, MONO_W32HANDLE_NAMEDMUTEX);
+       return mutex_handle_own (handle, MONO_W32HANDLE_NAMEDMUTEX, statuscode);
 }
 
 static gboolean namedmutex_is_owned (gpointer handle)
@@ -223,9 +231,11 @@ static gpointer mutex_handle_create (MonoW32HandleMutex *mutex_handle, MonoW32Ha
 {
        gpointer handle;
        int thr_ret;
+       guint32 statuscode;
 
        mutex_handle->tid = 0;
        mutex_handle->recursion = 0;
+       mutex_handle->abandoned = FALSE;
 
        handle = mono_w32handle_new (type, mutex_handle);
        if (handle == INVALID_HANDLE_VALUE) {
@@ -239,7 +249,7 @@ static gpointer mutex_handle_create (MonoW32HandleMutex *mutex_handle, MonoW32Ha
        g_assert (thr_ret == 0);
 
        if (owned)
-               mutex_handle_own (handle, type);
+               mutex_handle_own (handle, type, &statuscode);
        else
                mono_w32handle_set_signal_state (handle, TRUE, FALSE);
 
@@ -361,7 +371,10 @@ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
 
        tid = pthread_self ();
 
-       if (!pthread_equal (mutex_handle->tid, tid)) {
+       if (mutex_handle->abandoned) {
+               // The Win32 ReleaseMutex() function returns TRUE for abandoned mutexes
+               ret = TRUE;
+       } else if (!pthread_equal (mutex_handle->tid, tid)) {
                ret = FALSE;
 
                mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: we don't own %s handle %p (owned by %ld, me %ld)",
@@ -457,6 +470,7 @@ mono_w32mutex_abandon (gpointer handle, MonoNativeThreadId tid)
        if (pthread_equal (mutex_handle->tid, tid)) {
                mutex_handle->recursion = 0;
                mutex_handle->tid = 0;
+               mutex_handle->abandoned = TRUE;
 
                mono_w32handle_set_signal_state (handle, TRUE, FALSE);
 
index 54abc039e9547285708c6a1cccad944fe2a01e4a..1f99d8fdff35769bebde8d60c0a742256be27a7d 100644 (file)
@@ -24,10 +24,12 @@ struct MonoW32HandleNamedSemaphore {
        MonoW32HandleNamespace sharedns;
 };
 
-static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type)
+static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
 {
        MonoW32HandleSemaphore *sem_handle;
 
+       *statuscode = WAIT_OBJECT_0;
+
        if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
                g_warning ("%s: error looking up %s handle %p",
                        __func__, mono_w32handle_ops_typename (type), handle);
@@ -50,9 +52,9 @@ static void sema_signal(gpointer handle)
        ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal(handle, 1, NULL);
 }
 
-static gboolean sema_own (gpointer handle)
+static gboolean sema_own (gpointer handle, guint32 *statuscode)
 {
-       return sem_handle_own (handle, MONO_W32HANDLE_SEM);
+       return sem_handle_own (handle, MONO_W32HANDLE_SEM, statuscode);
 }
 
 static void namedsema_signal (gpointer handle)
@@ -61,9 +63,9 @@ static void namedsema_signal (gpointer handle)
 }
 
 /* NB, always called with the shared handle lock held */
-static gboolean namedsema_own (gpointer handle)
+static gboolean namedsema_own (gpointer handle, guint32 *statuscode)
 {
-       return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM);
+       return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM, statuscode);
 }
 
 static void sema_details (gpointer data)
index 4723e49b117d17247b5a5c1b1c7370c18ed18068..4ed38f2b58312bd22f6697f0ad9bd2d72be8e261 100644 (file)
@@ -473,13 +473,13 @@ allocate_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_clas
        return result;
 }
 
-inline gboolean
+static inline gboolean
 allocate_parameter_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_class, guint32 arg_size, guint32 *current_int_reg, guint32 *current_float_reg)
 {
        return allocate_register_for_valuetype_win64 (arg_info, arg_class, arg_size, param_regs, PARAM_REGS, float_param_regs, FLOAT_PARAM_REGS, current_int_reg, current_float_reg);
 }
 
-inline gboolean
+static inline gboolean
 allocate_return_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_class, guint32 arg_size, guint32 *current_int_reg, guint32 *current_float_reg)
 {
        return allocate_register_for_valuetype_win64 (arg_info, arg_class, arg_size, return_regs, RETURN_REGS, float_return_regs, FLOAT_RETURN_REGS, current_int_reg, current_float_reg);
index e6cdc49ff1484d8fba1bc1f78fdcabe9ebb3932e..1a83dfa5898c2ef363148e7340cbeb8c665b3609 100644 (file)
@@ -468,7 +468,6 @@ BASE_TEST_CS_SRC_UNIVERSAL=         \
        bug-29585.cs    \
        priority.cs     \
        abort-cctor.cs  \
-       reference-loader.cs     \
        namedmutex-destroy-race.cs
 
 if INSTALL_MOBILE_STATIC
@@ -802,22 +801,18 @@ endif
 # but that need to be compiled
 PREREQ_IL_SRC=event-il.il module-cctor.il
 PREREQ_CS_SRC=
-PREREQ_IL_DLL_SRC=
-PREREQ_CS_DLL_SRC=TestingReferenceAssembly.cs TestingReferenceReferenceAssembly.cs
+PREREQ_IL_DLL_SRC=event-il.il module-cctor.il
+PREREQ_CS_DLL_SRC=
 
-PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe) \
-       $(PREREQ_IL_DLL_SRC:.il=.dll)
-PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe) \
-       $(PREREQ_CS_DLL_SRC:.cs=.dll)
+PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
+PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe)
 TESTSI_CS=$(TEST_CS_SRC:.cs=.exe)
 TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
 TESTBS=$(BENCHSRC:.cs=.exe)
 STRESS_TESTS=$(STRESS_TESTS_SRC:.cs=.exe)
 
-PREREQSI_IL_AOT=$(PREREQ_IL_SRC:.il=.exe$(PLATFORM_AOT_SUFFIX)) \
-               $(PREREQ_IL_DLL_SRC:.il=.dll$(PLATFORM_AOT_SUFFIX))
-PREREQSI_CS_AOT=$(PREREQ_CS_SRC:.cs=.exe$(PLATFORM_AOT_SUFFIX)) \
-               $(PREREQ_CS_DLL_SRC:.cs=.dll$(PLATFORM_AOT_SUFFIX))
+PREREQSI_IL_AOT=$(PREREQ_IL_SRC:.il=.exe$(PLATFORM_AOT_SUFFIX))
+PREREQSI_CS_AOT=$(PREREQ_CS_SRC:.cs=.exe$(PLATFORM_AOT_SUFFIX))
 
 EXTRA_DIST=test-driver test-runner.cs $(TEST_CS_SRC_DIST) $(TEST_IL_SRC) \
        $(BENCHSRC) $(STRESS_TESTS_SRC) stress-runner.pl $(PREREQ_IL_SRC) $(PREREQ_CS_SRC)
@@ -838,12 +833,6 @@ endif
 %.exe: %.cs $(TEST_DRIVER_DEPEND)
        $(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $<
 
-%.dll: %.cs
-       $(MCS) -r:System.dll -target:library -out:$@ $<
-
-TestingReferenceReferenceAssembly.dll: TestingReferenceReferenceAssembly.cs TestingReferenceAssembly.dll
-       $(MCS) -r:TestingReferenceAssembly.dll -target:library -out:$@ $<
-
 %.exe$(PLATFORM_AOT_SUFFIX): %.exe 
        $(RUNTIME) $(AOT_BUILD_FLAGS) $<
 
diff --git a/mono/tests/TestingReferenceAssembly.cs b/mono/tests/TestingReferenceAssembly.cs
deleted file mode 100644 (file)
index e68a2c8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: ReferenceAssemblyAttribute]
-
-public class X {
-       public int Y;
-}
diff --git a/mono/tests/TestingReferenceReferenceAssembly.cs b/mono/tests/TestingReferenceReferenceAssembly.cs
deleted file mode 100644 (file)
index 0acb6f1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// An assembly that refereces the TestingReferenceAssembly
-
-class Z : X {
-       public Z () {
-               Y = 1;
-       }
-}
diff --git a/mono/tests/reference-loader.cs b/mono/tests/reference-loader.cs
deleted file mode 100644 (file)
index 9cdda7a..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-//
-// reference-loader.cs:
-//
-//  Test for reference assembly loading
-
-using System;
-using System.IO;
-using System.Reflection;
-
-public class Tests {
-       public static int Main (string[] args)
-       {
-               return TestDriver.RunTests (typeof (Tests), args);
-       }
-
-       public static int test_0_loadFrom_reference ()
-       {
-               // Check that loading a reference assembly by filename for execution is an error
-               try {
-                       var a = Assembly.LoadFrom ("./TestingReferenceAssembly.dll");
-               } catch (BadImageFormatException exn) {
-                       // Console.Error.WriteLine ("exn was {0}", exn);
-                       return 0;
-               }
-               return 1;
-       }
-
-       public static int test_0_load_reference ()
-       {
-               // Check that loading a reference assembly for execution is an error
-               try {
-                       var an = new AssemblyName ("TestingReferenceAssembly");
-                       var a = Assembly.Load (an);
-               } catch (BadImageFormatException exn) {
-                       //Console.Error.WriteLine ("exn was {0}", exn);
-                       return 0;
-               } catch (FileNotFoundException exn) {
-                       Console.Error.WriteLine ("incorrect exn was {0}", exn);
-                       return 2;
-               }
-               return 1;
-       }
-
-       public static int test_0_reflection_load_reference ()
-       {
-               // Check that reflection-only loading a reference assembly is okay
-               var an = new AssemblyName ("TestingReferenceAssembly");
-               var a = Assembly.ReflectionOnlyLoad (an.FullName);
-               var t = a.GetType ("X");
-               var f = t.GetField ("Y");
-               if (f.FieldType.Equals (typeof (Int32)))
-                       return 0;
-               return 1;
-       }
-
-       public static int test_0_load_reference_asm_via_reference ()
-       {
-               // Check that loading an assembly that references a reference assembly doesn't succeed.
-               var an = new AssemblyName ("TestingReferenceReferenceAssembly");
-               try {
-                       var a = Assembly.Load (an);
-                       var t = a.GetType ("Z");
-               } catch (FileNotFoundException){
-                       return 0;
-               }
-               return 1;
-       }
-
-       public static int test_0_reflection_load_reference_asm_via_reference ()
-       {
-               // Check that reflection-only loading an assembly that
-               // references a reference assembly is okay.
-               var an = new AssemblyName ("TestingReferenceReferenceAssembly");
-               var a = Assembly.ReflectionOnlyLoad (an.FullName);
-               var t = a.GetType ("Z");
-               var f = t.GetField ("Y");
-               if (f.FieldType.Equals (typeof (Int32)))
-                       return 0;
-               return 1;
-       }
-
-
-       public static int test_0_load_reference_bytes ()
-       {
-               // Check that loading a reference assembly from a byte array for execution is an error
-               byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
-               try {
-                       var a = Assembly.Load (bs);
-               } catch (BadImageFormatException) {
-                       return 0;
-               } catch (FileNotFoundException exn) {
-                       Console.Error.WriteLine ("incorrect exn was {0}", exn);
-                       return 2;
-               }
-               return 1;
-       }
-
-       public static int test_0_reflection_load_reference_bytes ()
-       {
-               // Check that loading a reference assembly from a byte
-               // array for reflection only is okay.
-               byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
-               var a = Assembly.ReflectionOnlyLoad (bs);
-               var t = a.GetType ("X");
-               var f = t.GetField ("Y");
-               if (f.FieldType.Equals (typeof (Int32)))
-                       return 0;
-               return 1;
-       }
-
-}
index 1bd0a646054f2e7e7586ad1e8b46b4ce2c215969..cf631d04ffd1ffbab5ad389a20239da3fa6acf4a 100644 (file)
@@ -35,10 +35,10 @@ mono_coop_mutex_init_recursive (MonoCoopMutex *mutex)
        mono_os_mutex_init_recursive (&mutex->m);
 }
 
-static inline gint
+static inline void
 mono_coop_mutex_destroy (MonoCoopMutex *mutex)
 {
-       return mono_os_mutex_destroy (&mutex->m);
+       mono_os_mutex_destroy (&mutex->m);
 }
 
 static inline void
@@ -73,10 +73,10 @@ mono_coop_cond_init (MonoCoopCond *cond)
        mono_os_cond_init (&cond->c);
 }
 
-static inline gint
+static inline void
 mono_coop_cond_destroy (MonoCoopCond *cond)
 {
-       return mono_os_cond_destroy (&cond->c);
+       mono_os_cond_destroy (&cond->c);
 }
 
 static inline void
index 52cef09d84bcb8f84b3ed15d22b179ea516a94ef..cd33375894c1db0f95fdf61ae054c50043a18f2d 100644 (file)
@@ -76,16 +76,14 @@ mono_os_mutex_init_recursive (mono_mutex_t *mutex)
                g_error ("%s: pthread_mutexattr_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
 }
 
-static inline int
+static inline void
 mono_os_mutex_destroy (mono_mutex_t *mutex)
 {
        int res;
 
        res = pthread_mutex_destroy (mutex);
-       if (G_UNLIKELY (res != 0 && res != EBUSY))
+       if (G_UNLIKELY (res != 0))
                g_error ("%s: pthread_mutex_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
-
-       return res != 0 ? -1 : 0;
 }
 
 static inline void
@@ -130,16 +128,14 @@ mono_os_cond_init (mono_cond_t *cond)
                g_error ("%s: pthread_cond_init failed with \"%s\" (%d)", __func__, g_strerror (res), res);
 }
 
-static inline int
+static inline void
 mono_os_cond_destroy (mono_cond_t *cond)
 {
        int res;
 
        res = pthread_cond_destroy (cond);
-       if (G_UNLIKELY (res != 0 && res != EBUSY))
+       if (G_UNLIKELY (res != 0))
                g_error ("%s: pthread_cond_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
-
-       return res != 0 ? -1 : 0;
 }
 
 static inline void
@@ -296,11 +292,10 @@ mono_os_mutex_init_recursive (mono_mutex_t *mutex)
                g_error ("%s: InitializeCriticalSectionEx failed with error %d", __func__, GetLastError ());
 }
 
-static inline int
+static inline void
 mono_os_mutex_destroy (mono_mutex_t *mutex)
 {
        DeleteCriticalSection (mutex);
-       return 0;
 }
 
 static inline void
@@ -327,11 +322,10 @@ mono_os_cond_init (mono_cond_t *cond)
        InitializeConditionVariable (cond);
 }
 
-static inline int
+static inline void
 mono_os_cond_destroy (mono_cond_t *cond)
 {
        /* Beauty of win32 API: do not destroy it */
-       return 0;
 }
 
 static inline void
index 3003476a4436e17463034089732fdfceba047518..fc3d1a33f368212a5f1ed9c4272c4713a70acdeb 100644 (file)
@@ -322,8 +322,6 @@ mono_w32handle_init (void)
        initialized = TRUE;
 }
 
-static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_busy_handles);
-
 void
 mono_w32handle_cleanup (void)
 {
@@ -345,7 +343,7 @@ mono_w32handle_cleanup (void)
                        gpointer handle = GINT_TO_POINTER (i*HANDLE_PER_SLOT+j);
 
                        for(k = handle_data->ref; k > 0; k--) {
-                               mono_w32handle_unref_full (handle, TRUE);
+                               mono_w32handle_unref (handle);
                        }
                }
        }
@@ -566,7 +564,7 @@ mono_w32handle_foreach (gboolean (*on_each)(gpointer handle, gpointer data, gpoi
                        handle = GUINT_TO_POINTER (i * HANDLE_PER_SLOT + k);
 
                        if (!mono_w32handle_ref_core (handle, handle_data)) {
-                               /* we are racing with mono_w32handle_unref_full:
+                               /* we are racing with mono_w32handle_unref:
                                 *  the handle ref has been decremented, but it
                                 *  hasn't yet been destroyed. */
                                continue;
@@ -682,7 +680,7 @@ void mono_w32handle_ref (gpointer handle)
        MonoW32HandleBase *handle_data;
 
        if (!mono_w32handle_lookup_data (handle, &handle_data)) {
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Attempting to ref invalid private handle %p", __func__, handle);
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to ref handle %p, unknown handle", __func__, handle);
                return;
        }
 
@@ -693,21 +691,21 @@ void mono_w32handle_ref (gpointer handle)
 static void (*_wapi_handle_ops_get_close_func (MonoW32HandleType type))(gpointer, gpointer);
 
 /* The handle must not be locked on entry to this function */
-static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_busy_handles)
+void
+mono_w32handle_unref (gpointer handle)
 {
        MonoW32HandleBase *handle_data;
-       gboolean destroy = FALSE, early_exit = FALSE;
-       int thr_ret;
+       gboolean destroy;
 
        if (!mono_w32handle_lookup_data (handle, &handle_data)) {
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Attempting to unref invalid private handle %p",
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to unref handle %p, unknown handle",
                        __func__, handle);
                return;
        }
 
        destroy = mono_w32handle_unref_core (handle, handle_data, 1);
 
-       if(destroy==TRUE) {
+       if (destroy) {
                /* Need to copy the handle info, reset the slot in the
                 * array, and _only then_ call the close function to
                 * avoid race conditions (eg file descriptors being
@@ -723,35 +721,15 @@ static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_
 
                mono_os_mutex_lock (&scan_mutex);
 
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Destroying handle %p", __func__, handle);
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: destroy %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
 
-               /* Destroy the mutex and cond var.  We hope nobody
-                * tried to grab them between the handle unlock and
-                * now, but pthreads doesn't have a
-                * "unlock_and_destroy" atomic function.
-                */
-               thr_ret = mono_os_mutex_destroy (&handle_data->signal_mutex);
-               /*WARNING gross hack to make cleanup not crash when exiting without the whole runtime teardown.*/
-               if (thr_ret == EBUSY && ignore_private_busy_handles) {
-                       early_exit = TRUE;
-               } else {
-                       if (thr_ret != 0)
-                               g_error ("Error destroying handle %p mutex due to %d\n", handle, thr_ret);
-
-                       thr_ret = mono_os_cond_destroy (&handle_data->signal_cond);
-                       if (thr_ret == EBUSY && ignore_private_busy_handles)
-                               early_exit = TRUE;
-                       else if (thr_ret != 0)
-                               g_error ("Error destroying handle %p cond var due to %d\n", handle, thr_ret);
-               }
+               mono_os_mutex_destroy (&handle_data->signal_mutex);
+               mono_os_cond_destroy (&handle_data->signal_cond);
 
                memset (handle_data, 0, sizeof (MonoW32HandleBase));
 
                mono_os_mutex_unlock (&scan_mutex);
 
-               if (early_exit)
-                       return;
-
                close_func = _wapi_handle_ops_get_close_func (type);
                if (close_func != NULL) {
                        close_func (handle, handle_specific);
@@ -761,11 +739,6 @@ static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_
        }
 }
 
-void mono_w32handle_unref (gpointer handle)
-{
-       mono_w32handle_unref_full (handle, FALSE);
-}
-
 void
 mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops)
 {
@@ -861,7 +834,7 @@ void mono_w32handle_ops_signal (gpointer handle)
        }
 }
 
-gboolean mono_w32handle_ops_own (gpointer handle)
+gboolean mono_w32handle_ops_own (gpointer handle, guint32 *statuscode)
 {
        MonoW32HandleBase *handle_data;
        MonoW32HandleType type;
@@ -873,7 +846,7 @@ gboolean mono_w32handle_ops_own (gpointer handle)
        type = handle_data->type;
 
        if (handle_ops[type] != NULL && handle_ops[type]->own_handle != NULL) {
-               return(handle_ops[type]->own_handle (handle));
+               return(handle_ops[type]->own_handle (handle, statuscode));
        } else {
                return(FALSE);
        }
@@ -1167,22 +1140,24 @@ void mono_w32handle_dump (void)
 }
 
 static gboolean
-own_if_signalled (gpointer handle)
+own_if_signalled (gpointer handle, guint32 *statuscode)
 {
        if (!mono_w32handle_issignalled (handle))
                return FALSE;
 
-       mono_w32handle_ops_own (handle);
+       *statuscode = WAIT_OBJECT_0;
+       mono_w32handle_ops_own (handle, statuscode);
        return TRUE;
 }
 
 static gboolean
-own_if_owned( gpointer handle)
+own_if_owned( gpointer handle, guint32 *statuscode)
 {
        if (!mono_w32handle_ops_isowned (handle))
                return FALSE;
 
-       mono_w32handle_ops_own (handle);
+       *statuscode = WAIT_OBJECT_0;
+       mono_w32handle_ops_own (handle, statuscode);
        return TRUE;
 }
 
@@ -1193,6 +1168,7 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        gboolean alerted;
        gint64 start;
        gint thr_ret;
+       guint32 statuscode = 0;
 
        alerted = FALSE;
 
@@ -1204,6 +1180,9 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
                case WAIT_OBJECT_0:
                        ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
                        break;
+               case WAIT_ABANDONED_0:
+                       ret = MONO_W32HANDLE_WAIT_RET_ABANDONED_0;
+                       break;
                case WAIT_IO_COMPLETION:
                        ret = MONO_W32HANDLE_WAIT_RET_ALERTED;
                        break;
@@ -1234,11 +1213,11 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        g_assert (thr_ret == 0);
 
        if (mono_w32handle_test_capabilities (handle, MONO_W32HANDLE_CAP_OWN)) {
-               if (own_if_owned (handle)) {
+               if (own_if_owned (handle, &statuscode)) {
                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p already owned",
                                __func__, handle);
 
-                       ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+                       ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
                        goto done;
                }
        }
@@ -1249,11 +1228,11 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        for (;;) {
                gint waited;
 
-               if (own_if_signalled (handle)) {
+               if (own_if_signalled (handle, &statuscode)) {
                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p signalled",
                                __func__, handle);
 
-                       ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+                       ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
                        goto done;
                }
 
@@ -1299,6 +1278,7 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital
        gint i, thr_ret;
        gint64 start;
        gpointer handles_sorted [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS];
+       guint32 statuscodes [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS] = {0};
 
        if (nhandles == 0)
                return MONO_W32HANDLE_WAIT_RET_FAILED;
@@ -1381,13 +1361,19 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital
 
                if (signalled) {
                        for (i = 0; i < nhandles; i++)
-                               own_if_signalled (handles [i]);
+                               own_if_signalled (handles [i], &statuscodes [i]);
                }
 
                mono_w32handle_unlock_handles (handles, nhandles);
 
                if (signalled) {
                        ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + lowest;
+                       for (i = lowest; i < nhandles; i++) {
+                               if (statuscodes [i] == WAIT_ABANDONED_0) {
+                                       ret = MONO_W32HANDLE_WAIT_RET_ABANDONED_0 + lowest;
+                                       break;
+                               }
+                       }
                        goto done;
                }
 
@@ -1474,6 +1460,7 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        gint64 start;
        gboolean alerted;
        gint thr_ret;
+       guint32 statuscode = 0;
 
        alerted = FALSE;
 
@@ -1493,11 +1480,11 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        mono_w32handle_ops_signal (signal_handle);
 
        if (mono_w32handle_test_capabilities (wait_handle, MONO_W32HANDLE_CAP_OWN)) {
-               if (own_if_owned (wait_handle)) {
+               if (own_if_owned (wait_handle, &statuscode)) {
                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p already owned",
                                __func__, wait_handle);
 
-                       ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+                       ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
                        goto done;
                }
        }
@@ -1508,11 +1495,11 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        for (;;) {
                gint waited;
 
-               if (own_if_signalled (wait_handle)) {
+               if (own_if_signalled (wait_handle, &statuscode)) {
                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p signalled",
                                __func__, wait_handle);
 
-                       ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+                       ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
                        goto done;
                }
 
index 27c403ce39dde47cb9563be14b0d5d58ecc5bdb0..de65da19e9fb9c106f45097e5a1ff1ebf6042cf3 100644 (file)
@@ -39,8 +39,10 @@ typedef struct
        /* Called by WaitForSingleObject and WaitForMultipleObjects,
         * with the handle locked (shared handles aren't locked.)
         * Returns TRUE if ownership was established, false otherwise.
+        * If TRUE, *statuscode contains a status code such as
+        * WAIT_OBJECT_0 or WAIT_ABANDONED_0.
         */
-       gboolean (*own_handle)(gpointer handle);
+       gboolean (*own_handle)(gpointer handle, guint32 *statuscode);
 
        /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
         * handle in question is "ownable" (ie mutexes), to see if the current
@@ -129,7 +131,7 @@ void
 mono_w32handle_ops_signal (gpointer handle);
 
 gboolean
-mono_w32handle_ops_own (gpointer handle);
+mono_w32handle_ops_own (gpointer handle, guint32 *statuscode);
 
 gboolean
 mono_w32handle_ops_isowned (gpointer handle);
@@ -165,10 +167,11 @@ int
 mono_w32handle_unlock_handle (gpointer handle);
 
 typedef enum {
-       MONO_W32HANDLE_WAIT_RET_SUCCESS_0 =  0,
-       MONO_W32HANDLE_WAIT_RET_ALERTED   = -1,
-       MONO_W32HANDLE_WAIT_RET_TIMEOUT   = -2,
-       MONO_W32HANDLE_WAIT_RET_FAILED    = -3,
+       MONO_W32HANDLE_WAIT_RET_SUCCESS_0   =  0,
+       MONO_W32HANDLE_WAIT_RET_ABANDONED_0 =  MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS,
+       MONO_W32HANDLE_WAIT_RET_ALERTED     = -1,
+       MONO_W32HANDLE_WAIT_RET_TIMEOUT     = -2,
+       MONO_W32HANDLE_WAIT_RET_FAILED      = -3,
 } MonoW32HandleWaitRet;
 
 MonoW32HandleWaitRet