You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Merge pull request #104279 from L2750558108/pr-fix-nested-in-generic-errors
Fix nested GodotObject class in generic class lead to source generator errors in C#
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Godot.SourceGenerators.Tests;
|
||||||
|
|
||||||
|
public class NestedInGenericTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async void GenerateScriptMethodsTest()
|
||||||
|
{
|
||||||
|
await CSharpSourceGeneratorVerifier<ScriptMethodsGenerator>.Verify(
|
||||||
|
"NestedInGeneric.cs",
|
||||||
|
"GenericClass(Of T).NestedClass_ScriptMethods.generated.cs"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Godot;
|
||||||
|
using Godot.NativeInterop;
|
||||||
|
|
||||||
|
partial class GenericClass<T>
|
||||||
|
{
|
||||||
|
partial class NestedClass
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword
|
||||||
|
/// <summary>
|
||||||
|
/// Cached StringNames for the methods contained in this class, for fast lookup.
|
||||||
|
/// </summary>
|
||||||
|
public new class MethodName : global::Godot.GodotObject.MethodName {
|
||||||
|
}
|
||||||
|
#pragma warning restore CS0109
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class GenericClass<T>
|
||||||
|
{
|
||||||
|
public partial class NestedClass : GodotObject
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -183,7 +183,7 @@ namespace Godot.SourceGenerators
|
|||||||
|
|
||||||
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
|
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
|
||||||
{
|
{
|
||||||
return symbol.IsGenericType ?
|
return symbol.IsGenericType && symbol.TypeParameters.Length > 0 ?
|
||||||
string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
|
string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
|
||||||
symbol.Name;
|
symbol.Name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ internal static class ExtensionMethods
|
|||||||
|
|
||||||
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
|
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
|
||||||
{
|
{
|
||||||
return symbol.IsGenericType ?
|
return symbol.IsGenericType && symbol.TypeParameters.Length > 0 ?
|
||||||
string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
|
string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
|
||||||
symbol.Name;
|
symbol.Name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user