dbremner / obfuscar

Automatically exported from code.google.com/p/obfuscar
0 stars 0 forks source link

[Patch] Allow skipping all public classes/methods #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This patch adds a new attribute to the configuration of <Module>:
skipPublicAPI="true".

If set to true (default is false), all types and members visible to other
assemblies will be skipped.
This allows obfuscating assemblies that are intended to be consumed by
other developers.

Original issue reported on code.google.com by daniel.g...@gmail.com on 2 Apr 2010 at 5:35

Attachments:

GoogleCodeExporter commented 8 years ago
Maybe I am missing the point, but where is the difference between the 
skipPublicAPI
flag and the following (besides that it is shorter):

<SkipType name="*" />
<SkipField type="*" attrib="protected" name="*" />
<SkipProperty type="*" attrib="protected" name="*" />
<SkipEvent type="*" attrib="protected" name="*" />
<SkipMethod type="*" attrib="protected" name="*" />

Original comment by webbi...@gmail.com on 3 Apr 2010 at 3:40

GoogleCodeExporter commented 8 years ago
My assembly contains:
a) public members inside public classes
b) internal members inside public classes
c) public members inside internal classes
d) internal members inside internal classes

I need something that renames everything but a). Your suggestion only renames 
b) and
d). Moreover your suggestion doesn't rename the internal classes themselves, 
making
reverse engineering of the data structures trivial.

Original comment by daniel.g...@gmail.com on 3 Apr 2010 at 3:45

GoogleCodeExporter commented 8 years ago
This is right. I didn't consider internal classes.
I added two new flags for the configuration xml:
1. typeattrib="public" for Skip member methods. With this flag set only members
declared by public classes are skipped. (Using your IsPublic() function)
2. With attrib="public" the SkipType element only applies to public types.

This should do what you described:

<SkipType name="*" attrib="public" />
<SkipField type="*" attrib="protected" typeattrib="public" name="*" />
<SkipProperty type="*" attrib="protected" typeattrib="public" name="*" />
<SkipEvent type="*" attrib="protected" typeattrib="public" name="*" />
<SkipMethod type="*" attrib="protected" typeattrib="public" name="*" />

Additionally I changed the renaming behavior of method parameters. When a 
method is
renamed, the names of its parameters are removed.

I checked the changes into SVN. Please verify if everything works as expected.

Original comment by webbi...@gmail.com on 4 Apr 2010 at 3:50

GoogleCodeExporter commented 8 years ago
Yes, the member renaming now works as expected.

But your version of the parameter renaming patch for issue #34 introduced a 
small new
bug: the type parameters of generic classes now are always renamed even if the 
class
is skipped.
My version of the patch moved down the "info.ShouldSkip(new TypeKey(type))" 
check to
the code handling type parameters, your version completely removed the check.

Original comment by daniel.g...@gmail.com on 4 Apr 2010 at 4:02

GoogleCodeExporter commented 8 years ago
Sorry, I overlooked that.
The fix is checked in.

Original comment by webbi...@gmail.com on 4 Apr 2010 at 7:47