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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ComputeSharp.SourceGenerators.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
@@ -34,10 +35,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
// Only process compute shader types
|
||||
if (!structDeclarationSymbol.Interfaces.Any(interfaceSymbol => interfaceSymbol.Name == "IComputeShader")) continue;
|
||||
|
||||
var structFullName = structDeclarationSymbol.ToDisplayString(new SymbolDisplayFormat(
|
||||
SymbolDisplayGlobalNamespaceStyle.Omitted,
|
||||
SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
|
||||
SymbolDisplayGenericsOptions.IncludeTypeParameters));
|
||||
var structFullName = structDeclarationSymbol.GetFullMetadataName();
|
||||
|
||||
// Find all declared methods in the type
|
||||
ImmutableArray<MethodDeclarationSyntax> methodDeclarations = (
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする