Updated Generators

Removed un-nesscary Attribute generation, as now is part of core.
This commit is contained in:
Mario Steele 2025-09-26 20:15:14 -05:00
parent 02d23935fa
commit d96fbaf0e9
3 changed files with 8 additions and 54 deletions

View file

@ -13,28 +13,8 @@ namespace Godot.Sharp.Extended.Generators;
[Generator]
public class NodePropBindGenerator : IIncrementalGenerator
{
private const string AttributeSourceCode = """
// <auto-generated/>
namespace Godot.Sharp.Extended.Generators;
[System.AttributeUsage(System.AttributeTargets.Member)]
public class NodePropBindAttribute : System.Attribute
{
public string TargetNodeName { get; private set; }
public string GodotPropertyName { get; private set; }
public NodePropBindAttribute(string targetNodeName, string godotPropertyName)
{
TargetNodeName = targetNodeName;
GodotPropertyName = godotPropertyName;
}
}
""";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterPostInitializationOutput(ctx => ctx.AddSource(
"NodePropBind.g.cs",
SourceText.From(AttributeSourceCode, Encoding.UTF8)));
var propertyProvider = context.SyntaxProvider
.CreateSyntaxProvider(
@ -69,7 +49,7 @@ public class NodePropBindGenerator : IIncrementalGenerator
continue;
var attributeName = symbol.ContainingType.ToDisplayString();
if (attributeName == "Godot.Sharp.Extended.Generators.NodePropBind")
if (attributeName == "Godot.Sharp.Extended.Attributes.NodePropBind")
return declarationSyntax;
}
@ -132,7 +112,11 @@ public class NodePropBindGenerator : IIncrementalGenerator
propCode.AppendLine($$"""
public {{memberDefinition.Type}} {{propName}}
{
get => {{memberDefinition.Name}};
get {
if ({{memberDefinition.NodeProp}} == null)
return {{memberDefinition.Name}};
return {{memberDefinition.NodeProp}}.{{godotProp}};
}
set {
{{memberDefinition.Name}} = value;
if ({{memberDefinition.NodeProp}} != null)