SDT0405: Incompatible Field/Property Mapping
| Property | Value |
|---|---|
| Rule ID | SDT0405 |
| Title | Incompatible Field/Property Mapping |
| Category | Input |
| Severity | Error |
Cause
A field or property is decorated with [ActionInput] or [RangeInput], but its type is incompatible with the mapping attribute.
Rule Description
When a field or property is decorated with an action- or range input attribute, it must have the appropriate type.
How to Fix Violations
Ensure every field and property must have a valid type depending on the attribute. For [ActionInput] this is a bool, and for [RangeInput] this is a float or double.
Violation:
public sealed class PlayerInputState : IInputReceiver
{
[ActionInput(PlayerActions.Crouch)]
public int IsCrouching = 0; // Incompatible type!
[RangeInput(PlayerActions.WalkForward)]
public decimal WalkForward = 0.0; // Incompatible type!
}
Fix:
public sealed class PlayerInputState : IInputReceiver
{
[ActionInput(PlayerActions.Crouch)]
public bool IsCrouching = false;
[RangeInput(PlayerActions.WalkForward)]
public float WalkForward = 0.0F;
}
When to Suppress Warnings
Danger
Do not suppress this error. Incorrectly typed field or property mappings will cause runtime crashes when attempting to register the input receiver.