diff options
author | Raul Santos <raulsntos@gmail.com> | 2022-12-23 18:59:08 +0100 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2022-12-23 19:04:14 +0100 |
commit | 03c26d661856bdbd110e00aa502c018acfdd0e70 (patch) | |
tree | a1712e7823dbfb6e4cf051c1a21435b5b00e5c62 /modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs | |
parent | d0398f62f08ce0cfba80990b21c6af4181f93fe9 (diff) |
C#: Disallow init-only properties
ReadOnly properties are currently not allowed because the generated code
needs to set them, this also apply to `init` properties because they
need to be set after initialization.
Diffstat (limited to 'modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs')
-rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs index d67e57edc2..8852b7ebad 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs @@ -295,8 +295,8 @@ namespace Godot.SourceGenerators foreach (var property in properties) { // TODO: We should still restore read-only properties after reloading assembly. Two possible ways: reflection or turn RestoreGodotObjectData into a constructor overload. - // Ignore properties without a getter or without a setter. Godot properties must be both readable and writable. - if (property.IsWriteOnly || property.IsReadOnly) + // Ignore properties without a getter, without a setter or with an init-only setter. Godot properties must be both readable and writable. + if (property.IsWriteOnly || property.IsReadOnly || property.SetMethod!.IsInitOnly) continue; var marshalType = MarshalUtils.ConvertManagedTypeToMarshalType(property.Type, typeCache); |