You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
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.
This commit is contained in:
@@ -158,7 +158,7 @@ namespace Godot.SourceGenerators
|
||||
// Generate SetGodotClassPropertyValue
|
||||
|
||||
bool allPropertiesAreReadOnly = godotClassFields.All(fi => fi.FieldSymbol.IsReadOnly) &&
|
||||
godotClassProperties.All(pi => pi.PropertySymbol.IsReadOnly);
|
||||
godotClassProperties.All(pi => pi.PropertySymbol.IsReadOnly || pi.PropertySymbol.SetMethod!.IsInitOnly);
|
||||
|
||||
if (!allPropertiesAreReadOnly)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace Godot.SourceGenerators
|
||||
isFirstEntry = true;
|
||||
foreach (var property in godotClassProperties)
|
||||
{
|
||||
if (property.PropertySymbol.IsReadOnly)
|
||||
if (property.PropertySymbol.IsReadOnly || property.PropertySymbol.SetMethod!.IsInitOnly)
|
||||
continue;
|
||||
|
||||
GeneratePropertySetter(property.PropertySymbol.Name,
|
||||
@@ -407,7 +407,7 @@ namespace Godot.SourceGenerators
|
||||
return null;
|
||||
}
|
||||
|
||||
if (propertySymbol.SetMethod == null)
|
||||
if (propertySymbol.SetMethod == null || propertySymbol.SetMethod.IsInitOnly)
|
||||
{
|
||||
// This should never happen, as we filtered ReadOnly properties, but just in case.
|
||||
Common.ReportExportedMemberIsReadOnly(context, propertySymbol);
|
||||
|
||||
Reference in New Issue
Block a user