nyxiscoo1 / obfuscar

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

Methods (members?) lose their code attributes after obfuscation #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Obfuscate an assembly where a method has a code Attribute
2. Using .NET Reflector you can see the new obfuscated assembly method 
does NOT have any code attributes.
3.

What is the expected output? What do you see instead?
I expect that all code attribute are copied to the new obfuscated method.

What version of the product are you using? On what operating system?
WinXP, Obfuscar 1.0.1.0

Please provide any additional information below.

Original issue reported on code.google.com by obiwanja...@hotmail.com on 15 May 2007 at 5:22

GoogleCodeExporter commented 8 years ago
I cannot reproduce this problem...I've committed an update to the unit tests 
(in r20)
that obfuscates an assembly with an attribute on a class and an attribute on a 
method
within the class.  In both cases, the attribute stays in place after the 
obfuscation.

Can you provide some example code?

Original comment by drcfor...@gmail.com on 15 May 2007 at 7:03

GoogleCodeExporter commented 8 years ago

Original comment by drcfor...@gmail.com on 15 May 2007 at 8:54

GoogleCodeExporter commented 8 years ago
After I obfuscate my VS.NET 2005 project my (Properties.)Settings are 
generating 
what seems to be a Configuration Exception (SettingsPropertyNotFoundException). 
I 
think it is because all the code attributes are gone.

The Settings type itself as well as the property are excluded from obfuscation 
using 
SkipType and SkipMethod. Perhaps it is a bug that only occurs to 'skipped' 
members?

Original comment by obiwanja...@hotmail.com on 17 May 2007 at 10:54

GoogleCodeExporter commented 8 years ago
I've created a test project that demonstrates the problem. I've put in the 
obfuscar 
group at 
http://groups.google.com/group/obfuscar/web/ObfuscarCodeAttributeTest.zip

It is a VS.NET 2005 console project with a Settings class. There is a build 
event 
that obfuscates the output in the 'obfuscated' dir of either Debug or Release. 
The 
zip also contains the obfuscar.exe v1.0.1.0.

Good luck ;-)

Original comment by obiwanja...@hotmail.com on 17 May 2007 at 1:51

GoogleCodeExporter commented 8 years ago
This is now fixed in Obfuscar 1.1.0, by the addition of the SkipProperty 
element. 
The problem is caused by the platform reflecting into your assembly at runtime 
to
retrieve the value of a property.

In your example, you used the following xml:

  <Module file="$(InPath)\ObfuscarCodeAttributeTest.exe" >
    <SkipType name="ObfuscarCodeAttributeTest.Properties.Settings" />
    <SkipMethod type="ObfuscarCodeAttributeTest.Properties.Settings" attrib="public"
rx=".*" />
  </Module>

The xml caused it to skip renaming of the Settings class and all methods within 
it,
but the flags that state that the methods make up a property were being 
stripped.

Now that we have a SkipProperty element, you can skip just the property:

  <Module file="$(InPath)\ObfuscarCodeAttributeTest.exe">
    <SkipProperty type="ObfuscarCodeAttributeTest.Properties.Settings"
name="SomeSetting" />
  </Module>

Or you can skip all of the properties in your settings class as follows:

  <Module file="$(InPath)\ObfuscarCodeAttributeTest.exe">
    <SkipProperty type="ObfuscarCodeAttributeTest.Properties.Settings" rx=".*" />
  </Module>

The SkipProperty element allows Obfuscar to rename the type, while leaving the
get_XXX / set_XXX methods alone, and leaving in place the flag that says they 
make up
a property.

Original comment by drcfor...@gmail.com on 17 May 2007 at 7:52

GoogleCodeExporter commented 8 years ago
It works great! Thanx!

Is there an overlap in what SkipMethod and SkipProperty does? Does SkipMethod 
still 
affect properties?

Original comment by obiwanja...@hotmail.com on 18 May 2007 at 6:26

GoogleCodeExporter commented 8 years ago
There is a bit of overlap...SkipMethod can still be made to skip get_XXX/set_XXX
methods, but if SkipProperty isn't used, they will no longer be marked as being
associated with a property.

I.e., SkipProperty instructs Obfuscar not to strip the property and not to 
rename the
methods, whereas SkipMethod can only instruct Obfuscar not to rename the 
methods.

Original comment by drcfor...@gmail.com on 18 May 2007 at 6:33

GoogleCodeExporter commented 8 years ago
So will there be a conflict if I use both SkipMethod and SkipProperty both with 
a '.*' expression? Or will SkipProperty take precendence over SkipMethod for 
properties and SkipMethod for methods.

I saw a similar thing happening with events. Works this in the same way?

Original comment by obiwanja...@hotmail.com on 21 May 2007 at 6:47

GoogleCodeExporter commented 8 years ago
They shouldn't conflict, the SkipProperty / SkipEvent will take precedence over 
the
SkipMethod elements (they're processed first to avoid trouble).

Original comment by drcfor...@gmail.com on 21 May 2007 at 12:48