Exemplo n.º 1
0
        public void TestDependencyMissingProperty()
        {
            PatchInstaller   installer = new PatchInstaller(new MockModuleSource(module));
            StandardPatch    patch     = new StandardPatch("TestPatch");
            TypeModification type      = patch.Module(module.Name, ModificationKind.FailIfMissing, true).Type(ReadOnlyNamespace, NormalClass, ModificationKind.FailIfMissing);

            type.Attributes = TypeAttributes.BeforeFieldInit;
            type.Property(MissingMember, new PropertySignature(true, new CorLibTypeSignature(new TypeReference(patch.Module("System.Runtime", ModificationKind.FailIfMissing, true), "System", "String", new ModuleReference("System.Runtime")), ElementType.String)), ModificationKind.FailIfMissing);
            installer.Add(patch);
            installer.Install();
        }
Exemplo n.º 2
0
        public void TestDependencyExistingProperty()
        {
            PatchInstaller   installer = new PatchInstaller(new MockModuleSource(module));
            StandardPatch    patch     = new StandardPatch("TestPatch");
            TypeModification type      = patch.Module(module.Name, ModificationKind.FailIfMissing, true).Type(ReadOnlyNamespace, NormalClass, ModificationKind.FailIfMissing);

            type.Attributes = TypeAttributes.BeforeFieldInit;
            MethodModification propertyGet = type.Method("get_" + StringProperty, new MethodSignature(CallingConvention.HasThis, 0u, new CorLibTypeSignature(new TypeReference(patch.Module("System.Runtime", ModificationKind.FailIfMissing, true), "System", "String", new ModuleReference("System.Runtime")), ElementType.String)), ModificationKind.FailIfMissing);

            propertyGet.Attributes = MethodAttributes.HideBySig | MethodAttributes.SpecialName;
            type.Property(StringProperty, new PropertySignature(true, new CorLibTypeSignature(new TypeReference(patch.Module("System.Runtime", ModificationKind.FailIfMissing, true), "System", "String", new ModuleReference("System.Runtime")), ElementType.String)), ModificationKind.FailIfMissing).Get(propertyGet);
            installer.Add(patch);
            installer.Install();
        }