Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
[AttributeUsage(AttributeTargets.Delegate | (AttributeTargets.Parameter | (AttributeTargets.Interface | (AttributeTargets.Event | (AttributeTargets.Field | (AttributeTargets.Property | (AttributeTargets.Method | (AttributeTargets.Enum | (AttributeTargets.Struct | (AttributeTargets.Class | AttributeTargets.Assembly))))))))), AllowMultiple=true, Inherited=false), ComVisible(true)] public sealed class ObfuscationAttribute : Attribute { // Constructor public ObfuscationAttribute(); // Properties public bool ApplyToMembers; public bool Excludet public string Feature; public bool StripAfterObfuscation; // Fields private bool mApplyToMembers; private bool mExclude; private string mFeature; private bool mStripAfterObfuscation; }
public ObfuscationAttribute(){ mStrip = true; mExclude = true; mApplyToMembers = true; mFeature = "all"; }
[System.Reflection.Obfuscation()] public int ObfuscateThisPlease() { int j = 6; int i = 5 + j; return (j - i); } .method public hidebysig instance int32 ObfuscateThisPlease() cil managed { .custom instance void [mscorlib]ObfuscationAttribute::.ctor()=(01 00 00 00) // Code size 10 (0xa) .maxstack 2 .locals init ([0] int32 j, [1] int32 i) IL_0000: ldc.i4.6 IL_0001: stloc.0 IL_0002: ldc.i4.5 IL_0003: ldloc.0 IL_0004: add IL_0005: stloc.1 IL_0006: ldloc.0 IL_0007: ldloc.1 IL_0008: sub IL_0009: ret } // end of method Program::ObfuscateThisPlease
"Instructs obfuscation tools to take the specified actions for an assembly, type, or member."