SDT0404: Non Void Method Mapping
| Property | Value |
|---|---|
| Rule ID | SDT0451 |
| Title | Non Void Method Mapping |
| Category | Input |
| Severity | Warning |
Cause
A method is decorated with [ActionInput] or [RangeInput], but it has a non-void return type.
Rule Description
When a method is decorated with an action- or range input attribute, it should not provide any return type.
How to Fix Violations
Remove the return type and mark it as void
Violation:
public sealed class PlayerInputState : IInputReceiver
{
[RangeInput(PlayerActions.WalkForward)]
public float StartWalk(float target) { // non-void return type!
// ...
}
}
Fix:
public sealed class PlayerInputState : IInputReceiver
{
[RangeInput(PlayerActions.WalkForward)]
public void StartWalk(float target) {
// ...
}
}
When to Suppress Warnings
Info
You may suppress this warning if the method is invoked by a process that requires a return value, however refactoring to side-step this effect is highly recommended.