示例#1
0
        public void ManuallyWrittenSerializeCallbackStructSimple(CallbackStructSimple obj, ProtoWriter writer)
        {
            obj.OnSerializing();
            string bar = obj.Bar;

            if (bar != null)
            {
                ProtoWriter.WriteFieldHeader(1, WireType.String, writer);
                ProtoWriter.WriteString(bar, writer);
            }
            obj.OnSerialized();
        }
示例#2
0
#pragma warning disable IDE0051 // Remove unused private members
        private void ManuallyWrittenSerializeCallbackStructSimple(CallbackStructSimple obj, ref ProtoWriter.State state)
#pragma warning restore IDE0051 // Remove unused private members
        {
            obj.OnSerializing();
            string bar = obj.Bar;

            if (bar != null)
            {
                state.WriteFieldHeader(1, WireType.String);
                state.WriteString(bar);
            }
            obj.OnSerialized();
        }
示例#3
0
        public void TestStructSimple_Basic()
        {
            var model = RuntimeTypeModel.Create();

            model.Add(typeof(CallbackStructSimple), true);
            model.Add(typeof(CallbackSimple), true);
            var compiled = model.Compile("TestStructSimple", "TestStructSimple.dll");

            PEVerify.AssertValid("TestStructSimple.dll");

            var obj   = new CallbackStructSimple();
            var clone = compiled.DeepClone(obj);

            Assert.Equal(";OnDeserializing;OnDeserialized", clone.History);
        }