我想从程序集中删除ObfuscationExclude属性:
我的尝试:
但我不知道我怎么做到这一点,有人可以帮助我吗?
public static void CleanCustomAttributes(AssemblyDefinition asmdef)
{
foreach(ModuleDefinition ModuleDef in asmdef.Modules )
{
foreach(TypeDefinition TypeDef in ModuleDef.Types )
{
foreach(CustomAttribute CustomAttrib in TypeDef.CustomAttributes )
{
if (CustomAttrib.AttributeType = // ? )
{
}
}
}
}
}
答案 0 :(得分:1)
只需检查属性的全名并将其删除即可。
public static void CleanCustomAttributes(AssemblyDefinition asmdef)
{
foreach (ModuleDefinition ModuleDef in asmdef.Modules)
{
foreach (TypeDefinition TypeDef in ModuleDef.Types)
{
foreach (CustomAttribute CustomAttrib in TypeDef.CustomAttributes)
{
if (CustomAttrib.AttributeType.FullName == "System.Reflection.ObfuscationAttribute")
{
TypeDef.CustomAttributes.Remove(CustomAttrib);
break;
}
}
}
}
}