Exemplo n.º 1
0
	unsafe static int Test () {
		TestNew tt = new TestNew ();
		tt.SetTest ();
		tt.test2 [2] = false;
		tt.T [1] = 5544;
		if (tt.T [1] != 5544)
			return 2;
	
		ExternalStruct es = new ExternalStruct ();
		es.double_buffer [1] = 999999.8888;
		es.double_buffer [0] = es.double_buffer [1];

		// Attributes test
		if (Attribute.GetCustomAttribute (typeof (TestNew).GetField ("test2"), typeof (System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
			return 3;

		
		if (typeof (TestNew).GetNestedTypes ().Length != 5)
			return 5;

		foreach (Type t in typeof (TestNew).GetNestedTypes ()) {
			if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
				return 4;
		}

		Console.WriteLine ("OK");
		return 0;
	}
Exemplo n.º 2
0
    unsafe static int Test()
    {
        TestNew tt = new TestNew();

        tt.SetTest();
        tt.test2 [2] = false;
        tt.T [1]     = 5544;
        if (tt.T [1] != 5544)
        {
            return(2);
        }

        ExternalStruct es = new ExternalStruct();

        es.double_buffer [1] = 999999.8888;
        es.double_buffer [0] = es.double_buffer [1];

        // Attributes test
        if (Attribute.GetCustomAttribute(typeof(TestNew).GetField("test2"), typeof(System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
        {
            return(3);
        }


        if (typeof(TestNew).GetNestedTypes().Length != 5)
        {
            return(5);
        }

        foreach (Type t in typeof(TestNew).GetNestedTypes())
        {
            if (Attribute.GetCustomAttribute(t, typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
            {
                return(40);
            }

            if (Attribute.GetCustomAttribute(t, typeof(System.Runtime.CompilerServices.UnsafeValueTypeAttribute)) == null)
            {
                return(41);
            }

            if (!t.IsUnicodeClass)
            {
                return(42);
            }
        }

        Console.WriteLine("OK");
        return(0);
    }
Exemplo n.º 3
0
 /// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary>
 public static byte[] SerializeToBytes(ExternalStruct instance)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(ms, instance);
         return ms.ToArray();
     }
 }
Exemplo n.º 4
0
 /// <summary>Helper: Serialize with a varint length prefix</summary>
 public static void SerializeLengthDelimited(Stream stream, ExternalStruct instance)
 {
     var data = SerializeToBytes(instance);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
     stream.Write(data, 0, data.Length);
 }
Exemplo n.º 5
0
 /// <summary>Serialize the instance into the stream</summary>
 public static void Serialize(Stream stream, ExternalStruct instance)
 {
     BinaryWriter bw = new BinaryWriter(stream);
     // Key for field: 1, Fixed64
     stream.WriteByte(9);
     bw.Write(instance.X);
 }
Exemplo n.º 6
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static ExternalStruct DeserializeLengthDelimited(Stream stream)
 {
     ExternalStruct instance = new ExternalStruct();
     DeserializeLengthDelimited(stream, ref instance);
     return instance;
 }
Exemplo n.º 7
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static ExternalStruct DeserializeLength(Stream stream, int length)
 {
     ExternalStruct instance = new ExternalStruct();
     DeserializeLength(stream, length, ref instance);
     return instance;
 }
Exemplo n.º 8
0
 /// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary>
 public static ExternalStruct Deserialize(byte[] buffer)
 {
     ExternalStruct instance = new ExternalStruct();
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, ref instance);
     return instance;
 }
Exemplo n.º 9
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static ExternalStruct Deserialize(Stream stream)
 {
     ExternalStruct instance = new ExternalStruct();
     Deserialize(stream, ref instance);
     return instance;
 }
 /// <summary>Serialize the instance into the stream</summary>
 public static void Serialize(Stream stream, ExternalStruct instance)
 {
     var bw = new BinaryWriter(stream);
     var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
     // Key for field: 1, Fixed64
     stream.WriteByte(9);
     bw.Write(instance.X);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
 }
Exemplo n.º 11
0
 /// <summary>Serialize the instance into the stream</summary>
 public static void Serialize(Stream stream, ExternalStruct instance)
 {
     BinaryWriter bw = new BinaryWriter(stream);
     using (var msField = new MemoryStream(0))
     {
         // Key for field: 1, Fixed64
         stream.WriteByte(9);
         bw.Write(instance.X);
     }
 }