Fix discovery of bytecode attributes

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:10 +02:00
1 親 8d3a7a0771
コミット 4652a5a1cd
2ファイル変更
+5 -16

検索条件に一致するファイルはありません

+3 -14
ファイルの表示
@@ -30,17 +30,6 @@ internal static class ISymbolExtensions
.WithMemberOptions(SymbolDisplayMemberOptions.IncludeContainingType)
.WithParameterOptions(SymbolDisplayParameterOptions.None);
/// <summary>
/// Checks whether or not a given type symbol has a specified full name.
/// </summary>
/// <param name="symbol">The input <see cref="ISymbol"/> instance to check.</param>
/// <param name="name">The full name to check.</param>
/// <returns>Whether <paramref name="symbol"/> has a full name equals to <paramref name="name"/>.</returns>
public static bool HasFullyQualifiedName(this ISymbol symbol, string name)
{
return symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == name;
}
/// <summary>
/// Gets the full metadata name for a given <see cref="ITypeSymbol"/> instance.
/// </summary>
@@ -145,19 +134,19 @@ internal static class ISymbolExtensions
}
/// <summary>
/// Tries to get an attribute with the specified full name.
/// Tries to get an attribute with the specified full metadata name.
/// </summary>
/// <param name="symbol">The input <see cref="ISymbol"/> instance to check.</param>
/// <param name="name">The attribute name to look for.</param>
/// <param name="attributeData">The resulting attribute data, if found.</param>
/// <returns>Whether or not <paramref name="symbol"/> has an attribute with the specified name.</returns>
public static bool TryGetAttributeWithFullyQualifiedName(this ISymbol symbol, string name, out AttributeData? attributeData)
public static bool TryGetAttributeWithFullMetadataName(this ISymbol symbol, string name, out AttributeData? attributeData)
{
ImmutableArray<AttributeData> attributes = symbol.GetAttributes();
foreach (AttributeData attribute in attributes)
{
if (attribute.AttributeClass?.HasFullyQualifiedName(name) == true)
if (attribute.AttributeClass?.GetFullMetadataName() == name)
{
attributeData = attribute;
@@ -29,7 +29,7 @@ partial class ID2D1ShaderGenerator
/// <returns>The shader profile to use to compile the shader, if present.</returns>
public static D2D1ShaderProfile? GetShaderProfile(INamedTypeSymbol structDeclarationSymbol)
{
if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedName("ComputeSharp.D2D1Interop.D2DEmbeddedBytecodeAttribute", out AttributeData? attributeData))
if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1Interop.D2DEmbeddedBytecodeAttribute", out AttributeData? attributeData))
{
return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!;
}
@@ -44,7 +44,7 @@ partial class ID2D1ShaderGenerator
/// <returns>Whether the shader only has simple inputs.</returns>
public static bool IsSimpleInputShader(INamedTypeSymbol structDeclarationSymbol)
{
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedName("ComputeSharp.D2D1Interop.D2DInputCountAttribute", out AttributeData? inputCountAttribute))
if (!structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1Interop.D2DInputCountAttribute", out AttributeData? inputCountAttribute))
{
return false;
}