Comments
3 comments
-
Hi Ivan,
According to the documentation here on serialization, it indicates thatClasses and properties in an executable assembly, however, will be made private and renamed, breaking serialization if the class is defined in the executable. SmartAssembly attempts to work around this by automatically excluding from obfuscation all classes with the Serializable attribute set.
It has further information on a way to get the obfuscation working in this instance.
I hope this helps!
Kind regards,
Alex -
Hi Alex,
Thanks for the reply.
Yes, I see, that's make sense for private fields to not be obfuscated when the type is [Serializable].
How about private constants?
Consider this class:[Serializable] public class Class1 { private const int State = 123; private readonly string timestamp = DateTime.Now.ToTimestamp(); public string GetStatus() { return string.IsNullOrEmpty(timestamp) ? "Not initialized " + State.ToString() : "Initialized at " + timestamp + " " + State.ToString(); } }
Obfuscated version has "private const int State" unobfuscated. Any reasons why? It does not seem to have any effect on serialization.
If I apply [NonSerialized] attribute to the constant, its name gets mangled during obfuscation.
Thanks. -
Hi Ivan,
As stated before, the entire Class1 class is excluded from obfuscation, which includes the private constant. In the link it mentions you can work around this by implementing ISerializable on the class. Have a look at the documentation on serialization.
Kind regards,
Alex
Add comment
Please sign in to leave a comment.
Note the private field "implementation ".
This dependency is merged into main application and obfuscated:
After the obfuscation name of the private field "implementation" is not mangled:
https://www.dropbox.com/s/w64ibwonkf1nh0v/PrivateFieldNotMangled.png?dl=0
I would expect the name to be obfuscated, it is only used once as displayed in the snippet above, no access by reflection or anything like this.
Is there something I am missing from obfuscation configuration?
I was using SmartAssembly 6.9.0.114 for this test.