Obfuscation, Dofuscator attribute not being honored

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    Obfuscation, Dofuscator attribute not being honored

    Something that seems reasonably straightforward is causing me to pull my hair out.

    I have a rather simple project that performs file backups at regular timed intervals.
    There are check boxes for Monday, Tuesday etc.
    There are properties that correspond: bool RunOnMonday, etc.
    Checking the checkbox changes the property
    Changing the property check/unchecks the checkbox.
    The settings are saved in the registry and when read back at program launch they set the properties.

    All this works great when the application in not obfuscated.
    The obfuscated version can save settings, but not load them.
    It turns out that the property is NOT obfuscating the 'get' method, but is dropping the set method entirely


    Am I just stupid? Doesn't this attribute read like it is supposed to keep the entire property from being obfuscated? Exclude true, apply to members true.
    Code:
    [Category("CustomValues"),
    Obfuscation(Exclude = true, StripAfterObfuscation = false, ApplyToMembers = true)]
    public bool RunOnMonday
    {
        set
        {
           chkMonday.Checked = value;
        }
        get
        {
             return chkMonday.Checked;
        }
    }
    The fact that the get method is not obfuscated and the set method *is*, is what is really driving me bonkers.

    In the Dofuscator project the "Honor Obfuscation Attributes" property is set to true.

    If I uncomment the attribute for the entire assembly it gets honored, meaning the entire assembly is NOT obfuscated and the application runs fine. But then all my code is visible to the world.

    I should be able to just keep the one property unobfuscated for both the get and set methods and can't seem to figure out how.

    Does anyone else have some experience with Dotfuscator or obfuscation in general that can lend me a hand?
  • johnbr
    New Member
    • Feb 2010
    • 1

    #2
    Hi,

    The default obfuscation attribute configuration will apply to the Renaming action. The set method is getting pruned by the "Removal" transform. The Removal transform removes any methods, fields, etc that are never called directly. In order to preserve the set method, try adding an obfuscation attribute for a removal include trigger:

    [Obfuscation(Fea ture = "trigger", ApplyToMembers = true, Exclude = false)]

    Please let me know if this helps...

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      I'll be back in the office Wednesday and will give it a try. Thanks!

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        [Obfuscation(Fea ture = "trigger", ApplyToMembers = true, Exclude = false)]
        Does indeed keep the get and set methods intact in the properties. The full use for others looks like this:
        Code:
        [Obfuscation(Feature = "trigger", ApplyToMembers = true, Exclude = false)]
        public bool DeleteWhenDone
        {
            get { return chkDeleteAfterCopy.Checked; }
            set { chkDeleteAfterCopy.Checked = value; }
        }
        So John, let me ask... Where did you come up with this? I have searched, googled and read all the docs I could lay my hand on from Dotfuscator and MSDN and have not found a good explanation of the obfuscation attributes beyond stuff like.

        Obfuscation attribute... Use this attribute to set various obfuscation flags as needed.
        No kidding. But I haven't found a good list or explanation of what the various attributes are and their meanings.

        Even in this example 'Exclude = false' would make someone think the property this attribute is for is NOT going to be excluded from obfuscation when in practice it seems that it DOES exclude from obfuscation.

        It seems my understanding of this is what has been obfuscated. <laugh>

        Comment

        Working...