Skip to main content
Version: 2024.1

5.8. Method Parameters Obfuscation

5.8.1. Renaming

By default, Eazfuscator.NET treats method parameters without special discretion. They get renamed when the method is renamed, and kept intact when method belongs to the public API surface of an assembly.

Such approach does not pose a problem, but sometimes you may prefer to affect the default behavior. For example, some third-party libraries may rely on names of method parameters to do their job. An obvious solution would be to disable the obfuscation of a whole method, like so:

[Obfuscation(Feature = "all", Exclude = true)]
void YourMethod(string description, int level)
{
...
}

But there is a better approach. Eazfuscator.NET can be instructed to disable just method parameters renaming, without disabling the renaming of a method itself:

[Obfuscation(Feature = "parameters renaming", Exclude = true)]
void YourMethod(string description, int level)
{
...
}

In this way, the original parameter names will be preserved with a better obfuscation coverage.

5.8.2. Optional Parameters Pruning

Eazfuscator.NET is a smart beast. Despite its simplistic user interface, it does a lot of wizardry behind the scenes. Removing the default values of optional method parameters is just one of such things.

As you know, some .NET languages allow to define a default value for a method parameter:

void YourMethod(string text = "abc")
{
...
}

In this way, a parameter becomes optional because it now has a default value.

More often than not, the information about default values can be safely removed from internal methods of an assembly. It becomes possible due to the fact that default values are only used during compile time while being completely unused at run time. Eazfuscator.NET automatically prunes the unneeded default values of optional parameters without affecting the observed assembly behavior. This is a good thing: obfuscated assembly becomes smaller while the amount of potentially disclosing information is reduced.

But what if you want to keep the default values of method parameters due to some very specific reason? An obvious approach is to exclude the whole method from renaming:

[Obfuscation(Feature = "renaming", Exclude = true)]
void YourMethod(string text = "abc")
{
...
}

Or even better, to only exclude its parameters while allowing the method to be renamed:

[Obfuscation(Feature = "parameters renaming", Exclude = true)]
void YourMethod(string text = "abc")
{
...
}

However, there is a more precise way to achieve the goal. A special directive can be used to disable the pruning of default values of method parameters while allowing them to be renamed:

[Obfuscation(Feature = "optional parameters pruning", Exclude = true)]
void YourMethod(string text = "abc")
{
...
}

In this way, optional method parameters will be preserved with a better obfuscation coverage.