Skip to content

Commit

Permalink
Merge pull request #70511 from raulsntos/dotnet/fix-update-script-cla…
Browse files Browse the repository at this point in the history
…ss-info

C#: Skip getting class info for unbound generics
  • Loading branch information
neikeq authored Dec 30, 2022
2 parents a754930 + a43e828 commit 0daa86d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public void Execute(GeneratorExecutionContext context)
return false;
})
)
// Ignore classes whose name is not the same as the file name
.Where(x => Path.GetFileNameWithoutExtension(x.cds.SyntaxTree.FilePath) == x.symbol.Name)
.Where(x =>
// Ignore classes whose name is not the same as the file name
Path.GetFileNameWithoutExtension(x.cds.SyntaxTree.FilePath) == x.symbol.Name &&
// Ignore generic classes
!x.symbol.IsGenericType)
.GroupBy(x => x.symbol)
.ToDictionary(g => g.Key, g => g.Select(x => x.cds));

Expand Down Expand Up @@ -150,8 +153,6 @@ private static void AddScriptTypesAssemblyAttr(GeneratorExecutionContext context
first = false;
sourceBuilder.Append("typeof(");
sourceBuilder.Append(qualifiedName);
if (godotClass.Key.IsGenericType)
sourceBuilder.Append($"<{new string(',', godotClass.Key.TypeParameters.Count() - 1)}>");
sourceBuilder.Append(")");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static void LookupScriptForClass(Type type)

foreach (var type in assembly.GetTypes())
{
if (type.IsNested)
if (type.IsNested || type.IsGenericType)
continue;

if (!typeOfGodotObject.IsAssignableFrom(type))
Expand All @@ -314,9 +314,12 @@ static void LookupScriptForClass(Type type)

if (scriptTypes != null)
{
for (int i = 0; i < scriptTypes.Length; i++)
foreach (var type in scriptTypes)
{
LookupScriptForClass(scriptTypes[i]);
if (type.IsGenericType)
continue;

LookupScriptForClass(type);
}
}
}
Expand Down Expand Up @@ -729,6 +732,7 @@ internal static unsafe void UpdateScriptClassInfo(IntPtr scriptPtr, godot_bool*
{
ExceptionUtils.LogException(e);
*outTool = godot_bool.False;
*outMethodsDest = NativeFuncs.godotsharp_array_new();
*outRpcFunctionsDest = NativeFuncs.godotsharp_dictionary_new();
*outEventSignalsDest = NativeFuncs.godotsharp_dictionary_new();
*outBaseScript = default;
Expand Down

0 comments on commit 0daa86d

Please sign in to comment.