Exemple #1
0
        static RuntimeTypeModel CreateDefaultRefModel(bool aFirst, bool comp)
        {
            ProtoCompatibilitySettingsValue fullComp = ProtoCompatibilitySettingsValue.FullCompatibility;

            fullComp.SuppressValueEnhancedFormat = false;
            var model = TypeModel.Create(false, comp ? fullComp : ProtoCompatibilitySettingsValue.Incompatible);

            if (comp)
            {
                model.SkipForcedLateReference = true;
            }
            // otherwise will not be compatible
            model.SkipForcedAdvancedVersioning = true;
            if (aFirst)
            {
                model.Add(typeof(A_WithDefaultRef), true);
                model.Add(typeof(B_WithDefaultRef), true);
            }
            else
            {
                model.Add(typeof(B_WithDefaultRef), true);
                model.Add(typeof(A_WithDefaultRef), true);
            }

            ValueMember f = model[typeof(B_WithDefaultRef)][2];
            MemberLevelSettingsValue s = f.GetSettingsCopy(0);

            Assert.That(s.Format, Is.EqualTo(ValueFormat.NotSpecified));
            s.Format = ValueFormat.Compact;
            f.SetSettings(s);

            model.AutoCompile = false;

            return(model);
        }
Exemple #2
0
        RuntimeTypeModel CreateModel()
        {
            ProtoCompatibilitySettingsValue c = ProtoCompatibilitySettingsValue.FullCompatibility;

            c.SuppressValueEnhancedFormat = false;
            RuntimeTypeModel model = TypeModel.Create(false, c);

            model.Add(typeof(ObjectArrayContainerClass), true);
            model.Add(typeof(BaseClassArrayContainerClass), true);
            model.Add(typeof(Base), true);
            model[typeof(Base)].AddSubType(100, typeof(Derived));

            return(model);
        }
Exemple #3
0
        static RuntimeTypeModel CreateSurrogateModel(bool comp)
        {
            ProtoCompatibilitySettingsValue fullComp = ProtoCompatibilitySettingsValue.FullCompatibility;

            fullComp.SuppressValueEnhancedFormat = false;
            var model = TypeModel.Create(false, comp ? fullComp : ProtoCompatibilitySettingsValue.Incompatible);

            model.SkipForcedAdvancedVersioning = true;
            if (comp)
            {
                model.SkipForcedLateReference = true;
            }
            model.AutoCompile = false;
            model[typeof(B)][2].AsReference = false; // or just remove AsReference on Items

            // this is the evil bit:
            model[typeof(KeyValuePair <int, A>)].SetSurrogate(typeof(RefPair <int, A>));
            model[typeof(KeyValuePair <int, A>)].AsReferenceDefault = true;
            return(model);
        }
Exemple #4
0
        static RuntimeTypeModel CreateFieldsModel(bool comp)
        {
            ProtoCompatibilitySettingsValue fullComp = ProtoCompatibilitySettingsValue.FullCompatibility;

            fullComp.SuppressValueEnhancedFormat = false;
            var model = TypeModel.Create(false, comp ? fullComp : ProtoCompatibilitySettingsValue.Incompatible);

            if (comp)
            {
                model.SkipForcedLateReference = true;
            }
            model.SkipForcedAdvancedVersioning = true;
            model.AutoCompile = false;
            var type = model.Add(typeof(KeyValuePair <int, A>), false);

            model.SkipCompiledVsNotCheck = true;
            type.Add(1, "key");
            type.AddField(2, "value").AsReference = true;

            model[typeof(B)][2].AsReference = false; // or just remove AsReference on Items
            return(model);
        }
Exemple #5
0
        public void ExecuteWithSubType()
        {
            ProtoCompatibilitySettingsValue comp = ProtoCompatibilitySettingsValue.Default;
            // late reference mode is not allowed on surrogates
            // TODO move LateReference mode to attributes
            //comp.AllowExtensionDefinitions &= ~NetObjectExtensionTypes.LateReference;
            var m = TypeModel.Create(false, comp);

            m.AutoCompile = false;
            m.Add(typeof(C), false).SetSurrogate(typeof(CS));
            m.Add(typeof(O), false).SetSurrogate(typeof(OS));
            m.Add(typeof(I), false).AddSubType(1, typeof(O));

            var c = new C();

            c.PopulateRun();

            Test(m, c, "Runtime");
            m.Compile("ExecuteWithSubType", "ExecuteWithSubType.dll");
            PEVerify.AssertValid("ExecuteWithSubType.dll");
            //m.CompileInPlace();
            Test(m, c, "CompileInPlace");
            Test(m.Compile(), c, "Compile");
        }