I am working on an obfuscation mechanism using F#.
I wrote the same thing using C# before a few months as follows:
public void testobfusc(string file)
{
AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(file);
ModuleDefinition module = assembly.MainModule;
foreach (TypeDefinition type in module.Types)
{
type.Name = "Yaobfuscatethis"; // Maybe I should use random function here
}
}
Now, I’m trying to write the same thing in F#. First, I reference Mono.Cecil and then write:
open Mono.Cecil
let obfus(file:string)=
use asm = AssemblyDefinition.ReadAssembly(file)
let ModuleDefinition = asm.MainModule
TypeDefinition(asm.MainModule.Types)
t.Name = ""
.. but this code does not work.
Translated (not tested):