public void TestDependencyMissingType() { PatchInstaller installer = new PatchInstaller(new MockModuleSource(module)); StandardPatch patch = new StandardPatch("TestPatch"); patch.Module(module.Name, ModificationKind.FailIfMissing, true).Type(MissingNamespace, NormalClass, ModificationKind.FailIfMissing).Attributes = TypeAttributes.BeforeFieldInit; installer.Add(patch); installer.Install(); }
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(); }
public void TestDependencyMissingMethod() { 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.Method(MissingMember, new MethodSignature(CallingConvention.HasThis, 0u, new CorLibTypeSignature(new TypeReference(patch.Module("System.Runtime", ModificationKind.FailIfMissing, true), "System", "Void", new ModuleReference("System.Runtime")), ElementType.Void)), ModificationKind.FailIfMissing).Attributes = MethodAttributes.HideBySig; installer.Add(patch); installer.Install(); }
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(); }
public StandardPatch CreatePatch(ModuleDef module, string patchName) { StandardPatch patch = new StandardPatch(patchName ?? module.Name); modules = new Dictionary <UTF8String, ModuleModification>(); transformer = new ModuleTokenTransformer(this, module); foreach (CustomAttribute attribute in module.CustomAttributes.FindAll(ModuleExtensions.Required)) { UTF8String name = attribute.ConstructorArguments[0].ExtractName(); modules.Add(name, patch.Module(name, ModificationKind.FailIfMissing, (bool)attribute.ConstructorArguments[1].Value)); } for (Stack <TypeDef> types = new Stack <TypeDef>(module.Types); types.Count > 0;) { TypeDef type = types.Pop(); Populate(type); foreach (TypeDef nested in type.NestedTypes) { types.Push(nested); } } return(patch); }