You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
C#: Avoid generic types in the script path attribute generator
- Avoid generic types in `ScriptPathAttributeGenerator`, this means they won't be added to the `[AssemblyHasScripts]` attribute and a `[ScriptPath]` attribute won't be added to the class. Since generic classes can't be used as scripts they shouldn't use those attributes, this also makes CSharpScript consider those types invalid since they won't be added to the script/type map. - Avoid generic types in `ScriptManagerBridge.LookupScriptsInAssembly`. - Set `outMethodsDest` in `ScriptManagerBridge.UpdateScriptClassInfo`.
This commit is contained in:
@@ -45,8 +45,11 @@ namespace Godot.SourceGenerators
|
|||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
.Where(x =>
|
||||||
// Ignore classes whose name is not the same as the file name
|
// Ignore classes whose name is not the same as the file name
|
||||||
.Where(x => Path.GetFileNameWithoutExtension(x.cds.SyntaxTree.FilePath) == x.symbol.Name)
|
Path.GetFileNameWithoutExtension(x.cds.SyntaxTree.FilePath) == x.symbol.Name &&
|
||||||
|
// Ignore generic classes
|
||||||
|
!x.symbol.IsGenericType)
|
||||||
.GroupBy(x => x.symbol)
|
.GroupBy(x => x.symbol)
|
||||||
.ToDictionary(g => g.Key, g => g.Select(x => x.cds));
|
.ToDictionary(g => g.Key, g => g.Select(x => x.cds));
|
||||||
|
|
||||||
@@ -150,8 +153,6 @@ namespace Godot.SourceGenerators
|
|||||||
first = false;
|
first = false;
|
||||||
sourceBuilder.Append("typeof(");
|
sourceBuilder.Append("typeof(");
|
||||||
sourceBuilder.Append(qualifiedName);
|
sourceBuilder.Append(qualifiedName);
|
||||||
if (godotClass.Key.IsGenericType)
|
|
||||||
sourceBuilder.Append($"<{new string(',', godotClass.Key.TypeParameters.Count() - 1)}>");
|
|
||||||
sourceBuilder.Append(")");
|
sourceBuilder.Append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ namespace Godot.Bridge
|
|||||||
|
|
||||||
foreach (var type in assembly.GetTypes())
|
foreach (var type in assembly.GetTypes())
|
||||||
{
|
{
|
||||||
if (type.IsNested)
|
if (type.IsNested || type.IsGenericType)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!typeOfGodotObject.IsAssignableFrom(type))
|
if (!typeOfGodotObject.IsAssignableFrom(type))
|
||||||
@@ -314,9 +314,12 @@ namespace Godot.Bridge
|
|||||||
|
|
||||||
if (scriptTypes != null)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -729,6 +732,7 @@ namespace Godot.Bridge
|
|||||||
{
|
{
|
||||||
ExceptionUtils.LogException(e);
|
ExceptionUtils.LogException(e);
|
||||||
*outTool = godot_bool.False;
|
*outTool = godot_bool.False;
|
||||||
|
*outMethodsDest = NativeFuncs.godotsharp_array_new();
|
||||||
*outRpcFunctionsDest = NativeFuncs.godotsharp_dictionary_new();
|
*outRpcFunctionsDest = NativeFuncs.godotsharp_dictionary_new();
|
||||||
*outEventSignalsDest = NativeFuncs.godotsharp_dictionary_new();
|
*outEventSignalsDest = NativeFuncs.godotsharp_dictionary_new();
|
||||||
*outBaseScript = default;
|
*outBaseScript = default;
|
||||||
|
|||||||
Reference in New Issue
Block a user