Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am not able to access private variable value using PrivateObject if my library is obfuscated. i know the variable name and other information are changed when we do obfuscation but is there any workaround for that ?

if i am accessing private variable of the serialized class then it is working fine but non-serialized class's private variables are not accessible using PrivateObject.

can anyone suggest any other solution to get private variable value ?

Thanks
-Amit.
Posted

1 solution

Does your obfuscator generate a log file which tells you what each method/field was translated to? If so, you might be able to use that to reverse the mappings in your test harness and look up the post-obfuscation value.

Note that if you're using reflection looking for known class/method/property names in your actual code (as opposed to the tests), you will need to exclude the targets of that reflection from obfuscation.
 
Share this answer
 
Comments
AmitGajjar 31-May-12 6:51am    
i only have obfuscated library,even i don't know which tool is used to obfuscate :)
BobJanova 31-May-12 9:36am    
Then you're pretty much screwed, the whole purpose of obfuscation is to remove meaning from the compiled code (IL in this case) so if you're looking for particular meaningful names you will not succeed.
AmitGajjar 1-Jun-12 0:31am    
actually i have created lots of test cases for checking private variable. but till date we are checking on non-obfuscated library. now client have requirement to check our all test cases on obfuscated library. so stuck there... :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900