diff options
author | William Scalf <wscalf@gmail.com> | 2023-08-13 18:35:10 -0400 |
---|---|---|
committer | William Scalf <wscalf@gmail.com> | 2023-08-13 18:35:10 -0400 |
commit | 41cf94e8b61ee81fc0e682f2ee4ea2c6df893d37 (patch) | |
tree | df51a5d8f0f871b6d765c29f439cbde572ac2d9b /modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs | |
parent | 7ba79d68bd0f97797d7cb37452da6a036ba7c7c9 (diff) | |
download | redot-engine-41cf94e8b61ee81fc0e682f2ee4ea2c6df893d37.tar.gz |
Allow readonly and writeonly C# properties to be accessed from GDScript
Diffstat (limited to 'modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs')
-rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs index 231a7be021..9de99414b6 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSerializationGenerator.cs @@ -119,8 +119,14 @@ namespace Godot.SourceGenerators .Where(s => !s.IsStatic && s.Kind == SymbolKind.Field && !s.IsImplicitlyDeclared) .Cast<IFieldSymbol>(); - var godotClassProperties = propertySymbols.WhereIsGodotCompatibleType(typeCache).ToArray(); - var godotClassFields = fieldSymbols.WhereIsGodotCompatibleType(typeCache).ToArray(); + // 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, without a setter or with an init-only setter. Godot properties must be both readable and writable. + var godotClassProperties = propertySymbols.Where(property => !(property.IsReadOnly || property.IsWriteOnly || property.SetMethod!.IsInitOnly)) + .WhereIsGodotCompatibleType(typeCache) + .ToArray(); + var godotClassFields = fieldSymbols.Where(property => !property.IsReadOnly) + .WhereIsGodotCompatibleType(typeCache) + .ToArray(); var signalDelegateSymbols = members .Where(s => s.Kind == SymbolKind.NamedType) |