Diagnostics Warning STRDIAG006
Invalid DataMemberMode for the specified
[DataMember]member '{0}'. A public/internal/internal protected setter is required for 'DataMemberMode.Assign'.
Explanation
The Assign let's the serializers create new objects and sets them into the target property. The Property needs an accessible/visible setter.
Example: Invalid Cases
The following example generates STRDIAG006:
using Stride.Core;
public class STRDIAG006
{
// non existent setters count as non visible
[DataMember(DataMemberMode.Assign)]
public int Property1 { get; }
[DataMember(DataMemberMode.Assign)]
public int Property2 { get; private set; }
[DataMember(DataMemberMode.Assign)]
public int Property3 { get; protected set; }
[DataMember(DataMemberMode.Assign)]
public int Property4 { get; private protected set; }
}
Example: Special Case internal
Important
To explicitly set the DataMemberMode.Assign the DataMemberAttribute has to be applied.
Internal visibility counts then as visible for the serializers and becomes valid.
using Stride.Core;
public class STRDIAG006
{
// non existent setters count as non visible
[DataMember(DataMemberMode.Assign)]
public int Property1 { get; internal set; }
[DataMember(DataMemberMode.Assign)]
public int Property2 { get; internal protected set; }
}
Solution
To resolve the warning, increase the accessibility of the properties set to public/internal. Or remove the explicit DataMemberMode.Assign, this can result in the DataMemberMode.Content, if the property is a non valuetype/string type.