What can we really do with RAIL?
n//Create the RAssemblyDef representation of the Teste3.exe assembly
nRAssemblyDef rAssembly = RAssemblyDef.LoadAssembly("Teste3.exe");
n//Get the RTypeDef obejct for the type where the field and property are declared
nRTypeDef rtd = (RTypeDef)rAssembly.RModuleDef.GetType("FooBar");
n//Get tje constructor method where to apply the changes
nRConstructorDef rcd = (RConstructorDef)rtd.GetConstructor(new RType[0]);
n//Get the field
nRField rfld1 = rtd.GetField("Val1");
n//Get the property
nRProperty rprop = rtd.GetProperty("Prop");
n//Create the code trasnformer object
nCodeTransformer cc = new CodeTransformer();
n//Set the transformation to make in the code
ncc.RedirectFieldAccess(rfld1,rprop);
n//Apply the changes
nrcd.Accept(cc);
n//Save the assembly
nrAssembly.SaveAssembly("Teste3.exe");
Redirect field access
Redirect field access to property
Redirect field read and write access to methods