-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Disable type name rename when marked with SerializableAttribute #493
base: master
Are you sure you want to change the base?
Conversation
Thank you very much for this patch. We shall add the following line into the else if (property.DeclaringType.IsSerializable) {
service.SetCanRename(property, false);
} |
SerializableAttribute doesn't care about properties, it cares about fields only. My understanding is SerializableAttribute is only for .NET Framework's rule on (de)serialization, which will not call constructors and will only serialize fileds (private and public). This is also the behavior of BinaryFormatter and SoapFormatter. All classes that come with the framework and marked as Serializable follows this rule. Many third party serializer, including Newtonsoft.Json, can also be set to follow this rule. If the author of the class want it to be Json serialized or something, there is no need to use SerializableAttribute. Instead, apply DataMemberAttribute or the serializer specific ones. |
Thank you for the explanation. |
Probably better disabling renaming for the entire class using Confuser's attribute. This is not worth the effort. |
@fjch1997 Did you mean |
It's been a while since I had to use Confuser so I'm forgetting all the details. But yes, I mean ObfuscatorAttribute. Confuser doesn't have its own attributes. Actually you can set parameters to ObfuscatorAttribute to instruct ConfuserEx to only disable rename for a class and everything. I know this is not properly documented but it is supported. So overall it's quite powerful. I can't tell you how to use it since I don't even remember myself. But you can take a look at the samples and source code. |
#58
This way serialized data is fully compatible with unobfuscated version