When I use the 'Easy Save Types' window to create an ES3Type, the generated type is incorrect:
Here is the custom type:
/// <summary> /// Manage a profile /// </summary> [Serializable] // Needed for ES3 serialization (and also, the fields must NOT begin with 'm_', or they won't be serialized) public class QProfile { /// <summary>The name of the profile</summary> public String Name { get { return _Name; } } private String _Name = String.Empty; /// <summary>The path of the profile</summary> public String Path { get { return m_Path; } internal set { m_Path = value; } } private String m_Path = String.Empty; /// <summary> /// Standard cosntructor /// </summary> public QProfile() { _Name = String.Empty; m_Path = String.Empty; } /// <summary> /// Standard cosntructor /// </summary> public QProfile(String ProfileName) { _Name = ProfileName; m_Path = String.Empty; } }Here is the window that shows that the detection is correct:
Here is the generated code:
[ES3PropertiesAttribute("_Name")] public class ES3Type_QProfile : ES3ObjectType { public static ES3Type Instance = null; public ES3Type_QProfile() : base(typeof(Common.Types.QProfile)){ Instance = this; } protected override void WriteObject(object obj, ES3Writer writer) { var instance = (Common.Types.QProfile)obj; writer.WritePrivateProperty("_Name", instance); } protected override void ReadObject<T>(ES3Reader reader, object obj) { var instance = (Common.Types.QProfile)obj; foreach(string propertyName in reader.Properties) { switch(propertyName) { case "_Name": reader.SetPrivateField("_Name", reader.Read<System.String>(), instance); break; default: reader.Skip(); break; } } } protected override object ReadObject<T>(ES3Reader reader) { var instance = new Common.Types.QProfile(); ReadObject<T>(reader, instance); return instance; } } public class ES3Type_QProfileArray : ES3ArrayType { public static ES3Type Instance; public ES3Type_QProfileArray() : base(typeof(Common.Types.QProfile[]), ES3Type_QProfile.Instance) { Instance = this; } }As you can see, while the read part uses 'SetPrivateField()', which seems to be OK, the write part uses 'WritePrivateProperty()', which seems to be incorrect (and by following it, it really looks for a property, and fail).
Also, in the generated code, there's a couple of suspicious things, but they're probably not a problem:
- '[ES3PropertiesAttribute("_Name")]': It is a field, not a property
- 'foreach(string propertyName in reader.Properties)': Again, it is a field, not a property
- 'switch(propertyName)': Again, it is a field, not a property
To be more precise with namings, when speaking about either a property or a field I've always found it better to refer to it as 'Member'.