Skip to content

Commit ea2742f

Browse files
committed
Adding fix
1 parent 04fb986 commit ea2742f

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

SourceGenerators/SceneTreeExtensions/SceneTreeScraper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void NodeMatch()
6868
var parentPath = values.Get("parent");
6969
var resourceId = values.Get("instance");
7070
if (values.Get("instance_placeholder") is not null) nodeType = "InstancePlaceholder";
71+
else if (nodeType is not null) nodeType = compilation.ValidateTypeIgnoreCase("GodotSharp", "Godot", values.Get("type"));
7172
if (resourceId is not null) resourceId = ResIdRegex.Match(resourceId).Groups["Id"].Value;
7273

7374
var nodePath = GetNodePath();

SourceGenerators/Utilities/Extensions/CompilationExtensions.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,25 @@ void ResolveDuplicates()
3535
}
3636
}
3737
}
38+
39+
public static string ValidateTypeIgnoreCase(this Compilation compilation, string assemblyName, string namespaceName, string type)
40+
{
41+
var assemblyRef = compilation.References
42+
.OfType<PortableExecutableReference>()
43+
.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x.FilePath) == assemblyName);
44+
if (assemblyRef is null) return type;
45+
46+
var assemblySymbol = (IAssemblySymbol)compilation.GetAssemblyOrModuleSymbol(assemblyRef);
47+
if (assemblySymbol is null) return type;
48+
49+
var namespaceSymbol = assemblySymbol.GlobalNamespace.GetNamespaceMembers()?.FirstOrDefault(x => x.Name == namespaceName);
50+
if (namespaceSymbol is null) return type;
51+
52+
var typeSymbol = namespaceSymbol.GetTypeMembers().FirstOrDefault(x => CompareNameIgnoreCase(x.Name));
53+
return typeSymbol?.Name ?? type;
54+
55+
bool CompareNameIgnoreCase(string name)
56+
=> string.Equals(type, name, StringComparison.OrdinalIgnoreCase);
57+
}
3858
}
3959
}

0 commit comments

Comments
 (0)