Merge pull request #2603 from kumpera/fix_set_pending_exception
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 16 Feb 2016 16:02:23 +0000 (08:02 -0800)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 16 Feb 2016 16:02:23 +0000 (08:02 -0800)
[runtime] Move pending_exception from InternalThread to Thread to avoid crashing on domain unload.

88 files changed:
external/referencesource
mcs/build/library.make
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs
mcs/class/Mono.Security/mobile_Mono.Security.dll.sources
mcs/class/System.Configuration/System.Configuration/Configuration.cs
mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs
mcs/class/System.Core/System.Core-net_4_x.csproj
mcs/class/System.Core/System.Core-plaincore-net_4_x.csproj
mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs [deleted file]
mcs/class/System.Core/common_System.Core.dll.sources
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs
mcs/class/System.Web.Services/System.Web.Services_test.dll.sources
mcs/class/System.Web.Services/Test/System.Web.Services.Discovery/DiscoveryClientProtocolTest.cs [new file with mode: 0644]
mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs
mcs/class/System/Test/System.Net.Security/SslStreamTest.cs
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
mcs/class/corlib/Makefile
mcs/class/corlib/Mono/DataConverter.cs
mcs/class/corlib/System.IO/FileInfo.cs
mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs
mcs/class/corlib/System.Reflection/MethodInfo.cs [deleted file]
mcs/class/corlib/System.Reflection/MonoMethod.cs
mcs/class/corlib/Test/System.IO/FileInfoTest.cs
mcs/class/corlib/Test/System.IO/FileStreamTest.cs
mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs
mcs/class/corlib/Test/System/StringTest.cs
mcs/class/corlib/corlib-net_4_x.csproj
mcs/class/corlib/corlib.dll.sources
mcs/mcs/assembly.cs
mcs/mcs/attribute.cs
mcs/mcs/delegate.cs
mcs/mcs/typemanager.cs
mcs/tests/gtest-etree-07.cs
mcs/tests/gtest-etree-31.cs [new file with mode: 0644]
mcs/tests/test-892.cs
mcs/tests/ver-il-net_4_x.xml
mcs/tools/misc/.gitattributes [deleted file]
mcs/tools/misc/EnumCheck.cs [deleted file]
mcs/tools/misc/EnumCheckAssemblyCollection.cs [deleted file]
mcs/tools/misc/GenerateDelegate.cs [deleted file]
mcs/tools/misc/IFaceDisco.cs [deleted file]
mcs/tools/misc/XMLUtil.cs [deleted file]
mcs/tools/misc/monostyle.cs [deleted file]
mcs/tools/misc/sample_cast_const.cs [deleted file]
mcs/tools/misc/serialize.cs [deleted file]
mcs/tools/misc/verifier.cs [deleted file]
mono/io-layer/io.c
mono/io-layer/wapi-remap.h
mono/metadata/assembly.c
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/mono-perfcounters.c
mono/metadata/reflection-internals.h
mono/metadata/reflection.c
mono/metadata/reflection.h
mono/metadata/sgen-mono.c
mono/mini/aot-runtime.c
mono/mini/method-to-ir.c
mono/mini/mini-llvm-cpp.cpp
mono/mini/mini-llvm-cpp.h
mono/mini/mini-llvm.c
mono/mini/mini-runtime.c
mono/mini/mini-trampolines.c
mono/mini/mini.h
mono/sgen/sgen-alloc.c
mono/sgen/sgen-conf.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-los.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-memory-governor.c
mono/sgen/sgen-memory-governor.h
mono/tests/load-exceptions.cs
mono/tests/load-missing.il
msvc/mono.def
msvc/monosgen.def
msvc/scripts/order.xml

index 78dccece97d38f6e771ce039001c84fa8435349a..0cb499950a7ae61c62c433c8cce353d535dbd09e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 78dccece97d38f6e771ce039001c84fa8435349a
+Subproject commit 0cb499950a7ae61c62c433c8cce353d535dbd09e
index 5954ba2e316bc5e872bf4b92d3b0bdbd337a542a..65f11f600f9a8ff790f0e59ed834655300ba1179 100644 (file)
@@ -141,7 +141,7 @@ csproj-local: csproj-library csproj-test
 intermediate_clean=$(subst /,-,$(intermediate))
 csproj-library: 
        config_file=`basename $(LIBRARY) .dll`-$(intermediate_clean)$(PROFILE).input; \
-       [[ $(thisdir) == *"Facades"* ]] && config_file=Facades_$$config_file; \
+       case "$(thisdir)" in *"Facades"*) config_file=Facades_$$config_file;; esac; \
        echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
        (echo $(is_boot); \
        echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
index 5b5e74e48c10250bfef984801a0913b9081c3216..eb60c6bd086185c56c1317a29f70c1f278eeeac6 100644 (file)
@@ -46,12 +46,7 @@ using Mono.Security.Cryptography;
 namespace Mono.Security.Protocol.Ntlm {
 
        [Obsolete (Type3Message.LegacyAPIWarning)]
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       class ChallengeResponse : IDisposable {
+       public class ChallengeResponse : IDisposable {
 
                static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
 
index 747ab89c15b9a0c548ac98cebd1c54e76f607afc..abaef0e259bc57a95ab8913e903f99d8be14fae1 100644 (file)
@@ -49,12 +49,7 @@ using Mono.Security.Cryptography;
 
 namespace Mono.Security.Protocol.Ntlm {
 
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       static class ChallengeResponse2 {
+       public static class ChallengeResponse2 {
 
                static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
 
index 0e6e571bb4e2fd768d514053c7be0c5bc05b8518..d62ed40c973d02f51a13821b1c417c4e31699bce 100644 (file)
@@ -39,12 +39,7 @@ using System.Globalization;
 
 namespace Mono.Security.Protocol.Ntlm {
 
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       abstract class MessageBase {
+       public abstract class MessageBase {
 
                static private byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 };
                
index 2dc12129b5d9a1c7d8321b209f0cc143a9f25768..e66d5901b5b9dda3ed2d0768652a90f172159b84 100644 (file)
@@ -36,12 +36,7 @@ namespace Mono.Security.Protocol.Ntlm {
         * is LM_and_NTLM_and_try_NTLMv2_Session.
         */
        
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       enum NtlmAuthLevel {
+       public enum NtlmAuthLevel {
                /* Use LM and NTLM, never use NTLMv2 session security. */
                LM_and_NTLM,
                
index f835bd8b1456e1ad35fbc6ad14a8bbdc3369fdfd..5b5db641a4a18e5908fa11699fa55d95ef0ecb14 100644 (file)
@@ -40,12 +40,7 @@ using System;
 namespace Mono.Security.Protocol.Ntlm {
 
        [Flags]
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       enum NtlmFlags : int {
+       public enum NtlmFlags : int {
                // The client sets this flag to indicate that it supports Unicode strings.
                NegotiateUnicode = 0x00000001,
                // This is set to indicate that the client supports OEM strings.
index 7cd5c7f83275fa83a440d4bcd573919bb5b475de..02778af48e15664f0b24462074acf5ee1df4fa9e 100644 (file)
@@ -38,48 +38,13 @@ namespace Mono.Security.Protocol.Ntlm {
         * is LM_and_NTLM_and_try_NTLMv2_Session.
         */
 
-       #if INSIDE_SYSTEM
-       internal
-       #else
-       public
-       #endif
-       static class NtlmSettings {
+       public static class NtlmSettings {
 
                static NtlmAuthLevel defaultAuthLevel = NtlmAuthLevel.LM_and_NTLM_and_try_NTLMv2_Session;
 
-               static FieldInfo GetDefaultAuthLevelField ()
-               {
-                       #if INSIDE_SYSTEM
-                       return null;
-                       #else
-                       var type = typeof (HttpWebRequest).Assembly.GetType ("Mono.Security.Protocol.Ntlm.NtlmSettings", false);
-                       if (type == null)
-                               return null;
-                       return type.GetField ("defaultAuthLevel", BindingFlags.Static | BindingFlags.NonPublic);
-                       #endif
-               }
-
-               #if INSIDE_SYSTEM
-               internal
-               #else
-               public
-               #endif
-               static NtlmAuthLevel DefaultAuthLevel {
-                       get {
-                               var field = GetDefaultAuthLevelField ();
-                               if (field != null)
-                                       return (NtlmAuthLevel)field.GetValue (null);
-                               else
-                                       return defaultAuthLevel;
-                       }
-
-                       set {
-                               var field = GetDefaultAuthLevelField ();
-                               if (field != null)
-                                       field.SetValue (null, value);
-                               else
-                                       defaultAuthLevel = value;
-                       }
+               public static NtlmAuthLevel DefaultAuthLevel {
+                       get { return defaultAuthLevel; }
+                       set { defaultAuthLevel = value; }
                }
        }
 }
index b9ef85593601087d76b40ef943222e6fa69ac186..531fce0262275983510daa57a940382110393d26 100644 (file)
@@ -39,12 +39,7 @@ using System.Text;
 
 namespace Mono.Security.Protocol.Ntlm {
 
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       class Type1Message : MessageBase {
+       public class Type1Message : MessageBase {
 
                private string _host;
                private string _domain;
index e6a89936a908e919155df942f5739b9debd354a4..a2f65e3e584b06fb618ae541beb01d8f4769db5e 100644 (file)
@@ -39,12 +39,7 @@ using System.Security.Cryptography;
 
 namespace Mono.Security.Protocol.Ntlm {
 
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       class Type2Message : MessageBase {
+       public class Type2Message : MessageBase {
 
                private byte[] _nonce;
                private string _targetName;
index 7472e719400329eba68ad4a29c2d59c870c13a06..ddb44b2dfde08ff754f5125a6375c94b2fe2d6fd 100644 (file)
@@ -39,12 +39,7 @@ using System.Text;
 
 namespace Mono.Security.Protocol.Ntlm {
 
-#if INSIDE_SYSTEM
-       internal
-#else
-       public
-#endif
-       class Type3Message : MessageBase {
+       public class Type3Message : MessageBase {
 
                private NtlmAuthLevel _level;
                private byte[] _challenge;
index 05cc4faad16b660c7fd75e70f302800576974fcb..2e938683b3a0fd5099e48d2aaa1f6eb79cf8dc3c 100644 (file)
 ./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs
 ./Mono.Security.Cryptography/TlsHMAC.cs
 ./Mono.Security.Cryptography/MD5SHA1.cs
-./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs
-./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs
-./Mono.Security.Protocol.Ntlm/MessageBase.cs
-./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs
-./Mono.Security.Protocol.Ntlm/NtlmFlags.cs
-./Mono.Security.Protocol.Ntlm/NtlmSettings.cs
-./Mono.Security.Protocol.Ntlm/Type1Message.cs
-./Mono.Security.Protocol.Ntlm/Type2Message.cs
-./Mono.Security.Protocol.Ntlm/Type3Message.cs
 ./Mono.Security.Protocol.Tls/Alert.cs
 ./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
 ./Mono.Security.Protocol.Tls/CipherSuite.cs
index 760371766904e216889732ba05dc9a24cc7746b3..fb48cc9664f27b743154806f992f342e7e9a8f35 100644 (file)
@@ -133,8 +133,12 @@ namespace System.Configuration {
                                rootGroup.StreamName = streamName;
                        }
                        
-                       if (streamName != null)
-                               Load ();
+                       try {
+                               if (streamName != null)
+                                       Load ();
+                       } catch (XmlException ex) {
+                               throw new ConfigurationErrorsException (ex.Message, ex, streamName, 0);
+                       }
                }
                
                internal Configuration Parent {
index d2e1a240f6d5c59621fa35c79d182eac32151c33..7efff1dddffcf879f53a0a534b24cded54d0a213 100644 (file)
@@ -627,5 +627,23 @@ namespace MonoTests.System.Configuration {
                        Assert.AreEqual ("Server=(local);Initial Catalog=someDb;User Id=someUser;Password=somePassword;Application Name=someAppName;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;",
                                         connString);
                }
+
+               [Test]
+               public void BadConfig ()
+               {
+                       string xml = @" badXml";
+
+                       var file = Path.Combine (tempFolder, "badConfig.config");
+                       File.WriteAllText (file, xml);
+
+                       try {
+                               var fileMap = new ConfigurationFileMap (file);
+                               var configuration = ConfigurationManager.OpenMappedMachineConfiguration (fileMap);
+                               Assert.Fail ("Exception ConfigurationErrorsException was expected.");
+                       } catch (ConfigurationErrorsException e) {
+                               Assert.AreEqual (file, e.Filename);
+                       }
+
+               }
        }
 }
index f789945f01b6cdcb57bf03b6bf45c348d10f3588..1ff7e4d05f904f6eb9836484047b931a83e61e64 100644 (file)
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Runtime\CompilerServices\ExecutionScope.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\Aes.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />\r
+    <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\CngKeyBlobFormat.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellmanPublicKey.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDsa.cs" />\r
index ef334979b349500834ed67ff23d5bf1c00dc244e..85e07de17a51eece6b9c0d137f1fba6922cbc2a8 100644 (file)
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Runtime\CompilerServices\ExecutionScope.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\Aes.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\AesManaged.cs" />\r
+    <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\CngKeyBlobFormat.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellman.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDiffieHellmanPublicKey.cs" />\r
     <Compile Include="..\..\..\external\referencesource\System.Core\System\Security\Cryptography\ECDsa.cs" />\r
diff --git a/mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs b/mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs
deleted file mode 100644 (file)
index e8f184c..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-//
-// System.Security.Cryptography.CngKeyBlobFormat
-//
-// Authors:
-//      Sebastien Pouliot  <sebastien@ximian.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2011 Juho Vähä-Herttua
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace System.Security.Cryptography {
-
-       // note: CNG stands for "Cryptography API: Next Generation"
-
-       [Serializable]
-       public sealed class CngKeyBlobFormat : IEquatable<CngKeyBlobFormat> {
-
-               private string m_format;
-
-               public CngKeyBlobFormat (string format)
-               {
-                       if (format == null)
-                               throw new ArgumentNullException ("format");
-                       if (format.Length == 0)
-                               throw new ArgumentException ("format");
-
-                       m_format = format;
-               }
-
-               public string Format {
-                       get { return m_format; }
-               }
-
-               public bool Equals (CngKeyBlobFormat other)
-               {
-                       if (other == null)
-                               return false;
-                       return m_format == other.m_format;
-               }
-
-               public override bool Equals (object obj)
-               {
-                       return Equals (obj as CngKeyBlobFormat);
-               }
-
-               public override int GetHashCode ()
-               {
-                       return m_format.GetHashCode ();
-               }
-
-               public override string ToString ()
-               {
-                       return m_format;
-               }
-
-               // static
-
-               private static CngKeyBlobFormat opaqueTransportBlob;
-               private static CngKeyBlobFormat genericPrivateBlob;
-               private static CngKeyBlobFormat genericPublicBlob;
-               private static CngKeyBlobFormat eccPrivateBlob;
-               private static CngKeyBlobFormat eccPublicBlob;
-               private static CngKeyBlobFormat pkcs8PrivateBlob;
-
-               public static CngKeyBlobFormat OpaqueTransportBlob {
-                       get {
-                               if (opaqueTransportBlob == null)
-                                       opaqueTransportBlob = new CngKeyBlobFormat ("OpaqueTransport");
-                               return opaqueTransportBlob;
-                       }
-               }
-
-               public static CngKeyBlobFormat GenericPrivateBlob {
-                       get {
-                               if (genericPrivateBlob == null)
-                                       genericPrivateBlob = new CngKeyBlobFormat ("PRIVATEBLOB");
-                               return genericPrivateBlob;
-                       }
-               }
-
-               public static CngKeyBlobFormat GenericPublicBlob {
-                       get {
-                               if (genericPublicBlob == null)
-                                       genericPublicBlob = new CngKeyBlobFormat ("PUBLICBLOB");
-                               return genericPublicBlob;
-                       }
-               }
-
-               public static CngKeyBlobFormat EccPrivateBlob {
-                       get {
-                               if (eccPrivateBlob == null)
-                                       eccPrivateBlob = new CngKeyBlobFormat ("ECCPRIVATEBLOB");
-                               return eccPrivateBlob;
-                       }
-               }
-
-               public static CngKeyBlobFormat EccPublicBlob {
-                       get {
-                               if (eccPublicBlob == null)
-                                       eccPublicBlob = new CngKeyBlobFormat ("ECCPUBLICBLOB");
-                               return eccPublicBlob;
-                       }
-               }
-
-               public static CngKeyBlobFormat Pkcs8PrivateBlob {
-                       get {
-                               if (pkcs8PrivateBlob == null)
-                                       pkcs8PrivateBlob = new CngKeyBlobFormat ("PKCS8_PRIVATEKEY");
-                               return pkcs8PrivateBlob;
-                       }
-               }
-
-               public static bool operator == (CngKeyBlobFormat left, CngKeyBlobFormat right)
-               {
-                       if ((object)left == null)
-                               return ((object)right == null);
-                       return left.Equals (right);
-               }
-
-               public static bool operator != (CngKeyBlobFormat left, CngKeyBlobFormat right)
-               {
-                       if ((object)left == null)
-                               return ((object)right != null);
-                       return !left.Equals (right);
-               }
-       }
-}
index 455930f26f82bc136fbfc566879b9fa8f2e7bbc8..634c075073a7cc6b89b6f5131f2302463265ae8b 100644 (file)
@@ -184,6 +184,7 @@ ReferenceSources/Strings.cs
 ../../../external/referencesource/System.Core/System/Runtime/CompilerServices/ExecutionScope.cs
 
 ../../../external/referencesource/System.Core/System/Security/Cryptography/Aes.cs
+../../../external/referencesource/System.Core/System/Security/Cryptography/CngKeyBlobFormat.cs
 ../../../external/referencesource/System.Core/System/Security/Cryptography/ECDiffieHellmanPublicKey.cs
 ../../../external/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs
 
index 9c1df61310afc8a0a3fa858179fe59bc55847ea4..0f881358df53ba2a369eead866e706fe59de4c3b 100644 (file)
@@ -38,6 +38,7 @@ using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
 using System.Text;
 using System.Xml;
+using System.Xml.Schema;
 using System.Xml.Serialization;
 
 namespace System.ServiceModel.Dispatcher
@@ -135,6 +136,11 @@ namespace System.ServiceModel.Dispatcher
 
                        protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
                        {
+                               if (writer.WriteState == WriteState.Element) {
+                                       writer.WriteXmlnsAttribute ("xsi", XmlSchema.InstanceNamespace);
+                                       writer.WriteXmlnsAttribute ("xsd", XmlSchema.Namespace);
+                               }
+
                                serializer.Serialize (writer, body);
                        }
                }
index 0a169ec364f9b637ccdf2093253623a73fb954ba..5282f954c050fb9d9a654eac6620d0e1af6937c1 100644 (file)
@@ -480,15 +480,16 @@ namespace MonoTests.System.ServiceModel
                [Test]
                public void OneWayOperationWithRequestReplyChannel ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        var host = new ServiceHost (typeof (OneWayService));
                        host.AddServiceEndpoint (typeof (IOneWayService),
                                new BasicHttpBinding (),
-                               new Uri ("http://localhost:30158"));
+                               new Uri ("http://localhost:" + port));
                        host.Open ();
                        try {
                                var cf = new ChannelFactory<IOneWayService> (
                                        new BasicHttpBinding (),
-                                       new EndpointAddress ("http://localhost:30158"));
+                                       new EndpointAddress ("http://localhost:" + port));
                                var ch = cf.CreateChannel ();
                                ch.GiveMessage ("test");
                                
index 3c12a4646869c95eb2857abe4afd116274b18837..4d15e9138a59a25c6b006e2a50b2bfec7c52d661 100644 (file)
 using System;
 using System.Collections.ObjectModel;
 using System.IO;
+using System.Net;
 using System.Net.Sockets;
 using System.Reflection;
 using System.ServiceModel;
 using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
+using System.Text;
+using System.Threading.Tasks;
 using System.Xml;
+using System.Xml.Serialization;
 using NUnit.Framework;
 
 using MonoTests.Helpers;
@@ -503,5 +507,82 @@ namespace MonoTests.System.ServiceModel
                        {
                        }
                }
+
+               [SerializableAttribute ()]
+               [XmlTypeAttribute (Namespace = "http://mono.com/")]
+               public class ValueWithXmlAttributes
+               {
+                       [XmlElementAttribute (ElementName = "Name")]
+                       public string FakeName;
+               }
+
+               [ServiceContractAttribute (Namespace = "http://mono.com/")]
+               public interface IXmlSerializerFormatService
+               {
+                       [OperationContractAttribute (Action = "http://mono.com/Send", ReplyAction = "*")]
+                       [XmlSerializerFormatAttribute ()]
+                       void SendValueWithXmlAttributes (ValueWithXmlAttributes v);
+               }
+
+               class XmlSerializerFormatClient : ClientBase<IXmlSerializerFormatService>
+               {
+                       public XmlSerializerFormatClient (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public void SendValue ()
+                       {
+                               var v = new ValueWithXmlAttributes () { FakeName = "name" };
+                               base.Channel.SendValueWithXmlAttributes (v);
+                       }
+               }
+
+               [Test]
+               public void TestXmlAttributes ()
+               {
+                       int port = NetworkHelpers.FindFreePort();
+                       var endpoint = new EndpointAddress ("http://localhost:" + port);
+                       var binding = new BasicHttpBinding ();
+                       var client = new XmlSerializerFormatClient (binding, endpoint);
+
+                       var server = new TcpListener (IPAddress.Any, port);
+                       server.Start ();
+
+                       var acceptTask = server.AcceptTcpClientAsync ();
+
+                       var t1 = new Task( () => client.SendValue ());
+                       t1.Start();
+
+                       if (!acceptTask.Wait (2000))
+                               Assert.Fail ("No request from client.");
+
+                       var netStream = acceptTask.Result.GetStream ();
+
+                       byte[] buffer = new byte [1024];
+                       int numBytesRead = 0;
+                       var message = new StringBuilder ();
+                       
+                       do {
+                               numBytesRead = netStream.Read (buffer, 0, buffer.Length);
+                               var str =  Encoding.UTF8.GetString (buffer, 0, numBytesRead);
+                               message.AppendFormat ("{0}", str);
+                               if (str.EndsWith ("</s:Envelope>", StringComparison.InvariantCulture))
+                                       break;
+                       } while (numBytesRead > 0);
+
+                       var messageStr = message.ToString ();
+                       var envelopeIndex = messageStr.IndexOf ("<s:Envelope");
+                       if (envelopeIndex < 0)
+                               Assert.Fail ("Soap envelope was not received.");
+                       
+                       var envelope = messageStr.Substring (envelopeIndex);
+
+                       var expected = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SendValueWithXmlAttributes xmlns=\"http://mono.com/\"><v><Name>name</Name></v></SendValueWithXmlAttributes></s:Body></s:Envelope>";
+
+                       Assert.AreEqual (expected, envelope);
+
+                       server.Stop ();
+               }
        }
 }
index 1d055d9cdafa9deda9d411059535ccdbb94f7c27..8d6ab724f1176714f7e35967db496155c1bf91c8 100644 (file)
@@ -10,6 +10,7 @@ System.Web.Services.Configuration/WsdlHelpGeneratorElementTest.cs
 System.Web.Services.Configuration/WsiProfilesElementTest.cs
 System.Web.Services.Configuration/XmlFormatExtensionAttributeTest.cs
 System.Web.Services.Discovery/ContractReferenceTest.cs
+System.Web.Services.Discovery/DiscoveryClientProtocolTest.cs
 System.Web.Services.Description/BindingCollectionTest.cs
 System.Web.Services.Description/DocumentableItemTest.cs
 System.Web.Services.Description/TypesTest.cs
diff --git a/mcs/class/System.Web.Services/Test/System.Web.Services.Discovery/DiscoveryClientProtocolTest.cs b/mcs/class/System.Web.Services/Test/System.Web.Services.Discovery/DiscoveryClientProtocolTest.cs
new file mode 100644 (file)
index 0000000..4a12ce5
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// MonoTests.System.Web.Services.Discovery.DiscoveryClientProtocolTest.cs
+//
+// Author:
+//   Marcos Henrich (marcos.henrich@xamarin.com)
+//
+// Copyright (C) Xamarin Inc. 2016
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Web.Services.Discovery;
+
+namespace MonoTests.System.Web.Services.Discovery {
+
+       [TestFixture]
+       public class DiscoveryClientProtocolTest {
+
+               [Test] // Covers #36116
+               [Category ("InetAccess")]
+               public void ReadWriteTest ()
+               {
+                       string directory = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ());
+                       Directory.CreateDirectory (directory);
+                       try {
+                               string url = "http://www.w3schools.com/WebServices/TempConvert.asmx";
+                               var p1 = new DiscoveryClientProtocol ();
+                               p1.DiscoverAny (url);
+                               p1.ResolveAll ();
+
+                               p1.WriteAll (directory, "Reference.map");
+
+                               var p2 = new DiscoveryClientProtocol ();
+                               var results = p2.ReadAll (Path.Combine (directory, "Reference.map"));
+
+                               Assert.AreEqual (2, results.Count);
+                               Assert.AreEqual ("TempConvert.disco", results [0].Filename);
+                               Assert.AreEqual ("TempConvert.wsdl", results [1].Filename);
+                       } finally {
+                               Directory.Delete (directory, true);
+                       }
+               }
+       }
+}
index 4b69010b975f59370e4afc85cabae0f96640dcfd..31d56ce09eb38acf77a1e3a2a9ab1466b66b1266 100644 (file)
@@ -578,6 +578,34 @@ namespace System.Configuration
                private ExeConfigurationFileMap exeMapPrev = null;
                private SettingsPropertyValueCollection values = null;
 
+               /// <remarks>
+               /// Hack to remove the XmlDeclaration that the XmlSerializer adds.
+               /// <br />
+               /// see <a href="https://github.com/mono/mono/pull/2273">Issue 2273</a> for details
+               /// </remarks>
+               private string StripXmlHeader (string serializedValue)
+               {
+                       if (serializedValue == null)
+                       {
+                               return string.Empty;
+                       }
+
+                       XmlDocument doc = new XmlDocument ();
+                       XmlElement valueXml = doc.CreateElement ("value");
+                       valueXml.InnerXml = serializedValue;
+
+                       foreach (XmlNode child in valueXml.ChildNodes) {
+                               if (child.NodeType == XmlNodeType.XmlDeclaration) {
+                                       valueXml.RemoveChild (child);
+                                       break;
+                               }
+                       }
+
+                       // InnerXml will give you well-formed XML that you could save as a separate document, and 
+                       // InnerText will immediately give you a pure-text representation of this inner XML.
+                       return valueXml.InnerXml;
+               }
+
                private void SaveProperties (ExeConfigurationFileMap exeMap, SettingsPropertyValueCollection collection, ConfigurationUserLevel level, SettingsContext context, bool checkUserLevel)
                {
                        Configuration config = ConfigurationManager.OpenMappedExeConfiguration (exeMap, level);
@@ -585,8 +613,6 @@ namespace System.Configuration
                        UserSettingsGroup userGroup = config.GetSectionGroup ("userSettings") as UserSettingsGroup;
                        bool isRoaming = (level == ConfigurationUserLevel.PerUserRoaming);
 
-#if true // my reimplementation
-
                        if (userGroup == null) {
                                userGroup = new UserSettingsGroup ();
                                config.SectionGroups.Add ("userSettings", userGroup);
@@ -623,7 +649,7 @@ namespace System.Configuration
                                        element.Value.ValueXml = new XmlDocument ().CreateElement ("value");
                                switch (value.Property.SerializeAs) {
                                case SettingsSerializeAs.Xml:
-                                       element.Value.ValueXml.InnerXml = (value.SerializedValue as string) ?? string.Empty;
+                                       element.Value.ValueXml.InnerXml = StripXmlHeader (value.SerializedValue as string);
                                        break;
                                case SettingsSerializeAs.String:
                                        element.Value.ValueXml.InnerText = value.SerializedValue as string;
@@ -637,43 +663,6 @@ namespace System.Configuration
                        }
                        if (hasChanges)
                                config.Save (ConfigurationSaveMode.Minimal, true);
-
-#else // original impl. - likely buggy to miss some properties to save
-
-                       foreach (ConfigurationSection configSection in userGroup.Sections)
-                       {
-                               ClientSettingsSection userSection = configSection as ClientSettingsSection;
-                               if (userSection != null)
-                               {
-/*
-                                       userSection.Settings.Clear();
-
-                                       foreach (SettingsPropertyValue propertyValue in collection)
-                                       {
-                                               if (propertyValue.IsDirty)
-                                               {
-                                                       SettingElement element = new SettingElement(propertyValue.Name, SettingsSerializeAs.String);
-                                                       element.Value.ValueXml = new XmlDocument();
-                                                       element.Value.ValueXml.InnerXml = (string)propertyValue.SerializedValue;
-                                                       userSection.Settings.Add(element);
-                                               }
-                                       }
-*/
-                                       foreach (SettingElement element in userSection.Settings)
-                                       {
-                                               if (collection [element.Name] != null) {
-                                                       if (collection [element.Name].Property.Attributes.Contains (typeof (SettingsManageabilityAttribute)) != isRoaming)
-                                                               continue;
-
-                                                       element.SerializeAs = SettingsSerializeAs.String;
-                                                       element.Value.ValueXml.InnerXml = (string) collection [element.Name].SerializedValue;   ///Value = XmlElement
-                                               }
-                                       }
-                               }
-                       }
-                       config.Save (ConfigurationSaveMode.Minimal, true);
-#endif
                }
 
                // NOTE: We should add here all the chars that are valid in a name of a class (Ecma-wise),
index 7b0b3ac8152a99b66953033ad54429352806d452..e12f53291d208b523a3b974f70e561018a4a9ea2 100644 (file)
 
 //#define SPEW
 
-
 using System;
+using System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Xml.Schema;
 using System.Text;
 using System.Configuration;
 using System.ComponentModel;
@@ -461,6 +464,60 @@ namespace MonoTests.System.Configuration {
                        Assert.AreEqual ("eclair", holder1.TestKey, "#4");
                        Assert.AreEqual ("", holder2.TestKey, "#5");
                }
+
+               class Settings : ApplicationSettingsBase
+               {
+                       [UserScopedSetting]
+                       public WindowPositionList WindowPositions {
+                               get {
+                                       return ((WindowPositionList)(this ["WindowPositions"]));
+                               }
+                               set {
+                                       this ["WindowPositions"] = value;
+                               }
+                       }
+               }
+
+               [Serializable]
+               public class WindowPositionList : IXmlSerializable
+               {
+                       public XmlSchema GetSchema ()
+                       {
+                               return null;
+                       }
+
+                       public void ReadXml (XmlReader reader)
+                       {
+                               reader.ReadStartElement ("sampleNode");
+                               reader.ReadEndElement ();
+                       }
+
+                       public void WriteXml (XmlWriter writer)
+                       {
+                               writer.WriteStartElement ("sampleNode");
+                               writer.WriteEndElement ();
+                       }
+               }
+
+               [Test] //Covers 36388
+               public void XmlHeader ()
+               {
+                       try {
+                               var settings = new Settings ();
+                               settings.Reset ();
+                               settings.Save ();
+
+                               settings.WindowPositions = new WindowPositionList ();
+
+                               settings.Save ();
+                               // If Reloads fails then saved data is corrupted
+                               settings.Reload ();
+                       } catch (ConfigurationErrorsException e) {
+                               // Delete corrupted config file so other test won't fail.
+                               File.Delete (e.Filename);
+                               Assert.Fail ("Invalid data was saved to config file.");
+                       }
+               }
        }
 }
 
index 2dd0d0674632ab82bd8a73d99724e3f1cc9c43b3..cea6bb18c14aabe8003407800c9af58a4d809714 100644 (file)
@@ -39,6 +39,8 @@ using System.Net.Security;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net.Security
 {
 
@@ -64,7 +66,7 @@ public class SslStreamTest {
 
        void AuthenticateClientAndServer (bool server, bool client)
        {
-               IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 10000);
+               IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), NetworkHelpers.FindFreePort ());
                ClientServerState state = new ClientServerState ();
                state.Client = new TcpClient ();
                state.Listener = new TcpListener (endPoint);
index a0e19d4f2d15d6d856fcf37ff33c86c1173274d5..a53a5d5624ab010ece48667b8bfe72719d856110 100755 (executable)
@@ -22,6 +22,8 @@ using System.IO;
 
 using System.Collections.Generic;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net.Sockets
 {
        [TestFixture]
@@ -34,7 +36,7 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void ConnectIPAddressAny ()
                {
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Any, 0);
+                       IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
 
                        /* UDP sockets use Any to disconnect
                        try {
@@ -64,7 +66,7 @@ namespace MonoTests.System.Net.Sockets
                public void IncompatibleAddress ()
                {
                        IPEndPoint epIPv6 = new IPEndPoint (IPAddress.IPv6Any,
-                                                               0);
+                                                               NetworkHelpers.FindFreePort ());
 
                        try {
                                using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP)) {
@@ -111,9 +113,9 @@ namespace MonoTests.System.Net.Sockets
                        Socket.Select (list, list, list, 1000);
                }
                
-               private bool BlockingConnect (bool block)
+               private bool BlockingConnect (bool block, int port)
                {
-                       IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 1234);
+                       IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port);
                        Socket server = new Socket(AddressFamily.InterNetwork,
                                                   SocketType.Stream,
                                                   ProtocolType.Tcp);
@@ -155,11 +157,12 @@ namespace MonoTests.System.Net.Sockets
                public void AcceptBlockingStatus()
                {
                        bool block;
-
-                       block = BlockingConnect(true);
+                       var port = NetworkHelpers.FindFreePort ();
+       
+                       block = BlockingConnect(true, port);
                        Assert.AreEqual (block, true, "BlockingStatus01");
 
-                       block = BlockingConnect(false);
+                       block = BlockingConnect(false, port);
                        Assert.AreEqual (block, false, "BlockingStatus02");
                }
 
@@ -208,7 +211,7 @@ namespace MonoTests.System.Net.Sockets
                         * anything...
                         */
                        sock.BeginConnect (new IPEndPoint (IPAddress.Loopback,
-                                                          114),
+                                                          NetworkHelpers.FindFreePort ()),
                                           new AsyncCallback (CFACallback),
                                           sock);
                        CFACalledBack.WaitOne ();
@@ -219,7 +222,7 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void SetSocketOptionBoolean ()
                {
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1);
+                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        Socket sock = new Socket (ep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                        try {
                                sock.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
@@ -230,7 +233,7 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void TestSelect1 ()
                {
-                       Socket srv = CreateServer ();
+                       Socket srv = CreateServer (NetworkHelpers.FindFreePort ());
                        ClientSocket clnt = new ClientSocket (srv.LocalEndPoint);
                        Thread th = new Thread (new ThreadStart (clnt.ConnectSleepClose));
                        Socket acc = null;
@@ -260,10 +263,10 @@ namespace MonoTests.System.Net.Sockets
                        }
                }
 
-               static Socket CreateServer ()
+               static Socket CreateServer (int port)
                {
                        Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-                       sock.Bind (new IPEndPoint (IPAddress.Loopback, 0));
+                       sock.Bind (new IPEndPoint (IPAddress.Loopback, port));
                        sock.Listen (1);
                        return sock;
                }
@@ -369,7 +372,7 @@ namespace MonoTests.System.Net.Sockets
                public void Disposed19 ()
                {
                        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
-                       EndPoint ep = new IPEndPoint (IPAddress.Any, 31337);
+                       EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
                        s.Close();
 
                        s.SendTo (buf, 0, ep);
@@ -380,7 +383,7 @@ namespace MonoTests.System.Net.Sockets
                public void Disposed20 ()
                {
                        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
-                       EndPoint ep = new IPEndPoint (IPAddress.Any, 31337);
+                       EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
                        s.Close();
 
                        s.SendTo (buf, 10, 0, ep);
@@ -391,7 +394,7 @@ namespace MonoTests.System.Net.Sockets
                public void Disposed21 ()
                {
                        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
-                       EndPoint ep = new IPEndPoint (IPAddress.Any, 31337);
+                       EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
                        s.Close();
 
                        s.SendTo (buf, 0, 10, 0, ep);
@@ -402,7 +405,7 @@ namespace MonoTests.System.Net.Sockets
                public void Disposed22 ()
                {
                        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
-                       EndPoint ep = new IPEndPoint (IPAddress.Any, 31337);
+                       EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
                        s.Close();
 
                        s.SendTo (buf, ep);
@@ -424,7 +427,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket server = new Socket (AddressFamily.InterNetwork,
                                SocketType.Stream, ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       9010);
+                                                       NetworkHelpers.FindFreePort ());
                        server.Bind (ep);
                        server.Listen (1);
 
@@ -682,7 +685,7 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        
-                       sock.Bind (new IPEndPoint (IPAddress.Any, 1235));
+                       sock.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                        sock.ExclusiveAddressUse = true;
                        sock.Close ();
                }
@@ -1329,7 +1332,7 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
 
-                       sock.Bind (new IPEndPoint (IPAddress.Any, 1236));
+                       sock.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                        
                        sock.BeginAccept (BACallback, sock);
                        
@@ -1343,7 +1346,7 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1237);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
@@ -1410,7 +1413,7 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1238);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
@@ -1478,7 +1481,7 @@ namespace MonoTests.System.Net.Sockets
                                                 ProtocolType.Udp);
                        
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1239);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
@@ -1507,10 +1510,10 @@ namespace MonoTests.System.Net.Sockets
                                                 ProtocolType.Tcp);
                        
                        IPEndPoint ep1 = new IPEndPoint (IPAddress.Loopback,
-                                                        1240);
+                                                        NetworkHelpers.FindFreePort ());
                        
                        IPEndPoint ep2 = new IPEndPoint (IPAddress.Loopback,
-                                                        1241);
+                                                        NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep1);
                        sock.Listen (1);
@@ -1540,7 +1543,7 @@ namespace MonoTests.System.Net.Sockets
                                                 ProtocolType.Tcp);
                        
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1242);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
@@ -1622,7 +1625,7 @@ namespace MonoTests.System.Net.Sockets
                                                 SocketType.Stream,
                                                 ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1243);
+                                                       NetworkHelpers.FindFreePort ());
 
                        sock.Bind (ep);
                        sock.Listen (1);
@@ -1673,7 +1676,7 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1244);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
 
                        listen.Bind (ep);
                        listen.Listen (1);
@@ -1682,7 +1685,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        BCConnected = false;
                        
-                       sock.BeginConnect (ip, 1244, BCCallback, sock);
+                       sock.BeginConnect (ip, ep.Port, BCCallback, sock);
 
                        if (BCCalledBack.WaitOne (2000, false) == false) {
                                Assert.Fail ("BeginConnectAddressPort wait timed out");
@@ -1721,13 +1724,13 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1245);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
 
                        sock.Bind (ep);
                        sock.Listen (1);
                        
                        try {
-                               sock.BeginConnect (ip, 1245, BCCallback, sock);
+                               sock.BeginConnect (ip, ep.Port, BCCallback, sock);
                                Assert.Fail ("BeginConnectAddressPortListen #1");
                        } catch (InvalidOperationException) {
                        } catch {
@@ -1772,7 +1775,7 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1246);
+                                                       NetworkHelpers.FindFreePort ());
                        IPAddress[] ips = new IPAddress[4];
                        
                        ips[0] = IPAddress.Parse ("127.0.0.4");
@@ -1787,7 +1790,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        BCConnected = false;
                        
-                       sock.BeginConnect (ips, 1246, BCCallback, sock);
+                       sock.BeginConnect (ips, ep.Port, BCCallback, sock);
                        
                        /* Longer wait here, because the ms runtime
                         * takes a lot longer to not connect
@@ -1835,7 +1838,7 @@ namespace MonoTests.System.Net.Sockets
                         * succeed it it can connect to at least one of the requested
                         * addresses.
                         */
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1246);
+                       IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        listen.Bind (ep);
                        listen.Listen (1);
@@ -1844,7 +1847,7 @@ namespace MonoTests.System.Net.Sockets
                        
                        BCConnected = false;
                        
-                       sock.BeginConnect (allIps, 1246, BCCallback, sock);
+                       sock.BeginConnect (allIps, ep.Port, BCCallback, sock);
                        
                        /* Longer wait here, because the ms runtime
                         * takes a lot longer to not connect
@@ -1892,7 +1895,7 @@ namespace MonoTests.System.Net.Sockets
                                                  ProtocolType.Tcp);
                        IPAddress[] ips = new IPAddress[4];
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1247);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        ips[0] = IPAddress.Parse ("127.0.0.4");
                        ips[1] = IPAddress.Parse ("127.0.0.3");
@@ -1903,7 +1906,7 @@ namespace MonoTests.System.Net.Sockets
                        sock.Listen (1);
                        
                        try {
-                               sock.BeginConnect (ips, 1247, BCCallback,
+                               sock.BeginConnect (ips, ep.Port, BCCallback,
                                                   sock);
                                Assert.Fail ("BeginConnectMultipleListen #1");
                        } catch (InvalidOperationException) {
@@ -1959,13 +1962,13 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1248);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
                        
                        try {
-                               sock.BeginConnect ("localhost", 1248,
+                               sock.BeginConnect ("localhost", ep.Port,
                                                   BCCallback, sock);
                                Assert.Fail ("BeginConnectHostPortListen #1");
                        } catch (InvalidOperationException) {
@@ -2033,12 +2036,12 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1254);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
                        
                        listen.Bind (ep);
                        listen.Listen (1);
                        
-                       sock.Connect (ip, 1254);
+                       sock.Connect (ip, ep.Port);
                        
                        Assert.AreEqual (true, sock.Connected, "BeginDisconnect #1");
                        
@@ -2128,9 +2131,9 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPEndPoint ep1 = new IPEndPoint (IPAddress.Loopback,
-                                                       1256);
+                                                       NetworkHelpers.FindFreePort ());
                        IPEndPoint ep2 = new IPEndPoint (IPAddress.Loopback,
-                                                        1257);
+                                                        NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep1);
                        
@@ -2156,7 +2159,7 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1258);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        listen.Bind (ep);
                        listen.Listen (1);
@@ -2184,12 +2187,12 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1249);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
 
                        listen.Bind (ep);
                        listen.Listen (1);
                        
-                       sock.Connect (ip, 1249);
+                       sock.Connect (ip, ep.Port);
                        
                        Assert.AreEqual (true, sock.Connected, "ConnectAddressPort #1");
                        
@@ -2223,13 +2226,13 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1250);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
 
                        sock.Bind (ep);
                        sock.Listen (1);
                        
                        try {
-                               sock.Connect (ip, 1250);
+                               sock.Connect (ip, ep.Port);
                                Assert.Fail ("ConnectAddressPortListen #1");
                        } catch (InvalidOperationException) {
                        } catch {
@@ -2281,7 +2284,7 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1251);
+                                                       NetworkHelpers.FindFreePort ());
                        IPAddress[] ips = new IPAddress[4];
                        
                        ips[0] = IPAddress.Parse ("127.0.0.4");
@@ -2292,7 +2295,7 @@ namespace MonoTests.System.Net.Sockets
                        listen.Bind (ep);
                        listen.Listen (1);
                        
-                       sock.Connect (ips, 1251);
+                       sock.Connect (ips, ep.Port);
                        
                        Assert.AreEqual (true, sock.Connected, "ConnectMultiple #1");
                        Assert.AreEqual (AddressFamily.InterNetwork, sock.RemoteEndPoint.AddressFamily, "ConnectMultiple #2");
@@ -2327,12 +2330,12 @@ namespace MonoTests.System.Net.Sockets
                         * Bind to IPAddress.Any; Connect() will fail unless it can
                         * connect to all the addresses in allIps.
                         */
-                       IPEndPoint ep = new IPEndPoint (IPAddress.Any, 1251);
+                       IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
 
                        listen.Bind (ep);
                        listen.Listen (1);
                        
-                       sock.Connect (allIps, 1251);
+                       sock.Connect (allIps, ep.Port);
                        
                        Assert.AreEqual (true, sock.Connected, "ConnectMultiple2 #1");
                        Assert.AreEqual (AddressFamily.InterNetwork, sock.RemoteEndPoint.AddressFamily, "ConnectMultiple2 #2");
@@ -2371,7 +2374,7 @@ namespace MonoTests.System.Net.Sockets
                                                  ProtocolType.Tcp);
                        IPAddress[] ips = new IPAddress[4];
                        IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
-                                                       1252);
+                                                       NetworkHelpers.FindFreePort ());
                        
                        ips[0] = IPAddress.Parse ("127.0.0.4");
                        ips[1] = IPAddress.Parse ("127.0.0.3");
@@ -2382,7 +2385,7 @@ namespace MonoTests.System.Net.Sockets
                        sock.Listen (1);
                        
                        try {
-                               sock.Connect (ips, 1252);
+                               sock.Connect (ips, ep.Port);
                                Assert.Fail ("ConnectMultipleListen #1");
                        } catch (InvalidOperationException) {
                        } catch {
@@ -2436,13 +2439,13 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1253);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
                        
                        sock.Bind (ep);
                        sock.Listen (1);
                        
                        try {
-                               sock.Connect ("localhost", 1253);
+                               sock.Connect ("localhost", ep.Port);
                                Assert.Fail ("ConnectHostPortListen #1");
                        } catch (InvalidOperationException) {
                        } catch {
@@ -2495,12 +2498,12 @@ namespace MonoTests.System.Net.Sockets
                                                    SocketType.Stream,
                                                    ProtocolType.Tcp);
                        IPAddress ip = IPAddress.Loopback;
-                       IPEndPoint ep = new IPEndPoint (ip, 1255);
+                       IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ());
                        
                        listen.Bind (ep);
                        listen.Listen (1);
                        
-                       sock.Connect (ip, 1255);
+                       sock.Connect (ip, ep.Port);
                        
                        Assert.AreEqual (true, sock.Connected, "Disconnect #1");
                        
@@ -2547,7 +2550,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        int i;
 
-                       IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1258);
+                       IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        Socket listensock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        listensock.Bind (endpoint);
@@ -2604,7 +2607,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        int i;
 
-                       IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1259);
+                       IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        Socket listensock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        listensock.Bind (endpoint);
@@ -2700,7 +2703,7 @@ namespace MonoTests.System.Net.Sockets
                                                SocketType.Dgram,
                                                ProtocolType.Udp);
                        CWRSocket.Bind (new IPEndPoint (IPAddress.Loopback,
-                                                       1256));
+                                                       NetworkHelpers.FindFreePort ()));
                        
                        Thread recv_thread = new Thread (new ThreadStart (CWRReceiveThread));
                        CWRReady.Reset ();
@@ -2718,7 +2721,7 @@ namespace MonoTests.System.Net.Sockets
                static bool RRCLastRead = false;
                static ManualResetEvent RRCReady = new ManualResetEvent (false);
                
-               private static void RRCClientThread ()
+               private static void RRCClientThread (int port)
                {
                        byte[] bytes = new byte[8];
                        int readbyte;
@@ -2727,7 +2730,7 @@ namespace MonoTests.System.Net.Sockets
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
                        sock.Connect (new IPEndPoint (IPAddress.Loopback,
-                                                     1257));
+                                                     port));
                        
                        NetworkStream stream = new NetworkStream (sock);
 
@@ -3068,7 +3071,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
                                ProtocolType.Tcp);
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, ref remoteEP);
                                Assert.Fail ("#1");
@@ -3110,7 +3113,7 @@ namespace MonoTests.System.Net.Sockets
                                ProtocolType.Tcp);
                        s.Close ();
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, ref remoteEP);
                                Assert.Fail ("#1");
@@ -3129,7 +3132,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
                                ProtocolType.Tcp);
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, (SocketFlags) 666, ref remoteEP);
                                Assert.Fail ("#1");
@@ -3171,7 +3174,7 @@ namespace MonoTests.System.Net.Sockets
                                ProtocolType.Tcp);
                        s.Close ();
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, (SocketFlags) 666, ref remoteEP);
                                Assert.Fail ("#1");
@@ -3190,7 +3193,7 @@ namespace MonoTests.System.Net.Sockets
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
                                ProtocolType.Tcp);
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, 0, (SocketFlags) 666,
                                        ref remoteEP);
@@ -3231,7 +3234,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        Socket s;
                        byte [] buffer = new byte [5];
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        // size negative
                        s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3274,7 +3277,7 @@ namespace MonoTests.System.Net.Sockets
                                ProtocolType.Tcp);
                        s.Close ();
 
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom ((Byte []) null, -1, (SocketFlags) 666,
                                        ref remoteEP);
@@ -3293,7 +3296,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
                                ProtocolType.Tcp);
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        try {
                                s.ReceiveFrom ((Byte []) null, -1, -1, (SocketFlags) 666,
@@ -3312,7 +3315,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        Socket s;
                        byte [] buffer = new byte [5];
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        // offset negative
                        s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3375,7 +3378,7 @@ namespace MonoTests.System.Net.Sockets
                {
                        Socket s;
                        byte [] buffer = new byte [5];
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 
                        // size negative
                        s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3436,7 +3439,7 @@ namespace MonoTests.System.Net.Sockets
                        s.Close ();
 
                        byte [] buffer = new byte [5];
-                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001);
+                       EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        try {
                                s.ReceiveFrom (buffer, -1, -1, (SocketFlags) 666,
                                        ref remoteEP);
@@ -3453,14 +3456,15 @@ namespace MonoTests.System.Net.Sockets
                [Test]
                public void ReceiveRemoteClosed ()
                {
+                       var port = NetworkHelpers.FindFreePort ();
                        Socket sock = new Socket (AddressFamily.InterNetwork,
                                                  SocketType.Stream,
                                                  ProtocolType.Tcp);
-                       sock.Bind (new IPEndPoint (IPAddress.Loopback, 1257));
+                       sock.Bind (new IPEndPoint (IPAddress.Loopback, port));
                        sock.Listen (1);
                        
                        RRCReady.Reset ();
-                       Thread client_thread = new Thread (new ThreadStart (RRCClientThread));
+                       Thread client_thread = new Thread (() => RRCClientThread (port));
                        client_thread.Start ();
                        
                        Socket client = sock.Accept ();
@@ -3482,12 +3486,13 @@ namespace MonoTests.System.Net.Sockets
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                        s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                        
-                       s.Bind (new IPEndPoint (IPAddress.Any, 12345));
+                       var ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
+                       s.Bind (ep);
                        
                        Socket ss = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                        ss.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                        
-                       ss.Bind (new IPEndPoint (IPAddress.Any, 12345));
+                       ss.Bind (new IPEndPoint (IPAddress.Any, ep.Port));
 
                        // If we make it this far, we succeeded.
                        
@@ -3525,15 +3530,15 @@ namespace MonoTests.System.Net.Sockets
                        using (Socket ss = new Socket (AddressFamily.InterNetwork,
                                                SocketType.Stream, ProtocolType.Tcp)) {
                                s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
-
-                               s.Bind (new IPEndPoint (IPAddress.Any, 12345));
+                               var ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
+                               s.Bind (ep);
                                s.Listen(1);
 
                                ss.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
 
                                Exception ex = null;
                                try {
-                                       ss.Bind (new IPEndPoint (IPAddress.Any, 12345));
+                                       ss.Bind (new IPEndPoint (IPAddress.Any, ep.Port));
                                        ss.Listen(1);
                                } catch (SocketException e) {
                                        ex = e;
@@ -3547,11 +3552,11 @@ namespace MonoTests.System.Net.Sockets
                [Category ("NotOnMac")]
                 public void ConnectedProperty ()
                 {
-                       TcpListener listener = new TcpListener (IPAddress.Loopback, 23456);
+                       TcpListener listener = new TcpListener (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        listener.Start();
 
                        Socket client = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-                       client.Connect (IPAddress.Loopback, 23456);
+                       client.Connect (IPAddress.Loopback, ((IPEndPoint)listener.LocalEndpoint).Port);
                        Socket server = listener.AcceptSocket ();
 
                        try {
@@ -3753,7 +3758,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 
                        using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.Any, 1901));
+                               s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                                try {
                                        s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership,
                                                new IPv6MulticastOption (mcast_addr));
@@ -3775,7 +3780,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 
                        using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.Any, 1901));
+                               s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                                s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership,
                                        new MulticastOption (mcast_addr));
                        }
@@ -3814,7 +3819,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
                        using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ()));
                                s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
                                        new IPv6MulticastOption (mcast_addr));
                        }
@@ -3829,7 +3834,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
                        using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ()));
                                try {
                                        s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
                                                new MulticastOption (mcast_addr));
@@ -3980,7 +3985,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 
                        using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.Any, 1901));
+                               s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                                s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership,
                                        new MulticastOption (mcast_addr));
                                try {
@@ -4006,7 +4011,7 @@ namespace MonoTests.System.Net.Sockets
                        using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) {
                                MulticastOption option = new MulticastOption (mcast_addr);
 
-                               s.Bind (new IPEndPoint (IPAddress.Any, 1901));
+                               s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()));
                                s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership,
                                        option);
                                s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.DropMembership,
@@ -4065,7 +4070,7 @@ namespace MonoTests.System.Net.Sockets
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
 
                        using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) {
-                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+                               s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ()));
                                s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
                                        new IPv6MulticastOption (mcast_addr));
                                try {
@@ -4194,7 +4199,7 @@ namespace MonoTests.System.Net.Sockets
                public void Shutdown_NoConnect ()
                {
                        Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-                       s.Bind (new IPEndPoint (IPAddress.Loopback, 0));
+                       s.Bind (new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()));
                        s.Listen (1);
                        try {
                                s.Shutdown (SocketShutdown.Both);
@@ -4332,7 +4337,7 @@ namespace MonoTests.System.Net.Sockets
                public void ConnectToIPV4EndPointUsingDualModelSocket () {
                        using (var server = new Socket (SocketType.Stream, ProtocolType.Tcp))
                        using (var client = new Socket (SocketType.Stream, ProtocolType.Tcp)) {
-                               var host = new IPEndPoint (IPAddress.Loopback, 0);
+                               var host = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                                        
                                server.Bind (host);
                                server.Listen (0);
@@ -4354,7 +4359,7 @@ namespace MonoTests.System.Net.Sockets
                public void BeginConnectToIPV4EndPointUsingDualModelSocket () {
                        using (var server = new Socket (SocketType.Stream, ProtocolType.Tcp))
                        using (var client = new Socket (SocketType.Stream, ProtocolType.Tcp)) {
-                               var host = new IPEndPoint (IPAddress.Loopback, 0);
+                               var host = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                                        
                                server.Bind (host);
                                server.Listen (0);
@@ -4383,7 +4388,7 @@ namespace MonoTests.System.Net.Sockets
 
                        Socket listenSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        
-                       listenSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
+                       listenSocket.Bind (new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()));
                        listenSocket.Listen (1);
 
                        listenSocket.BeginAccept (new AsyncCallback (ReceiveCallback), listenSocket);
@@ -4408,7 +4413,7 @@ namespace MonoTests.System.Net.Sockets
                        /* see https://bugzilla.xamarin.com/show_bug.cgi?id=36941 */
 
                        using (Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) {
-                               IPEndPoint end_point = new IPEndPoint (IPAddress.Any, 11000);
+                               IPEndPoint end_point = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
                                socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                                socket.Bind (end_point);
                                socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 19);
index 9fc807acc278015e9beb1b7b7d510f912c7957f4..2540e23603143f4999cba59f4c9b11cdc42d6a09 100644 (file)
@@ -67,7 +67,7 @@ CORLIB_MONO_POSIX_REF = -r:Mono.Posix.dll
 endif
 
 # System.IO/DirectoryInfoTest.cs needs Mono.Posix
-TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe $(CORLIB_MONO_POSIX_REF) -r:System.Core.dll \
+TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe $(CORLIB_MONO_POSIX_REF) -r:System.Core.dll -r:System.dll \
                                 -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%)
 
 EXTRA_DISTFILES = \
@@ -95,39 +95,6 @@ CLEAN_FILES += $(TEST_RESX_RESOURCES)
 
 include $(topdir)/build/library.make
 
-ifdef FIXME_CORLIB_CMP
-# corlib_cmp
-corlib_flags = -unsafe -nostdlib
-cmplib = $(topdir)/class/lib/$(PROFILE)/corlib_cmp.dll
-cmppdb = $(cmplib:.dll=.pdb)
-cmp_response = $(depsdir)/$(PROFILE)_corlib_cmp.dll.response
-cmp_makefrag = $(depsdir)/$(PROFILE)_corlib_cmp.dll.makefrag
-cmp_flags = -r:$(PLATFORM_CORLIB) $(corlib_flags)
-
-EXTRA_DISTFILES += corlib_cmp.dll.excludes
-CLEAN_FILES += $(cmplib) $(cmp_response) $(cmp_makefrag) $(cmppdb)
-
-$(cmplib): $(cmp_makefrag) $(cmp_response)
-       $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) -target:library -out:$@ @$(cmp_response)
-
-$(cmp_response): $(sourcefile) corlib_cmp.dll.excludes
-       @echo Creating $@ ...
-       @sort $(sourcefile) corlib_cmp.dll.excludes | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
-
-$(cmp_makefrag): $(cmp_response)
-       @echo Creating $@ ...
-       @sed 's,^,$(cmplib): ,' $< >$@
-
-# Since we make corlib_cmp on demand, there isn't a real need
-# to have full dep tracking for it. Also, the generation of this
-# file is busted on Win32 ('sort' seems to mess up line endings),
-# leading to a broken build.
-#
-# -include $(cmp_makefrag)
-
-$(cmp_response) $(cmp_makefrag): Makefile $(depsdir)/.stamp
-endif
-
 $(TEST_RESX_RESOURCES) $(TEST_RESX_RESOURCES_SATELITE): %.resources: %.resx
        $(RESGEN) $< || cp $@.prebuilt $@
 
index daf8eb72322c4afb80c2da740219ce0ba5f0d2db..b442da4d2fb51057e180cb1252e4409cc024306d 100644 (file)
@@ -683,7 +683,11 @@ namespace Mono {
                                                n = 2;
                                                break;
                                        case '7':
+#if PCL
+                                               e = Encoding.GetEncoding ("utf-7");
+#else
                                                e = Encoding.UTF7;
+#endif
                                                n = 1;
                                                break;
                                        case 'b':
@@ -691,11 +695,19 @@ namespace Mono {
                                                n = 2;
                                                break;
                                        case '3':
+#if PCL
+                                               e = Encoding.GetEncoding ("utf-32");
+#else
                                                e = Encoding.GetEncoding (12000);
+#endif
                                                n = 4;
                                                break;
                                        case '4':
+#if PCL
+                                               e = Encoding.GetEncoding ("utf-32BE");
+#else
                                                e = Encoding.GetEncoding (12001);
+#endif
                                                n = 4;
                                                break;
                                        
index cad54a4d553f71ff2141c8227c880d16332a2add..1e53bade58fbf5653b11b0d124bbbe31e7ead55b 100644 (file)
@@ -230,13 +230,17 @@ namespace System.IO {
                {
                        if (destFileName == null)
                                throw new ArgumentNullException ("destFileName");
-                       if (destFileName == Name || destFileName == FullName)
+                       if (destFileName.Length == 0)
+                               throw new ArgumentException ("An empty file name is not valid.", "destFileName");
+
+                       var destFullPath = Path.GetFullPath (destFileName);
+                       if (destFullPath == FullPath)
                                return;
                        if (!File.Exists (FullPath))
                                throw new FileNotFoundException ();
 
-                       File.Move (FullPath, destFileName);
-                       this.FullPath = Path.GetFullPath (destFileName);
+                       File.Move (FullPath, destFullPath);
+                       this.FullPath = destFullPath;
                }
 
                public FileInfo CopyTo (string destFileName)
index 41a79eb6d7e560e48797c385a6804d1f51070533..9bc0b8a5994500a625b81919aa59c85cb18192a9 100644 (file)
@@ -283,6 +283,12 @@ namespace System.Reflection.Emit
                        throw new NotSupportedException ();
                }
 
+               public override ParameterInfo ReturnParameter {
+                       get {
+                               throw new NotSupportedException();
+                       }
+               }
+
                public override ICustomAttributeProvider ReturnTypeCustomAttributes {
                        get {
                                throw new NotSupportedException ();
diff --git a/mcs/class/corlib/System.Reflection/MethodInfo.cs b/mcs/class/corlib/System.Reflection/MethodInfo.cs
deleted file mode 100644 (file)
index 83fc9a7..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-//
-// System.Reflection/MethodInfo.cs
-//
-// Author:
-//   Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace System.Reflection {
-
-       [ComVisible (true)]
-       [ComDefaultInterfaceAttribute (typeof (_MethodInfo))]
-       [Serializable]
-       [ClassInterface(ClassInterfaceType.None)]
-#if MOBILE
-       public abstract class MethodInfo: MethodBase {
-#else
-       public abstract class MethodInfo: MethodBase, _MethodInfo {
-#endif
-               public abstract MethodInfo GetBaseDefinition();
-
-               internal virtual MethodInfo GetBaseMethod ()
-               {
-                       return this;
-               }
-
-               protected MethodInfo() {
-               }
-
-
-               public override MemberTypes MemberType { get {return MemberTypes.Method;} }
-
-               public virtual Type ReturnType {
-                       get { return null; }
-               }
-
-               public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
-
-#if !MOBILE
-               void _MethodInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               Type _MethodInfo.GetType ()
-               {
-                       // Required or object::GetType becomes virtual final
-                       return base.GetType ();
-               }
-
-               void _MethodInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               void _MethodInfo.GetTypeInfoCount (out uint pcTInfo)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               void _MethodInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
-               {
-                       throw new NotImplementedException ();
-               }
-#endif
-
-               [ComVisible (true)]
-               public virtual MethodInfo GetGenericMethodDefinition ()
-               {
-                       throw new NotSupportedException ();
-               }
-
-               public virtual MethodInfo MakeGenericMethod (params Type [] typeArguments)
-               {
-                       throw new NotSupportedException (this.GetType().ToString ());
-               }
-
-               // GetGenericArguments, IsGenericMethod, IsGenericMethodDefinition
-               // and ContainsGenericParameters are implemented in the derived classes.
-               [ComVisible (true)]
-               public override Type [] GetGenericArguments () {
-                       return Type.EmptyTypes;
-               }
-
-
-               public virtual ParameterInfo ReturnParameter {
-                       get {
-                               throw new NotSupportedException ();
-                       }
-               }
-
-               public override bool Equals (object obj)
-               {
-                       return obj == (object) this;
-               }
-
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-
-               public static bool operator == (MethodInfo left, MethodInfo right)
-               {
-                       if ((object)left == (object)right)
-                               return true;
-                       if ((object)left == null ^ (object)right == null)
-                               return false;
-                       return left.Equals (right);
-               }
-
-               public static bool operator != (MethodInfo left, MethodInfo right)
-               {
-                       if ((object)left == (object)right)
-                               return false;
-                       if ((object)left == null ^ (object)right == null)
-                               return true;
-                       return !left.Equals (right);
-               }
-
-               public virtual Delegate CreateDelegate (Type delegateType)
-               {
-                       return Delegate.CreateDelegate (delegateType, this);
-               }
-
-               public virtual Delegate CreateDelegate (Type delegateType, object target)
-               {
-                       return Delegate.CreateDelegate (delegateType, target, this);
-               }
-       }
-}
index f9a931f1135d39d71828ea7573124ee49683542e..544774d1786061abd71dcd490fc36a4c8e4dbf4b 100644 (file)
@@ -149,6 +149,16 @@ namespace System.Reflection {
             return sbName.ToString();
         }
 
+               public override Delegate CreateDelegate (Type delegateType)
+               {
+                       return Delegate.CreateDelegate (delegateType, this);
+               }
+
+               public override Delegate CreateDelegate (Type delegateType, object target)
+               {
+                       return Delegate.CreateDelegate (delegateType, target, this);
+               }
+
         public override String ToString() 
         {
             return ReturnType.FormatTypeName() + " " + FormatNameAndSig(false);
index 297a54bf74b853ee15086f6aa7de325687526cf7..0068c4643b8fdcae08e5070ee5ed340ab9d64cdf 100644 (file)
@@ -651,6 +651,33 @@ namespace MonoTests.System.IO
                        }
                }
 
+               [Test] //Covers #18361
+               public void MoveTo_SameName ()
+               {
+                       string name = "FIT.MoveTo.SameName.Test";
+                       string path1 = TempFolder + DSC + name;
+                       string path2 = name;
+                       DeleteFile (path1);
+                       DeleteFile (path2);
+                       
+                       try {
+                               File.Create (path1).Close ();
+                               FileInfo info1 = new FileInfo (path1);
+                               FileInfo info2 = new FileInfo (path2);
+                               Assert.IsTrue (info1.Exists, "#A1");
+                               Assert.IsFalse (info2.Exists, "#A2");
+
+                               info1.MoveTo (path2);
+                               info1 = new FileInfo (path1);
+                               info2 = new FileInfo (path2);
+                               Assert.IsFalse (info1.Exists, "#B1");
+                               Assert.IsTrue (info2.Exists, "#B2");
+                       } finally {
+                               DeleteFile (path1);
+                               DeleteFile (path2);
+                       }
+               }
+
                [Test]
                public void MoveTo_DestFileName_AlreadyExists ()
                {
index be6236d6a0700d5c07c399ad02479732d13bd050..2eae58e3e444e17fdc8447ccaee689a3aa6605bf 100644 (file)
@@ -1660,6 +1660,25 @@ namespace MonoTests.System.IO
                        
                }
 
+               [Test]
+               public void OpenCharDeviceRepeatedly ()
+               {
+                       // https://bugzilla.xamarin.com/show_bug.cgi?id=38408
+                       try {
+                               using (var f = new FileStream ("/dev/zero", FileMode.Open))
+                               {
+                               }
+                       } catch (FileNotFoundException) {
+                               // Only run this test on platforms where /dev/zero exists
+                               Assert.Ignore();
+                       }
+
+                       // this shouldn't throw
+                       using (var g = new FileStream ("/dev/zero", FileMode.Open))
+                       {
+                       }
+               }
+
 #if !MOBILE
                [Test]
                public void WriteWithExposedHandle ()
index 82aab2be0613795941937c7499286cc7e067d308..474abcd2208084f4ab516897df9e560c0d1d667a 100644 (file)
@@ -175,7 +175,14 @@ namespace MonoTests.System.Text
                        Assert.AreEqual (0x32, (int) s [5], "#B7");
                }
 
-               // UTF8 decoding tests from http://www.cl.cam.ac.uk/~mgk25/
+               //
+               // UTF8 decoding tests are based on the test file from http://www.cl.cam.ac.uk/~mgk25/
+               // The test file is: https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
+               // which is licensed under CC-by-4.0: https://creativecommons.org/licenses/by/4.0/
+               //
+               // The file is not copied verbatim, instead individual
+               // tests are based on individual portions of that file
+               //
 
                [Test]
                public void T1_Correct_GreekWord_kosme () 
index 7119236c8aab2bb638ec9916a2191e761088ed7c..a45c7ec198cb62b2fb068a2a13b743b86f535288 100644 (file)
@@ -16,6 +16,10 @@ using System.Globalization;
 using System.Reflection;
 using System.Threading;
 
+#if !MOBILE
+using System.Diagnostics;
+#endif
+
 using NUnit.Framework;
 
 namespace MonoTests.System
@@ -92,19 +96,36 @@ public class StringTest
                }
        }
 
+       // Several tests in this file, to run properly, allocate 4GB objects.
+       // Obviously this creates problems on several kinds of systems, so we
+       // conservatively skip these tests unless we find a high-RAM environment.
+       // Checking RAM requires PerformanceCounter which is absent on mobile,
+       // so any test that calls this must be category MobileNotWorking.
+       static void RequireHighMemoryTestEnvironment ()
+       {
+#if MOBILE
+               Assert.Ignore("PerformanceCounter not available.");
+#else
+               if (!Environment.Is64BitProcess)
+                       Assert.Ignore("This test cannot run on a 32-bit system.");
+
+               // Require 6 GB physical RAM, for the 4GB string plus 2GB headroom
+               var pc = new PerformanceCounter ("Mono Memory", "Total Physical Memory");
+
+               if (pc.RawValue < 6L*1024L*1024L*1024L)
+                       Assert.Ignore("This machine may not have enough RAM to run this test.");
+#endif
+       }
+
        [Test] // ctor (Char, Int32)
+       [Category ("MobileNotWorking")]
        public void Constructor4_LargeString ()
        {
-               try {
-                       var x = new String ('A', int.MaxValue);
-                       if (Environment.Is64BitProcess) {
-                               Assert.AreEqual ('A', x[0]);
-                               Assert.AreEqual ('A', x[int.MaxValue - 1]);
-                       }
-                       else
-                               Assert.Fail ("Expected OutOfMemoryException.");
-               } catch (OutOfMemoryException) {
-               }
+               RequireHighMemoryTestEnvironment();
+
+               var x = new String ('A', int.MaxValue);
+               Assert.AreEqual ('A', x[0]);
+               Assert.AreEqual ('A', x[int.MaxValue - 1]);
        }
 
        [Test] // ctor (Char [], Int32, Int32)
@@ -3008,18 +3029,14 @@ public class StringTest
        }
 
        [Test]
+       [Category ("MobileNotWorking")]
        public void PadLeft_LargeString ()
        {
-               try {
-                       var x = "x".PadLeft (int.MaxValue, '-');
-                       if (Environment.Is64BitProcess) {
-                               Assert.AreEqual ('-', x[0]);
-                               Assert.AreEqual ('x', x[int.MaxValue - 1]);
-                       }
-                       else
-                               Assert.Fail ("Expected OutOfMemoryException.");
-               } catch (OutOfMemoryException) {
-               }
+               RequireHighMemoryTestEnvironment();
+
+               var x = "x".PadLeft (int.MaxValue, '-');
+               Assert.AreEqual ('-', x[0]);
+               Assert.AreEqual ('x', x[int.MaxValue - 1]);
        }
 
        [Test] // PadRight (Int32)
@@ -3064,18 +3081,14 @@ public class StringTest
        }
 
        [Test]
+       [Category ("MobileNotWorking")]
        public void PadRight_LargeString ()
        {
-               try {
-                       var x = "x".PadRight (int.MaxValue, '-');
-                       if (Environment.Is64BitProcess) {
-                               Assert.AreEqual ('x', x[0]);
-                               Assert.AreEqual ('-', x[int.MaxValue - 1]);
-                       }
-                       else
-                               Assert.Fail ("Expected OutOfMemoryException.");
-               } catch (OutOfMemoryException) {
-               }
+               RequireHighMemoryTestEnvironment();
+
+               var x = "x".PadRight (int.MaxValue, '-');
+               Assert.AreEqual ('x', x[0]);
+               Assert.AreEqual ('-', x[int.MaxValue - 1]);
        }
 
        [Test] // Remove (Int32, Int32)
index 223880c02974001e645a20cc5cd045655f8a6e2c..b4b398166e83411b01d8ad167b3f5f55882f48d5 100644 (file)
@@ -60,6 +60,7 @@
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\action.cs" />\r
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\activator.cs" />\r
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\AggregateException.cs" />\r
+    <Compile Include="..\..\..\external\referencesource\mscorlib\system\AppContext\AppContext.cs" />\r
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\appdomainattributes.cs" />\r
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\appdomainunloadedexception.cs" />\r
     <Compile Include="..\..\..\external\referencesource\mscorlib\system\applicationexception.cs" />\r
     <Compile Include="System.Security\PermissionBuilder.cs" />\r
     <Compile Include="System.Security\PermissionSet.cs" />\r
     <Compile Include="System.Security\PolicyLevelType.cs" />\r
+    <Compile Include="System.Security\SafeAccessTokenHandle.cs" />\r
     <Compile Include="System.Security\SecureString.cs" />\r
     <Compile Include="System.Security\SecurityElement.cs" />\r
     <Compile Include="System.Security\SecurityException.cs" />\r
     <Compile Include="System\__ComObject.cs" />\r
     <Compile Include="System\ActivationContext.cs" />\r
     <Compile Include="System\AndroidPlatform.cs" />\r
-    <Compile Include="System\AppContext.cs" />\r
     <Compile Include="System\AppDomain.cs" />\r
     <Compile Include="System\AppDomainInitializer.cs" />\r
     <Compile Include="System\AppDomainManager.cs" />\r
index 8e353e5539c4ada9eeb3d7aa420dbfdb80518856..55755abad47c39e0c920ee200f0f79f386ea7981 100644 (file)
@@ -239,7 +239,6 @@ System.Reflection/FieldInfo.cs
 System.Reflection/ImageFileMachine.cs
 System.Reflection/LocalVariableInfo.cs
 System.Reflection/MethodBody.cs
-System.Reflection/MethodInfo.cs
 System.Reflection/Module.cs
 System.Reflection/ModuleResolveEventHandler.cs
 System.Reflection/MonoAssembly.cs
@@ -1238,6 +1237,7 @@ ReferenceSources/SecurityContext.cs
 ../../../external/referencesource/mscorlib/system/reflection/methodbase.cs
 ../../../external/referencesource/mscorlib/system/reflection/methodbody.cs
 ../../../external/referencesource/mscorlib/system/reflection/methodimplattributes.cs
+../../../external/referencesource/mscorlib/system/reflection/methodinfo.cs
 ../../../external/referencesource/mscorlib/system/reflection/missing.cs
 ../../../external/referencesource/mscorlib/system/reflection/obfuscateassemblyattribute.cs
 ../../../external/referencesource/mscorlib/system/reflection/obfuscationattribute.cs
index 69097d496391df35fbb67104ea05d9f113dd6946..d69feb3de5b15bd0bd0c08a986db9865c0098104 100644 (file)
@@ -77,6 +77,7 @@ namespace Mono.CSharp
 
                // Win32 version info values
                string vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark;
+               string pa_file_version, pa_assembly_version;
 
                protected AssemblyDefinition (ModuleContainer module, string name)
                {
@@ -240,6 +241,7 @@ namespace Mono.CSharp
                                        SetCustomAttribute (ctor, cdata);
                                } else {
                                        builder_extra.SetVersion (vinfo, a.Location);
+                                       pa_assembly_version = vinfo.ToString ();
                                }
 
                                return;
@@ -357,15 +359,15 @@ namespace Mono.CSharp
                        } else if (a.Type == pa.RuntimeCompatibility) {
                                wrap_non_exception_throws_custom = true;
                        } else if (a.Type == pa.AssemblyFileVersion) {
-                               vi_product_version = a.GetString ();
-                               if (string.IsNullOrEmpty (vi_product_version) || IsValidAssemblyVersion (vi_product_version, false) == null) {
+                               pa_file_version = a.GetString ();
+                               if (string.IsNullOrEmpty (pa_file_version) || IsValidAssemblyVersion (pa_file_version, false) == null) {
                                        Report.Warning (7035, 1, a.Location, "The specified version string `{0}' does not conform to the recommended format major.minor.build.revision",
-                                               vi_product_version, a.Name);
+                                                       pa_file_version, a.Name);
                                        return;
                                }
 
                                // File version info decoding from blob is not supported
-                               var cab = new CustomAttributeBuilder ((ConstructorInfo) ctor.GetMetaInfo (), new object[] { vi_product_version });
+                               var cab = new CustomAttributeBuilder ((ConstructorInfo)ctor.GetMetaInfo (), new object [] { pa_file_version });
                                Builder.SetCustomAttribute (cab);
                                return;
                        } else if (a.Type == pa.AssemblyProduct) {
@@ -378,6 +380,8 @@ namespace Mono.CSharp
                                vi_trademark = a.GetString ();
                        } else if (a.Type == pa.Debuggable) {
                                has_user_debuggable = true;
+                       } else if (a.Type == pa.AssemblyInformationalVersion) {
+                               vi_product_version = a.GetString ();
                        }
 
                        //
@@ -817,7 +821,11 @@ namespace Mono.CSharp
                        if (Compiler.Settings.Win32ResourceFile != null) {
                                Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile);
                        } else {
-                               Builder.DefineVersionInfoResource (vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark);
+                               Builder.DefineVersionInfoResource (vi_product, 
+                                                                  vi_product_version ?? pa_file_version ?? pa_assembly_version,
+                                                                  vi_company,
+                                                                  vi_copyright,
+                                                                  vi_trademark);
                        }
 
                        if (Compiler.Settings.Win32IconFile != null) {
index a145c37211fd58b2441b23dd32ec5b35a6a12a7a..8edce969a443819cabe510b5da2804ba4796a2dd 100644 (file)
@@ -1700,6 +1700,7 @@ namespace Mono.CSharp {
                public readonly PredefinedAttribute AssemblyAlgorithmId;
                public readonly PredefinedAttribute AssemblyFlags;
                public readonly PredefinedAttribute AssemblyFileVersion;
+               public readonly PredefinedAttribute AssemblyInformationalVersion;
                public readonly PredefinedAttribute ComImport;
                public readonly PredefinedAttribute CoClass;
                public readonly PredefinedAttribute AttributeUsage;
@@ -1800,6 +1801,7 @@ namespace Mono.CSharp {
                        AssemblyCompany = new PredefinedAttribute (module, "System.Reflection", "AssemblyCompanyAttribute");
                        AssemblyCopyright = new PredefinedAttribute (module, "System.Reflection", "AssemblyCopyrightAttribute");
                        AssemblyTrademark = new PredefinedAttribute (module, "System.Reflection", "AssemblyTrademarkAttribute");
+                       AssemblyInformationalVersion = new PredefinedAttribute (module, "System.Reflection", "AssemblyInformationalVersionAttribute");
 
                        AsyncStateMachine = new PredefinedStateMachineAttribute (module, "System.Runtime.CompilerServices", "AsyncStateMachineAttribute");
 
index 9ec4d99766cda5ed9e154a080e11c270297262ba..8553856ac585229093f9edb551cd9f993ce78276 100644 (file)
@@ -499,9 +499,7 @@ namespace Mono.CSharp {
 
                public override Expression CreateExpressionTree (ResolveContext ec)
                {
-                       MemberAccess ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);
-
-                       Arguments args = new Arguments (3);
+                       Arguments args = new Arguments (2);
                        args.Add (new Argument (new TypeOf (type, loc)));
 
                        if (method_group.InstanceExpression == null)
@@ -509,7 +507,21 @@ namespace Mono.CSharp {
                        else
                                args.Add (new Argument (method_group.InstanceExpression));
 
-                       args.Add (new Argument (method_group.CreateExpressionTree (ec)));
+                       Expression ma;
+                       var create_v45 = ec.Module.PredefinedMembers.MethodInfoCreateDelegate.Get ();
+                       if (create_v45 != null) {
+                               //
+                               // .NET 4.5 has better API but it produces different instance than Delegate::CreateDelegate
+                               // and because csc uses this enhancement we have to as well to be fully compatible
+                               //
+                               var mg = MethodGroupExpr.CreatePredefined (create_v45, create_v45.DeclaringType, loc);
+                               mg.InstanceExpression = method_group.CreateExpressionTree (ec);
+                               ma = mg;
+                       } else {
+                               ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);
+                               args.Add (new Argument (method_group.CreateExpressionTree (ec)));
+                       }
+
                        Expression e = new Invocation (ma, args).Resolve (ec);
                        if (e == null)
                                return null;
index b16e2f38b9fefa8e189722f9fc636405a3ee5ff8..a5a9ad15607da053892c5073fee28ecfcdd25130 100644 (file)
@@ -384,6 +384,7 @@ namespace Mono.CSharp
                public readonly PredefinedMember<MethodSpec> FixedBufferAttributeCtor;
                public readonly PredefinedMember<MethodSpec> MethodInfoGetMethodFromHandle;
                public readonly PredefinedMember<MethodSpec> MethodInfoGetMethodFromHandle2;
+               public readonly PredefinedMember<MethodSpec> MethodInfoCreateDelegate;
                public readonly PredefinedMember<MethodSpec> MonitorEnter;
                public readonly PredefinedMember<MethodSpec> MonitorEnter_v4;
                public readonly PredefinedMember<MethodSpec> MonitorExit;
@@ -659,6 +660,10 @@ namespace Mono.CSharp
                        MethodInfoGetMethodFromHandle2 = new PredefinedMember<MethodSpec> (module, types.MethodBase,
                                "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType (btypes.RuntimeTypeHandle));
 
+                       MethodInfoCreateDelegate = new PredefinedMember<MethodSpec> (module, types.MethodInfo,
+                                                                                    "CreateDelegate", MemberKind.Method,
+                                                                                    new PredefinedType (btypes.Type), new PredefinedType (btypes.Object));
+
                        MonitorEnter = new PredefinedMember<MethodSpec> (module, types.Monitor, "Enter", btypes.Object);
 
                        MonitorEnter_v4 = new PredefinedMember<MethodSpec> (module, types.Monitor,
index 74a4d1ad1f4f4788e16453eb942c84357efa6f5c..6e46735c81812f4a1fb0de37d530bf5b3529ee1b 100644 (file)
@@ -27,13 +27,13 @@ class C
        int TestInstance ()
        {
                Expression<Func<EmptyDelegate>> e = () => M;
-               if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, value(C), Void M()))")
+               if (e.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, value(C)))")
                        return 1;
                
                e.Compile () ();
                
                Expression<Func<C, EmptyDelegate>> e2 = (l) => l.M;
-               if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, l, Void M()))")
+               if (e2.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, l))")
                        return 2;
                
                e2.Compile () (this);
@@ -43,8 +43,7 @@ class C
        public static int Main ()
        {
                Expression<Func<EmptyDelegate>> e = () => new EmptyDelegate (Test);
-               
-               if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
+               if (e.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
                        return 1;
 
                var v = e.Compile ();
@@ -54,7 +53,7 @@ class C
                        return 2;
                
                Expression<Func<EmptyDelegate>> e2 = () => Test;
-               if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
+               if (e2.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
                        return 3;
 
                var v2 = e2.Compile ();
@@ -65,7 +64,7 @@ class C
                        
                unsafe {
                        Expression<Func<UnsafeDelegate>> e3 = () => new UnsafeDelegate (Foo);
-                       if (e3.Body.ToString () != "Convert(CreateDelegate(UnsafeDelegate, null, Int32* Foo()))")
+                       if (e3.Body.ToString () != "Convert(Int32* Foo().CreateDelegate(UnsafeDelegate, null))")
                                return 5;
                        
                        var v3 = e3.Compile ();
diff --git a/mcs/tests/gtest-etree-31.cs b/mcs/tests/gtest-etree-31.cs
new file mode 100644 (file)
index 0000000..350a64a
--- /dev/null
@@ -0,0 +1,31 @@
+using System;
+using System.Linq.Expressions;
+
+class X
+{
+       class HasAction
+       {
+               public void Start ()
+               {
+               }
+       }
+
+       public static int Main ()
+       {
+               var expectedObject = typeof (HasAction).GetMethod("Start");
+
+               Expression<Func<HasAction, Action>> methodToUse = r => r.Start;
+               
+               UnaryExpression unary = methodToUse.Body as UnaryExpression;
+               MethodCallExpression methodCall = unary.Operand as MethodCallExpression;
+               ConstantExpression constantExpression = methodCall.Object as ConstantExpression;
+
+               if (expectedObject != constantExpression.Value)
+                       return 1;
+
+               if (methodCall.Object == null)
+                       return 2;
+
+               return 0;
+       }
+}
\ No newline at end of file
index b649279812506f9d02a19cf558fec4681c024a20..e57c81cfd743f451e79d7b95069add58d551b878 100644 (file)
@@ -14,6 +14,9 @@ class X
                if (fvi.FileVersion != "2011.02.0.0")
                        return 1;
 
+               if (fvi.ProductVersion != "2011.02.0.0")
+                       return 2;
+
                return 0;
        }
 }
\ No newline at end of file
index 76a4c4217b67d1d3de70cf638339671c5b8f18dd..47486e7f971cd3edee09a15d8db0996657c48d37 100644 (file)
         <size>102</size>
       </method>
       <method name="Void ConvertTest_12()" attrs="129">
-        <size>142</size>
+        <size>141</size>
       </method>
       <method name="Void ConvertTest_13()" attrs="129">
         <size>87</size>
         <size>313</size>
       </method>
       <method name="Void EqualTestDelegate_3()" attrs="129">
-        <size>230</size>
+        <size>229</size>
       </method>
       <method name="Void ExclusiveOrTest()" attrs="129">
         <size>116</size>
         <size>2</size>
       </method>
       <method name="Int32 TestInstance()" attrs="129">
-        <size>339</size>
+        <size>337</size>
       </method>
       <method name="Int32 Main()" attrs="150">
-        <size>583</size>
+        <size>580</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
         <size>9</size>
       </method>
       <method name="Int32 Main()" attrs="150">
-        <size>222</size>
+        <size>221</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
       </method>
     </type>
   </test>
+  <test name="gtest-etree-31.cs">
+    <type name="X">
+      <method name="Int32 Main()" attrs="150">
+        <size>241</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X+HasAction">
+      <method name="Void Start()" attrs="134">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-exmethod-01.cs">
     <type name="SimpleTest">
       <method name="System.String Prefix(System.String, System.String)" attrs="150">
   <test name="test-892.cs">
     <type name="X">
       <method name="Int32 Main()" attrs="150">
-        <size>66</size>
+        <size>94</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
diff --git a/mcs/tools/misc/.gitattributes b/mcs/tools/misc/.gitattributes
deleted file mode 100644 (file)
index 3ca3e2b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/EnumCheck.cs -crlf
-/EnumCheckAssemblyCollection.cs -crlf
-/GenerateDelegate.cs -crlf
-/IFaceDisco.cs -crlf
-/XMLUtil.cs -crlf
diff --git a/mcs/tools/misc/EnumCheck.cs b/mcs/tools/misc/EnumCheck.cs
deleted file mode 100644 (file)
index 8c564cc..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/**\r
- * Namespace: System.Web\r
- * Class:     EnumCheck\r
- *\r
- * Author:  Gaurav Vaish\r
- * Contact: <gvaish@iitk.ac.in>\r
- * Status:  100%\r
- *\r
- * (C) Gaurav Vaish (2002)\r
- */\r
-\r
-using System;\r
-using System.Xml;\r
-using System.Collections;\r
-using System.Reflection;\r
-\r
-namespace Mono.Enumerations\r
-{\r
-       public class EnumCheck\r
-       {\r
-               private string className;\r
-               private Type   type;\r
-               private EnumCheckAssemblyCollection ecac = new EnumCheckAssemblyCollection();\r
-               \r
-               public static string confFile = "assemblies.xml";\r
-\r
-               public EnumCheck(string className)\r
-               {\r
-                       this.className = className;\r
-                       ecac.Parse();\r
-               }\r
-\r
-               public void Display()\r
-               {\r
-                       ecac.ConfigFile = confFile;\r
-                       LoadType();\r
-                       if(type == null || !type.IsEnum)\r
-                       {\r
-                               System.Console.Write("-->Failed to load the enumeration: " + className);\r
-                               return;\r
-                       }\r
-                       Array ar = Enum.GetValues(type);\r
-                       System.Console.WriteLine("-->Enumeration: {0}", type.ToString());\r
-                       for(int i=0; i < ar.Length; i++)\r
-                       {\r
-                               Enum b = (Enum)ar.GetValue(i);\r
-                               System.Console.Write(" {0}", Enum.Format(type, b, "G"));\r
-                               System.Console.WriteLine(" ({0}) ", Enum.Format(type, b, "D"));\r
-                       }\r
-               }\r
-\r
-               private void LoadType()\r
-               {\r
-                       type = null;\r
-                       foreach(string url in ecac)\r
-                       {\r
-                               try\r
-                               {\r
-                                       Assembly assembly = Assembly.LoadFrom(url);\r
-                                       foreach(Type t in assembly.GetTypes())\r
-                                       {\r
-                                               if(!t.IsEnum)\r
-                                                       continue;\r
-                                               if(className == t.ToString())\r
-                                               {\r
-                                                       type = t;\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                               } catch(BadImageFormatException)\r
-                               {\r
-                               } catch(ReflectionTypeLoadException)\r
-                               {\r
-                               } catch(ArgumentException)\r
-                               {\r
-                               }\r
-                               if(type != null)\r
-                                       return;\r
-                       }\r
-               }\r
-\r
-               public static void PrintUsage()\r
-               {\r
-                       System.Console.WriteLine("Usage:");\r
-                       System.Console.WriteLine("EnumCheck [<enum> [<enum> [... ] ] ]");\r
-                       System.Console.WriteLine("");\r
-                       System.Console.WriteLine("enum := <namespace>[.<subnamespace>[...]].enum_name");\r
-                       System.Console.WriteLine("");\r
-               }\r
-\r
-               public static void Main(string[] args)\r
-               {\r
-                       if(args.Length > 0 && (args[0] == "--help" || args[0] == "-h"))\r
-                       {\r
-                               PrintUsage();\r
-                               return;\r
-                       }\r
-                       EnumCheck check = null;\r
-                       string bdir;\r
-                       System.Console.Write("Enter assembly configuration file [{0}]:", confFile);\r
-                       //System.Console.Write("[{0}]: ", confFile);\r
-                       bdir = System.Console.ReadLine();\r
-                       while(bdir.EndsWith("/") || bdir.EndsWith("\\"))\r
-                       {\r
-                               bdir = bdir.Substring(0, bdir.Length - 1);\r
-                       }\r
-                       if(bdir != "")\r
-                       {\r
-                               confFile = bdir;\r
-                       }\r
-                       if(args.Length != 0)\r
-                       {\r
-                               foreach(string clName in args)\r
-                               {\r
-                                       check = new EnumCheck(clName);\r
-                                       check.Display();\r
-                                       System.Console.WriteLine("\n");\r
-                               }\r
-                       }\r
-                       while(true)\r
-                       {\r
-                               System.Console.Write("Enter the name of the Enumeration (end to stop): ");\r
-                               string clName = System.Console.ReadLine();\r
-                               if(clName == "stop" || clName == "end" || clName.Length == 0)\r
-                                       break;\r
-                               check = new EnumCheck(clName);\r
-                               check.Display();\r
-                               System.Console.WriteLine("\n");\r
-                       }\r
-               }\r
-       }\r
-}\r
diff --git a/mcs/tools/misc/EnumCheckAssemblyCollection.cs b/mcs/tools/misc/EnumCheckAssemblyCollection.cs
deleted file mode 100644 (file)
index 470492c..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/**\r
- * Namespace: System.Web\r
- * Class:     EnumCheckAssembly\r
- *\r
- * Author:  Gaurav Vaish\r
- * Contact: <gvaish@iitk.ac.in>\r
- * Status:  100%\r
- *\r
- * (C) Gaurav Vaish (2002)\r
- */\r
-\r
-using System;\r
-using System.IO;\r
-using System.Xml;\r
-using System.Collections;\r
-using System.Reflection;\r
-\r
-namespace Mono.Enumerations\r
-{\r
-       public class EnumCheckAssemblyCollection: IEnumerable\r
-       {\r
-               public string ConfigFile = "assemblies.xml";\r
-               \r
-               private ArrayList assemblyList = new ArrayList();\r
-\r
-               public EnumCheckAssemblyCollection()\r
-               {\r
-               }\r
-\r
-               public void Parse()\r
-               {\r
-                       Stream      fStream;\r
-                       XmlReader   reader;\r
-                       XmlDocument document;\r
-                       string      url;\r
-\r
-                       fStream = new FileStream(ConfigFile, FileMode.Open, FileAccess.Read, FileShare.Read);\r
-                       reader = new XmlTextReader(fStream);\r
-                       document = new XmlDocument();\r
-                       document.Load(reader);\r
-                       if(document.DocumentElement != null)\r
-                       {\r
-                               if(document.DocumentElement.LocalName == "assemblies")\r
-                               {\r
-                                       foreach(XmlNode pathNode in document.DocumentElement)\r
-                                       {\r
-                                               if(pathNode.NodeType == XmlNodeType.Element && pathNode.LocalName=="path")\r
-                                               {\r
-                                                       url = pathNode.Attributes["url"].Value;\r
-                                                       while(url.EndsWith("\\") || url.EndsWith("/"))\r
-                                                       {\r
-                                                               url = url.Substring(0, url.Length - 1);\r
-                                                       }\r
-                                                       if(url == null || url.Length == 0)\r
-                                                       {\r
-                                                               continue;\r
-                                                       }\r
-                                                       foreach(XmlNode assemblyNode in pathNode.ChildNodes)\r
-                                                       {\r
-                                                               if(assemblyNode.LocalName == "assembly")\r
-                                                               {\r
-                                                                       assemblyList.Add(url + "\\" + assemblyNode.Attributes["file"].Value);\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-                       fStream.Close();\r
-               }\r
-\r
-               public IEnumerator GetEnumerator()\r
-               {\r
-                       return assemblyList.GetEnumerator();\r
-               }\r
-       }\r
-}\r
diff --git a/mcs/tools/misc/GenerateDelegate.cs b/mcs/tools/misc/GenerateDelegate.cs
deleted file mode 100644 (file)
index 0ba8e78..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/**\r
- * Namespace: com.mastergaurav.utils\r
- * Class:     GenerateDelegate\r
- *\r
- * Author:  Gaurav Vaish\r
- * Maintainer: gvaish@iitk.ac.in\r
- * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
- * Implementation: yes\r
- * Status:  100%\r
- *\r
- * (C) Gaurav Vaish (2001)\r
- */\r
-\r
-using System;\r
-using System.IO;\r
-\r
-namespace com.mastergaurav.Utils\r
-{\r
-       public class GenerateDelegate\r
-       {\r
-               public static string TargetDirectory = String.Empty;\r
-               public static string NamespaceName   = String.Empty;\r
-\r
-               public static readonly string PROLOGUE = "/**\n * Namespace: ";\r
-               public static readonly string DETAILS   = " *\n * Author: Gaurav Vaish\n" +\r
-                                                         " * Maintainer: gvaish@iitk.ac.in\n" +\r
-                                                         " * Contact:  <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\n" +\r
-                                                         " * Implementation: yes\n" +\r
-                                                         " * Status: 100%\n" +\r
-                                                         " *\n" +\r
-                                                         " * (C) Gaurav Vaish (2002)\n" +\r
-                                                         " */\n\n";\r
-               public static readonly string USING     = "using System;\n" +\r
-                                                         "using System.Web;\n" +\r
-                                                         "using System.Web.UI;\n\n";\r
-\r
-               public static readonly string NAMESPACE = "namespace ";\r
-\r
-               public static string AskForNamespace()\r
-               {\r
-                       string nm = String.Empty;\r
-                       System.Console.Write("Enter the name of the namespace: ");\r
-                       nm = System.Console.ReadLine();\r
-                       return nm;\r
-               }\r
-\r
-               public static string AskForMore()\r
-               {\r
-                       string del = String.Empty;\r
-                       System.Console.Write("Enter the name of the delegate (end to stop): ");\r
-                       del = System.Console.ReadLine();\r
-                       if(del == String.Empty || del == "end")\r
-                               return String.Empty;\r
-                       return del;\r
-               }\r
-\r
-               public static void Generate(string delName)\r
-               {\r
-                       string fileName = TargetDirectory + "\\" + delName + "EventHandler.cs";\r
-                       System.Console.Write("File: ");//, fileName);\r
-                       System.Console.Write(fileName);\r
-                       System.Console.Write("\tGenerating");\r
-\r
-                       StreamWriter writer;\r
-                       try\r
-                       {\r
-                               Stream stream = new FileStream(fileName, FileMode.Truncate, FileAccess.Write);\r
-                               writer = new StreamWriter(stream);\r
-                       } catch(FileNotFoundException)\r
-                       {\r
-                               writer = File.CreateText(fileName);\r
-                       }\r
-                       if(writer == null)\r
-                       {\r
-                               System.Console.WriteLine("Null writer...\n");\r
-                               return;\r
-                       }\r
-                       writer.Write(PROLOGUE);\r
-                       writer.Write(NamespaceName + "\n");\r
-                       writer.Write(DETAILS);\r
-                       writer.Write(NAMESPACE);\r
-                       writer.Write(NamespaceName + "\n");\r
-                       writer.Write("{\n");\r
-                       writer.Write("\tpublic delegate void ");\r
-                       writer.Write(delName);\r
-                       writer.Write("EventHandler(object sender, ");\r
-                       writer.Write(delName);\r
-                       writer.Write("EventArgs e);\n");\r
-                       writer.Write("}");\r
-\r
-                       writer.Flush();\r
-                       writer.Close();\r
-\r
-                       System.Console.WriteLine("\tGenerated\n");\r
-               }\r
-\r
-               public static string GetTargetDir()\r
-               {\r
-                       System.Console.Write("Enter target directory: ");\r
-                       return System.Console.ReadLine();\r
-               }\r
-\r
-               public static void Usage(bool wrong)\r
-               {\r
-                       if(wrong)\r
-                       {\r
-                               System.Console.WriteLine("Wrong # arguments.");\r
-                       }\r
-                       System.Console.WriteLine("Usage: GenerateDelegate [target-dir] [namespace] [delegate1 [delegate2 [...]]]");\r
-               }\r
-\r
-               public static bool IsHelp(string arg)\r
-               {\r
-                       return (arg == "-h" || arg == "--help");\r
-               }\r
-\r
-               public static bool IsDirectory(string dirName)\r
-               {\r
-                       FileAttributes attrs;\r
-                       try\r
-                       {\r
-                               attrs = File.GetAttributes(dirName);\r
-                               if( (attrs & FileAttributes.Directory) != FileAttributes.Directory)\r
-                               {\r
-                                       Usage(true);\r
-                                       return false;\r
-                               }\r
-                       }catch(Exception e)\r
-                       {\r
-                               System.Console.WriteLine("Exception: {0}", e.ToString());\r
-                               return false;\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               public static void Main(string[] args)\r
-               {\r
-                       if(args.Length == 1 && IsHelp(args[0]))\r
-                       {\r
-                               Usage(false);\r
-                               return;\r
-                       }\r
-\r
-                       if(args.Length == 0)\r
-                       {\r
-                               TargetDirectory = GetTargetDir();\r
-                               while(TargetDirectory.EndsWith("\\"))\r
-                               {\r
-                                       TargetDirectory = TargetDirectory.Substring(0, TargetDirectory.Length - 1);\r
-                               }\r
-                       } else\r
-                       {\r
-                               while(args[0].EndsWith("\\"))\r
-                               {\r
-                                       args[0] = args[0].Substring(0, args[0].Length - 1);\r
-                               }\r
-                               TargetDirectory = args[0];\r
-                       }\r
-\r
-                       if(!IsDirectory(TargetDirectory))\r
-                               return;\r
-\r
-                       if(args.Length > 1)\r
-                       {\r
-                               NamespaceName = args[1];\r
-                       } else\r
-                       {\r
-                               NamespaceName = AskForNamespace();\r
-                       }\r
-\r
-                       if(args.Length > 2)\r
-                       {\r
-                               int i=0;\r
-                               foreach(string currArg in args)\r
-                               {\r
-                                       if(i != 0)\r
-                                       {\r
-                                               Generate(currArg);\r
-                                       }\r
-                                       i++;\r
-                               }\r
-                       }\r
-                       string delegateName = String.Empty;\r
-                       while((delegateName = AskForMore()) != String.Empty)\r
-                       {\r
-                               Generate(delegateName);\r
-                       }\r
-               }\r
-       }\r
-}\r
diff --git a/mcs/tools/misc/IFaceDisco.cs b/mcs/tools/misc/IFaceDisco.cs
deleted file mode 100644 (file)
index 0f8a062..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-// IFaceDisco.cs\r
-//\r
-// Nick Drochak (ndrochak@gol.com)\r
-//\r
-// (C) 2001 Nick Drochak\r
-\r
-using System;\r
-using System.Reflection;\r
-using System.Collections;\r
-using System.IO;\r
-\r
-namespace Mono.Util\r
-{\r
-       class IFaceDisco {\r
-               public static void Main(string[] args) {\r
-                       Assembly                                        asm;\r
-                       Type[]                                          asmTypes;\r
-                       InterfaceMapping                map;\r
-                       Type[]                                          interfaces;\r
-                       ArrayList                                       TypesList                                       = new ArrayList();\r
-                       ArrayList                                       implementingTypes       = new ArrayList();\r
-                       string                                          asmFullPath                             = null;\r
-                       string                                          ifaceToDiscover         = null;\r
-                       \r
-                       if (args.Length < 1 || args.Length > 3) {\r
-                               Usage();\r
-                               return;\r
-                       }\r
-\r
-                       for (int i = 0; i < args.Length; i++) {\r
-                               string arg = args[i];\r
-\r
-                               if (arg.StartsWith("-") && ((i + 1) < args.Length)) {\r
-                                       if (arg == "--asm") {\r
-                                               asmFullPath = args[++i];\r
-                                       } else {\r
-                                               Usage();\r
-                                               return;\r
-                                       }\r
-                               } else {\r
-                                       // allow only one interface to discover\r
-                                       if (ifaceToDiscover != null){\r
-                                               Usage();\r
-                                               return;\r
-                                       }\r
-                                       ifaceToDiscover = arg;\r
-                               }\r
-                       }\r
-\r
-                       // find the assembly\r
-                       if (null == asmFullPath){\r
-                               asm = Assembly.GetAssembly(typeof (System.Object));\r
-                       }\r
-                       else {\r
-                               try{\r
-                                       asm = Assembly.LoadFrom(asmFullPath);\r
-                               }\r
-                               catch(Exception e){\r
-                                       Console.WriteLine("Could not open assembly '{0}' for discovery. Error is: "+e.Message, asmFullPath);\r
-                                       return;\r
-                               }\r
-                       }\r
-                       asmTypes = asm.GetTypes();\r
-\r
-                       // examine all the public types\r
-                       foreach(Type t in asmTypes) {\r
-                               if (t.IsPublic) {\r
-                                       // find out which, if any, interfaces are "in" the type\r
-                                       interfaces= t.GetInterfaces();\r
-                                       if (null != interfaces){\r
-                                               // look for the interface we want to discover\r
-                                               foreach (Type iface in interfaces) {\r
-                                                       // this area seems to throw an exception sometimes, just ignore it\r
-                                                       try{\r
-                                                               if (iface.FullName.ToLower() == args[0].ToLower()) {\r
-                                                                       // find out if this type is the one which "declares" the interface\r
-                                                                       map = t.GetInterfaceMap(iface);\r
-                                                                       if (map.TargetMethods[0].DeclaringType.FullName == t.FullName){\r
-                                                                               // if so, then we found a class to report\r
-                                                                               implementingTypes.Add(t.FullName);\r
-                                                                       } // if\r
-                                                               }  // if\r
-                                                       }catch{}\r
-                                               } // foreach\r
-                                       } // if\r
-                               } // if\r
-                       } // foreach\r
-\r
-                       // sort the list to make it easier to find what you are looking for\r
-                       implementingTypes.Sort();\r
-                       Console.WriteLine(XMLUtil.ToXML(implementingTypes, "Type", "ImplementingTypes"));\r
-               } // Main()\r
-\r
-               private static void Usage() {\r
-                       Console.WriteLine (\r
-                               "Mono Interface Discovery Tool\n" +\r
-                               "usage: ifacedisco [--asm assembly] interface\n\n" +\r
-                               "  The full path to 'assembly' should be specified when using --asm.\n" +\r
-                               "  If 'assembly' is not specified, the assembly that contains System.Object will be used.\n" +\r
-                               "  Use the fully qualified form for 'interface', e.g. System.Runtime.Serialization.ISerializable\n"\r
-                               );\r
-               } // Usage()\r
-\r
-       } // class IFaceDisco\r
-}  // namespace Mono.Util\r
diff --git a/mcs/tools/misc/XMLUtil.cs b/mcs/tools/misc/XMLUtil.cs
deleted file mode 100644 (file)
index 0643472..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// IFaceDisco.cs\r
-//\r
-// Nick Drochak (ndrochak@gol.com)\r
-//\r
-// (C) 2001 Nick Drochak\r
-\r
-using System;\r
-using System.Text;\r
-using System.Collections;\r
-\r
-namespace Mono.Util\r
-{\r
-       class XMLUtil{\r
-               public static string ToXML(\r
-                       ArrayList list, \r
-                       string itemWrap,\r
-                       string listWrap)\r
-               {\r
-                       if (null == itemWrap){\r
-                               throw new ArgumentNullException("itemWrap");\r
-                       }\r
-                       if (null == listWrap){\r
-                               throw new ArgumentNullException("listWrap");\r
-                       }\r
-                       StringBuilder output = new StringBuilder();\r
-                       output.Append("<"+listWrap+">");\r
-                       foreach(object o in list){\r
-                               output.Append("\n<"+itemWrap+">");\r
-                               output.Append(o.ToString());\r
-                               output.Append("</"+itemWrap+">");\r
-                       }\r
-                       output.Append("\n</"+listWrap+">");\r
-                       return output.ToString();\r
-               }\r
-       }\r
-}
\ No newline at end of file
diff --git a/mcs/tools/misc/monostyle.cs b/mcs/tools/misc/monostyle.cs
deleted file mode 100644 (file)
index 845ab93..0000000
+++ /dev/null
@@ -1,368 +0,0 @@
-//     monostyle.cs
-//
-//     Adam Treat (manyoso@yahoo.com)
-//     Ben Maurer (bmaurer@users.sf.net)
-//     (C) 2002 Adam Treat
-//     (C) 2003 Ben Maurer
-//
-//     This program is free software; you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation; either version 2 of the License, or
-//     (at your option) any later version.
-
-using System;
-using System.IO;
-using System.Text.RegularExpressions;
-using System.Collections.Specialized;
-
-namespace Mono.Util {
-
-       class MonoStyle {
-
-               string file;
-               StringCollection filebuffer;
-               bool linespace = true;
-
-               void Usage()
-               {
-                       Console.Write (
-                               "monostyle -f file.cs -l <true|false> > output.cs\n\n" +
-                               "   -f || /-f || --file  file.cs        The csharp source file to parse.\n\n" +
-                               "   -l || /-l || --line  <true|false>   Specifies wether to use line spacing.\n\n");
-               }
-
-               public static void Main (string[] args)
-               {
-                       MonoStyle style = new MonoStyle(args);
-               }
-
-               public MonoStyle (string[] args)
-               {
-                       int argc = args.Length;
-                       for(int i = 0; i < argc; i++) {
-                               string arg = args[i];
-                               // The "/" switch is there for wine users, like me ;-)
-                               if(arg.StartsWith("-") || arg.StartsWith("/")) {
-                                       switch(arg) {
-                                               case "-l": case "/-l": case "--line":
-                                               if((i + 1) >= argc) {
-                                                       Usage();
-                                                       return;
-                                               }
-                                               if (args[i++] == "false") {
-                                                       linespace = false;
-                                               }
-                                               continue;
-                                               case "-f": case "/-f": case "--file":
-                                               if((i + 1) >= argc) {
-                                                       Usage();
-                                                       return;
-                                               }
-                                               file = args[++i];
-                                               continue;
-                                               default:
-                                               Usage();
-                                               return;
-                                       }
-                               }
-                       }
-                       if(file == null) {
-                               Usage();
-                               return;
-                       }
-                       filebuffer = new StringCollection();
-                       StreamReader sr = new StreamReader(file);
-                       FillBuffer(sr);
-                       FixMonoStyle();
-                       PrintToConsole();
-               }
-
-               public void FillBuffer(StreamReader sr)
-               {
-                       sr.BaseStream.Seek(0, SeekOrigin.Begin);
-                       while (sr.Peek() > -1) {
-                               filebuffer.Add(sr.ReadLine());
-                       }
-                       sr.Close();
-               }
-
-               public void FixMonoStyle()
-               {
-                       for (int i=0; i < filebuffer.Count; i++) {
-                               IsBadMonoStyle(filebuffer[i]);
-                       }
-               }
-
-               public void PrintToConsole()
-               {
-                       for (int i=0; i < filebuffer.Count; i++) {
-                               Console.WriteLine(filebuffer[i]);
-                       }
-               }
-
-               public void IsBadMonoStyle(String str)
-               {
-                       if (IsBadMonoType(str)) {
-                               FixHangingBrace(str);
-                       } else if(IsBadMonoFlow(str)) {
-                               FixHangingBrace(str);
-                       } else if(IsBadMonoFunction(str)) {
-                               FixEndBrace(str);
-                       } else if(IsBadMonoProperty(str)) {
-                               FixHangingBrace(str);
-                       } else {
-                       }
-               }
-
-               public void FixHangingBrace(String str)
-               {
-                       int strloc = filebuffer.IndexOf(str);
-                       int brcloc = FindHangingBrace(strloc);
-                       int diff = brcloc - strloc;
-                       if (brcloc > 0) {
-                               for (int i = 0; i < diff+1; i++) {
-                                       filebuffer.RemoveAt(strloc);
-                               }
-                               filebuffer.Insert(strloc, str + " {");
-                               if (linespace) {
-                                       filebuffer.Insert(strloc+1, "");
-                               }
-                       } else {}
-               }
-
-               public int FindHangingBrace(int strloc)
-               {
-                       strloc++;
-                       bool found = false;
-                       while (!found) {
-                               try {
-                                       string str = filebuffer[strloc++];
-                                       found = IsHangingBrace(str);
-                                       if (!found && !IsBlankLine(str)) {
-                                               return -1;
-                                       }
-                               } catch (Exception) {
-                                       return -1;
-                               }
-                       }
-                       return strloc -1;
-               }
-
-               public void FixEndBrace(String str)
-               {
-                       int strloc = filebuffer.IndexOf(str);
-                       filebuffer.RemoveAt(strloc);
-                       filebuffer.Insert(strloc, RemoveEndBrace(str));
-                       filebuffer.Insert(strloc+1, AddHangingBrace(str));
-               }
-
-               public static bool IsBadMonoType(String str)
-               {
-                       if ( IsType(str) && !EndWithBrace(str)) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsBadMonoFlow(String str)
-               {
-                       if (IsFlow(str) && !EndWithBrace(str)) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsBadMonoFunction(String str)
-               {
-                       if (IsFunction(str) && EndWithBrace(str)) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsBadMonoProperty(String str)
-               {
-                       if (IsProperty(str) && !EndWithBrace(str)) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsType(String str)
-               {
-                       if (    !IsComment(str) && (
-                                       IsNameSpace(str) ||
-                                       IsClass(str) ||
-                                       IsStruct(str) ||
-                                       IsEnum(str) )) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsFlow(String str)
-               {
-                       if (    !IsComment(str) && (
-                                       IsIf(str) ||
-                                       IsElse(str) ||
-                                       IsElseIf(str) ||
-                                       IsTry(str) ||
-                                       IsCatch(str) ||
-                                       IsFinally(str) ||
-                                       IsFor(str) ||
-                                       IsForEach(str) ||
-                                       IsWhile(str) ||
-                                       IsSwitch(str)
-                                       )) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsFunction(String str)
-               {
-                       if (    Regex.IsMatch(str, @"^\s*(\w+)\s+(\w+).*\(+") &&
-                                       !IsDeclaration(str) &&
-                                       !IsComment(str) &&
-                                       !IsType(str) &&
-                                       !IsFlow(str) ) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static bool IsProperty(String str)
-               {
-                       if (    Regex.IsMatch(str, @"^\s*(\w+)\s+(\w+).*") &&
-                                       !IsDeclaration(str) &&
-                                       !IsComment(str) &&
-                                       !IsType(str) &&
-                                       !IsFlow(str) &&
-                                       !IsFunction(str) ) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-
-               public static string RemoveEndBrace(String str)
-               {
-                       Regex rg = new Regex(@"\{\s*$");
-                       return rg.Replace(str, "");
-               }
-
-               public static string AddHangingBrace(String str)
-               {
-                       Regex rg = new Regex(@"\S+\s*");
-                       string blank = rg.Replace(str,"");
-                       return blank + "{";
-               }
-
-               public static bool IsDeclaration(String str)
-               {
-                       return Regex.IsMatch(str, @"\;\s*$");
-               }
-
-               public static bool IsComment(String str)
-               {
-                       return Regex.IsMatch(str, @"^(\s*\/+|\s*\*+|\s*\#+)");
-               }
-
-               public static bool EndWithBrace(String str)
-               {
-                       return Regex.IsMatch(str, @"\{\s*$");
-               }
-
-               public static bool IsHangingBrace(String str)
-               {
-                       return Regex.IsMatch(str, @"^\s*\{");
-               }
-
-               public static bool IsBlankLine(String str)
-               {
-                       return Regex.IsMatch(str, @"^\s*$");
-               }
-
-               public static bool IsNameSpace(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+)namespace\s+");
-               }
-
-               public static bool IsClass(String str)
-               {
-                       return Regex.IsMatch(str, @"\s+class\s+");
-               }
-
-               public static bool IsStruct(String str)
-               {
-                       return Regex.IsMatch(str, @"\s+struct\s+");
-               }
-
-               public static bool IsEnum(String str)
-               {
-                       return Regex.IsMatch(str, @"\s+enum\s+");
-               }
-
-               public static bool IsIf(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)if(\s+|\(+|$)");
-               }
-
-               public static bool IsElse(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)else(\s+|\{+|$)");
-               }
-
-               public static bool IsElseIf(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)else if(\s+|\(+|$)");
-               }
-
-               public static bool IsTry(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)try(\s+|\(+|$)");
-               }
-
-               public static bool IsCatch(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)catch(\s+|\(+|$)");
-               }
-
-               public static bool IsFinally(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)finally(\s+|\{+|$)");
-               }
-
-               public static bool IsFor(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)for(\s+|\(+|$)");
-               }
-
-               public static bool IsForEach(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)foreach(\s+|\(+|$)");
-               }
-
-               public static bool IsWhile(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)while(\s+|\(+|$)");
-               }
-
-               public static bool IsSwitch(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)switch(\s+|\(+|$)");
-               }
-
-               public static bool IsCase(String str)
-               {
-                       return Regex.IsMatch(str, @"(^|\s+|\}+)case(\s+|\(+|$)");
-               }
-       }
-}
diff --git a/mcs/tools/misc/sample_cast_const.cs b/mcs/tools/misc/sample_cast_const.cs
deleted file mode 100644 (file)
index 0496931..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-
-class X {
-       static void w (string s)
-       {
-               Console.WriteLine ("\t" + s);
-       }
-       
-       static void Main ()
-       {
-               object [,] names = 
-                       { { "Byte", "byte" },
-                         { "SByte", "sbyte" },
-                         { "Short", "short" },
-                         { "UShort", "ushort" },
-                         { "Int", "int32" },
-                         { "UInt", "uint32" },
-                         { "Long", "int64" },
-                         { "ULong", "uint64" },
-                         { "Float", "float" },
-                         { "Double", "double" },
-                         { null, null }
-                       };
-
-               for (int i = 0; names [i,0] != null; i++){
-                       string big = names [i, 0] + "Constant";
-                       string small = "TypeManager." + names [i, 1] + "_type";
-                       string nat = ((string) names [i,0]).ToLower ();
-                       
-                       w ("\t\tif (expr is " + big + "){");
-                       w ("\t\t\t" + nat + " v = ((" + big + ") expr).Value;");
-                       w ("");
-
-                       for (int j = 0; names [j,0] != null; j++){
-                               string b = names [j, 0] + "Constant";
-                               string s = "TypeManager." + names [j, 1] + "_type";
-                               string n = ((string) names [j,0]).ToLower ();
-
-                               if (i == j)
-                                       continue;
-                               
-                               w ("\t\t\tif (target_type == " + s + ")");
-                               w ("\t\t\t\treturn new " + b + " ((" + n + ") v);");
-                       }
-                       w ("\t\t}");
-               }
-       }
-}
-       
diff --git a/mcs/tools/misc/serialize.cs b/mcs/tools/misc/serialize.cs
deleted file mode 100644 (file)
index 01b83f8..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// Serialize.cs
-//
-// This program creates a SerializationInfo and requests an object
-// to serialize itself.
-//
-// We serialize because we need to know the *exact* names that are
-// used for the values being serialized.
-//
-// Author: Miguel de Icaza
-//        Duncan Mak
-//
-// (C) Ximian, Inc.
-//
-
-using System;
-using System.Collections;
-using System.Globalization;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Soap;
-using System.IO;
-
-namespace Mono.Serialize {
-       class Driver {
-               static object StaticCreateObject ()
-               {
-                       //
-                       // Change the object type here.
-                       //
-                       return null;
-               }
-
-               static object LiveCreateObject (Type obj, Type[] types, string[] values)
-               {
-                       if (types.Length != values.Length)
-                               throw new ArgumentException ();
-                       
-                       object[] a = new object [types.Length];
-                       
-                       for (int i = 0; i < a.Length; i++)
-                               a [i] = Convert.ChangeType (values [i], types [i]);
-                       
-                       return Activator.CreateInstance (obj, a);
-               }
-        
-               static void Main (string[] args)
-               {
-                       object x = null;
-                       string strTypes = null;
-                       string argValues = null;
-                       
-                       if (args.Length == 1) {
-                               Type t = Type.GetType (args[0]);
-                               Console.WriteLine ("\nPlease enter the arguments to the constructor for type {0}", t.ToString());
-                               strTypes = Console.ReadLine ();
-                               Console.WriteLine ("\nPlease enter the values");
-                               argValues = Console.ReadLine ();
-                               Type[] types = ToTypeArray (strTypes.Split (','));
-                               string[] param = argValues.Split (',');
-                               
-                               x = LiveCreateObject (t, types, param);
-                       } else {
-                               x = StaticCreateObject ();
-                       }
-                       
-                       string fileName = x.GetType().FullName + ".xml";
-                       Stream output = new FileStream (fileName, FileMode.Create,
-                                                       FileAccess.Write, FileShare.None);
-                       IFormatter formatter = new SoapFormatter ();
-                       
-                       formatter.Serialize ((Stream) output, x);
-                       output.Close ();
-               }
-               
-               public static Type[] ToTypeArray (string[] strTypes)
-               {
-                       Type[] t = new Type [strTypes.Length];
-                       
-                       for (int i = 0; i < strTypes.Length; i++)
-                               t [i] = StringToType (strTypes [i]);
-                       return t;
-               }
-               
-               public static Type StringToType (string s)
-               {
-                       switch (s) {
-                       case "bool":
-                               return typeof (System.Boolean);
-                               break;
-                       case "byte":
-                               return typeof (System.Byte);
-                               break;
-                       case "sbyte":
-                               return typeof (System.SByte);
-                               break;
-                       case "char":
-                               return typeof (System.Char);
-                               break;
-                       case "decimal":
-                               return typeof (System.Decimal);
-                               break;
-                       case "double":
-                               return typeof (System.Double);
-                               break;
-                       case "float":
-                               return typeof (System.Single);
-                               break;
-                       case "int":
-                               return typeof (System.Int32);
-                               break;
-                       case "uint":
-                               return typeof (System.UInt32);
-                               break;
-                       case "long":
-                               return typeof (System.Int64);
-                               break;
-                       case "ulong":
-                               return typeof (System.UInt64);
-                               break;
-                       case "object":
-                               return typeof (System.Object);
-                               break;
-                       case "short":
-                               return typeof (System.Int16);
-                               break;
-                       case "ushort":
-                               return typeof (System.UInt16);
-                               break;
-                       case "string":
-                               return typeof (System.String);
-                               break;
-                       default:
-                               return Type.GetType (s);
-                               break;
-                       }
-               }
-       }
-}
diff --git a/mcs/tools/misc/verifier.cs b/mcs/tools/misc/verifier.cs
deleted file mode 100644 (file)
index 2526814..0000000
+++ /dev/null
@@ -1,1587 +0,0 @@
-//
-// verifier.cs: compares two assemblies and reports differences.
-//
-// Author:
-//   Sergey Chaban (serge@wildwestsoftware.com)
-//
-// (C) Sergey Chaban (serge@wildwestsoftware.com)
-//
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Reflection;
-
-namespace Mono.Verifier {
-
-
-
-       ////////////////////////////////
-       // Collections
-       ////////////////////////////////
-
-       public abstract class MemberCollection : IEnumerable {
-
-               public delegate MemberInfo [] InfoQuery (Type type, BindingFlags bindings);
-               public delegate bool MemberComparer (MemberInfo mi1, MemberInfo mi2);
-
-               protected SortedList list;
-               protected MemberComparer comparer;
-
-               protected BindingFlags bindings;
-
-               protected MemberCollection (Type type, InfoQuery query, MemberComparer comparer, BindingFlags bindings)
-               {
-                       if (query == null)
-                               throw new NullReferenceException ("Invalid query delegate.");
-
-                       if (comparer == null)
-                               throw new NullReferenceException ("Invalid comparer.");
-
-                       this.comparer = comparer;
-                       this.bindings = bindings;
-
-                       this.list = new SortedList ();
-
-                       MemberInfo [] data = query (type, bindings);
-                       foreach (MemberInfo info in data) {
-                               this.list [info.Name] = info;
-                       }
-               }
-
-
-
-               public MemberInfo this [string name] {
-                       get {
-                               return list [name] as MemberInfo;
-                       }
-               }
-
-
-               public override int GetHashCode ()
-               {
-                       return list.GetHashCode ();
-               }
-
-
-               public override bool Equals (object o)
-               {
-                       bool res = (o is MemberCollection);
-                       if (res) {
-                               MemberCollection another = o as MemberCollection;
-                               IEnumerator it = GetEnumerator ();
-                               while (it.MoveNext () && res) {
-                                       MemberInfo inf1 = it.Current as MemberInfo;
-                                       MemberInfo inf2 = another [inf1.Name];
-                                       res &= comparer (inf1, inf2);
-                               }
-                       }
-                       return res;
-               }
-
-
-
-               public static bool operator == (MemberCollection c1, MemberCollection c2)
-               {
-                       return c1.Equals (c2);
-               }
-
-               public static bool operator != (MemberCollection c1, MemberCollection c2)
-               {
-                       return !(c1 == c2);
-               }
-
-
-
-               public IEnumerator GetEnumerator()
-               {
-                       return new Iterator (this);
-               }
-
-
-               internal class Iterator : IEnumerator  {
-                       private MemberCollection host;
-                       private int pos;
-
-                       internal Iterator (MemberCollection host)
-                       {
-                               this.host=host;
-                               this.Reset ();
-                       }
-
-                       /// <summary></summary>
-                       public object Current
-                       {
-                               get {
-                                       if (host != null && pos >=0 && pos < host.list.Count) {
-                                               return host.list.GetByIndex (pos);
-                                       } else {
-                                               return null;
-                                       }
-                               }
-                       }
-
-                       /// <summary></summary>
-                       public bool MoveNext ()
-                       {
-                               if (host!=null) {
-                                       return (++pos) < host.list.Count;
-                               } else {
-                                       return false;
-                               }
-                       }
-
-                       /// <summary></summary>
-                       public void Reset ()
-                       {
-                               this.pos = -1;
-                       }
-               }
-
-       }
-
-
-
-
-       //--- Method collections
-
-       /// <summary>
-       /// Abstract collection of class' methods.
-       /// </summary>
-       public abstract class MethodCollectionBase : MemberCollection {
-
-
-               protected MethodCollectionBase (Type type, BindingFlags bindings)
-                      : base (type, new InfoQuery (Query), new MemberComparer (Comparer), bindings)
-               {
-               }
-
-
-               private static MemberInfo [] Query (Type type, BindingFlags bindings)
-               {
-                       // returns MethodInfo []
-                       return type.GetMethods (bindings);
-               }
-
-               private static bool Comparer (MemberInfo mi1, MemberInfo mi2)
-               {
-                       bool res = false;
-                       if (mi1 is MethodInfo && (mi2 == null || mi2 is MethodInfo)) {
-                               MethodInfo inf1 = mi1 as MethodInfo;
-                               MethodInfo inf2 = mi2 as MethodInfo;
-                               res = Compare.Methods (inf1, inf2);
-                       } else {
-                               Verifier.log.Write ("internal-error", "Wrong comparer arguments.", ImportanceLevel.HIGH);
-                       }
-                       return res;
-               }
-       }
-
-
-
-       /// <summary>
-       /// Collection of public instance methods of a class.
-       /// </summary>
-       public class PublicMethods : MethodCollectionBase {
-
-               public PublicMethods (Type type)
-                      : base (type, BindingFlags.Public | BindingFlags.Instance)
-               {
-               }
-       }
-
-       /// <summary>
-       /// Collection of public static methods of a class.
-       /// </summary>
-       public class PublicStaticMethods : MethodCollectionBase {
-
-               public PublicStaticMethods (Type type)
-                      : base (type, BindingFlags.Public | BindingFlags.Static)
-               {
-               }
-       }
-
-       /// <summary>
-       /// Collection of non-public instance methods of a class.
-       /// </summary>
-       public class NonPublicMethods : MethodCollectionBase {
-
-               public NonPublicMethods (Type type)
-                      : base (type, BindingFlags.NonPublic | BindingFlags.Instance)
-               {
-               }
-       }
-
-       /// <summary>
-       /// Collection of non-public static methods of a class.
-       /// </summary>
-       public class NonPublicStaticMethods : MethodCollectionBase {
-
-               public NonPublicStaticMethods (Type type)
-                      : base (type, BindingFlags.NonPublic | BindingFlags.Static)
-               {
-               }
-       }
-
-
-
-
-
-       //--- Field collections
-
-       public abstract class FieldCollectionBase : MemberCollection {
-
-
-               protected FieldCollectionBase (Type type, BindingFlags bindings)
-                      : base (type, new InfoQuery (Query), new MemberComparer (Comparer), bindings)
-               {
-               }
-
-
-               private static MemberInfo [] Query (Type type, BindingFlags bindings)
-               {
-                       // returns FieldInfo []
-                       return type.GetFields (bindings);
-               }
-
-               private static bool Comparer (MemberInfo mi1, MemberInfo mi2)
-               {
-                       bool res = false;
-                       if (mi1 is FieldInfo && (mi2 == null || mi2 is FieldInfo)) {
-                               FieldInfo inf1 = mi1 as FieldInfo;
-                               FieldInfo inf2 = mi2 as FieldInfo;
-                               res = Compare.Fields (inf1, inf2);
-                       } else {
-                               Verifier.log.Write ("internal-error", "Wrong comparer arguments.", ImportanceLevel.HIGH);
-                       }
-                       return res;
-               }
-       }
-
-
-       public class PublicFields : FieldCollectionBase {
-
-               public PublicFields (Type type)
-                      : base (type, BindingFlags.Public | BindingFlags.Instance)
-               {
-               }
-       }
-
-       public class PublicStaticFields : FieldCollectionBase {
-
-               public PublicStaticFields (Type type)
-                      : base (type, BindingFlags.Public | BindingFlags.Static)
-               {
-               }
-       }
-
-       public class NonPublicFields : FieldCollectionBase {
-
-               public NonPublicFields (Type type)
-                      : base (type, BindingFlags.NonPublic | BindingFlags.Instance)
-               {
-               }
-       }
-
-       public class NonPublicStaticFields : FieldCollectionBase {
-
-               public NonPublicStaticFields (Type type)
-                      : base (type, BindingFlags.NonPublic | BindingFlags.Static)
-               {
-               }
-       }
-
-
-
-
-
-       public abstract class AbstractTypeStuff {
-               public readonly Type type;
-
-               public AbstractTypeStuff (Type type)
-               {
-                       if (type == null)
-                               throw new NullReferenceException ("Invalid type.");
-
-                       this.type = type;
-               }
-
-               public override int GetHashCode ()
-               {
-                       return type.GetHashCode ();
-               }
-
-               public static bool operator == (AbstractTypeStuff t1, AbstractTypeStuff t2)
-               {
-                       if ((t1 as object) == null) {
-                               if ((t2 as object) == null) return true;
-                               return false;
-                       }
-                       return t1.Equals (t2);
-               }
-
-               public static bool operator != (AbstractTypeStuff t1, AbstractTypeStuff t2)
-               {
-                       return !(t1 == t2);
-               }
-
-               public override bool Equals (object o)
-               {
-                       return (o is AbstractTypeStuff && CompareTypes (o as AbstractTypeStuff));
-               }
-
-               protected virtual bool CompareTypes (AbstractTypeStuff that)
-               {
-                       Verifier.Log.Write ("info", "Comparing types.", ImportanceLevel.LOW);
-                       bool res;
-
-                       res = Compare.Types (this.type, that.type);
-
-                       return res;
-               }
-
-       }
-
-
-
-
-       /// <summary>
-       ///  Represents a class.
-       /// </summary>
-       public class ClassStuff : AbstractTypeStuff {
-
-               public PublicMethods publicMethods;
-               public PublicStaticMethods publicStaticMethods;
-               public NonPublicMethods nonpublicMethods;
-               public NonPublicStaticMethods nonpublicStaticMethods;
-
-               public PublicFields publicFields;
-               public PublicStaticFields publicStaticFields;
-               public NonPublicFields nonpublicFields;
-               public NonPublicStaticFields nonpublicStaticFields;
-
-               public ClassStuff (Type type) : base (type)
-               {
-                       publicMethods = new PublicMethods (type);
-                       publicStaticMethods = new PublicStaticMethods (type);
-                       nonpublicMethods = new NonPublicMethods (type);
-                       nonpublicStaticMethods = new NonPublicStaticMethods (type);
-
-                       publicFields = new PublicFields (type);
-                       publicStaticFields = new PublicStaticFields (type);
-                       nonpublicFields = new NonPublicFields (type);
-                       nonpublicStaticFields = new NonPublicStaticFields (type);
-               }
-
-
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-
-               private bool CompareMethods (ClassStuff that)
-               {
-                       bool res = true;
-                       bool ok;
-
-                       Verifier.Log.Write ("info", "Comparing public instance methods.", ImportanceLevel.LOW);
-                       ok = (this.publicMethods == that.publicMethods);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing public static methods.", ImportanceLevel.LOW);
-                       ok = (this.publicStaticMethods == that.publicStaticMethods);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing non-public instance methods.", ImportanceLevel.LOW);
-                       ok = (this.nonpublicMethods == that.nonpublicMethods);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing non-public static methods.", ImportanceLevel.LOW);
-                       ok = (this.nonpublicStaticMethods == that.nonpublicStaticMethods);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       return res;
-               }
-
-
-               private bool CompareFields (ClassStuff that)
-               {
-                       bool res = true;
-                       bool ok;
-
-                       Verifier.Log.Write ("info", "Comparing public instance fields.", ImportanceLevel.LOW);
-                       ok = (this.publicFields == that.publicFields);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing public static fields.", ImportanceLevel.LOW);
-                       ok = (this.publicStaticFields == that.publicStaticFields);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing non-public instance fields.", ImportanceLevel.LOW);
-                       ok = (this.nonpublicFields == that.nonpublicFields);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       Verifier.Log.Write ("info", "Comparing non-public static fields.", ImportanceLevel.LOW);
-                       ok = (this.nonpublicStaticFields == that.nonpublicStaticFields);
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-                       return res;
-               }
-
-
-               public override bool Equals (object o)
-               {
-                       bool res = (o is ClassStuff);
-                       if (res) {
-                               ClassStuff that = o as ClassStuff;
-
-                               res &= this.CompareTypes (that);
-                               if (!res && Verifier.stopOnError) return res;
-
-                               res &= this.CompareMethods (that);
-                               if (!res && Verifier.stopOnError) return res;
-
-                               res &= this.CompareFields (that);
-                               if (!res && Verifier.stopOnError) return res;
-
-                       }
-                       return res;
-               }
-
-       }
-
-
-
-       /// <summary>
-       ///  Represents an interface.
-       /// </summary>
-       public class InterfaceStuff : AbstractTypeStuff {
-
-               public PublicMethods publicMethods;
-
-               public InterfaceStuff (Type type) : base (type)
-               {
-                       publicMethods = new PublicMethods (type);
-               }
-
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-
-               public override bool Equals (object o)
-               {
-                       bool res = (o is InterfaceStuff);
-                       if (res) {
-                               bool ok;
-                               InterfaceStuff that = o as InterfaceStuff;
-
-                               res = this.CompareTypes (that);
-                               if (!res && Verifier.stopOnError) return res;
-
-                               Verifier.Log.Write ("info", "Comparing interface methods.", ImportanceLevel.LOW);
-                               ok = (this.publicMethods == that.publicMethods);
-                               res &= ok;
-                               if (!ok && Verifier.stopOnError) return res;
-                       }
-                       return res;
-               }
-
-       }
-
-
-
-       /// <summary>
-       ///  Represents an enumeration.
-       /// </summary>
-       public class EnumStuff : AbstractTypeStuff {
-
-               //public FieldInfo [] members;
-
-               public string baseType;
-               public Hashtable enumTable;
-               public bool isFlags;
-
-               public EnumStuff (Type type) : base (type)
-               {
-                       //members = type.GetFields (BindingFlags.Public | BindingFlags.Static);
-
-                       Array values = Enum.GetValues (type);
-                       Array names = Enum.GetNames (type);
-
-                       baseType = Enum.GetUnderlyingType (type).Name;
-
-                       enumTable = new Hashtable ();
-
-                       object [] attrs = type.GetCustomAttributes (false);
-                       isFlags = (attrs != null && attrs.Length > 0);
-                       if (isFlags) {
-                               foreach (object attr in attrs) {
-                                       isFlags |= (attr is FlagsAttribute);
-                               }
-                       }
-
-                       int indx = 0;
-                       foreach (string id in names) {
-                               enumTable [id] = Convert.ToInt64(values.GetValue(indx) as Enum);
-                               ++indx;
-                       }
-               }
-
-               public override int GetHashCode ()
-               {
-                       return base.GetHashCode ();
-               }
-
-               public override bool Equals (object o)
-               {
-                       bool res = (o is EnumStuff);
-                       bool ok;
-
-                       if (res) {
-                               EnumStuff that = o as EnumStuff;
-                               ok = this.CompareTypes (that);
-                               res &= ok;
-                               if (!ok && Verifier.stopOnError) return res;
-
-                               ok = (this.baseType == that.baseType);
-                               res &= ok;
-                               if (!ok) {
-                                       Verifier.log.Write ("error",
-                                               String.Format ("Underlying types mismatch [{0}, {1}].", this.baseType, that.baseType),
-                                               ImportanceLevel.MEDIUM);
-                                       if (Verifier.stopOnError) return res;
-                               }
-
-                               Verifier.Log.Write ("info", "Comparing [Flags] attribute.");
-                               ok = !(this.isFlags ^ that.isFlags);
-                               res &= ok;
-                               if (!ok) {
-                                       Verifier.log.Write ("error",
-                                               String.Format ("[Flags] attribute mismatch ({0} : {1}).", this.isFlags ? "Yes" : "No", that.isFlags ? "Yes" : "No"),
-                                           ImportanceLevel.MEDIUM);
-                                       if (Verifier.stopOnError) return res;
-                               }
-
-                               Verifier.Log.Write ("info", "Comparing enum values.");
-
-                               ICollection names = enumTable.Keys;
-                               foreach (string id in names) {
-                                       ok = that.enumTable.ContainsKey (id);
-                                       res &= ok;
-                                       if (!ok) {
-                                               Verifier.log.Write ("error", String.Format("{0} absent in enumeration.", id),
-                                                       ImportanceLevel.MEDIUM);
-                                               if (Verifier.stopOnError) return res;
-                                       }
-
-                                       if (ok) {
-                                               long val1 = (long) this.enumTable [id];
-                                               long val2 = (long) that.enumTable [id];
-                                               ok = (val1 == val2);
-                                               res &= ok;
-                                               if (!ok) {
-                                                       Verifier.log.Write ("error",
-                                                               String.Format ("Enum values mismatch [{0}: {1} != {2}].", id, val1, val2),
-                                                               ImportanceLevel.MEDIUM);
-                                                       if (Verifier.stopOnError) return res;
-                                               }
-                                       }
-                               }
-                       }
-                       return res;
-               }
-       }
-
-
-
-       public sealed class TypeArray {
-               public static readonly TypeArray empty = new TypeArray (Type.EmptyTypes);
-
-               public Type [] types;
-
-               public TypeArray (Type [] types)
-               {
-                       this.types = new Type [types.Length];
-                       for (int i = 0; i < types.Length; i++) {
-                               this.types.SetValue (types.GetValue (i), i);
-                       }
-               }
-       }
-
-
-
-       public class AssemblyLoader {
-               public delegate void Hook (TypeArray assemblyTypes);
-
-               private static Hashtable cache;
-
-               private Hook hook;
-
-               static AssemblyLoader ()
-               {
-                       cache = new Hashtable (11);
-               }
-
-               public AssemblyLoader (Hook hook)
-               {
-                       if (hook == null)
-                               throw new NullReferenceException ("Invalid loader hook.");
-
-                       this.hook = hook;
-               }
-
-
-               public bool LoadFrom (string assemblyName)
-               {
-                       bool res = false;
-                       try {
-                               TypeArray types = TypeArray.empty;
-
-                               lock (cache) {
-                                       if (cache.Contains (assemblyName)) {
-                                               types = (cache [assemblyName] as TypeArray);
-                                               if (types == null) types = TypeArray.empty;
-                                       } else {
-                                               Assembly asm = Assembly.LoadFrom (assemblyName);
-                                               Type [] allTypes = asm.GetTypes ();
-                                               if (allTypes == null) allTypes = Type.EmptyTypes;
-                                               types = new TypeArray (allTypes);
-                                               cache [assemblyName] = types;
-                                       }
-                               }
-                               hook (types);
-                               res = true;
-                       } catch (ReflectionTypeLoadException rtle) {
-                               // FIXME: Should we try to recover? Use loaded portion of types.
-                               Type [] loaded = rtle.Types;
-                               for (int i = 0, xCnt = 0; i < loaded.Length; i++) {
-                                       if (loaded [i] == null) {
-                                               Verifier.log.Write ("fatal error",
-                                                   String.Format ("Unable to load {0}, reason - {1}", loaded [i], rtle.LoaderExceptions [xCnt++]),
-                                                   ImportanceLevel.LOW);
-                                       }
-                               }
-                       } catch (FileNotFoundException fnfe) {
-                                       Verifier.log.Write ("fatal error", fnfe.ToString (), ImportanceLevel.LOW);
-                       } catch (Exception x) {
-                                       Verifier.log.Write ("fatal error", x.ToString (), ImportanceLevel.LOW);
-                       }
-
-                       return res;
-               }
-
-       }
-
-
-
-
-       public abstract class AbstractTypeCollection : SortedList {
-
-               private AssemblyLoader loader;
-
-               public AbstractTypeCollection ()
-               {
-                       loader = new AssemblyLoader (new AssemblyLoader.Hook (LoaderHook));
-               }
-
-               public AbstractTypeCollection (string assemblyName) : this ()
-               {
-                       LoadFrom (assemblyName);
-               }
-
-               public abstract void LoaderHook (TypeArray types);
-
-
-               public bool LoadFrom (string assemblyName)
-               {
-                       return loader.LoadFrom (assemblyName);
-               }
-
-       }
-
-
-
-       public class ClassCollection : AbstractTypeCollection {
-
-               public ClassCollection () : base ()
-               {
-               }
-
-               public ClassCollection (string assemblyName)
-               : base (assemblyName)
-               {
-               }
-
-
-               public override void LoaderHook (TypeArray types)
-               {
-                       foreach (Type type in types.types) {
-                               if (type.IsClass) {
-                                       this [type.FullName] = new ClassStuff (type);
-                               }
-                       }
-               }
-
-       }
-
-
-       public class InterfaceCollection : AbstractTypeCollection {
-
-               public InterfaceCollection () : base ()
-               {
-               }
-
-               public InterfaceCollection (string assemblyName)
-               : base (assemblyName)
-               {
-               }
-
-
-               public override void LoaderHook (TypeArray types)
-               {
-                       foreach (Type type in types.types) {
-                               if (type.IsInterface) {
-                                       this [type.FullName] = new InterfaceStuff (type);
-                               }
-                       }
-               }
-
-       }
-
-
-
-       public class EnumCollection : AbstractTypeCollection {
-
-               public EnumCollection () : base ()
-               {
-               }
-
-               public EnumCollection (string assemblyName)
-               : base (assemblyName)
-               {
-               }
-
-               public override void LoaderHook (TypeArray types)
-               {
-                       foreach (Type type in types.types) {
-                               if (type.IsEnum) {
-                                       this [type.FullName] = new EnumStuff (type);
-                               }
-                       }
-               }
-       }
-
-
-
-       public class AssemblyStuff {
-
-               public string name;
-               public bool valid;
-
-               public ClassCollection classes;
-               public InterfaceCollection interfaces;
-               public EnumCollection enums;
-
-
-               protected delegate bool Comparer (AssemblyStuff asm1, AssemblyStuff asm2);
-               private static ArrayList comparers;
-
-               static AssemblyStuff ()
-               {
-                       comparers = new ArrayList ();
-                       comparers.Add (new Comparer (CompareNumClasses));
-                       comparers.Add (new Comparer (CompareNumInterfaces));
-                       comparers.Add (new Comparer (CompareClasses));
-                       comparers.Add (new Comparer (CompareInterfaces));
-                       comparers.Add (new Comparer (CompareEnums));
-               }
-
-               protected static bool CompareNumClasses (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       bool res = (asm1.classes.Count == asm2.classes.Count);
-                       if (!res) Verifier.Log.Write ("error", "Number of classes mismatch.", ImportanceLevel.MEDIUM);
-                       return res;
-               }
-
-               protected static bool CompareNumInterfaces (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       bool res = (asm1.interfaces.Count == asm2.interfaces.Count);
-                       if (!res) Verifier.Log.Write ("error", "Number of interfaces mismatch.", ImportanceLevel.MEDIUM);
-                       return res;
-               }
-
-
-               protected static bool CompareClasses (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       bool res = true;
-                       Verifier.Log.Write ("info", "Comparing classes.");
-
-                       foreach (DictionaryEntry c in asm1.classes) {
-                               string className = c.Key as string;
-
-                               if (Verifier.Excluded.Contains (className)) {
-                                       Verifier.Log.Write ("info", String.Format ("Ignoring class {0}.", className), ImportanceLevel.MEDIUM);
-                                       continue;
-                               }
-
-                               Verifier.Log.Write ("class", className);
-
-                               ClassStuff class1 = c.Value as ClassStuff;
-                               ClassStuff class2 = asm2.classes [className] as ClassStuff;
-
-                               if (class2 == null) {
-                                       Verifier.Log.Write ("error", String.Format ("There is no such class in {0}", asm2.name));
-                                       res = false;
-                                       if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res;
-                                       continue;
-                               }
-
-                               res &= (class1 == class2);
-                               if (!res && Verifier.stopOnError) return res;
-                       }
-
-                       return res;
-               }
-
-
-               protected static bool CompareInterfaces (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       bool res = true;
-                       Verifier.Log.Write ("info", "Comparing interfaces.");
-
-                       foreach (DictionaryEntry ifc in asm1.interfaces) {
-                               string ifcName = ifc.Key as string;
-                               Verifier.Log.Write ("interface", ifcName);
-
-                               InterfaceStuff ifc1 = ifc.Value as InterfaceStuff;
-                               InterfaceStuff ifc2 = asm2.interfaces [ifcName] as InterfaceStuff;
-
-                               if (ifc2 == null) {
-                                       Verifier.Log.Write ("error", String.Format ("There is no such interface in {0}", asm2.name));
-                                       res = false;
-                                       if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res;
-                                       continue;
-                               }
-
-                               res &= (ifc1 == ifc2);
-                               if (!res && Verifier.stopOnError) return res;
-
-                       }
-
-                       return res;
-               }
-
-
-               protected static bool CompareEnums (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       bool res = true;
-                       Verifier.Log.Write ("info", "Comparing enums.");
-
-                       foreach (DictionaryEntry e in asm1.enums) {
-                               string enumName = e.Key as string;
-                               Verifier.Log.Write ("enum", enumName);
-
-                               EnumStuff e1 = e.Value as EnumStuff;
-                               EnumStuff e2 = asm2.enums [enumName] as EnumStuff;
-
-                               if (e2 == null) {
-                                       Verifier.Log.Write ("error", String.Format ("There is no such enum in {0}", asm2.name));
-                                       res = false;
-                                       if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res;
-                                       continue;
-                               }
-                               res &= (e1 == e2);
-                               if (!res && Verifier.stopOnError) return res;
-                       }
-
-                       return res;
-               }
-
-
-
-               public AssemblyStuff (string assemblyName)
-               {
-                       this.name = assemblyName;
-                       valid = false;
-               }
-
-               public bool Load ()
-               {
-                       bool res = true;
-                       bool ok;
-
-                       classes = new ClassCollection ();
-                       ok = classes.LoadFrom (name);
-                       res &= ok;
-                       if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load classes from {0}.", name), ImportanceLevel.HIGH);
-
-                       interfaces = new InterfaceCollection ();
-                       ok = interfaces.LoadFrom (name);
-                       res &= ok;
-                       if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load interfaces from {0}.", name), ImportanceLevel.HIGH);
-
-                       enums = new EnumCollection ();
-                       ok = enums.LoadFrom (name);
-                       res &= ok;
-                       if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load enums from {0}.", name), ImportanceLevel.HIGH);
-
-                       valid = res;
-                       return res;
-               }
-
-
-               public override bool Equals (object o)
-               {
-                       bool res = (o is AssemblyStuff);
-                       if (res) {
-                               AssemblyStuff that = o as AssemblyStuff;
-                               IEnumerator it = comparers.GetEnumerator ();
-                               while ((res || !Verifier.stopOnError) && it.MoveNext ()) {
-                                       Comparer compare = it.Current as Comparer;
-                                       res &= compare (this, that);
-                               }
-                       }
-                       return res;
-               }
-
-
-               public static bool operator == (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       return asm1.Equals (asm2);
-               }
-
-               public static bool operator != (AssemblyStuff asm1, AssemblyStuff asm2)
-               {
-                       return !(asm1 == asm2);
-               }
-
-               public override int GetHashCode ()
-               {
-                       return classes.GetHashCode () ^ interfaces.GetHashCode ();
-               }
-
-
-               public override string ToString ()
-               {
-                       string res;
-                       if (valid) {
-                               res = String.Format ("Asssembly {0}, valid, {1} classes, {2} interfaces, {3} enums.",
-                                            name, classes.Count, interfaces.Count, enums.Count);
-                       } else {
-                               res = String.Format ("Asssembly {0}, invalid.", name);
-                       }
-                       return res;
-               }
-
-       }
-
-
-
-
-       ////////////////////////////////
-       // Compare
-       ////////////////////////////////
-
-       public sealed class Compare {
-
-               private Compare ()
-               {
-               }
-
-
-               public static bool Parameters (ParameterInfo[] params1, ParameterInfo[] params2)
-               {
-                       bool res = true;
-                       if (params1.Length != params2.Length) {
-                               Verifier.Log.Write ("Parameter count mismatch.");
-                               return false;
-                       }
-
-                       int count = params1.Length;
-
-                       for (int i = 0; i < count && res; i++) {
-                               if (params1 [i].Name != params2 [i].Name) {
-                                       Verifier.Log.Write ("error", String.Format ("Parameters names mismatch {0}, {1}.", params1 [i].Name, params2 [i].Name));
-                                       res = false;
-                                       if (Verifier.stopOnError) break;
-                               }
-
-                               Verifier.Log.Write ("parameter", params1 [i].Name);
-
-                               if (!Compare.Types (params1 [i].ParameterType, params2 [i].ParameterType)) {
-                                       Verifier.Log.Write ("error", String.Format ("Parameters types mismatch {0}, {1}.", params1 [i].ParameterType, params2 [i].ParameterType));
-                                       res = false;
-                                       if (Verifier.stopOnError) break;
-                               }
-
-
-                               if (Verifier.checkOptionalFlags) {
-                                       if (params1 [i].IsIn != params2 [i].IsIn) {
-                                               Verifier.Log.Write ("error", "[in] mismatch.");
-                                               res = false;
-                                               if (Verifier.stopOnError) break;
-                                       }
-
-                                       if (params1 [i].IsOut != params2 [i].IsOut) {
-                                               Verifier.Log.Write ("error", "[out] mismatch.");
-                                               res = false;
-                                               if (Verifier.stopOnError) break;
-                                       }
-
-                                       if (params1 [i].IsRetval != params2 [i].IsRetval) {
-                                               Verifier.Log.Write ("error", "[ref] mismatch.");
-                                               res = false;
-                                               if (Verifier.stopOnError) break;
-                                       }
-
-                                       if (params1 [i].IsOptional != params2 [i].IsOptional) {
-                                               Verifier.Log.Write ("error", "Optional flag mismatch.");
-                                               res = false;
-                                               if (Verifier.stopOnError) break;
-                                       }
-
-                               } // checkOptionalFlags
-
-
-                       }
-
-                       return res;
-               }
-
-
-
-               public static bool Methods (MethodInfo mi1, MethodInfo mi2)
-               {
-                       
-                       if (mi2 == null) {
-                               Verifier.Log.Write ("error", String.Format ("There is no such method {0}.", mi1.Name), ImportanceLevel.MEDIUM);
-                               return false;
-                       }
-
-
-                       Verifier.Log.Flush ();
-                       Verifier.Log.Write ("method", String.Format ("{0}.", mi1.Name));
-                       bool res = true;
-                       bool ok;
-                       string expected;
-
-                       ok = Compare.Types (mi1.ReturnType, mi2.ReturnType);
-                       res &= ok;
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Return types mismatch.", ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-
-
-                       ok = (mi1.IsAbstract == mi2.IsAbstract);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsAbstract) ? "abstract" : "non-abstract";
-                               Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (mi1.IsVirtual == mi2.IsVirtual);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsVirtual) ? "virtual" : "non-virtual";
-                               Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (mi1.IsFinal == mi2.IsFinal);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsFinal) ? "final" : "overridable";
-                               Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-
-                       // compare access modifiers
-
-                       ok = (mi1.IsPrivate == mi2.IsPrivate);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsPublic) ? "public" : "private";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-                       ok = (mi1.IsFamily == mi2.IsFamily);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsFamily) ? "protected" : "!protected";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (mi1.IsAssembly == mi2.IsAssembly);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsAssembly) ? "internal" : "!internal";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-                       ok = (mi1.IsStatic == mi2.IsStatic);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (mi1.IsStatic) ? "static" : "instance";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-
-                       // parameters
-
-                       ok = Compare.Parameters (mi1.GetParameters (), mi2.GetParameters ());
-                       res &= ok;
-                       if (!ok && Verifier.stopOnError) return res;
-
-
-                       ok = (mi1.CallingConvention == mi2.CallingConvention);
-                       res &= ok;
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Calling conventions mismatch.", ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-
-
-
-                       return res;
-               }
-
-
-               public static bool Fields (FieldInfo fi1, FieldInfo fi2)
-               {
-                       if (fi2 == null) {
-                               Verifier.Log.Write ("error", String.Format ("There is no such field {0}.", fi1.Name), ImportanceLevel.MEDIUM);
-                               return false;
-                       }
-
-                       bool res = true;
-                       bool ok;
-                       string expected;
-
-                       Verifier.Log.Write ("field", String.Format ("{0}.", fi1.Name));
-
-                       ok = (fi1.IsPrivate == fi2.IsPrivate);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (fi1.IsPublic) ? "public" : "private";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (fi1.IsFamily == fi2.IsFamily);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (fi1.IsFamily) ? "protected" : "!protected";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (fi1.IsAssembly == fi2.IsAssembly);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (fi1.IsAssembly) ? "internal" : "!internal";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (fi1.IsInitOnly == fi2.IsInitOnly);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (fi1.IsInitOnly) ? "readonly" : "!readonly";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       ok = (fi1.IsStatic == fi2.IsStatic);
-                       res &= ok;
-                       if (!ok) {
-                               expected = (fi1.IsStatic) ? "static" : "instance";
-                               Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM);
-                               if (Verifier.stopOnError) return res;
-                       }
-
-                       return res;
-               }
-
-
-
-               public static bool Types (Type type1, Type type2)
-               {
-                       // NOTE:
-                       // simply calling type1.Equals (type2) won't work,
-                       // types are in different assemblies hence they have
-                       // different (fully-qualified) names.
-                       int eqFlags = 0;
-                       eqFlags |= (type1.IsAbstract  == type2.IsAbstract)  ? 0 : 0x001;
-                       eqFlags |= (type1.IsClass     == type2.IsClass)     ? 0 : 0x002;
-                       eqFlags |= (type1.IsValueType == type2.IsValueType) ? 0 : 0x004;
-                       eqFlags |= (type1.IsPublic    == type2.IsPublic)    ? 0 : 0x008;
-                       eqFlags |= (type1.IsSealed    == type2.IsSealed)    ? 0 : 0x010;
-                       eqFlags |= (type1.IsEnum      == type2.IsEnum)      ? 0 : 0x020;
-                       eqFlags |= (type1.IsPointer   == type2.IsPointer)   ? 0 : 0x040;
-                       eqFlags |= (type1.IsPrimitive == type2.IsPrimitive) ? 0 : 0x080;
-                       bool res = (eqFlags == 0);
-
-                       if (!res) {
-                               // TODO: convert flags into descriptive message.
-                               Verifier.Log.Write ("error", "Types mismatch (0x" + eqFlags.ToString("X") + ").", ImportanceLevel.HIGH);
-                       }
-
-
-                       bool ok;
-
-                       ok = (type1.Attributes & TypeAttributes.BeforeFieldInit) ==
-                            (type2.Attributes & TypeAttributes.BeforeFieldInit);
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Types attributes mismatch: BeforeFieldInit.", ImportanceLevel.HIGH);
-                       }
-                       res &= ok;
-
-                       ok = (type1.Attributes & TypeAttributes.ExplicitLayout) ==
-                            (type2.Attributes & TypeAttributes.ExplicitLayout);
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Types attributes mismatch: ExplicitLayout.", ImportanceLevel.HIGH);
-                       }
-                       res &= ok;
-
-                       ok = (type1.Attributes & TypeAttributes.SequentialLayout) ==
-                            (type2.Attributes & TypeAttributes.SequentialLayout);
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Types attributes mismatch: SequentialLayout.", ImportanceLevel.HIGH);
-                       }
-                       res &= ok;
-
-                       ok = (type1.Attributes & TypeAttributes.Serializable) ==
-                            (type2.Attributes & TypeAttributes.Serializable);
-                       if (!ok) {
-                               Verifier.Log.Write ("error", "Types attributes mismatch: Serializable.", ImportanceLevel.HIGH);
-                       }
-                       res &= ok;
-
-                       return res;
-               }
-
-       }
-
-
-
-
-       ////////////////////////////////
-       // Log
-       ////////////////////////////////
-
-       public enum ImportanceLevel : int {
-               LOW = 0, MEDIUM, HIGH
-       }
-
-
-       public interface ILogger {
-
-               void Write (string tag, string msg, ImportanceLevel importance);
-               void Write (string msg, ImportanceLevel level);
-               void Write (string tag, string msg);
-               void Write (string msg);
-               ImportanceLevel DefaultImportance {get; set;}
-               void Flush ();
-               void Close ();
-       }
-
-
-       public abstract class AbstractLogger : ILogger {
-               private ImportanceLevel defImportance = ImportanceLevel.MEDIUM;
-
-               public abstract void Write (string tag, string msg, ImportanceLevel importance);
-               public abstract void Write (string msg, ImportanceLevel level);
-
-               public virtual void Write (string tag, string msg)
-               {
-                       Write (tag, msg, DefaultImportance);
-               }
-
-               public virtual void Write (string msg)
-               {
-                       Write (msg, DefaultImportance);
-               }
-
-               public virtual ImportanceLevel DefaultImportance {
-                       get {
-                               return defImportance;
-                       }
-                       set {
-                               defImportance = value < ImportanceLevel.LOW
-                                                ? ImportanceLevel.LOW
-                                                : value > ImportanceLevel.HIGH
-                                                  ? ImportanceLevel.HIGH
-                                                  : value;
-                       }
-               }
-
-               public abstract void Flush ();
-               public abstract void Close ();
-
-       }
-
-
-
-       public class TextLogger : AbstractLogger {
-
-               private TextWriter writer;
-
-               public TextLogger (TextWriter writer)
-               {
-                       if (writer == null)
-                               throw new NullReferenceException ();
-
-                       this.writer = writer;
-               }
-
-               private void DoWrite (string tag, string msg)
-               {
-                       if (tag != null && tag.Length > 0) {
-                               writer.WriteLine ("[{0}]\t{1}", tag, msg);
-                       } else {
-                               writer.WriteLine ("\t\t" + msg);
-                       }
-               }
-
-               public override void Write (string tag, string msg, ImportanceLevel importance)
-               {
-                       int v = Log.VerboseLevel;
-                       switch (v) {
-                       case 0 :
-                               break;
-                       case 1 :
-                               if (importance >= ImportanceLevel.HIGH) {
-                                       DoWrite (tag, msg);
-                               }
-                               break;
-                       case 2 :
-                               if (importance >= ImportanceLevel.MEDIUM) {
-                                       DoWrite (tag, msg);
-                               }
-                               break;
-                       case 3 :
-                               DoWrite (tag, msg);
-                               break;
-                       default:
-                               break;
-                       }
-               }
-
-               public override void Write (string msg, ImportanceLevel importance)
-               {
-                       Write (null, msg, importance);
-               }
-
-               public override void Flush ()
-               {
-                       Console.Out.Flush ();
-               }
-
-               public override void Close ()
-               {
-                       if (writer != Console.Out && writer != Console.Error) {
-                               writer.Close ();
-                       }
-               }
-       }
-
-
-
-       public sealed class Log {
-
-               private static int verbose = 3;
-
-               private ArrayList consumers;
-
-               public Log (bool useDefault)
-               {
-                       consumers = new ArrayList ();
-                       if (useDefault) AddConsumer (new TextLogger (Console.Out));
-               }
-
-               public Log () : this (true)
-               {
-               }
-
-
-               public static int VerboseLevel {
-                       get {
-                               return verbose;
-                       }
-                       set {
-                               verbose = (value < 0)
-                                          ? 0
-                                          : (value > 3)
-                                            ? 3 : value;
-                       }
-               }
-
-               public void AddConsumer (ILogger consumer)
-               {
-                       consumers.Add (consumer);
-               }
-
-
-               public void Write (string tag, string msg, ImportanceLevel importance)
-               {
-                       foreach (ILogger logger in consumers) {
-                               if (tag == null || tag == "") {
-                                       logger.Write (msg, importance);
-                               } else {
-                                       logger.Write (tag, msg, importance);
-                               }
-                       }
-               }
-
-               public void Write (string msg, ImportanceLevel importance)
-               {
-                       Write (null, msg, importance);
-               }
-
-
-               public void Write (string tag, string msg)
-               {
-                       foreach (ILogger logger in consumers) {
-                               if (tag == null || tag == "") {
-                                       logger.Write (msg);
-                               } else {
-                                       logger.Write (tag, msg);
-                               }
-                       }
-               }
-
-               public void Write (string msg)
-               {
-                       Write (null, msg);
-               }
-
-
-               public void Flush ()
-               {
-                       foreach (ILogger logger in consumers) {
-                               logger.Flush ();
-                       }
-               }
-
-
-               public void Close ()
-               {
-                       foreach (ILogger logger in consumers) {
-                               logger.Flush ();
-                               logger.Close ();
-                       }
-               }
-
-       }
-
-
-
-
-
-
-       ////////////////////////////////
-       // Main
-       ////////////////////////////////
-
-       public class Verifier {
-
-               public static readonly Log log = new Log ();
-               public static bool stopOnError = false;
-               public static bool ignoreMissingTypes = true;
-               public static bool checkOptionalFlags = true;
-
-               private static readonly IList excluded;
-
-               static Verifier ()
-               {
-                       excluded = new ArrayList ();
-                       excluded.Add ("<PrivateImplementationDetails>");
-               }
-
-
-               private Verifier ()
-               {
-               }
-
-               public static Log Log {
-                       get {
-                               return log;
-                       }
-               }
-
-               public static IList Excluded {
-                       get {
-                               return excluded;
-                       }
-               }
-
-
-
-               public static void Main (String [] args)
-               {
-                       if (args.Length < 2) {
-                               Console.WriteLine ("Usage: verifier assembly1 assembly2");
-                       } else {
-                               string name1 = args [0];
-                               string name2 = args [1];
-
-                               bool ok = false;
-
-                               AssemblyStuff asm1 = new AssemblyStuff (name1);
-                               AssemblyStuff asm2 = new AssemblyStuff (name2);
-                               ok = asm1.Load ();
-                               if (!ok) {
-                                       Console.WriteLine ("Unable to load assembly {0}.", name1);
-                                       Environment.Exit (-1);
-                               }
-
-                               ok = asm2.Load ();
-                               if (!ok) {
-                                       Console.WriteLine ("Unable to load assembly {0}.", name2);
-                                       Environment.Exit (-1);
-                               }
-
-
-                               try {
-                                       ok = (asm1 == asm2);
-                               } catch {
-                                       ok = false;
-                               } finally {
-                                       Log.Close ();
-                               }
-
-                               if (!ok) {
-                                       Console.WriteLine ("--- not equal");
-                                       Environment.Exit (-1);
-                               }
-                       }
-               }
-
-       }
-
-
-}
-
index 4fe2e248be7fcf25b053db356f8a0d7c24cb882e..bac7e8749989225afd4371dc853b4ee6a64d3303 100644 (file)
@@ -1037,8 +1037,11 @@ static void console_close (gpointer handle, gpointer data)
 
        g_free (console_handle->filename);
 
-       if (fd > 2)
+       if (fd > 2) {
+               if (console_handle->share_info)
+                       _wapi_handle_share_release (console_handle->share_info);
                close (fd);
+       }
 }
 
 static WapiFileType console_getfiletype(void)
@@ -1159,6 +1162,9 @@ static void pipe_close (gpointer handle, gpointer data)
 
        /* No filename with pipe handles */
 
+       if (pipe_handle->share_info)
+               _wapi_handle_share_release (pipe_handle->share_info);
+
        close (fd);
 }
 
@@ -1630,6 +1636,10 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
 #endif
        if (S_ISFIFO (statbuf.st_mode)) {
                handle_type = WAPI_HANDLE_PIPE;
+               /* maintain invariant that pipes have no filename */
+               file_handle.filename = NULL;
+               g_free (filename);
+               filename = NULL;
        } else if (S_ISCHR (statbuf.st_mode)) {
                handle_type = WAPI_HANDLE_CONSOLE;
        } else {
index 211c92bba176c3d054a87177385a527bec908998..1011818361818960c0573dbd552c34c9d5bcc016 100644 (file)
 #define WaitForMultipleObjects wapi_WaitForMultipleObjects
 #define WaitForMultipleObjectsEx wapi_WaitForMultipleObjectsEx
 #define WaitForInputIdle wapi_WaitForInputIdle
+#define GetThreadPriority wapi_GetThreadPriority
+#define SetThreadPriority wapi_SetThreadPriority
 
 #endif /* __WAPI_REMAP_H__ */
index 56fd2c41dd527909790edfb6ef87ec8953df6ff5..381d102b39bddab4358193835d8bb065ac4b454c 100644 (file)
@@ -105,7 +105,6 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"Mono.Security.Win32", 0},
        {"Mono.Xml.Ext", 0},
        {"Novell.Directory.Ldap", 0},
-       {"Npgsql", 0},
        {"PEAPI", 0},
        {"System", 0},
        {"System.ComponentModel.Composition", 2},
index 538371bf50cf4938bd72ceefb026f1e6a48348f2..9a4aafe05979712ab971ba788ace1a40c142612f 100644 (file)
@@ -399,7 +399,7 @@ ICALL(MATH_17, "Tan", ves_icall_System_Math_Tan)
 ICALL(MATH_18, "Tanh", ves_icall_System_Math_Tanh)
 
 ICALL_TYPE(MCATTR, "System.MonoCustomAttrs", MCATTR_1)
-ICALL(MCATTR_1, "GetCustomAttributesDataInternal", mono_reflection_get_custom_attrs_data)
+ICALL(MCATTR_1, "GetCustomAttributesDataInternal", ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal)
 ICALL(MCATTR_2, "GetCustomAttributesInternal", custom_attrs_get_by_type)
 ICALL(MCATTR_3, "IsDefinedInternal", custom_attrs_defined_internal)
 
index 4c456dfaedd0f5c6d7df87a90350a68992b60d64..ba18aac5ac1dc12273a31838da77f1d752ee9b99 100644 (file)
@@ -1273,16 +1273,16 @@ get_caller_no_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed
 }
 
 static MonoReflectionType *
-type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase)
+type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase, MonoError *error)
 {
-       MonoError error;
-       MonoReflectionType *ret;
        MonoMethod *m, *dest;
 
        MonoType *type = NULL;
        MonoAssembly *assembly = NULL;
        gboolean type_resolve = FALSE;
 
+       mono_error_init (error);
+
        /*
         * We must compute the calling assembly as type loading must happen under a metadata context.
         * For example. The main assembly is a.exe and Type.GetType is called from dir/b.dll. Without
@@ -1330,42 +1330,15 @@ type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase)
        if (!type) 
                return NULL;
 
-       ret = mono_type_get_object_checked (mono_domain_get (), type, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
-
-       return ret;
+       return mono_type_get_object_checked (mono_domain_get (), type, error);
 }
 
-#ifdef UNUSED
-MonoReflectionType *
-mono_type_get (const char *str)
-{
-       char *copy = g_strdup (str);
-       MonoTypeNameParse info;
-       MonoReflectionType *type;
-       gboolean parsedOk;
-
-       parsedOk = mono_reflection_parse_type(copy, &info);
-       if (!parsedOk) {
-               mono_reflection_free_type_info (&info);
-               g_free(copy);
-               return NULL;
-       }
-
-       type = type_from_parsed_name (&info, FALSE);
-
-       mono_reflection_free_type_info (&info);
-       g_free(copy);
-
-       return type;
-}
-#endif
-
 ICALL_EXPORT MonoReflectionType*
 ves_icall_type_from_name (MonoString *name,
                          MonoBoolean throwOnError,
                          MonoBoolean ignoreCase)
 {
+       MonoError error;
        char *str = mono_string_to_utf8 (name);
        MonoTypeNameParse info;
        MonoReflectionType *type;
@@ -1383,11 +1356,19 @@ ves_icall_type_from_name (MonoString *name,
                return NULL;
        }
 
-       type = type_from_parsed_name (&info, ignoreCase);
+       type = type_from_parsed_name (&info, ignoreCase, &error);
 
        mono_reflection_free_type_info (&info);
        g_free (str);
 
+       if (!mono_error_ok (&error)) {
+               if (throwOnError)
+                       mono_error_set_pending_exception (&error);
+               else
+                       mono_error_cleanup (&error);
+               return NULL;
+       }
+
        if (type == NULL){
                MonoException *e = NULL;
                
@@ -4595,13 +4576,14 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAss
 }
 
 static MonoObject*
-create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision)
+create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision, MonoError *error)
 {
        static MonoClass *System_Version = NULL;
        static MonoMethod *create_version = NULL;
-       MonoError error;
        MonoObject *result;
        gpointer args [4];
+
+       mono_error_init (error);
        
        if (!System_Version) {
                System_Version = mono_class_from_name (mono_defaults.corlib, "System", "Version");
@@ -4619,11 +4601,11 @@ create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build,
        args [1] = &minor;
        args [2] = &build;
        args [3] = &revision;
-       result = mono_object_new_checked (domain, System_Version, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       result = mono_object_new_checked (domain, System_Version, error);
+       return_val_if_nok (error, NULL);
 
-       mono_runtime_invoke_checked (create_version, result, args, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       mono_runtime_invoke_checked (create_version, result, args, error);
+       return_val_if_nok (error, NULL);
 
        return result;
 }
@@ -4659,6 +4641,7 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
        }
 
        for (i = 0; i < count; i++) {
+               MonoObject *version;
                MonoReflectionAssemblyName *aname;
                guint32 cols [MONO_ASSEMBLYREF_SIZE];
 
@@ -4677,7 +4660,11 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
                aname->flags = cols [MONO_ASSEMBLYREF_FLAGS];
                aname->versioncompat = 1; /* SameMachine (default) */
                aname->hashalg = ASSEMBLY_HASH_SHA1; /* SHA1 (default) */
-               MONO_OBJECT_SETREF (aname, version, create_version (domain, aname->major, aname->minor, aname->build, aname->revision));
+
+               version = create_version (domain, aname->major, aname->minor, aname->build, aname->revision, &error);
+               mono_error_raise_exception (&error);
+
+               MONO_OBJECT_SETREF (aname, version, version);
 
                if (create_culture) {
                        gpointer args [2];
@@ -5161,10 +5148,9 @@ ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *rfield)
 }
 
 static void
-fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token)
+fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token, MonoError *error)
 {
        static MonoMethod *create_culture = NULL;
-       MonoError error;
        MonoObject *obj;
        gpointer args [2];
        guint32 pkey_len;
@@ -5172,6 +5158,8 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
        gchar *codebase;
        MonoBoolean assembly_ref = 0;
 
+       mono_error_init (error);
+
        MONO_OBJECT_SETREF (aname, name, mono_string_new (domain, name->name));
        aname->major = name->major;
        aname->minor = name->minor;
@@ -5182,8 +5170,14 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
        aname->versioncompat = 1; /* SameMachine (default) */
        aname->processor_architecture = name->arch;
 
-       if (by_default_version)
-               MONO_OBJECT_SETREF (aname, version, create_version (domain, name->major, name->minor, name->build, name->revision));
+       if (by_default_version) {
+               MonoObject *version;
+
+               version = create_version (domain, name->major, name->minor, name->build, name->revision, error);
+               return_if_nok (error);
+
+               MONO_OBJECT_SETREF (aname, version, version);
+       }
 
        codebase = NULL;
        if (absolute != NULL && *absolute != '\0') {
@@ -5227,8 +5221,8 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
                args [0] = mono_string_new (domain, name->culture);
                args [1] = &assembly_ref;
 
-               obj = mono_runtime_invoke_checked (create_culture, NULL, args, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
+               obj = mono_runtime_invoke_checked (create_culture, NULL, args, error);
+               return_if_nok (error);
 
                MONO_OBJECT_SETREF (aname, cultureInfo, obj);
        }
@@ -5281,20 +5275,19 @@ ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssembly *assem
 ICALL_EXPORT void
 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
 {
+       MonoError error;
        gchar *absolute;
        MonoAssembly *mass = assembly->assembly;
 
        if (g_path_is_absolute (mass->image->name)) {
-               fill_reflection_assembly_name (mono_object_domain (assembly),
-                       aname, &mass->aname, mass->image->name, TRUE,
-                       TRUE, TRUE);
+               fill_reflection_assembly_name (mono_object_domain (assembly), aname, &mass->aname, mass->image->name, TRUE, TRUE, TRUE, &error);
+               mono_error_set_pending_exception (&error);
                return;
        }
        absolute = g_build_filename (mass->basedir, mass->image->name, NULL);
 
-       fill_reflection_assembly_name (mono_object_domain (assembly),
-               aname, &mass->aname, absolute, TRUE, TRUE,
-               TRUE);
+       fill_reflection_assembly_name (mono_object_domain (assembly), aname, &mass->aname, absolute, TRUE, TRUE, TRUE, &error);
+       mono_error_set_pending_exception (&error);
 
        g_free (absolute);
 }
@@ -5302,6 +5295,7 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
 ICALL_EXPORT void
 ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, MonoReflectionAssemblyName *aname)
 {
+       MonoError error;
        char *filename;
        MonoImageOpenStatus status = MONO_IMAGE_OK;
        gboolean res;
@@ -5337,11 +5331,11 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname,
                return;
        }
 
-       fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename,
-               TRUE, FALSE, TRUE);
+       fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename, TRUE, FALSE, TRUE, &error);
+       mono_error_set_pending_exception (&error);
 
-       g_free (filename);
        mono_image_close (image);
+       g_free (filename);
 }
 
 ICALL_EXPORT MonoBoolean
@@ -5389,15 +5383,16 @@ mono_module_type_is_visible (MonoTableInfo *tdef, MonoImage *image, int type)
 }
 
 static MonoArray*
-mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly)
+mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly, MonoError *error)
 {
-       MonoError error;
        MonoReflectionType *rt;
        MonoArray *res;
        MonoClass *klass;
        MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF];
        int i, count;
 
+       mono_error_init (error);
+
        /* we start the count from 1 because we skip the special type <Module> */
        if (exportedOnly) {
                count = 0;
@@ -5413,17 +5408,17 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti
        count = 0;
        for (i = 1; i < tdef->rows; ++i) {
                if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) {
-                       klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, &error);
+                       klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, error);
                        mono_loader_assert_no_error (); /* Plug any leaks */
-                       g_assert (mono_error_ok (&error));
+                       mono_error_assert_ok (error);
                        
                        if (klass) {
-                               rt = mono_type_get_object_checked (domain, &klass->byval_arg, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               rt = mono_type_get_object_checked (domain, &klass->byval_arg, error);
+                               return_val_if_nok (error, NULL);
 
                                mono_array_setref (res, count, rt);
                        } else {
-                               MonoException *ex = mono_error_convert_to_exception (&error);
+                               MonoException *ex = mono_error_convert_to_exception (error);
                                mono_array_setref (*exceptions, count, ex);
                        }
                        count++;
@@ -5436,6 +5431,7 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti
 ICALL_EXPORT MonoArray*
 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
 {
+       MonoError error;
        MonoArray *res = NULL;
        MonoArray *exceptions = NULL;
        MonoImage *image = NULL;
@@ -5449,7 +5445,8 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        g_assert (!assembly_is_dynamic (assembly->assembly));
        image = assembly->assembly->image;
        table = &image->tables [MONO_TABLE_FILE];
-       res = mono_module_get_types (domain, image, &exceptions, exportedOnly);
+       res = mono_module_get_types (domain, image, &exceptions, exportedOnly, &error);
+       mono_error_raise_exception (&error);
 
        /* Append data from all modules in the assembly */
        for (i = 0; i < table->rows; ++i) {
@@ -5457,7 +5454,11 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
                        MonoImage *loaded_image = mono_assembly_load_module (image->assembly, i + 1);
                        if (loaded_image) {
                                MonoArray *ex2;
-                               MonoArray *res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly);
+                               MonoArray *res2;
+
+                               res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly, &error);
+                               mono_error_raise_exception (&error);
+
                                /* Append the new types to the end of the array */
                                if (mono_array_length (res2) > 0) {
                                        guint32 len1, len2;
@@ -5543,6 +5544,7 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
 ICALL_EXPORT gboolean
 ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname)
 {
+       MonoError error;
        MonoAssemblyName aname;
        MonoDomain *domain = mono_object_domain (name);
        char *val;
@@ -5557,8 +5559,8 @@ ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *
                return FALSE;
        }
        
-       fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined,
-               FALSE, is_token_defined);
+       fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined, FALSE, is_token_defined, &error);
+       mono_error_set_pending_exception (&error);
 
        mono_assembly_name_free (&aname);
        g_free ((guint8*) aname.public_key);
@@ -5646,13 +5648,18 @@ ves_icall_System_Reflection_Module_GetMDStreamVersion (MonoImage *image)
 ICALL_EXPORT MonoArray*
 ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *module)
 {
+       MonoError error;
        MonoArray *exceptions;
        int i;
 
        if (!module->image)
                return mono_array_new (mono_object_domain (module), mono_defaults.monotype_class, 0);
        else {
-               MonoArray *res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE);
+               MonoArray *res;
+
+               res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE, &error);
+               mono_error_raise_exception (&error);
+
                for (i = 0; i < mono_array_length (exceptions); ++i) {
                        MonoException *ex = mono_array_get (exceptions, MonoException *, i);
                        if (ex) {
@@ -7741,6 +7748,17 @@ custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type)
        }
 }
 
+ICALL_EXPORT MonoArray*
+ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal (MonoObject *obj)
+{
+       MonoError error;
+       MonoArray *result;
+       result = mono_reflection_get_custom_attrs_data_checked (obj, &error);
+       mono_error_set_pending_exception (&error);
+       return result;
+}
+
+
 ICALL_EXPORT MonoString*
 ves_icall_Mono_Runtime_GetDisplayName (void)
 {
index e622308066a44d2e8d632909c69007b00796381b..267f87d47350f6da4ff85b3c4f966a2d6c63e8e6 100644 (file)
@@ -498,13 +498,16 @@ mono_determine_physical_ram_available_size (void)
        return ((guint64) value.t_free * page_size) / 1024;
 #elif defined (__APPLE__)
        mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
+       mach_port_t host = mach_host_self();
+       vm_size_t page_size;
        vm_statistics_data_t vmstat;
-       if (KERN_SUCCESS != host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count)) {
+       if (KERN_SUCCESS != host_statistics(host, HOST_VM_INFO, (host_info_t)&vmstat, &count)) {
                g_warning ("Mono was unable to retrieve memory usage!");
                return 0;
        }
 
-       return (guint64) vmstat.free_count;
+       host_page_size(host, &page_size);
+       return (guint64) vmstat.free_count * page_size;
 
 #elif defined (HAVE_SYSCONF)
        guint64 page_size = 0, num_pages = 0;
index 9ff3b451281e4940dbc2b47e8f1917ad989e0352..f445b436172f47095af789edaddac055c35dffdb 100644 (file)
@@ -11,6 +11,9 @@
 MonoObject*
 mono_custom_attrs_get_attr_checked (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass, MonoError *error);
 
+MonoArray*
+mono_reflection_get_custom_attrs_data_checked (MonoObject *obj, MonoError *error);
+
 char*
 mono_identifier_unescape_type_name_chars (char* identifier);
 
index d568f3614d8bbd3d39c51ddd8efda9557aac6add..49cac40c7adb4c7b782d3718bd00118507e94f60 100644 (file)
@@ -10018,10 +10018,31 @@ mono_reflection_get_custom_attrs (MonoObject *obj)
  */
 MonoArray*
 mono_reflection_get_custom_attrs_data (MonoObject *obj)
+{
+       MonoError error;
+       MonoArray* result;
+       result = mono_reflection_get_custom_attrs_data_checked (obj, &error);
+       mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */
+       return result;
+}
+
+/*
+ * mono_reflection_get_custom_attrs_data_checked:
+ * @obj: a reflection obj handle
+ * @error: set on error
+ *
+ * Returns an array of System.Reflection.CustomAttributeData,
+ * which include information about attributes reflected on
+ * types loaded using the Reflection Only methods
+ */
+MonoArray*
+mono_reflection_get_custom_attrs_data_checked (MonoObject *obj, MonoError *error)
 {
        MonoArray *result;
        MonoCustomAttrInfo *cinfo;
 
+       mono_error_init (error);
+
        cinfo = mono_reflection_get_custom_attrs_info (obj);
        if (cinfo) {
                result = mono_custom_attrs_data_construct (cinfo);
@@ -10030,6 +10051,9 @@ mono_reflection_get_custom_attrs_data (MonoObject *obj)
        } else
                result = mono_array_new (mono_domain_get (), mono_defaults.customattribute_data_class, 0);
 
+       if (mono_loader_get_last_error ())
+               mono_error_set_from_loader_error (error);
+
        return result;
 }
 
index e3e84f11e7311e200c42f3f07696affb8fbad8e4..a8bdff969b0d1ba22e7bae710de50b99775c5f40 100644 (file)
@@ -70,6 +70,7 @@ MONO_API MonoObject *mono_get_dbnull_object (MonoDomain *domain);
 
 MONO_API MonoArray*  mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass *attr_klass, MonoError *error);
 MONO_API MonoArray*  mono_reflection_get_custom_attrs (MonoObject *obj);
+MONO_RT_EXTERNAL_ONLY
 MONO_API MonoArray*  mono_reflection_get_custom_attrs_data (MonoObject *obj);
 MONO_API MonoArray*  mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
 
index 74ee377c49a8eb5f2275bbc7f8f2e9539398b801..8f86228dce17bece01892b1e24934f67aa7af264 100644 (file)
@@ -2738,7 +2738,7 @@ sgen_client_degraded_allocation (size_t size)
        static int last_major_gc_warned = -1;
        static int num_degraded = 0;
 
-       if (last_major_gc_warned < gc_stats.major_gc_count) {
+       if (last_major_gc_warned < (int)gc_stats.major_gc_count) {
                ++num_degraded;
                if (num_degraded == 1 || num_degraded == 3)
                        mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "Warning: Degraded allocation.  Consider increasing nursery-size if the warning persists.");
index 5248748953ad7c2bb04e7673b673a759d4cf3d03..b082a6e3b0f2f7b0ed66b398e7e2d495020f6cbf 100644 (file)
@@ -4599,7 +4599,7 @@ mono_aot_patch_plt_entry (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_
  * Returns NULL if the something cannot be loaded.
  */
 gpointer
-mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code)
+mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error)
 {
 #ifdef MONO_ARCH_AOT_SUPPORTED
        guint8 *p, *target, *plt_entry;
@@ -4607,9 +4607,10 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
        MonoAotModule *module = (MonoAotModule*)aot_module;
        gboolean res, no_ftnptr = FALSE;
        MonoMemPool *mp;
-       MonoError error;
        gboolean using_gsharedvt = FALSE;
 
+       mono_error_init (error);
+
        //printf ("DYN: %p %d\n", aot_module, plt_info_offset);
 
        p = &module->blob [plt_info_offset];
@@ -4636,12 +4637,14 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
         */
        if (mono_aot_only && ji.type == MONO_PATCH_INFO_METHOD && !ji.data.method->is_generic && !mono_method_check_context_used (ji.data.method) && !(ji.data.method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) &&
                !mono_method_needs_static_rgctx_invoke (ji.data.method, FALSE) && !using_gsharedvt) {
-               target = (guint8 *)mono_jit_compile_method (ji.data.method, &error);
-               if (!mono_error_ok (&error))
-                       mono_error_raise_exception (&error);
+               target = (guint8 *)mono_jit_compile_method (ji.data.method, error);
+               if (!mono_error_ok (error))
+                       return NULL;
                no_ftnptr = TRUE;
        } else {
-               target = (guint8 *)mono_resolve_patch_target (NULL, mono_domain_get (), NULL, &ji, TRUE);
+               target = (guint8 *)mono_resolve_patch_target_checked (NULL, mono_domain_get (), NULL, &ji, TRUE, error);
+               if (!mono_error_ok (error))
+                       return NULL;
        }
 
        /*
@@ -5728,7 +5731,7 @@ mono_aot_get_plt_entry (guint8 *code)
 }
 
 gpointer
-mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code)
+mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error)
 {
        return NULL;
 }
index d804fa67259b8a4efade9e323c534a2e2f92c11c..cc25ae065d6916d516c5c0c1c695b98bb9784f29 100644 (file)
@@ -6100,18 +6100,14 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                         * To make async stack traces work, icalls which can block should have a wrapper.
                         * For Monitor.Enter, emit two calls: a fastpath which doesn't have a wrapper, and a slowpath, which does.
                         */
-                       MonoBasicBlock *end_bb, *slowpath_bb;
+                       MonoBasicBlock *end_bb;
 
                        NEW_BBLOCK (cfg, end_bb);
-                       NEW_BBLOCK (cfg, slowpath_bb);
 
-                       ins = mono_emit_jit_icall (cfg, is_v4 ? mono_monitor_enter_v4_fast : mono_monitor_enter_fast, args);
-                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, ins->dreg, 0);
-                       MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBEQ, slowpath_bb);
-                       MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
-                       MONO_START_BB (cfg, slowpath_bb);
-                       ins = mono_emit_jit_icall (cfg, is_v4 ? mono_monitor_enter_v4 : mono_monitor_enter, args);
-                       MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
+                       ins = mono_emit_jit_icall (cfg, is_v4 ? (gpointer)mono_monitor_enter_v4_fast : (gpointer)mono_monitor_enter_fast, args);
+                       MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, ins->dreg, 0);
+                       MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBNE_UN, end_bb);
+                       ins = mono_emit_jit_icall (cfg, is_v4 ? (gpointer)mono_monitor_enter_v4 : (gpointer)mono_monitor_enter, args);
                        MONO_START_BB (cfg, end_bb);
                        return ins;
                }
index cb5ddd33e79032ea2a81781d811f6df9ef68e754..6fab934f479b6d7503dffc9e043e367814bc9db2 100644 (file)
@@ -28,6 +28,7 @@
 #include <llvm/IR/Function.h>
 #include <llvm/IR/IRBuilder.h>
 #include <llvm/IR/Module.h>
+#include <llvm/IR/DIBuilder.h>
 
 #include "mini-llvm-cpp.h"
 
@@ -216,3 +217,11 @@ mono_llvm_set_call_preserveall_cc (LLVMValueRef func)
 {
        unwrap<CallInst>(func)->setCallingConv (CallingConv::PreserveAll);
 }
+
+void
+mono_llvm_create_di_compile_unit (LLVMModuleRef module)
+{
+       DIBuilder d(*unwrap(module));
+
+       d.createCompileUnit (0, "X", "Y", "Z", false, "", 0, "", DIBuilder::DebugEmissionKind::FullDebug, true);
+}
index 78bccd07ff9422a5adcc1ddc75af0343f5a84a8c..9e551e2557d8ace03612505abb36b9c4f2c2310f 100644 (file)
@@ -111,6 +111,9 @@ mono_llvm_set_unhandled_exception_handler (void);
 void
 default_mono_llvm_unhandled_exception (void);
 
+void
+mono_llvm_create_di_compile_unit (LLVMModuleRef module);
+
 G_END_DECLS
 
 #endif /* __MONO_MINI_LLVM_CPP_H__ */  
index 3484ed3faecd954d4e87bd83f8e16699f43d47a8..ae0767d176978ff9c286055cca1c9e96de665d47 100644 (file)
@@ -7999,6 +7999,8 @@ mono_llvm_emit_aot_module (const char *filename, const char *cu_name)
        emit_dbg_info (&aot_module, filename, cu_name);
        emit_aot_file_info (&aot_module);
 
+       mono_llvm_create_di_compile_unit (aot_module.lmodule);
+
        /*
         * Replace GOT entries for directly callable methods with the methods themselves.
         * It would be easier to implement this by predefining all methods before compiling
index 52aaacbdd551f022f7159f1456e5e8ccd9523ba8..170cc65e7bd98d7bab78a20e6b21c046a19554cf 100644 (file)
@@ -1355,11 +1355,13 @@ mono_patch_info_equal (gconstpointer ka, gconstpointer kb)
 }
 
 gpointer
-mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors)
+mono_resolve_patch_target_checked (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors, MonoError *error)
 {
        unsigned char *ip = patch_info->ip.i + code;
        gconstpointer target = NULL;
 
+       mono_error_init (error);
+
        switch (patch_info->type) {
        case MONO_PATCH_INFO_BB:
                /*
@@ -1572,29 +1574,27 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
        case MONO_PATCH_INFO_TYPE_FROM_HANDLE: {
                gpointer handle;
                MonoClass *handle_class;
-               MonoError error;
 
                handle = mono_ldtoken_checked (patch_info->data.token->image,
-                                                          patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error);
-               if (!mono_error_ok (&error))
-                       g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error));
+                                                          patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, error);
+               if (!mono_error_ok (error))
+                       g_error ("Could not patch ldtoken due to %s", mono_error_get_message (error));
                mono_class_init (handle_class);
                mono_class_init (mono_class_from_mono_type ((MonoType *)handle));
 
-               target = mono_type_get_object_checked (domain, (MonoType *)handle, &error);
-               mono_error_raise_exception (&error);
-
+               target = mono_type_get_object_checked (domain, (MonoType *)handle, error);
+               if (!mono_error_ok (error))
+                       return NULL;
                break;
        }
        case MONO_PATCH_INFO_LDTOKEN: {
                gpointer handle;
                MonoClass *handle_class;
-               MonoError error;
 
                handle = mono_ldtoken_checked (patch_info->data.token->image,
-                                                          patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error);
-               if (!mono_error_ok (&error))
-                       g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error));
+                                                          patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, error);
+               if (!mono_error_ok (error))
+                       g_error ("Could not patch ldtoken due to %s", mono_error_get_message (error));
                mono_class_init (handle_class);
 
                target = handle;
@@ -1612,8 +1612,10 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                        if (run_cctors) {
                                target = mono_lookup_pinvoke_call (patch_info->data.method, &exc_class, &exc_arg);
                                if (!target) {
-                                       if (mono_aot_only)
-                                               mono_raise_exception (mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg));
+                                       if (mono_aot_only) {
+                                               mono_error_set_exception_instance (error, mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg));
+                                               return NULL;
+                                       }
                                        g_error ("Unable to resolve pinvoke method '%s' Re-run with MONO_LOG_LEVEL=debug for more information.\n", mono_method_full_name (patch_info->data.method, TRUE));
                                }
                        } else {
@@ -1728,6 +1730,17 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
        return (gpointer)target;
 }
 
+gpointer
+mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors)
+{
+       MonoError error;
+       gpointer res;
+
+       res = mono_resolve_patch_target_checked (method, domain, code, patch_info, run_cctors, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       return res;
+}
+
 void
 mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *context, MonoGenericSharingContext *gsctx)
 {
index a28fd9168d38616ba856829ab4f7987fbee9db3a..a624f37d37e1aa1a857c73f886feaeee657cbca4 100644 (file)
@@ -1006,11 +1006,16 @@ mono_aot_plt_trampoline (mgreg_t *regs, guint8 *code, guint8 *aot_module,
 {
        guint32 plt_info_offset = mono_aot_get_plt_info_offset (regs, code);
        gpointer res;
+       MonoError error;
 
        trampoline_calls ++;
 
-       res = mono_aot_plt_resolve (aot_module, plt_info_offset, code);
+       res = mono_aot_plt_resolve (aot_module, plt_info_offset, code, &error);
        if (!res) {
+               if (!mono_error_ok (&error)) {
+                       mono_error_set_pending_exception (&error);
+                       return NULL;
+               }
                if (mono_loader_get_last_error ()) {
                        MonoError error;
 
index 81ef032a467a828e45969b030b7a06130135b251..1b1c728f248b36ad128429b235aa9607940e4754 100644 (file)
@@ -2324,6 +2324,7 @@ guint     mono_patch_info_hash (gconstpointer data);
 gint      mono_patch_info_equal (gconstpointer ka, gconstpointer kb);
 MonoJumpInfo *mono_patch_info_list_prepend  (MonoJumpInfo *list, int ip, MonoJumpInfoType type, gconstpointer target);
 gpointer  mono_resolve_patch_target         (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors) MONO_LLVM_INTERNAL;
+gpointer  mono_resolve_patch_target_checked (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors, MonoError *error) MONO_LLVM_INTERNAL;
 gpointer  mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji);
 gpointer  mono_jit_find_compiled_method     (MonoDomain *domain, MonoMethod *method);
 gpointer  mono_jit_compile_method           (MonoMethod *method, MonoError *error);
@@ -2438,7 +2439,7 @@ guint32   mono_aot_get_plt_info_offset      (mgreg_t *regs, guint8 *code);
 gboolean  mono_aot_get_cached_class_info    (MonoClass *klass, MonoCachedClassInfo *res);
 gboolean  mono_aot_get_class_from_name      (MonoImage *image, const char *name_space, const char *name, MonoClass **klass);
 MonoJitInfo* mono_aot_find_jit_info         (MonoDomain *domain, MonoImage *image, gpointer addr);
-gpointer mono_aot_plt_resolve               (gpointer aot_module, guint32 plt_info_offset, guint8 *code);
+gpointer mono_aot_plt_resolve               (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error);
 void     mono_aot_patch_plt_entry           (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_t *regs, guint8 *addr);
 gpointer mono_aot_get_method_from_vt_slot   (MonoDomain *domain, MonoVTable *vtable, int slot);
 gpointer mono_aot_create_specific_trampoline   (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
index 349eff5401457757c9757591a398a275d7990aab..2c69c7d932f24a5109cbc92e289676dcb2fc86ca 100644 (file)
@@ -101,7 +101,7 @@ alloc_degraded (GCVTable vtable, size_t size, gboolean for_mature)
        if (!for_mature) {
                sgen_client_degraded_allocation (size);
                SGEN_ATOMIC_ADD_P (degraded_mode, size);
-               sgen_ensure_free_space (size);
+               sgen_ensure_free_space (size, GENERATION_OLD);
        } else {
                if (sgen_need_major_collection (size))
                        sgen_perform_collection (size, GENERATION_OLD, "mature allocation failure", !for_mature);
@@ -271,7 +271,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size)
                                         * always loop we will loop endlessly in the case of
                                         * OOM).
                                         */
-                                       sgen_ensure_free_space (real_size);
+                                       sgen_ensure_free_space (real_size, GENERATION_NURSERY);
                                        if (!degraded_mode)
                                                p = (void **)sgen_nursery_alloc (size);
                                }
@@ -288,7 +288,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size)
                                p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size);
                                if (!p) {
                                        /* See comment above in similar case. */
-                                       sgen_ensure_free_space (tlab_size);
+                                       sgen_ensure_free_space (tlab_size, GENERATION_NURSERY);
                                        if (!degraded_mode)
                                                p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size);
                                }
index 5a0e871e22fecc779083f53fea42bc4945f6849a..11a8998478e765e8083e337c57a9f48c6fb7a9ee 100644 (file)
@@ -190,12 +190,6 @@ typedef mword SgenDescriptor;
  */
 #define SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO 0.33
 
-/*
- * How much more we allow the heap to grow, relative to the allowance, while doing
- * a concurrent collection, before forcing its finish.
- */
-#define SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO 0.25
-
 /*
  * Default ratio of memory we want to release in a major collection in relation to the the current heap size.
  *
index 34da3f15ab339c4b84d83585d4d265832fdc1c24..89af85f4387d92646edc38554aa138dd0b9dbdec 100644 (file)
@@ -1560,8 +1560,6 @@ collect_nursery (SgenGrayQueue *unpin_queue, gboolean finish_up_concurrent_mark)
 
        sgen_pin_stats_print_class_stats ();
 
-       sgen_drain_gray_stack (ctx);
-
        /* FIXME: Why do we do this at this specific, seemingly random, point? */
        sgen_client_collecting_minor (&fin_ready_queue, &critical_fin_queue);
 
@@ -1974,6 +1972,7 @@ major_finish_collection (const char *reason, size_t old_next_pin_slot, gboolean
        time_major_fragment_creation += TV_ELAPSED (atv, btv);
 
        binary_protocol_sweep_begin (GENERATION_OLD, !major_collector.sweeps_lazily);
+       sgen_memgov_major_pre_sweep ();
 
        TV_GETTIME (atv);
        time_major_free_bigobjs += TV_ELAPSED (btv, atv);
@@ -2154,12 +2153,12 @@ major_finish_concurrent_collection (gboolean forced)
  * LOCKING: The GC lock MUST be held.
  */
 void
-sgen_ensure_free_space (size_t size)
+sgen_ensure_free_space (size_t size, int generation)
 {
        int generation_to_collect = -1;
        const char *reason = NULL;
 
-       if (size > SGEN_MAX_SMALL_OBJ_SIZE) {
+       if (generation == GENERATION_OLD) {
                if (sgen_need_major_collection (size)) {
                        reason = "LOS overflow";
                        generation_to_collect = GENERATION_OLD;
index afd5ba5dce858c2721c9a7e53d6113d2205b9c83..4b2f895d890badc5f42157ebe4009f57211ad1b4 100644 (file)
@@ -802,7 +802,7 @@ enum {
 void sgen_pin_object (GCObject *object, SgenGrayQueue *queue);
 void sgen_set_pinned_from_failed_allocation (mword objsize);
 
-void sgen_ensure_free_space (size_t size);
+void sgen_ensure_free_space (size_t size, int generation);
 void sgen_gc_collect (int generation);
 void sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish);
 
index 8cc92e34553f5008105bcc16fdc80232c1cb595c..a89ec99fe353517580f0695f6d45e68859a18101 100644 (file)
@@ -380,7 +380,7 @@ sgen_los_alloc_large_inner (GCVTable vtable, size_t size)
        los_segment_index += size + sizeof (LOSObject);
        g_assert (los_segment_index <= LOS_SEGMENT_SIZE);
 #else
-       sgen_ensure_free_space (size);
+       sgen_ensure_free_space (size, GENERATION_OLD);
 
 #ifdef USE_MALLOC
        obj = malloc (size + sizeof (LOSObject));
index 929d86031fee406233d691cde0c4933781f1e9ad..7aaaa0221e1d900931d9f052314379a3a00271e5 100644 (file)
@@ -1401,8 +1401,8 @@ bitcount (mword d)
        int count = 0;
 
 #ifdef __GNUC__
-       if (sizeof (mword) == sizeof (unsigned long))
-               count += __builtin_popcountl (d);
+       if (sizeof (mword) == 8)
+               count += __builtin_popcountll (d);
        else
                count += __builtin_popcount (d);
 #else
index ce34f7f4a67a7d304ff038e674c01aa38651e0c5..611ae5c118f4d66b7e1eb982fd4d32048e78a20b 100644 (file)
@@ -56,6 +56,9 @@ static gboolean debug_print_allowance = FALSE;
 /* use this to tune when to do a major/minor collection */
 static mword major_collection_trigger_size;
 
+static mword major_pre_sweep_heap_size;
+static mword major_start_heap_size;
+
 static mword last_major_num_sections = 0;
 static mword last_los_memory_usage = 0;
 
@@ -73,6 +76,7 @@ static void
 sgen_memgov_calculate_minor_collection_allowance (void)
 {
        size_t new_major, new_heap_size, allowance_target, allowance;
+       size_t decrease;
 
        if (!need_calculate_minor_collection_allowance)
                return;
@@ -90,6 +94,16 @@ sgen_memgov_calculate_minor_collection_allowance (void)
 
        allowance = MAX (allowance_target, MIN_MINOR_COLLECTION_ALLOWANCE);
 
+       /*
+        * For the concurrent collector, we decrease the allowance relative to the memory
+        * growth during the M&S phase, survival rate of the collection and the allowance
+        * ratio.
+        */
+       decrease = (major_pre_sweep_heap_size - major_start_heap_size) * ((float)new_heap_size / major_pre_sweep_heap_size) * (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO + 1);
+       if (decrease > allowance)
+               decrease = allowance;
+       allowance -= decrease;
+
        if (new_heap_size + allowance > soft_heap_limit) {
                if (new_heap_size > soft_heap_limit)
                        allowance = MIN_MINOR_COLLECTION_ALLOWANCE;
@@ -129,13 +143,14 @@ sgen_need_major_collection (mword space_needed)
                if (heap_size <= major_collection_trigger_size)
                        return FALSE; 
 
-               /* We allow the heap to grow an additional third of the allowance during a concurrent collection */
-               if ((heap_size - major_collection_trigger_size) >
-                               (major_collection_trigger_size
-                               * (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO / (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO + 1))
-                               * SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO)) {
+               /*
+                * The more the heap grows, the more we need to decrease the allowance above,
+                * in order to have similar trigger sizes as the synchronous collector.
+                * If the heap grows so much that we would need to have a negative allowance,
+                * we force the finishing of the collection, to avoid increased memory usage.
+                */
+               if ((heap_size - major_start_heap_size) > major_start_heap_size * SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO)
                        return TRUE;
-               }
                return FALSE;
        }
 
@@ -163,13 +178,25 @@ sgen_memgov_minor_collection_end (void)
 {
 }
 
+void
+sgen_memgov_major_pre_sweep (void)
+{
+       if (sgen_concurrent_collection_in_progress ()) {
+               major_pre_sweep_heap_size = get_heap_size ();
+       } else {
+               /* We decrease the allowance only in the concurrent case */
+               major_pre_sweep_heap_size = major_start_heap_size;
+       }
+}
+
 void
 sgen_memgov_major_collection_start (void)
 {
        need_calculate_minor_collection_allowance = TRUE;
+       major_start_heap_size = get_heap_size ();
 
        if (debug_print_allowance) {
-               SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)get_heap_size ());
+               SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)major_start_heap_size);
        }
 }
 
index 0115ec6e0605e2755c4b28dc8c020b89f8ea9466..669b59734e99200ffadae2dc540a7b8137f6349c 100644 (file)
@@ -33,6 +33,7 @@ gboolean sgen_memgov_try_alloc_space (mword size, int space);
 void sgen_memgov_minor_collection_start (void);
 void sgen_memgov_minor_collection_end (void);
 
+void sgen_memgov_major_pre_sweep (void);
 void sgen_memgov_major_collection_start (void);
 void sgen_memgov_major_collection_end (gboolean forced);
 
index cb2fc0983757332593bf06f99e62f07cbdb0ed50..97279d2fb6ddbd9e2dabf09dbb61ee5af68a174e 100644 (file)
@@ -339,6 +339,16 @@ public class Tests : LoadMissing {
                return 2;
        }
 
+       public static int test_0_reflection_on_field_with_missing_custom_attr () {
+               var t = typeof (BadOverridesDriver).Assembly.GetType ("FieldWithMissingCustomAttribute");
+               try {
+                       Console.WriteLine (t.GetFields ()[0].CustomAttributes);
+                       return 1;
+               } catch (FileNotFoundException) {
+                       return 0;
+               }
+               return 2;
+       }
 
        public static int Main () {
                return TestDriver.RunTests (typeof (Tests));
index 3f2da10c57a8f6d507acc718faf8cfb4cb179605..1ae933d277bc598f764b08c4a6f4cf3796d09daf 100644 (file)
 {\r
   .ver 0:0:0:0\r
 }\r
+.assembly extern notFoundAssembly\r
+{\r
+  .ver 0:0:0:0\r
+}\r
 \r
 .assembly 'load-missing'\r
 {\r
        .field  public class [t]Missing BrokenField\r
     .field  public static int32 WorkingField\r
 }\r
+\r
+.class public auto ansi beforefieldinit FieldWithMissingCustomAttribute\r
+{\r
+    .field     public object f\r
+    .custom    instance void class [notFoundAssembly]SomeAttribute::'.ctor'() = (01 00 00 00 ) // ....\r
+}\r
index 43a9f7184d569925fe0296c3bdb1b81ad2ffddd2..e92d3720656aedef8edd71c808d08874b841e643 100644 (file)
@@ -471,6 +471,7 @@ mono_install_assembly_preload_hook
 mono_install_assembly_refonly_preload_hook
 mono_install_assembly_refonly_search_hook
 mono_install_assembly_search_hook
+mono_install_load_aot_data_hook
 mono_install_runtime_cleanup
 mono_install_unhandled_exception_hook
 mono_is_debugger_attached
@@ -834,8 +835,12 @@ mono_thread_new_init
 mono_thread_set_main
 mono_thread_set_manage_callback
 mono_thread_stop
+mono_threads_assert_gc_safe_region
+mono_threads_assert_gc_unsafe_region
 mono_threads_attach_tools_thread
+mono_threads_enter_gc_safe_region
 mono_threads_enter_gc_unsafe_region
+mono_threads_exit_gc_safe_region
 mono_threads_exit_gc_unsafe_region
 mono_threads_get_default_stacksize
 mono_threads_request_thread_dump
index 7c0bd3ae53048befd062f00568109975274ed488..dc32801d088054e5a333d5ebdaaf7fdbbfb700c8 100644 (file)
@@ -473,6 +473,7 @@ mono_install_assembly_preload_hook
 mono_install_assembly_refonly_preload_hook
 mono_install_assembly_refonly_search_hook
 mono_install_assembly_search_hook
+mono_install_load_aot_data_hook
 mono_install_runtime_cleanup
 mono_install_unhandled_exception_hook
 mono_is_debugger_attached
@@ -836,8 +837,12 @@ mono_thread_new_init
 mono_thread_set_main
 mono_thread_set_manage_callback
 mono_thread_stop
+mono_threads_assert_gc_safe_region
+mono_threads_assert_gc_unsafe_region
 mono_threads_attach_tools_thread
+mono_threads_enter_gc_safe_region
 mono_threads_enter_gc_unsafe_region
+mono_threads_exit_gc_safe_region
 mono_threads_exit_gc_unsafe_region
 mono_threads_get_default_stacksize
 mono_threads_request_thread_dump
index 644491b94d5a399d0bcc48f8ff18a2c9ab083638..09d652d968f1cde4b036a93ff6b3819416a775b4 100644 (file)
     </project>
     <project dir="class/corlib" library="corlib-tests-net_4_x">
       <boot>false</boot>
-      <flags>/codepage:65001 -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -debug -optimize -r:./../../class/lib/net_4_x/mscorlib.dll -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -debug -nowarn:168,219,618,672 -unsafe -r:Mono.Posix.dll -r:System.Core.dll -define:MONO_DATACONVERTER_STATIC_METHODS -resource:Test/resources/Resources.resources</flags>
+      <flags>/codepage:65001 -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -debug -optimize -r:./../../class/lib/net_4_x/mscorlib.dll -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -debug -nowarn:168,219,618,672 -unsafe -r:Mono.Posix.dll -r:System.Core.dll -r:System.dll -define:MONO_DATACONVERTER_STATIC_METHODS -resource:Test/resources/Resources.resources</flags>
       <output>net_4_x_corlib_test.dll</output>
       <built_sources></built_sources>
       <library_output>net_4_x_corlib_test.dll</library_output>
     </project>
     <project dir="class/System.Web.Extensions" library="System.Web.Extensions-tests-net_4_x">
       <boot>false</boot>
-      <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -r:mscorlib.dll -debug -optimize -r:./../../class/lib/net_4_x/System.Web.Extensions.dll -unsafe -define:NET_3_5 -define:SYSTEM_WEB_EXTENSIONS -r:mscorlib.dll -r:System.Web.ApplicationServices.dll /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.js -r:System -r:System.Core -r:System.Drawing -r:System.Data -r:System.Data.Linq -r:System.Xml -r:System.Web -r:System.Web.Services -r:System.Configuration -r:System.EnterpriseServices -r:System.ServiceModel -doc:net_4_x_System.Web.Extensions_test.xml -nowarn:219,169,1591 /resource:Test/resources/Web.mono.config /resource:Test/resources/profile.config.4.x /resource:Test/resources/ListViewSort.aspx /resource:Test/resources/ListViewTest.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_1.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_2.aspx /resource:Test/resources/ListViewTotalRowCount_Bug604053.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx.cs /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.master /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master -r:SystemWebTestShim.dll -define:SYSTEM_WEB_EXTENSIONS</flags>
+      <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -r:mscorlib.dll -debug -optimize -r:./../../class/lib/net_4_x/System.Web.Extensions.dll -unsafe -define:NET_3_5 -define:SYSTEM_WEB_EXTENSIONS -r:mscorlib.dll -r:System.Web.ApplicationServices.dll /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.js -r:System -r:System.Core -r:System.Drawing -r:System.Data -r:System.Data.Linq -r:System.Xml -r:System.Web -r:System.Web.Services -r:System.Configuration -r:System.EnterpriseServices -r:System.ServiceModel -doc:net_4_x_System.Web.Extensions_test.xml -nowarn:219,169,1591 /resource:Test/resources/Web.mono.config /resource:Test/resources/profile.config.4.x /resource:Test/resources/ListViewSort.aspx /resource:Test/resources/ListViewTest.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_1.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_2.aspx /resource:Test/resources/ListViewTotalRowCount_Bug604053.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx.cs /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.master -r:SystemWebTestShim.dll -define:SYSTEM_WEB_EXTENSIONS</flags>
       <output>net_4_x_System.Web.Extensions_test.dll</output>
       <built_sources></built_sources>
       <library_output>net_4_x_System.Web.Extensions_test.dll</library_output>