Suppressed unused field warnings. The code is like that on purpose.

This commit is contained in:
the_fiddler 2010-10-22 15:03:35 +00:00
parent 5ed98455d9
commit f0dd1370d8

View file

@ -1,44 +1,46 @@
// This code is in the Public Domain. It is provided "as is"
// without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Reflection;
using OpenTK;
namespace Examples.Tests
{
struct Simple { public int Value; }
struct Generic<T> { public T Value; }
enum Enum { First, Second }
struct Complex { public Simple Value; }
struct Complex<T> { public Generic<T> Value; }
struct Complex2 { public Enum Value; }
struct Complex3 { public Class Value; }
struct Complex4 : Interface { public Class Value; }
class Class { public int Value; }
class Class<T> { public T Value; }
interface Interface { }
[Example("Blittable Value Types", ExampleCategory.OpenTK, "Test", Documentation="BlittableValueTypes")]
public class BlittableValueTypes
{
public static void Main()
{
TestType(new Simple());
TestType(new Generic<Simple>());
TestType(new Generic<Enum>());
TestType(new Complex());
TestType(new Complex<Enum>());
TestType(new Complex2());
TestType(new Complex3());
TestType(new Complex4());
TestType(new Class());
TestType(new Class<Simple>());
}
// Tests whether specified type is blittable and prints its marshalled size if so.
static void TestType<T>(T instance)
// without express or implied warranty of any kind.
using System;
using System.Diagnostics;
using System.Reflection;
using OpenTK;
#pragma warning disable 0649 // Do not warn about unitialized fields, this is on purpose
namespace Examples.Tests
{
struct Simple { public int Value; }
struct Generic<T> { public T Value; }
enum Enum { First, Second }
struct Complex { public Simple Value; }
struct Complex<T> { public Generic<T> Value; }
struct Complex2 { public Enum Value; }
struct Complex3 { public Class Value; }
struct Complex4 : Interface { public Class Value; }
class Class { public int Value; }
class Class<T> { public T Value; }
interface Interface { }
[Example("Blittable Value Types", ExampleCategory.OpenTK, "Test", Documentation="BlittableValueTypes")]
public class BlittableValueTypes
{
public static void Main()
{
TestType(new Simple());
TestType(new Generic<Simple>());
TestType(new Generic<Enum>());
TestType(new Complex());
TestType(new Complex<Enum>());
TestType(new Complex2());
TestType(new Complex3());
TestType(new Complex4());
TestType(new Class());
TestType(new Class<Simple>());
}
// Tests whether specified type is blittable and prints its marshalled size if so.
static void TestType<T>(T instance)
{
PrintType<T>();
@ -52,9 +54,9 @@ namespace Examples.Tests
catch (Exception e)
{
Trace.Write(String.Format("({0})", e.GetType().Name));
}
Trace.WriteLine("");
}
Trace.WriteLine("");
}
// Prints a simple description for the type.
@ -71,6 +73,6 @@ namespace Examples.Tests
Trace.Write(typename.Substring(typename.LastIndexOf('.') + 1));
Trace.Write(" } ");
}
}
}
}
}
}