SDT1309: RmlDataVariable Outside Valid Type
| Property | Value |
|---|---|
| Rule ID | SDT1309 |
| Title | RmlDataVariable Outside Valid Type |
| Category | UI |
| Severity | Error |
Cause
The [RmlDataVariable] attribute is placed on a member whose containing type does not implement IRmlDataStruct and does not derive from RmlDataModel.
Rule Description
The [RmlDataVariable] attribute designates a field or property as a bindable element for RmlUi. The data-binding engine only discovers and registers variables inside:
* Classes derived from RmlDataModel (the root binding scope)
* Classes implementing IRmlDataStruct (nested structured data)
Placing [RmlDataVariable] inside any other class, struct, or service has no effect and indicates an architectural mistake.
How to Fix Violations
Implement IRmlDataStruct on the containing class, derive from RmlDataModel, or remove [RmlDataVariable] if the member should not be bound to UI markup.
Violation:
public sealed class PlayerComponent
{
// Not an IRmlDataStruct or RmlDataModel!
[RmlDataVariable] public string PlayerName = string.Empty;
}
Fix:
public sealed class PlayerDataStruct : IRmlDataStruct
{
[RmlDataVariable] public string PlayerName = string.Empty;
}
When to Suppress Warnings
Danger
Do not suppress this error. Variables decorated with [RmlDataVariable] outside an IRmlDataStruct or RmlDataModel will never be bound by RmlUi, resulting in inactive bindings in your UI documents.