Restructured
Re-Organized structure to allow for a Generator, and a Core library to be included.
This commit is contained in:
parent
c1d61d8a5c
commit
44c3d49aad
7 changed files with 18 additions and 15 deletions
|
|
@ -39,14 +39,14 @@ public class ActionGenerator : IIncrementalGenerator
|
||||||
using System;
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Godot.Sharp.Extended;
|
namespace Godot.Sharp.Extended.Generators;
|
||||||
|
|
||||||
public partial class Actions
|
public partial class Actions
|
||||||
{
|
{
|
||||||
{{memberCode}}
|
{{memberCode}}
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
ctx.AddSource("Godot.Sharp.Extended.Actions.g.cs", SourceText.From(code, Encoding.UTF8));
|
ctx.AddSource("Godot.Sharp.Extended.Generators.Actions.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetActions(string content)
|
public List<string> GetActions(string content)
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<!-- Nuget Tags -->
|
<!-- Nuget Tags -->
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<PackageId>Godot.Sharp.Extended</PackageId>
|
<PackageId>Godot.Sharp.Extended.Generators</PackageId>
|
||||||
<AssemblyTitle>Godot Sharp Extended</AssemblyTitle>
|
<AssemblyTitle>Godot Sharp Extended</AssemblyTitle>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Authors>Mario Steele</Authors>
|
<Authors>Mario Steele</Authors>
|
||||||
|
|
@ -47,5 +47,8 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Generators\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -14,7 +14,7 @@ public class NodeBindGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
private const string AttributeSourceCode = """
|
private const string AttributeSourceCode = """
|
||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
namespace Godot.Sharp.Extended;
|
namespace Godot.Sharp.Extended.Generators;
|
||||||
|
|
||||||
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
|
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
|
||||||
public class NodeBindAttribute : Attribute
|
public class NodeBindAttribute : Attribute
|
||||||
|
|
@ -60,7 +60,7 @@ public class NodeBindGenerator : IIncrementalGenerator
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var attributeName = symbol.ContainingType.ToDisplayString();
|
var attributeName = symbol.ContainingType.ToDisplayString();
|
||||||
if (attributeName == $"Godot.Sharp.Extended.NodeBind")
|
if (attributeName == $"Godot.Sharp.Extended.Generators.NodeBind")
|
||||||
return declarationSyntax;
|
return declarationSyntax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ public class NodeBindGenerator : IIncrementalGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
ctx.AddSource($"Godot.Sharp.Extended.{definition.ClassName}.NodeBind.g.cs", SourceText.From(code, Encoding.UTF8));
|
ctx.AddSource($"Godot.Sharp.Extended.Generators.{definition.ClassName}.NodeBind.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ClassDefinition
|
private class ClassDefinition
|
||||||
|
|
@ -15,7 +15,7 @@ public class NodePropBindGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
private const string AttributeSourceCode = """
|
private const string AttributeSourceCode = """
|
||||||
// <auto-generated/>
|
// <auto-generated/>
|
||||||
namespace Godot.Sharp.Extended;
|
namespace Godot.Sharp.Extended.Generators;
|
||||||
|
|
||||||
[System.AttributeUsage(System.AttributeTargets.Member)]
|
[System.AttributeUsage(System.AttributeTargets.Member)]
|
||||||
public class NodePropBindAttribute : System.Attribute
|
public class NodePropBindAttribute : System.Attribute
|
||||||
|
|
@ -69,7 +69,7 @@ public class NodePropBindGenerator : IIncrementalGenerator
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var attributeName = symbol.ContainingType.ToDisplayString();
|
var attributeName = symbol.ContainingType.ToDisplayString();
|
||||||
if (attributeName == "Godot.Sharp.Extended.NodePropBind")
|
if (attributeName == "Godot.Sharp.Extended.Generators.NodePropBind")
|
||||||
return declarationSyntax;
|
return declarationSyntax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class NodePropBindGenerator : IIncrementalGenerator
|
||||||
if (semanticModel.GetDeclaredSymbol(variable) is not IFieldSymbol fieldSymbol) continue;
|
if (semanticModel.GetDeclaredSymbol(variable) is not IFieldSymbol fieldSymbol) continue;
|
||||||
|
|
||||||
var attributeData = fieldSymbol.GetAttributes()
|
var attributeData = fieldSymbol.GetAttributes()
|
||||||
.FirstOrDefault(ad => ad.AttributeClass?.ToDisplayString() == "Godot.Sharp.Extended.NodePropBindAttribute");
|
.FirstOrDefault(ad => ad.AttributeClass?.ToDisplayString() == "Godot.Sharp.Extended.Generators.NodePropBindAttribute");
|
||||||
|
|
||||||
if (attributeData is null) continue;
|
if (attributeData is null) continue;
|
||||||
|
|
||||||
|
|
@ -159,7 +159,7 @@ public class NodePropBindGenerator : IIncrementalGenerator
|
||||||
{{propCode}}
|
{{propCode}}
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
context.AddSource($"Godot.Sharp.Extended.{definition.ClassName}.NodeBind.g.cs", SourceText.From(code, Encoding.UTF8));
|
context.AddSource($"Godot.Sharp.Extended.Generators.{definition.ClassName}.NodeBind.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ClassDefinition(string theNamespace, string className, HashSet<string> usingNamespaceName, List<MemberDefinition> memberDefinitions)
|
private class ClassDefinition(string theNamespace, string className, HashSet<string> usingNamespaceName, List<MemberDefinition> memberDefinitions)
|
||||||
|
|
@ -16,7 +16,7 @@ public class ResourceGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
private const string AttributeSourceCode = """
|
private const string AttributeSourceCode = """
|
||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
namespace Godot.Sharp.Extended;
|
namespace Godot.Sharp.Extended.Generators;
|
||||||
|
|
||||||
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
|
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
|
||||||
public class ResourcePathAttribute : System.Attribute
|
public class ResourcePathAttribute : System.Attribute
|
||||||
|
|
@ -82,7 +82,7 @@ public class ResourceGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
var symbolInfo = ctx.SemanticModel.GetSymbolInfo(attributeSyntax);
|
var symbolInfo = ctx.SemanticModel.GetSymbolInfo(attributeSyntax);
|
||||||
if (symbolInfo.Symbol is not IMethodSymbol attributeSymbol) continue;
|
if (symbolInfo.Symbol is not IMethodSymbol attributeSymbol) continue;
|
||||||
if (attributeSymbol.ContainingType.ToDisplayString() != "Godot.Sharp.Extended.ResourcePath") continue;
|
if (attributeSymbol.ContainingType.ToDisplayString() != "Godot.Sharp.Extended.Generators.ResourcePath") continue;
|
||||||
var parameter = attributeSyntax.ArgumentList;
|
var parameter = attributeSyntax.ArgumentList;
|
||||||
var pathArgument = parameter?.Arguments[0];
|
var pathArgument = parameter?.Arguments[0];
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ public class ResourceGenerator : IIncrementalGenerator
|
||||||
{{allMethod}}
|
{{allMethod}}
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
context.AddSource($"Godot.Sharp.Extended.{classDefinition.ClassName}.Res.g.cs", SourceText.From(code, Encoding.UTF8));
|
context.AddSource($"Godot.Sharp.Extended.Generators.{classDefinition.ClassName}.Res.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class SceneGenerator : IIncrementalGenerator
|
||||||
using System;
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Godot.Sharp.Extended;
|
namespace Godot.Sharp.Extended.Generators;
|
||||||
|
|
||||||
public class Scenes
|
public class Scenes
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ public class SceneGenerator : IIncrementalGenerator
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
context.AddSource("Godot.Sharp.Extended.Scenes.g.cs", SourceText.From(code, Encoding.UTF8));
|
context.AddSource("Godot.Sharp.Extended.Generators.Scenes.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue