Browse Source

C#: Compare symbol names without null flow state

Raul Santos 2 years ago
parent
commit
671a5b4ea5

+ 7 - 7
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs

@@ -37,7 +37,7 @@ namespace Godot.SourceGenerators
             while (symbol != null)
             while (symbol != null)
             {
             {
                 if (symbol.ContainingAssembly?.Name == assemblyName &&
                 if (symbol.ContainingAssembly?.Name == assemblyName &&
-                    symbol.ToString() == typeFullName)
+                    symbol.FullQualifiedNameOmitGlobal() == typeFullName)
                 {
                 {
                     return true;
                     return true;
                 }
                 }
@@ -230,22 +230,22 @@ namespace Godot.SourceGenerators
                 .Replace(">", ")");
                 .Replace(">", ")");
 
 
         public static bool IsGodotExportAttribute(this INamedTypeSymbol symbol)
         public static bool IsGodotExportAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.ExportAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.ExportAttr;
 
 
         public static bool IsGodotSignalAttribute(this INamedTypeSymbol symbol)
         public static bool IsGodotSignalAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.SignalAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.SignalAttr;
 
 
         public static bool IsGodotMustBeVariantAttribute(this INamedTypeSymbol symbol)
         public static bool IsGodotMustBeVariantAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.MustBeVariantAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.MustBeVariantAttr;
 
 
         public static bool IsGodotClassNameAttribute(this INamedTypeSymbol symbol)
         public static bool IsGodotClassNameAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.GodotClassNameAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.GodotClassNameAttr;
 
 
         public static bool IsGodotGlobalClassAttribute(this INamedTypeSymbol symbol)
         public static bool IsGodotGlobalClassAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.GlobalClassAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.GlobalClassAttr;
 
 
         public static bool IsSystemFlagsAttribute(this INamedTypeSymbol symbol)
         public static bool IsSystemFlagsAttribute(this INamedTypeSymbol symbol)
-            => symbol.ToString() == GodotClasses.SystemFlagsAttr;
+            => symbol.FullQualifiedNameOmitGlobal() == GodotClasses.SystemFlagsAttr;
 
 
         public static GodotMethodData? HasGodotCompatibleSignature(
         public static GodotMethodData? HasGodotCompatibleSignature(
             this IMethodSymbol method,
             this IMethodSymbol method,

+ 1 - 1
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs

@@ -362,7 +362,7 @@ namespace Godot.SourceGenerators
         {
         {
             foreach (var attr in memberSymbol.GetAttributes())
             foreach (var attr in memberSymbol.GetAttributes())
             {
             {
-                PropertyUsageFlags? propertyUsage = attr.AttributeClass?.ToString() switch
+                PropertyUsageFlags? propertyUsage = attr.AttributeClass?.FullQualifiedNameOmitGlobal() switch
                 {
                 {
                     GodotClasses.ExportCategoryAttr => PropertyUsageFlags.Category,
                     GodotClasses.ExportCategoryAttr => PropertyUsageFlags.Category,
                     GodotClasses.ExportGroupAttr => PropertyUsageFlags.Group,
                     GodotClasses.ExportGroupAttr => PropertyUsageFlags.Group,

+ 1 - 1
modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/ExtensionMethods.cs

@@ -38,7 +38,7 @@ internal static class ExtensionMethods
     }
     }
 
 
     private static bool IsGenerateUnmanagedCallbacksAttribute(this INamedTypeSymbol symbol)
     private static bool IsGenerateUnmanagedCallbacksAttribute(this INamedTypeSymbol symbol)
-        => symbol.ToString() == GeneratorClasses.GenerateUnmanagedCallbacksAttr;
+        => symbol.FullQualifiedNameOmitGlobal() == GeneratorClasses.GenerateUnmanagedCallbacksAttr;
 
 
     public static IEnumerable<(ClassDeclarationSyntax cds, INamedTypeSymbol symbol)> SelectUnmanagedCallbacksClasses(
     public static IEnumerable<(ClassDeclarationSyntax cds, INamedTypeSymbol symbol)> SelectUnmanagedCallbacksClasses(
         this IEnumerable<ClassDeclarationSyntax> source,
         this IEnumerable<ClassDeclarationSyntax> source,