Fix warnings in mscorlib's Test suite + bring a couple more tests + fix thread rename...
authorMiguel de Icaza <miguel@gnome.org>
Tue, 23 Sep 2014 14:55:57 +0000 (10:55 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 23 Sep 2014 14:56:04 +0000 (10:56 -0400)
23 files changed:
mcs/class/corlib/Test/System.Reflection.Emit/DynamicMethodTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/GenericTypeParameterBuilderTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs
mcs/class/corlib/Test/System.Reflection/AssemblyNameCas.cs
mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
mcs/class/corlib/Test/System.Reflection/MonoGenericClassTest.cs
mcs/class/corlib/Test/System.Reflection/ReflectedTypeTest.cs
mcs/class/corlib/Test/System.Runtime.CompilerServices/ConditionalWeakTableTest.cs
mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs
mcs/class/corlib/Test/System.Runtime.CompilerServices/TaskAwaiterTest.cs
mcs/class/corlib/Test/System.Runtime.InteropServices/GCHandleTest.cs
mcs/class/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs
mcs/class/corlib/Test/System.Runtime.Serialization/SerializationTest.cs
mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs
mcs/class/corlib/Test/System.Security.Cryptography/HMACSHA384Test.cs
mcs/class/corlib/Test/System.Security.Cryptography/HMACSHA512Test.cs
mcs/class/corlib/Test/System.Security.Permissions/RegistryPermissionTest.cs
mcs/class/corlib/Test/System.Security.Permissions/UrlIdentityPermissionTest.cs
mcs/class/corlib/Test/System.Threading/ThreadTest.cs
mcs/class/corlib/Test/System/AppDomainTest.cs
mcs/class/corlib/Test/System/SByteTest.cs
mcs/class/corlib/Test/System/TypeTest.cs

index 271412269c01f5f2f8b590d5473cda7616677df3..f65ac28ef5ed8bed9c4d2c680c158dc52b6286d5 100644 (file)
@@ -317,10 +317,12 @@ namespace MonoTests.System.Reflection.Emit
                        m1.Invoke(null, new object[] { 5 });
                }
 
+               // Disabl known warning, the Field is never used directly from C#
+               #pragma warning disable 414
                class Host {
                        static string Field = "foo";
                }
-
+               #pragma warning restore 414
                [Test]
                [Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=297416
                public void TestOwnerMemberAccess ()
index 1559d66369a80322b317137719fb8930f7fe3dcb..7f9db3b99fd0e53290e51e533cda40e407d2e53d 100644 (file)
@@ -27,7 +27,6 @@ namespace MonoTests.System.Reflection.Emit
        {
                AssemblyBuilder assembly;
                ModuleBuilder module;
-               int typeCount;
                static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
 
                [SetUp]
@@ -46,7 +45,6 @@ namespace MonoTests.System.Reflection.Emit
                                        assemblyName, mode, Path.GetTempPath ());
 
                        module = assembly.DefineDynamicModule ("module1");
-                       typeCount = 0;
                }
 
                [Test]
index 382f3f255279b48e53d7e85bf3b9d869cbf2488c..b1b7cf320f3f5346dd7e01ef4551018929f2d874 100644 (file)
@@ -92,8 +92,8 @@ namespace MonoTests.System.Reflection.Emit
                }
 
                public class Tuple <A,B> {
-                       A a;
-                       B b;
+                       public A a;
+                       public B b;
                }
 
                private AssemblyBuilder assembly;
index a24a4868d9b60c75ebab37907145a6cb37681719..087297b6f24006566fe9f1838c48c35a1a206b09 100644 (file)
@@ -42,7 +42,6 @@ namespace MonoCasTests.System.Reflection {
        public class AssemblyNameCas {
 
                private MonoTests.System.Reflection.AssemblyNameTest ant;
-               private AssemblyName main;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
index ccd923fa59c7517cbb2a74f803e8d769d37d02a3..a3639864f6a48730c1e7ac06d913f4c3aa44ceb3 100644 (file)
@@ -73,6 +73,8 @@ namespace MonoTests.System.Reflection
        {
        }
 
+       // Disable this warning, as the purpose of this struct is to poke at the internal via reflection
+       #pragma warning disable 649
        class FieldInvokeMatrix
        {
                public Byte field_Byte;
@@ -102,6 +104,7 @@ namespace MonoTests.System.Reflection
                public Int64Enum field_Int64Enum;
                public UInt64Enum field_UInt64Enum;
        }
+       #pragma warning restore 649
 
        public enum ByteEnum : byte
        {
@@ -376,10 +379,13 @@ namespace MonoTests.System.Reflection
                        Assert.AreEqual (typeof (Marshal1), Type.GetType (attr.MarshalType), "#I4");
                }
 
+               // Disable "field not used warning", this is intended.
+#pragma warning disable 649
                class Foo {
                        public static int static_field;
                        public int field;
                }
+#pragma warning restore 649
 
                [ExpectedException (typeof (ArgumentException))]
                public void GetValueWrongObject ()
@@ -1359,16 +1365,24 @@ namespace MonoTests.System.Reflection
 
        }
 
+       // We do not refernece the field, that is expected
+#pragma warning disable 169
        // Helper classes
        class RefOnlyFieldClass 
        {
                // Helper property
                static int RefOnlyField;
        }
-
+#pragma warning restore 169
+       
        class NonPublicFieldClass
        {
                protected int protectedField;
+
+               public void Dummy ()
+               {
+                       protectedField = 1;
+               }
        }
 
        public class FieldInfoTest<T>
index 65adf97aa51cb3fae0efc2b5d6374e45d5ebb2f2..00349880e1f1be6cbd4ca6336955cbb72830ad29 100644 (file)
@@ -42,9 +42,12 @@ using System.Collections.Generic;
 #endif
 
 namespace A.B.C {
+       // Disable expected warning
+#pragma warning disable 169
        public struct MethodInfoTestStruct {
                int p;
        }
+#pragma warning restore 169
 }
 namespace MonoTests.System.Reflection
 {
@@ -253,7 +256,7 @@ namespace MonoTests.System.Reflection
 
                public struct SimpleStruct
                {
-                       int a;
+                       public int a;
                }
 
                public static unsafe SimpleStruct* PtrFunc2 (SimpleStruct* a, A.B.C.MethodInfoTestStruct *b)
index 0b02596ec5bb273f7addb5fff8012667a47aa7f9..e47b5e1eb79fea692a19b050dcaa816515ee628e 100644 (file)
@@ -178,7 +178,7 @@ namespace MonoTests.System.Reflection.Emit
                }
 
                public class Bar<T> {
-                       public class Foo<T> {}
+                       public class Foo<U> {}
                }
 
                [Test]
index bcc814e04d36734425e9969e7c975daff96b8964..8347b4dabf7bd17ea22966512997afef6bae431f 100644 (file)
@@ -29,6 +29,8 @@ using System;
 using System.Reflection;
 using NUnit.Framework;
 
+// Various fields in this class are not used directly by the C# code, they are only here to be reflected upon
+#pragma warning disable 649
 namespace MonoTests.System.Reflection
 {
        [TestFixture]
index 92d19fe367eddda5638228faa7783c32bd345114..f6f4dabe2bad2eeee6dce0eeb2164a51b6645304 100644 (file)
@@ -402,9 +402,12 @@ namespace MonoTests.System.Runtime.CompilerServices {
        static int reachable = 0;
  
        public class FinalizableLink {
+               // The sole purpose of this object is to keep a reference to another object, so it is fine to not use it.
+               #pragma warning disable 414
                object obj;
-               ConditionalWeakTable <object,object> cwt;
                int id;
+               #pragma warning restore 414
+               ConditionalWeakTable <object,object> cwt;
 
                public FinalizableLink (int id, object obj, ConditionalWeakTable <object,object> cwt) {
                        this.id = id;
index fc4010bd21cd22d3394c54eb71047e449fbe6a21..593305d4a67543f5f2d341765e1a4dfd9a385e5f 100644 (file)
@@ -94,8 +94,10 @@ namespace MonoTests.System.Runtime.CompilerServices {
                        RuntimeHelpers.RunClassConstructor (rth);
                }
 
+               // Expected the handle here is that way, because we are going to test for an ArgumentException being thrown
+#pragma warning disable 649
                static RuntimeTypeHandle handle;
-
+#pragma warning restore 649
                [Test]
                [ExpectedException (typeof (ArgumentException))]
                public void RunClassConstructor_Uninitialized ()
@@ -122,7 +124,11 @@ namespace MonoTests.System.Runtime.CompilerServices {
                }
 
                static RuntimeFieldHandle rfh = typeof (Fielder).GetField ("array").FieldHandle;
+
+               // Disable expected warning: the point of the test is to validate that an exception is thrown for something with a null (the default value in this case)
+               #pragma warning disable  649
                static RuntimeFieldHandle static_rfh;
+               #pragma warning restore 649
 
                [Test]
                [ExpectedException (typeof (ArgumentNullException))]
index 5237e377e38c80d9a73ce149db5dde8934bdc428..1bc9d38414758f89d626e21e369236701da04839 100644 (file)
@@ -72,6 +72,11 @@ namespace MonoTests.System.Runtime.CompilerServices
                                Interlocked.Increment (ref ic);
                                return false;
                        }
+
+                       public override string ToString ()
+                       {
+                               return "Scheduler-" + name;
+                       }
                }
 
                class SingleThreadSynchronizationContext : SynchronizationContext
index 1ac8a825b641fc5c77b46dae882d53c56c9b8baf..17fe0d9045df543807ec622c71fa8e48c1032cab 100644 (file)
@@ -18,8 +18,11 @@ namespace MonoTests.System.Runtime.InteropServices
        [TestFixture]
        public class GCHandleTest
        {
+               // Expected warning, the tests that reference this handle are testing for the default values of the object
+               #pragma warning disable 649
                static GCHandle handle;
-
+               #pragma warning restore 649
+               
                [Test]
                public void DefaultZeroValue_Allocated ()
                {
index d6f2a49bf38d774f3ee0f8be8c7a3f1f2f37c685..28943159aa10520ef866a4c9b5d8c60355adfe6b 100644 (file)
@@ -28,7 +28,7 @@ namespace MonoTests.System.Runtime.InteropServices
                        public int field;
                }
 
-               class ClsNoLayout {
+               public class ClsNoLayout {
                        public int field;
                }
 
@@ -173,12 +173,12 @@ namespace MonoTests.System.Runtime.InteropServices
                        Marshal.FreeHGlobal (ptr);
                }
 
-               struct Foo {
-                       int a;
-                       static int b;
-                       long c;
-                       static char d;
-                       int e;
+               public struct Foo {
+                       public int a;
+                       public static int b;
+                       public long c;
+                       public static char d;
+                       public int e;
                }
 
                [Test]
index 90b2d3f73fc386c099bbace95e4a1f82707e1ba2..48e686ab8ddf840fa0d270485df8d622ae447611 100644 (file)
@@ -637,6 +637,8 @@ namespace MonoTests.System.Runtime.Serialization
                        Assert.AreEqual (_char, obj._char, context + "._char");
                        Assert.AreEqual (_dateTime, obj._dateTime, context + "._dateTime");
                        Assert.AreEqual (_decimal, obj._decimal, context + "._decimal");
+                       Assert.AreEqual (_double, obj._double, context + "._double");
+                       Assert.AreEqual (_short, obj._short, context = "._short");
                        Assert.AreEqual (_int, obj._int, context + "._int");
                        Assert.AreEqual (_long, obj._long, context + "._long");
                        Assert.AreEqual (_sbyte, obj._sbyte, context + "._sbyte");
index 10328b8e60fa59ba34c76298cae2bbb000b0e58c..3ad6cce71f9c43393cee9af143f6f4349c908ea8 100644 (file)
@@ -144,7 +144,6 @@ namespace MonoTests.System.Security.Cryptography {
                Stream readStream;
                Stream writeStream;
                ICryptoTransform encryptor;
-               ICryptoTransform decryptor;
                CryptoStream cs;
                SymmetricAlgorithm aes;
 
@@ -156,7 +155,6 @@ namespace MonoTests.System.Security.Cryptography {
                                writeStream = new MemoryStream (new byte [0], true);
                                aes = SymmetricAlgorithm.Create ();
                                encryptor = aes.CreateEncryptor ();
-                               decryptor = aes.CreateEncryptor ();
                        }
                }
 
index 115bdf30cc40f2f400002f373e0ed99bb91a980d..e243712d80c065bda63dfbbe7b175d6305c41a24 100644 (file)
@@ -28,6 +28,9 @@ namespace MonoTests.System.Security.Cryptography {
 
        public class SelectableHmacSha384: HMAC {
 
+               // legacy parameter:
+               //      http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
+               
                public SelectableHmacSha384 (byte[] key, bool legacy)
                {
                        HashName = "SHA384";
@@ -45,7 +48,6 @@ namespace MonoTests.System.Security.Cryptography {
        public class HMACSHA384Test : KeyedHashAlgorithmTest {
 
                protected HMACSHA384 algo;
-               private bool legacy;
 
                [SetUp]
                public override void SetUp () 
@@ -53,8 +55,6 @@ namespace MonoTests.System.Security.Cryptography {
                        algo = new HMACSHA384 ();
                        algo.Key = new byte [8];
                        hash = algo;
-                       // http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
-                       legacy = (new HS384 ().BlockSize == 64);
                }
 
                // the hash algorithm only exists as a managed implementation
index 04497415d0e9cbe428e2d7061e39ed414733027a..55a7b87589c0a0ac859ef512bd4c46ea4a66fac6 100644 (file)
@@ -26,6 +26,9 @@ namespace MonoTests.System.Security.Cryptography {
 
        public class SelectableHmacSha512: HMAC {
 
+               // Legacy parameter explanation:
+               // http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
+
                public SelectableHmacSha512 (byte[] key, bool legacy)
                {
                        HashName = "SHA512";
@@ -43,7 +46,6 @@ namespace MonoTests.System.Security.Cryptography {
        public class HMACSHA512Test : KeyedHashAlgorithmTest {
 
                protected HMACSHA512 algo;
-               private bool legacy;
 
                [SetUp]
                public override void SetUp () 
@@ -51,8 +53,6 @@ namespace MonoTests.System.Security.Cryptography {
                        algo = new HMACSHA512 ();
                        algo.Key = new byte [8];
                        hash = algo;
-                       // http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
-                       legacy = (new HS512 ().BlockSize == 64);
                }
 
                // the hash algorithm only exists as a managed implementation
index fb3770db4b43d8ae4fbb04ce133a1a0ae533883f..f95691c7f54e4ae5cacd5486e62afc0f27d5cf6b 100644 (file)
@@ -38,7 +38,6 @@ namespace MonoTests.System.Security.Permissions {
 
                private static string className = "System.Security.Permissions.RegistryPermission, ";
                private static string keyCurrentUser = @"HKEY_CURRENT_USER\Software\Novell iFolder\spouliot\Home";
-               private static string keyCurrentUserSubset = @"HKEY_CURRENT_USER\Software\Novell iFolder\";
                private static string keyLocalMachine = @"HKEY_LOCAL_MACHINE\SOFTWARE\Novell\Novell iFolder\1.00.000";
                private static string keyLocalMachineSubset = @"HKEY_LOCAL_MACHINE\SOFTWARE\Novell\";
 
index 62a0c35e1cd5b78cbe3ead43b38cea1fda50e4fd..f9a7d8ae21aa412702fbb824e87b4ce39bc3a17d 100644 (file)
@@ -51,12 +51,6 @@ namespace MonoTests.System.Security.Permissions {
                        "*",
                };
 
-               // accepted as Url but fails to work (as expected) in some methods
-               static string[] SemiBadUrls = {
-                       "www.mono-project.com:80",
-                       String.Empty,
-               };
-
                [Test]
                public void PermissionState_None ()
                {
index 11e611563c8e791f86d121cb8da5eb540b0dd43e..9fa19ee406018fef6b7edb726a5ef9b62af37964 100644 (file)
@@ -85,10 +85,10 @@ namespace MonoTests.System.Threading
        [Category("MobileNotWorking")] // Abort #10240
        public class ThreadTest
        {
-               TimeSpan Infinite = new TimeSpan (-10000);      // -10000 ticks == -1 ms
+               //TimeSpan Infinite = new TimeSpan (-10000);    // -10000 ticks == -1 ms
                TimeSpan SmallNegative = new TimeSpan (-2);     // between 0 and -1.0 (infinite) ms
                TimeSpan Negative = new TimeSpan (-20000);      // really negative
-               TimeSpan MaxValue = TimeSpan.FromMilliseconds ((long) Int32.MaxValue);
+               //TimeSpan MaxValue = TimeSpan.FromMilliseconds ((long) Int32.MaxValue);
                TimeSpan TooLarge = TimeSpan.FromMilliseconds ((long) Int32.MaxValue + 1);
 
                static bool is_win32;
@@ -545,14 +545,16 @@ namespace MonoTests.System.Threading
                                if (!rename_finished)
                                        Monitor.Wait (monitor);
                        }
-                       Assert.IsFalse (rename_failed);
+                       Assert.IsTrue (rename_failed);
                }
 
                void Rename_callback (object o) {
                        Thread.CurrentThread.Name = "a";
                        try {
                                Thread.CurrentThread.Name = "b";
-                       } catch (Exception) {
+                               Console.WriteLine ("Thread name is: {0}", Thread.CurrentThread.Name);
+                       } catch (Exception e) {
+                               Console.Error.WriteLine (e);
                                rename_failed = true;
                        }
                        object monitor = o;
@@ -1254,8 +1256,6 @@ namespace MonoTests.System.Threading
                        Assert.AreEqual (this, arg, "obj");     
                }               
 
-               bool set_name_failed;
-
                [Test]
                public void SetNameTpThread () {
                        ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));
index 8772d7afdea04e8771c54266715144cacfffa015..0836640057e3cfabdb47c8cc3ab4990f87869cad 100644 (file)
@@ -3240,6 +3240,7 @@ namespace MonoTests.System
                }
 #endif
 
+
                public class StuffToPick
                {
                        public StuffToPick () {}
@@ -3248,6 +3249,11 @@ namespace MonoTests.System
                        public event Action Event;
                        public int Field;
                        public void GenericMethod<T> () {}
+
+                       public void Dummy ()
+                       {
+                               Event += delegate {};
+                       }
                }
 
                public class StuffToPick<T>
@@ -3257,7 +3263,12 @@ namespace MonoTests.System
                        public int Property { get; set; }
                        public event Action Event;
                        public int Field;
-                       public void GenericMethod<T> () {}
+                       public void GenericMethod<U> () {}
+
+                       public void Dummy ()
+                       {
+                               Event += delegate {};
+                       }
                }
 
                static void TestSerialization (CrossDomainTester tester, object o)
index 9bf4d31a1cdffbcad8fd171426f40cff6c1971ce..c8d40396c299129c83d1754b1d718887b23b3b5c 100644 (file)
@@ -24,12 +24,15 @@ public class SByteTest
        private const string MyString3 = "127";
        private string[] Formats1 = {"c", "d", "e", "f", "g", "n", "p", "x" };
        private string[] Formats2 = {"c5", "d5", "e5", "f5", "g5", "n5", "p5", "x5" };
+#if false
+       // These are not currently being tested against, due to the locale-specific nature of the test, we need a different way of doing this
        private string[] Results1 = {"("+NumberFormatInfo.CurrentInfo.CurrencySymbol+"128.00)",
                                        "-128", "-1.280000e+002", "-128.00",
                                        "-128", "-128.00", "-12,800.00 %", "80"};
        private string[] Results2 = {NumberFormatInfo.CurrentInfo.CurrencySymbol+"127.00000",
                                        "00127", "1.27000e+002", "127.00000",
                                        "127", "127.00000", "12,700.00000 %", "0007f"};
+#endif
        private string[] ResultsNfi1 = {"("+NumberFormatInfo.InvariantInfo.CurrencySymbol+"128.00)", 
                                        "-128", "-1.280000e+002", "-128.00",
                                        "-128", "-128.00", "-12,800.00 %", "80"};
@@ -161,14 +164,17 @@ public class SByteTest
                Assert.IsTrue(String.Compare(MyString2, MySByte2.ToString()) == 0, "MyString2, MySByte2.ToString()");
                Assert.IsTrue(String.Compare(MyString3, MySByte3.ToString()) == 0, "MyString3, MySByte3.ToString()");
                //test ToString(string format)
+
+#if false
                /*
-               TODO: These tests depend on the culture of the system running the test.
-                       So, this needs to be tested in a different way.
+                * TODO: These tests depend on the culture of the system running the test.
+                * So, this needs to be tested in a different way.
+                /
                for (int i=0; i < Formats1.Length; i++) {
                        Assert.IsTrue("i="+i+", Results1[i]="+Results1[i]+", MySByte2.ToString(Formats1[i])="+MySByte2.ToString(Formats1[i]), String.Compare(Results1[i], MySByte2.ToString(Formats1[i])) == 0);
                        Assert.IsTrue(String.Compare(Results2[i], MySByte3.ToString(Formats2[i])) == 0, "Results2[i], MySByte3.ToString(Formats2[i])");
                }
-               */
+#endif
                //test ToString(string format, IFormatProvider provider);
                for (int i=0; i < Formats1.Length; i++) {
                        Assert.IsTrue(String.Compare(ResultsNfi1[i], MySByte2.ToString(Formats1[i], Nfi)) == 0, "i="+i+", ResultsNfi1[i]="+ResultsNfi1[i]+", MySByte2.ToString(Formats1[i]="+Formats1[i]+"): Expected "+ResultsNfi1[i]+" but got "+MySByte2.ToString(Formats1[i], Nfi));
index 00131c8d47f1d59ef4266e335ec71b293424a720..6acbac2dd9f4343e294871c32192c68a76bef31b 100644 (file)
@@ -143,6 +143,10 @@ namespace MonoTests.System
                }
 
                public event EventHandler E;
+               public void Dummy ()
+               {
+                       E += delegate {};
+               }
        }
 
        class Derived1 : Base1
@@ -159,7 +163,11 @@ namespace MonoTests.System
                        set { }
                }
 
-               public event Action E;
+               public new event Action E;
+               public new void Dummy ()
+               {
+                       E += delegate {};
+               }
        }
 
        public class Foo<T>
@@ -1860,7 +1868,9 @@ PublicKeyToken=b77a5c561934e089"));
 
                struct B
                {
+                       #pragma warning disable 169
                        int value;
+                       #pragma warning restore 169
                }
 
                [Test]
@@ -2153,7 +2163,7 @@ PublicKeyToken=b77a5c561934e089"));
                        a1 = new string [10];
                }
 
-               class X
+               public class X
                {
                        public static int Value;
                }