using ComputeSharp.D2D1.SourceGenerators.Helpers;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators;
///
partial class D2DPixelShaderDescriptorGenerator
{
///
/// A helper with all logic to generate the effect metadata properties.
///
private static partial class EffectMetadata
{
///
/// Extracts the effect display name info for the current shader.
///
/// The input object currently in use.
/// The for the shader type in use.
/// The resulting effect display name, if available.
public static string? GetEffectDisplayNameInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
{
if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
compilation,
structDeclarationSymbol,
"ComputeSharp.D2D1.D2DEffectDisplayNameAttribute",
isAssemblyLevelAttributeSupported: false,
out string? effectDisplayName))
{
return effectDisplayName;
}
return null;
}
///
/// Extracts the effect description info for the current shader.
///
/// The input object currently in use.
/// The for the shader type in use.
/// The resulting effect description, if available.
public static string? GetEffectDescriptionInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
{
if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
compilation,
structDeclarationSymbol,
"ComputeSharp.D2D1.D2DEffectDescriptionAttribute",
isAssemblyLevelAttributeSupported: false,
out string? effectDescription))
{
return effectDescription;
}
return null;
}
///
/// Extracts the effect category info for the current shader.
///
/// The input object currently in use.
/// The for the shader type in use.
/// The resulting effect category, if available.
public static string? GetEffectCategoryInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
{
if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
compilation,
structDeclarationSymbol,
"ComputeSharp.D2D1.D2DEffectCategoryAttribute",
isAssemblyLevelAttributeSupported: true,
out string? effectCategory))
{
return effectCategory;
}
return null;
}
///
/// Extracts the effect author info for the current shader.
///
/// The input object currently in use.
/// The for the shader type in use.
/// The resulting effect author, if available.
public static string? GetEffectAuthorInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
{
if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
compilation,
structDeclarationSymbol,
"ComputeSharp.D2D1.D2DEffectAuthorAttribute",
isAssemblyLevelAttributeSupported: true,
out string? effectAuthor))
{
return effectAuthor;
}
return null;
}
}
}