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 ()
{
AssemblyBuilder assembly;
ModuleBuilder module;
- int typeCount;
static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
[SetUp]
assemblyName, mode, Path.GetTempPath ());
module = assembly.DefineDynamicModule ("module1");
- typeCount = 0;
}
[Test]
}
public class Tuple <A,B> {
- A a;
- B b;
+ public A a;
+ public B b;
}
private AssemblyBuilder assembly;
public class AssemblyNameCas {
private MonoTests.System.Reflection.AssemblyNameTest ant;
- private AssemblyName main;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
}
+ // 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;
public Int64Enum field_Int64Enum;
public UInt64Enum field_UInt64Enum;
}
+ #pragma warning restore 649
public enum ByteEnum : byte
{
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 ()
}
+ // 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>
#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
{
public struct SimpleStruct
{
- int a;
+ public int a;
}
public static unsafe SimpleStruct* PtrFunc2 (SimpleStruct* a, A.B.C.MethodInfoTestStruct *b)
}
public class Bar<T> {
- public class Foo<T> {}
+ public class Foo<U> {}
}
[Test]
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]
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;
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 ()
}
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))]
Interlocked.Increment (ref ic);
return false;
}
+
+ public override string ToString ()
+ {
+ return "Scheduler-" + name;
+ }
}
class SingleThreadSynchronizationContext : SynchronizationContext
[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 ()
{
public int field;
}
- class ClsNoLayout {
+ public class ClsNoLayout {
public int field;
}
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]
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");
Stream readStream;
Stream writeStream;
ICryptoTransform encryptor;
- ICryptoTransform decryptor;
CryptoStream cs;
SymmetricAlgorithm aes;
writeStream = new MemoryStream (new byte [0], true);
aes = SymmetricAlgorithm.Create ();
encryptor = aes.CreateEncryptor ();
- decryptor = aes.CreateEncryptor ();
}
}
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";
public class HMACSHA384Test : KeyedHashAlgorithmTest {
protected HMACSHA384 algo;
- private bool legacy;
[SetUp]
public override void SetUp ()
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
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";
public class HMACSHA512Test : KeyedHashAlgorithmTest {
protected HMACSHA512 algo;
- private bool legacy;
[SetUp]
public override void SetUp ()
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
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\";
"*",
};
- // 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 ()
{
[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;
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;
Assert.AreEqual (this, arg, "obj");
}
- bool set_name_failed;
-
[Test]
public void SetNameTpThread () {
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));
}
#endif
+
public class StuffToPick
{
public StuffToPick () {}
public event Action Event;
public int Field;
public void GenericMethod<T> () {}
+
+ public void Dummy ()
+ {
+ Event += delegate {};
+ }
}
public class StuffToPick<T>
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)
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"};
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));
}
public event EventHandler E;
+ public void Dummy ()
+ {
+ E += delegate {};
+ }
}
class Derived1 : Base1
set { }
}
- public event Action E;
+ public new event Action E;
+ public new void Dummy ()
+ {
+ E += delegate {};
+ }
}
public class Foo<T>
struct B
{
+ #pragma warning disable 169
int value;
+ #pragma warning restore 169
}
[Test]
a1 = new string [10];
}
- class X
+ public class X
{
public static int Value;
}