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.
Checking the stable version of the documentation...
GD0104:被匯出的屬性為唯寫(write-only)
規則 ID |
GD0104 |
分類 |
用法 |
修正是否會破壞相容性 |
非破壞性 |
預設啟用 |
是 |
原因
唯寫屬性被標註為 [Export]。唯寫屬性無法被匯出。
規則說明
Godot 不允許匯出唯寫屬性。
private int _backingField;
// Write-only properties can't be exported.
[Export]
public int InvalidProperty { set => _backingField = value; }
// This property can be exported because it has both a getter and a setter.
[Export]
public int ValidProperty { get; set; }
修正方式
要修正此規則的違規情形,請確保屬性同時有 getter 與 setter,或移除 [Export] 屬性。
什麼時候應該忽略警告
請勿忽略此規則的警告。唯寫成員無法被匯出,Godot 會忽略該成員,造成執行階段錯誤。