Fixed metadata fully qualified name for shader type
このコミットが含まれているのは:
1 親
679e6b6d19
コミット
0ff0d062bf
2ファイル変更
+37
-4
検索条件に一致するファイルはありません
@@ -0,0 +1,35 @@
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Text;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for the <see cref="INamedTypeSymbol"/> type.
|
||||
/// </summary>
|
||||
internal static class INamedTypeSymbolExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the full metadata name for a given name symbol.
|
||||
/// </summary>
|
||||
/// <param name="namedTypeSymbol">The input <see cref="INamedTypeSymbol"/> instance.</param>
|
||||
/// <returns>The full metadata name for <paramref name="namedTypeSymbol"/>.</returns>
|
||||
[Pure]
|
||||
public static string GetFullMetadataName(this INamedTypeSymbol namedTypeSymbol)
|
||||
{
|
||||
static StringBuilder BuildFrom(ISymbol symbol, StringBuilder builder)
|
||||
{
|
||||
return symbol switch
|
||||
{
|
||||
INamespaceSymbol ns when ns.IsGlobalNamespace => builder.Insert(0, "global::"),
|
||||
INamespaceSymbol ns => BuildFrom(ns.ContainingNamespace, builder.Insert(0, $".{ns.MetadataName}")),
|
||||
ITypeSymbol ts when ts.ContainingType is ISymbol pt => BuildFrom(pt, builder.Insert(0, $"+{ts.MetadataName}")),
|
||||
ITypeSymbol ts when ts.ContainingNamespace is ISymbol pn => BuildFrom(pn, builder.Insert(0, $".{ts.MetadataName}")),
|
||||
_ => builder.Append(symbol.MetadataName)
|
||||
};
|
||||
}
|
||||
|
||||
return BuildFrom(namedTypeSymbol, new StringBuilder(256)).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする