SDT0404: Incompatible Method Mapping

Property Value
Rule ID SDT0406
Title Incompatible Method Mapping
Category Input
Severity Error

Cause

A method is decorated with [ActionInput] or [RangeInput], but its signature is incompatible with the mapping attribute.

Rule Description

When a method is decorated with an action- or range input attribute, it must have the appropriate signature.

How to Fix Violations

Ensure every method have a valid type depending on the attribute. For [ActionInput] this is either a void method with no input parameters, OR a single bool input parameter, and for [RangeInput] this strictly a single float or double input parameter.

Violation:

public sealed class PlayerInputState : IInputReceiver 
{
    [ActionInput(PlayerActions.Jump)]
    public void Jump(float strength) { // Incompatible signature!
        // ...
    } 

    [RangeInput(PlayerActions.WalkForward)]
    public void WalkForward() { // Incompatible signature! Missing float/double!
        // ...
    } 
}

Fix:

public sealed class PlayerInputState : IInputReceiver 
{
    [ActionInput(PlayerActions.Jump)]
    public void Jump() { 
        // ...
    } 

    [RangeInput(PlayerActions.WalkForward)]
    public void WalkForward(double amount) {
        // ...
    } 
}

When to Suppress Warnings

Danger

Do not suppress this error. Incorrectly typed method mappings will cause runtime crashes when attempting to register the input receiver.