diff --git a/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
index ce076d16..b9f62c79 100644
--- a/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
@@ -19,7 +19,7 @@ namespace ComputeSharp.__Internals
///
/// Creates a new instance with the specified parameters.
///
- /// The fully qualified name of the shader type.
+ /// The type of the current shader.
/// The collection of custom types.
/// The mapped collection of shader fields.
/// The source code for the method.
@@ -27,7 +27,7 @@ namespace ComputeSharp.__Internals
/// The collection of discovered constants.
/// The collection of group shared buffers.
public IComputeShaderSourceAttribute(
- string shaderTypeName,
+ Type shaderType,
string[] types,
object[] args,
string executeMethod,
@@ -35,7 +35,7 @@ namespace ComputeSharp.__Internals
object[] constants,
object[] sharedBuffers)
{
- ShaderTypeName = shaderTypeName;
+ ShaderType = shaderType;
Types = types;
Fields = args.Cast().ToDictionary(static arg => arg[0], static arg => (arg[1], arg[2]));
ExecuteMethod = executeMethod;
@@ -45,9 +45,9 @@ namespace ComputeSharp.__Internals
}
///
- /// Gets the fully qualified name of the shader type.
+ /// Gets the type of the current shader.
///
- internal string ShaderTypeName { get; }
+ internal Type ShaderType { get; }
///
/// Gets the collection of processed custom types.
@@ -87,18 +87,9 @@ namespace ComputeSharp.__Internals
[Pure]
internal static IComputeShaderSourceAttribute GetForType()
{
- // Resolve the fully qualified name of the current type, without generic parameters.
- // We can't use Type.FullName, as when T is a closed generic it includes the assembly too.
- string fullname = typeof(T) switch
- {
- { IsGenericType: true } => typeof(T).GetGenericTypeDefinition().ToString().Split('[')[0],
- _ => typeof(T).ToString()
- };
+ Type shaderType = typeof(T);
- return (
- from attribute in typeof(T).Assembly.GetCustomAttributes()
- where attribute.ShaderTypeName == fullname
- select attribute).Single();
+ return shaderType.Assembly.GetCustomAttributes().Single(attribute => attribute.ShaderType == shaderType);
}
}
}
\ No newline at end of file
diff --git a/src/ComputeSharp.SourceGenerators/IComputeShaderSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/IComputeShaderSourceGenerator.cs
index c7e4f57f..aebad7c3 100644
--- a/src/ComputeSharp.SourceGenerators/IComputeShaderSourceGenerator.cs
+++ b/src/ComputeSharp.SourceGenerators/IComputeShaderSourceGenerator.cs
@@ -64,7 +64,7 @@ namespace ComputeSharp.SourceGenerators
UsingDirective(IdentifierName("ComputeSharp.__Internals"))).AddAttributeLists(
AttributeList(SingletonSeparatedList(
Attribute(IdentifierName(typeof(IComputeShaderSourceAttribute).FullName)).AddArgumentListArguments(
- AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(structDeclarationSymbol.GetFullMetadataName()))),
+ AttributeArgument(TypeOfExpression(IdentifierName(structDeclarationSymbol.ToDisplayString()))),
AttributeArgument(ArrayExpression(processedTypes)),
AttributeArgument(NestedArrayExpression(processedMembers)),
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(entryPoint))),