Conditional Obfuscation

Eazfuscator.NET

Conditional Obfuscation

[assembly: Obfuscation(Feature = "Apply to type [name mask] when [condition]: [feature]")]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when internal and enum: renaming", Exclude = true, ApplyToMembers = true)]
Variable Description
abstract true if the type is abstract; otherwise, false
anonymous true if the type is anonymous; otherwise, false
class true if the type is a class; otherwise, false
delegate true if the type is a delegate; otherwise, false
enum true if the type is an enumeration; otherwise, false
generic true if the type is generic; otherwise, false
interface true if the type is an interface; otherwise, false
internal true if the type is internal; otherwise, false
nested true if the type is nested; otherwise, false
private true if the type is private; otherwise, false. Applies to nested types only; false if the type is not nested
protected true if the type is protected; otherwise, false. Applies to nested types only; false if the type is not nested
public true if the type is public; otherwise, false
sealed true if the type is sealed; otherwise, false
serializable true if the type is serializable; otherwise, false
static true if the type is static; otherwise, false
struct true if the type is a structure; otherwise, false
Constant Description
false false value
true true value
Function Description
inherits('type_name')
Returns true if the type inherits another type specified by type_name parameter; otherwise, false. Inherits function considers base and all inherited types including interfaces. Type name parameter can contain either the full type name or a mask for a bulk match
extends('type_name')
Returns true if the type extends another type specified by type_name parameter; otherwise, false. Extends function only checks the base type, but all implemented and inherited interfaces are considered. Type name parameter can contain either the full type name or a mask for a bulk match
has_attribute('type_name')
Returns true if the type or member has a custom attribute specified by type_name parameter; otherwise, false. Type name parameter can contain either the full type name or a mask for a bulk match.
Example:
has_attribute('System.ComponentModel.DisplayNameAttribute')
Operator Description Priority
not Unary operator for boolean negation Highest
and Binary operator for boolean and operation Medium
or Binary operator for boolean or operation Lower
= Binary operator for boolean equal operation Lowest
<> Binary operator for boolean not equal operation Lowest
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when not enum: renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when internal and (nested or serializable): renaming", Exclude = true, ApplyToMembers = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when not (internal and (nested or serializable)): renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type Contoso.Core.Services.* when interface: renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when class and extends('System.IDisposable'): renaming", Exclude = true, ApplyToMembers = true)]

Type Members

using System.Reflection;

[Obfuscation(Feature = "Apply to member [name mask] when [condition]: [feature]")]
class Sample1
{
  
}
Variable Description
abstract true if the member is abstract; otherwise, false
const true if the member defines a literal constant; otherwise, false. Applies to fields only; false if the member is not a field
constructor true if the member is a constructor; otherwise, false
event true if the member is an event; otherwise, false
field true if the member is a field; otherwise, false
generic true if the member is generic; otherwise, false. Applies to methods only; false if the member is not a method
internal true if the member is internal; otherwise, false
method true if the member is a method; otherwise, false
private true if the member is private; otherwise, false
property true if the member is a property; otherwise, false
protected true if the member is protected; otherwise, false
public true if the member is public; otherwise, false
readonly true if the member is read-only; otherwise, false. Applies to fields and properties only; false if the member is neither a field nor a property
static true if the member is static; otherwise, false
virtual true if the member is virtual; otherwise, false
using System.Reflection;

[Obfuscation(Feature = "Apply to member * when property and public: renaming", Exclude = true)]
class ImageQualityService
{
  
}
using System.Reflection;

[Obfuscation(Feature = "Apply to member * when method: renaming", Exclude = true)]
class CellCallEngine
{
  
}
using System.Reflection;

[Obfuscation(Feature = "Apply to member * when field and internal: renaming", Exclude = true)]
class ContosoHeadquarters
{
  
}

Options are Combinable

using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type Acme.Services: apply to member Contoso when property: renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type *: apply to member * when public and property: renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type MyNamespace.*: apply to member * when public and property: renaming", Exclude = true)]
using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when public: apply to member * when event and internal: renaming", Exclude = true)]

Diagnostics

How do you know which classes or members conditional obfuscation applies to?

using System.Reflection;

[assembly: Obfuscation(Feature = "Apply to type * when public: apply to member *: log")]
[Note] Note