Table of Contents

Diagnostics Warning STRDIAG005

The [DataMember] Attribute is applied to a read-only member '{0}' with a non supported type. Only mutable reference types are supported for read-only members.

Explanation

Having no set possibility automatically lets the serializers automatically use the DataMemberMode.Content. For immutable types the DataMemberMode.Content is never valid. Immutable types in this context are none reference types and string.

Example

The following example generates STRDIAG005 on each property:

using Stride.Core;

public class STRDIAG005
{
    [DataMember]
    public readonly int Value;
    [DataMember]
    public string Value { get; }
}

Solution

To resolve the warning for fields, remove the [DataMember] attribute or remove the readonly modifier.

To resolve the warning for properties, alter the type of the property to a supported type or remove the [DataMember] attribute.