Merge pull request #106744 from L2750558108/fix-@-error-in-c#
Fix source generator exceptions appearing when use "@+internal keyword" as type or namespace name in C# script
This commit is contained in:
@ -94,13 +94,6 @@ internal static class ExtensionMethods
|
||||
};
|
||||
}
|
||||
|
||||
public static string NameWithTypeParameters(this INamedTypeSymbol symbol)
|
||||
{
|
||||
return symbol.IsGenericType && symbol.TypeParameters.Length > 0 ?
|
||||
string.Concat(symbol.Name, "<", string.Join(", ", symbol.TypeParameters), ">") :
|
||||
symbol.Name;
|
||||
}
|
||||
|
||||
private static SymbolDisplayFormat FullyQualifiedFormatOmitGlobal { get; } =
|
||||
SymbolDisplayFormat.FullyQualifiedFormat
|
||||
.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted);
|
||||
@ -123,6 +116,8 @@ internal static class ExtensionMethods
|
||||
|
||||
public static string SanitizeQualifiedNameForUniqueHint(this string qualifiedName)
|
||||
=> qualifiedName
|
||||
// AddSource() doesn't support @ prefix
|
||||
.Replace("@", "")
|
||||
// AddSource() doesn't support angle brackets
|
||||
.Replace("<", "(Of ")
|
||||
.Replace(">", ")");
|
||||
|
||||
@ -140,7 +140,7 @@ using Godot.NativeInterop;
|
||||
source.Append("partial ");
|
||||
source.Append(containingType.GetDeclarationKeyword());
|
||||
source.Append(" ");
|
||||
source.Append(containingType.NameWithTypeParameters());
|
||||
source.Append(containingType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
source.Append("\n{\n");
|
||||
}
|
||||
}
|
||||
@ -319,7 +319,7 @@ using Godot.NativeInterop;
|
||||
source.Append("partial ");
|
||||
source.Append(containingType.GetDeclarationKeyword());
|
||||
source.Append(" ");
|
||||
source.Append(containingType.NameWithTypeParameters());
|
||||
source.Append(containingType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
source.Append("\n{\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user