Question

When I obfuscate this form, and "debug" it

public partial class Form1 : Form
{
  public void Form1()
  {
    InitializeComponents();
  }

  protected override void OnShown(EventArgs e)
  {
      base.OnShown(e);
      Console.WriteLine("Name: "+this.Name);
      Console.WriteLine("FullName: "+this.GetType().FullName);
  }
}

The output is like this:

Name: Form1
FullName: #Yab.#Zab


Question
Why is FullName obfuscated?
Form1 is public so I would expect SmartAssembly to ignore it.

Extra info
Form1 is public partial and so is the designer.cs

My SmartAssembly setup is like this:

    <ApplicationName />
    <Destination DestinationFileName=".\bin.obfuscated\MyProject.Form1.exe" />
    <Assemblies>
        <Assembly AssemblyName="MyProject.Form1, Culture=neutral, PublicKeyToken=omitted">
            <Merging>
                <ResourcesCompression Compress="0" />
                <MemberRefsProxy />
                <Pruning />
                <Obfuscation Obfuscate="1">
                  <Exclusions />
                </Obfuscation>
                <ControlFlow Obfuscate="1" />
            </Merging>
        </Assembly>
    </Assemblies>
    <Options>
      <Obfuscation FieldsNameMangling="2" NameMangling="1" />
      <ExceptionReporting />
      <FeatureUsageReporting Template="res:SmartUsageWithUIConsentFirstRun1033.dll" />
      <StrongNameSigning KeyFileName="PathToKeyFile" Sign="1" />
      <OtherProtections />
      <StringsEncoding />
      <OtherOptimizations />
      <Debugging />
    </Options>
Was it helpful?

Solution

Firstly, a public class isn't ignored by SmartAssembly in an application project (it will be ignored in a library project).

Secondly, the Name property of your form is a property set at runtime. In your case case, it may be initialized to "Form1" somewhere in your code, maybe in the designer.

This value can be changed anytime, example :

public Form1()
{
    InitializeComponent();
    this.Name = "foo";
}

So SmartAssembly cannot obfuscate this value, it would be wrong and would change the behavior of your code.

When SmartAssembly obfuscates your code, it only changes the names of the types, fields and methods. When your try to get the name of your type, it's logical to get the obfuscated name of your type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top