Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Fix generated nested class order #83532

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace Godot.SourceGenerators.Sample;

public partial class NestedClass : GodotObject
{
public partial class NestedClass2 : GodotObject
{
public partial class NestedClass3 : GodotObject
{
[Signal]
public delegate void MySignalEventHandler(string str, int num);

[Export] private String field_String = "foo";
[Export] private String property_String { get; set; } = "foo";

private void Method()
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,20 @@ INamedTypeSymbol symbol
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ INamedTypeSymbol symbol
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,20 @@ INamedTypeSymbol symbol
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ INamedTypeSymbol symbol
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,20 @@ INamedTypeSymbol symbol
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ private void GenerateInteropMethodImplementations(GeneratorExecutionContext cont
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down Expand Up @@ -303,16 +307,20 @@ private void GenerateUnmanagedCallbacksStruct(GeneratorExecutionContext context,
if (isInnerClass)
{
var containingType = symbol.ContainingType;
AppendPartialContainingTypeDeclarations(containingType);

while (containingType != null)
void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType)
{
if (containingType == null)
return;

AppendPartialContainingTypeDeclarations(containingType.ContainingType);

source.Append("partial ");
source.Append(containingType.GetDeclarationKeyword());
source.Append(" ");
source.Append(containingType.NameWithTypeParameters());
source.Append("\n{\n");

containingType = containingType.ContainingType;
}
}

Expand Down