You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Fix C# Hint NodeType and ResourceType HintString
This commit is contained in:
@@ -590,6 +590,11 @@ namespace Godot.SourceGenerators
|
|||||||
|
|
||||||
if (variantType == VariantType.Object && type is INamedTypeSymbol memberNamedType)
|
if (variantType == VariantType.Object && type is INamedTypeSymbol memberNamedType)
|
||||||
{
|
{
|
||||||
|
if (TryGetNodeOrResourceType(exportAttr, out hint, out hintString))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (memberNamedType.InheritsFrom("GodotSharp", "Godot.Resource"))
|
if (memberNamedType.InheritsFrom("GodotSharp", "Godot.Resource"))
|
||||||
{
|
{
|
||||||
hint = PropertyHint.ResourceType;
|
hint = PropertyHint.ResourceType;
|
||||||
@@ -607,6 +612,37 @@ namespace Godot.SourceGenerators
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool TryGetNodeOrResourceType(AttributeData exportAttr, out PropertyHint hint, out string? hintString)
|
||||||
|
{
|
||||||
|
hint = PropertyHint.None;
|
||||||
|
hintString = null;
|
||||||
|
|
||||||
|
if (exportAttr.ConstructorArguments.Length <= 1) return false;
|
||||||
|
|
||||||
|
var hintValue = exportAttr.ConstructorArguments[0].Value;
|
||||||
|
|
||||||
|
var hintEnum = hintValue switch
|
||||||
|
{
|
||||||
|
null => PropertyHint.None,
|
||||||
|
int intValue => (PropertyHint)intValue,
|
||||||
|
_ => (PropertyHint)(long)hintValue
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!hintEnum.HasFlag(PropertyHint.NodeType) && !hintEnum.HasFlag(PropertyHint.ResourceType))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var hintStringValue = exportAttr.ConstructorArguments[1].Value?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(hintStringValue))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hint = hintEnum;
|
||||||
|
hintString = hintStringValue;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static string GetTypeName(INamedTypeSymbol memberSymbol)
|
static string GetTypeName(INamedTypeSymbol memberSymbol)
|
||||||
{
|
{
|
||||||
if (memberSymbol.GetAttributes()
|
if (memberSymbol.GetAttributes()
|
||||||
|
|||||||
Reference in New Issue
Block a user