Declarative Obfuscation Using Custom Attributes

Eazfuscator.NET

Declarative Obfuscation Using Custom Attributes

System.Reflection.ObfuscateAssemblyAttribute

System.Reflection.ObfuscationAttribute

[System.Reflection.ObfuscationAttribute(Feature = "renaming", ApplyToMembers = false)]
class MyOneThousandAndFirstClass
{
    
}
[System.Reflection.ObfuscationAttribute(Feature = "renaming", ApplyToMembers = true)]
class MyOneThousandAndSecondClass
{
    
}
[System.Reflection.ObfuscationAttribute(Feature = "properties renaming")]
class MyOneThousandAndThirdClass
{
    
}
class MyOneThousandAndFourthClass
{
    [System.Reflection.ObfuscationAttribute(Feature = "renaming")]
    public string DisplayName
    {
        get;
        set;
    }
}
using System.Reflection;

[assembly: Obfuscation(Feature = "anonymous type properties renaming", Exclude = true)]

.NET Compact Framework, Silverlight, Windows Store and .NET Core Projects

[Note] Note

Indirect Declarative Obfuscation

using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type MyNamespace.ResourceClass1: renaming", Exclude = true, ApplyToMembers = false)]
namespace MyNamespace
{
    [System.Reflection.ObfuscationAttribute(Feature = "renaming", Exclude = true, ApplyToMembers = false)]
    class ResourceClass1
    {
        
    }
}
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type SomeExcludedNamespace.*: all", Exclude = true, ApplyToMembers = true)]

Obfuscation Attribute Priorities

Introduction

[assembly: Obfuscation(Feature = "string encryption", Exclude = true)]
[assembly: Obfuscation(Feature = "string encryption", Exclude = false)]

Priority Syntax

[Obfuscation(Feature = "1. <some feature here>")]
[Obfuscation(Feature = "1. <some high priorty feature here>")]
[Obfuscation(Feature = "2. <medium priorty feature>")]
[Obfuscation(Feature = "3. <a feature with the lowest priority>")]
[Note] Note

Complete Example

[assembly: Obfuscation(Feature = "2. string encryption", Exclude = true)]
[assembly: Obfuscation(Feature = "1. string encryption", Exclude = false)]