You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
C#/netcore: Add base desktop game export implementation
This base implementation is still very barebones but it defines the path for how exporting will work (at least when embedding the .NET runtime). Many manual steps are still needed, which should be automatized in the future. For example, in addition to the API assemblies, now you also need to copy the GodotPlugins assembly to each game project.
This commit is contained in:
@@ -19,6 +19,11 @@ namespace Godot.SourceGenerators
|
||||
toggle != null &&
|
||||
toggle.Equals("disabled", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static bool IsGodotToolsProject(this GeneratorExecutionContext context)
|
||||
=> context.TryGetGlobalAnalyzerProperty("IsGodotToolsProject", out string? toggle) &&
|
||||
toggle != null &&
|
||||
toggle.Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static bool InheritsFrom(this INamedTypeSymbol? symbol, string baseName)
|
||||
{
|
||||
if (symbol == null)
|
||||
@@ -75,9 +80,48 @@ namespace Godot.SourceGenerators
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPartial(this ClassDeclarationSyntax cds)
|
||||
public static bool IsNested(this TypeDeclarationSyntax cds)
|
||||
=> cds.Parent is TypeDeclarationSyntax;
|
||||
|
||||
public static bool IsPartial(this TypeDeclarationSyntax cds)
|
||||
=> cds.Modifiers.Any(SyntaxKind.PartialKeyword);
|
||||
|
||||
public static bool AreAllOuterTypesPartial(
|
||||
this TypeDeclarationSyntax cds,
|
||||
out TypeDeclarationSyntax? typeMissingPartial
|
||||
)
|
||||
{
|
||||
SyntaxNode? outerSyntaxNode = cds.Parent;
|
||||
|
||||
while (outerSyntaxNode is TypeDeclarationSyntax outerTypeDeclSyntax)
|
||||
{
|
||||
if (!outerTypeDeclSyntax.IsPartial())
|
||||
{
|
||||
typeMissingPartial = outerTypeDeclSyntax;
|
||||
return false;
|
||||
}
|
||||
|
||||
outerSyntaxNode = outerSyntaxNode.Parent;
|
||||
}
|
||||
|
||||
typeMissingPartial = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetDeclarationKeyword(this INamedTypeSymbol namedTypeSymbol)
|
||||
{
|
||||
string? keyword = namedTypeSymbol.DeclaringSyntaxReferences
|
||||
.OfType<TypeDeclarationSyntax>().FirstOrDefault()?
|
||||
.Keyword.Text;
|
||||
|
||||
return keyword ?? namedTypeSymbol.TypeKind switch
|
||||
{
|
||||
TypeKind.Interface => "interface",
|
||||
TypeKind.Struct => "struct",
|
||||
_ => "class"
|
||||
};
|
||||
}
|
||||
|
||||
private static SymbolDisplayFormat FullyQualifiedFormatOmitGlobal { get; } =
|
||||
SymbolDisplayFormat.FullyQualifiedFormat
|
||||
.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted);
|
||||
|
||||
Reference in New Issue
Block a user