Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GD0105: Attempted to export indexer property

规则 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.