SDT1351: RmlDataEvent Non-Void Return Type
| Property | Value |
|---|---|
| Rule ID | SDT1351 |
| Title | RmlDataEvent Non-Void Return Type |
| Category | UI |
| Severity | Warning |
Cause
A method decorated with [RmlDataEvent] has a return type other than void.
Rule Description
RmlUi invokes event callbacks as fire-and-forget actions. Any return value produced by an [RmlDataEvent] method is discarded by the RmlUi runtime. Returning values from event handlers can give the false impression that RmlUi uses the result (for example, to prevent default behavior or consume bubbling events).
How to Fix Violations
Change the method return type to void.
Violation:
public sealed class DialogModel(RmlDataModelToken token) : RmlDataModel(token)
{
[RmlDataEvent]
public bool OnConfirm()
{
CloseDialog();
return true; // Return value is ignored!
}
}
Fix:
public sealed class DialogModel(RmlDataModelToken token) : RmlDataModel(token)
{
[RmlDataEvent]
public void OnConfirm()
{
CloseDialog();
}
}
When to Suppress Warnings
Info
You can safely suppress this warning if the method is reused across both RmlUi event bindings and C# code where callers explicitly consume the return value. However, refactoring into an explicit void event handler is recommended to avoid confusion.