@@ -255,7 +255,31 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters
255255 else if ( parameters . GetParameter ( context , property , "forceRen" , false ) )
256256 return ;
257257
258- else if ( property . DeclaringType . Implements ( "System.ComponentModel.INotifyPropertyChanged" ) )
258+ /*
259+ * System.Xml.Serialization.XmlSerializer
260+ *
261+ * XmlSerializer by default serializes fields marked with [NonSerialized]
262+ * This is a work-around that causes all fields in a class marked [Serializable]
263+ * to _not_ be renamed, unless marked with [XmlIgnoreAttribute]
264+ *
265+ * If we have a way to detect which serializer method the code is going to use
266+ * for the class, or if Microsoft makes XmlSerializer respond to [NonSerialized]
267+ * we'll have a more accurate way to achieve this.
268+ */
269+ else if ( property . DeclaringType . IsSerializable ) // && !field.IsNotSerialized)
270+ service . SetCanRename ( property , false ) ;
271+
272+ else if ( property . DeclaringType . IsSerializable && ( property . CustomAttributes . IsDefined ( "XmlIgnore" )
273+ || property . CustomAttributes . IsDefined ( "XmlIgnoreAttribute" )
274+ || property . CustomAttributes . IsDefined ( "System.Xml.Serialization.XmlIgnore" )
275+ || property . CustomAttributes . IsDefined ( "System.Xml.Serialization.XmlIgnoreAttribute" )
276+ || property . CustomAttributes . IsDefined ( "T:System.Xml.Serialization.XmlIgnoreAttribute" ) ) ) // Can't seem to detect CustomAttribute
277+ service . SetCanRename ( property , true ) ;
278+ /*
279+ * End of XmlSerializer work-around
280+ */
281+
282+ else if ( property . DeclaringType . Implements ( "System.ComponentModel.INotifyPropertyChanged" ) )
259283 service . SetCanRename ( property , false ) ;
260284
261285 else if ( property . DeclaringType . Name . String . Contains ( "AnonymousType" ) )
0 commit comments