Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GD0105: The exported property is an indexer

规则 ID

GD0105

类别

用法

修复是中断修复还是非中断修复

Non-breaking

默认启用

原因

An indexer is annotated with the [Export] attribute. Indexers can't be exported.

规则说明

Godot doesn't allow exporting indexer properties.

private int[] _backingField;

// Indexers can't be exported.
[Export]
public int this[int index]
{
    get => _backingField[index];
    set => _backingField[index] = value;
}

如何解决冲突

To fix a violation of this rule, remove the [Export] attribute.

何时禁止显示警告

Do not suppress a warning from this rule. Indexers can't be exported so they will be ignored by Godot, resulting in runtime errors.