SDT1302: Too Many RML Data Type Implementations

Property Value
Rule ID SDT1302
Title Too Many RML Data Type Implementations
Category UI
Severity Error

Cause

A class implements more than one of the RML data marker interfaces (IRmlDataArray, IRmlDataStruct, or IRmlDataScalar).

Rule Description

Each RML data type must have a single, unambiguous role within the data-binding system. A type cannot simultaneously function as a struct and an array, or as a scalar and a struct. Implementing multiple marker interfaces creates conflicting serialization and traversal paths in RmlUi.

How to Fix Violations

Ensure that the class implements only one marker interface. If a type needs to expose structured fields as well as a list or scalar, split the responsibilities into nested types.

Violation:

public sealed class PlayerStats : IRmlDataStruct, IRmlDataScalar
{
    [RmlDataVariable] public int Health;

    public RmlVariant Get() => Health;
    public void Set(RmlVariant data) => Health = data;
}

Fix:

public sealed class PlayerStats : IRmlDataStruct
{
    [RmlDataVariable] public int Health;
}

When to Suppress Warnings

Danger

Do not suppress this error. Implementing multiple RML data marker interfaces creates ambiguous registration rules in the RmlUi type system, causing unexpected behavior or initialization crashes at runtime.