diff --git a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs index 288d6eae..3d6e8ab9 100644 --- a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs +++ b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs @@ -50,7 +50,7 @@ public sealed class AutoConstructorGenerator : IIncrementalGenerator { CompilationUnitSyntax compilationUnit = Ctor.GetSyntax(item.Left, item.Right); - context.AddSource($"{item.Left.FilenameHint}.Ctor.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Left.FullyQualifiedMetadataName}.Ctor.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } @@ -78,7 +78,7 @@ public sealed class AutoConstructorGenerator : IIncrementalGenerator } // Check whether the field is annotated to have a special behavior - if (fieldSymbol.Type.TryGetAttributeWithFullMetadataName("ComputeSharp.AutoConstructorBehaviorAttribute", out AttributeData? usageData) && + if (fieldSymbol.Type.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.AutoConstructorBehaviorAttribute", out AttributeData? usageData) && usageData!.ConstructorArguments is { Length: 1 } arguments && arguments[0].Value is (int)AutoConstructorBehavior.IgnoreAndSetToDefault) { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs index 65a2f074..004ee0ca 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs @@ -61,7 +61,7 @@ partial class D2DPixelShaderSourceGenerator /// The HLSL source to compile, if present. public static string GetHlslSource(ImmutableArrayBuilder diagnostics, IMethodSymbol methodSymbol) { - _ = methodSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DPixelShaderSourceAttribute", out AttributeData? attributeData); + _ = methodSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DPixelShaderSourceAttribute", out AttributeData? attributeData); if (!attributeData!.TryGetConstructorArgument(0, out string? hlslSource)) { @@ -83,12 +83,12 @@ partial class D2DPixelShaderSourceGenerator /// The shader profile to use to compile the shader, if present. public static D2D1ShaderProfile GetShaderProfile(ImmutableArrayBuilder diagnostics, IMethodSymbol methodSymbol) { - if (methodSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) + if (methodSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } - if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) + if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } @@ -110,12 +110,12 @@ partial class D2DPixelShaderSourceGenerator /// The compile options to use to compile the shader, if present. public static D2D1CompileOptions GetCompileOptions(ImmutableArrayBuilder diagnostics, IMethodSymbol methodSymbol) { - if (methodSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) + if (methodSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) { return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!; } - if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData)) + if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData)) { return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs index 1c58c1fb..af73afc5 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.cs @@ -114,7 +114,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato CompilationUnitSyntax compilationUnit = item.Hierarchy.GetSyntax(loadBytecodeMethod); SourceText text = fixup(compilationUnit); - context.AddSource($"{item.Hierarchy.FilenameHint}.{item.BytecodeInfo.MethodName}.g.cs", text); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{item.BytecodeInfo.MethodName}.g.cs", text); }); } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs index a0cf5ce7..e3dc2b6c 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidAssemblyLevelCompileOptionsAnalyzer.cs @@ -29,7 +29,7 @@ public sealed class InvalidAssemblyLevelCompileOptionsAnalyzer : DiagnosticAnaly // - The type symbol for the assembly, to get the AttributeData object for the [D2D1CompileOptions] attribute, if used. // - The syntax node representing the attribute targeting the assembly, to get a location (this is retrieved from the AttributeData). // - The input D2D1CompileOptions value, which can be retrieved from the constructor arguments of the AttributeData object. - if (assemblySymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) + if (assemblySymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) { D2D1CompileOptions options = (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs index 55caff9d..e78c4591 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs @@ -27,9 +27,9 @@ public sealed class InvalidD2DResourceTextureIndexUseAnalyzer : DiagnosticAnalyz { IFieldSymbol fieldSymbol = (IFieldSymbol)context.Symbol; - if (fieldSymbol.HasAttributeWithFullyQualifiedName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute")) + if (fieldSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out _)) { - string metadataName = fieldSymbol.Type.GetFullMetadataName(); + string metadataName = fieldSymbol.Type.GetFullyQualifiedMetadataName(); if (!HlslKnownTypes.IsResourceTextureType(metadataName)) { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs index d7c3ba60..a570e68f 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Suppressors/D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor.cs @@ -49,7 +49,7 @@ public sealed class D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor : // Check if the field is in a struct and it's of a D2D1 resource texture type if (declaredSymbol is IFieldSymbol { ContainingType: { TypeKind: TypeKind.Struct } structSymbol } fieldSymbol && - HlslKnownTypes.IsResourceTextureType(fieldSymbol.Type.GetFullMetadataName())) + HlslKnownTypes.IsResourceTextureType(fieldSymbol.Type.GetFullyQualifiedMetadataName())) { // Get the ID2D1PixelShader interface symbol to the check the containing type of the field INamedTypeSymbol? pixelShaderInterfaceSymbol = semanticModel.Compilation.GetTypeByMetadataName(typeof(ID2D1PixelShader).FullName)!; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index 8faf1d54..331cddbe 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -126,7 +126,7 @@ partial class ID2D1ShaderGenerator continue; } - string metadataName = typeSymbol.GetFullMetadataName(); + string metadataName = typeSymbol.GetFullyQualifiedMetadataName(); string typeName = HlslKnownTypes.GetMappedName(typeSymbol); _ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping); @@ -137,8 +137,8 @@ partial class ID2D1ShaderGenerator ITypeSymbol resourceTextureTypeArgumentSymbol = typeSymbol.TypeArguments[0]; // Validate that the type argument is only either float or float4 - if (!resourceTextureTypeArgumentSymbol.HasFullyQualifiedName("System.Single") && - !resourceTextureTypeArgumentSymbol.HasFullyQualifiedName("ComputeSharp.Float4")) + if (!resourceTextureTypeArgumentSymbol.HasFullyQualifiedMetadataName("System.Single") && + !resourceTextureTypeArgumentSymbol.HasFullyQualifiedMetadataName("ComputeSharp.Float4")) { diagnostics.Add( InvalidResourceTextureElementType, @@ -153,7 +153,7 @@ partial class ID2D1ShaderGenerator // If [D2DResourceTextureIndex] is present, get the resource texture index. // This generator doesn't need to emit diagnostics, as that's handled separately // by the logic handling the info gathering for LoadResourceTextureDescriptions. - if (fieldSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out AttributeData? attributeData)) + if (fieldSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out AttributeData? attributeData)) { _ = attributeData!.TryGetConstructorArgument(0, out index); } @@ -218,7 +218,7 @@ partial class ID2D1ShaderGenerator // Constant properties must be of a primitive, vector or matrix type if (fieldSymbol.Type is not INamedTypeSymbol typeSymbol || - !HlslKnownTypes.IsKnownHlslType(typeSymbol.GetFullMetadataName())) + !HlslKnownTypes.IsKnownHlslType(typeSymbol.GetFullyQualifiedMetadataName())) { diagnostics.Add(InvalidShaderStaticFieldType, variableDeclarator, structDeclarationSymbol, fieldSymbol.Name, fieldSymbol.Type); @@ -291,7 +291,7 @@ partial class ID2D1ShaderGenerator IMethodSymbol methodDeclarationSymbol = semanticModel.For(methodDeclaration).GetDeclaredSymbol(methodDeclaration)!; bool isShaderEntryPoint = methodDeclarationSymbol.Name == nameof(ID2D1PixelShader.Execute) && - methodDeclarationSymbol.ReturnType.HasFullyQualifiedName("ComputeSharp.Float4") && + methodDeclarationSymbol.ReturnType.HasFullyQualifiedMetadataName("ComputeSharp.Float4") && methodDeclarationSymbol.TypeParameters.Length == 0 && methodDeclarationSymbol.Parameters.Length == 0; @@ -394,7 +394,7 @@ partial class ID2D1ShaderGenerator // Process the discovered types foreach (INamedTypeSymbol type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) { - string structType = type.GetFullMetadataName().ToHlslIdentifierName(); + string structType = type.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); StructDeclarationSyntax structDeclaration = StructDeclaration(structType); // Declare the fields of the current type @@ -408,9 +408,9 @@ partial class ID2D1ShaderGenerator INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; // Convert the name to the fully qualified HLSL version - if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mappedType)) + if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullyQualifiedMetadataName(), out string? mappedType)) { - mappedType = fieldType.GetFullMetadataName().ToHlslIdentifierName(); + mappedType = fieldType.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); } // Get the field name as a valid HLSL identifier @@ -498,7 +498,7 @@ partial class ID2D1ShaderGenerator /// Whether requires the scene position. private static bool GetD2DRequiresScenePositionInfo(INamedTypeSymbol structDeclarationSymbol) { - return structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DRequiresScenePositionAttribute", out _); + return structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DRequiresScenePositionAttribute", out _); } /// diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs index c6e23620..4d79a732 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs @@ -46,7 +46,7 @@ partial class ID2D1ShaderGenerator foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes()) { - switch (attributeData.AttributeClass?.GetFullMetadataName()) + switch (attributeData.AttributeClass?.GetFullyQualifiedMetadataName()) { case "ComputeSharp.D2D1.D2DInputCountAttribute": rawInputCount = (int)attributeData.ConstructorArguments[0].Value!; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs index 3c746fb1..c6d17dde 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetOutputBufferMethod.cs @@ -23,7 +23,7 @@ partial class ID2D1ShaderGenerator out D2D1ChannelDepth channelDepth) { // Try to get the [D2DOutputBuffer] attribute - if (!structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DOutputBufferAttribute", out AttributeData? attributeData)) + if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DOutputBufferAttribute", out AttributeData? attributeData)) { bufferPrecision = D2D1BufferPrecision.Unknown; channelDepth = D2D1ChannelDepth.Default; @@ -35,7 +35,7 @@ partial class ID2D1ShaderGenerator if (attributeData!.ConstructorArguments.Length == 1) { if (attributeData.AttributeConstructor is IMethodSymbol { Parameters.Length: 1 } constructorSymbol && - constructorSymbol.Parameters[0].Type.HasFullyQualifiedName("ComputeSharp.D2D1.D2D1BufferPrecision")) + constructorSymbol.Parameters[0].Type.HasFullyQualifiedMetadataName("ComputeSharp.D2D1.D2D1BufferPrecision")) { bufferPrecision = (D2D1BufferPrecision)attributeData.ConstructorArguments[0].Value!; channelDepth = D2D1ChannelDepth.Default; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs index 18102a14..7b805a78 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetPixelOptionsMethod.cs @@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator /// The pixel options for the shader. public static void GetInfo(INamedTypeSymbol structDeclarationSymbol, out D2D1PixelOptions pixelOptions) { - if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DPixelOptionsAttribute", out AttributeData? attributeData)) + if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DPixelOptionsAttribute", out AttributeData? attributeData)) { pixelOptions = (D2D1PixelOptions)attributeData!.ConstructorArguments[0].Value!; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs index 4eeeca26..1854e959 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs @@ -33,12 +33,12 @@ partial class ID2D1ShaderGenerator /// The shader profile to use to compile the shader, if present. public static D2D1ShaderProfile? GetShaderProfile(INamedTypeSymbol structDeclarationSymbol) { - if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) + if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } - if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) + if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData)) { return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!; } @@ -54,7 +54,7 @@ partial class ID2D1ShaderGenerator /// The compile options to use to compile the shader, if present. public static D2D1CompileOptions? GetCompileOptions(ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol) { - if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) + if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData)) { D2D1CompileOptions options = (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!; @@ -70,7 +70,7 @@ partial class ID2D1ShaderGenerator return options | D2D1CompileOptions.PackMatrixRowMajor; } - if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData)) + if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData)) { // No need to validate against PackMatrixColumnMajor as that's checked separately return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value! | D2D1CompileOptions.PackMatrixRowMajor; @@ -98,7 +98,7 @@ partial class ID2D1ShaderGenerator foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes()) { - switch (attributeData.AttributeClass?.GetFullMetadataName()) + switch (attributeData.AttributeClass?.GetFullyQualifiedMetadataName()) { // Only retrieve indices of simple inputs that are in range. If an input is out of // range, the diagnostic for it will already be emitted by a previous generator step. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs index e3f23d17..46c83eb2 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -49,7 +49,7 @@ partial class ID2D1ShaderGenerator select fieldSymbol) { string fieldName = fieldSymbol.Name; - string typeName = fieldSymbol.Type.GetFullMetadataName(); + string typeName = fieldSymbol.Type.GetFullyQualifiedMetadataName(); // Disambiguates the name of target fields against the current input parameters if (fieldName is "loader") diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs index 55821ef0..02b5362e 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs @@ -34,7 +34,7 @@ partial class ID2D1ShaderGenerator foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes()) { - switch (attributeData.AttributeClass?.GetFullMetadataName()) + switch (attributeData.AttributeClass?.GetFullyQualifiedMetadataName()) { case "ComputeSharp.D2D1.D2DInputCountAttribute": inputCount = (int)attributeData.ConstructorArguments[0].Value!; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs index 4c6944b0..b8ae3707 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs @@ -42,7 +42,7 @@ partial class ID2D1ShaderGenerator continue; } - string metadataName = typeSymbol.GetFullMetadataName(); + string metadataName = typeSymbol.GetFullyQualifiedMetadataName(); // Check that the field is a resource texture type (if not, it will be processed by the HLSL rewriter too) if (HlslKnownTypes.IsResourceTextureType(metadataName)) @@ -52,7 +52,7 @@ partial class ID2D1ShaderGenerator int? index = null; // Get the index from the [D2DResourceTextureIndex] attribute over the field - if (fieldSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out AttributeData? attributeData)) + if (fieldSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out AttributeData? attributeData)) { // If the constructor argument isn't available, it means the code is invalid. Just do nothing then, as the // user will have to fix that to get the code to compile anyway. This way the generator won't crash too. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs index cbaa6994..bf135864 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs @@ -147,7 +147,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getInputCountMethod = GetInputCount.GetSyntax(item.InputCount); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getInputCountMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetInputCount)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetInputCount)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the GetInputType() info (hierarchy and input types) @@ -161,7 +161,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getInputTypeMethod = GetInputType.GetSyntax(item.InputTypes.InputTypes); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getInputTypeMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetInputType)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetInputType)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the LoadResourceTextureDescriptions() info (hierarchy and resource texture descriptions) @@ -175,7 +175,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getInputTypeMethod = LoadResourceTextureDescriptions.GetSyntax(item.ResourceTextureDescriptions); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getInputTypeMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(LoadResourceTextureDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadResourceTextureDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the info for InitializeFromDispatchData() (hierarchy and dispatch data) @@ -189,7 +189,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax loadDispatchDataMethod = InitializeFromDispatchData.GetSyntax(item.Dispatch); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, loadDispatchDataMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(InitializeFromDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(InitializeFromDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the info for LoadDispatchData() (same as InitializeFromDispatchData(), but with [SkipLocalsInit] support flag as well) @@ -203,7 +203,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax loadDispatchDataMethod = LoadDispatchData.GetSyntax(item.Info.Dispatch); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, loadDispatchDataMethod, item.CanUseSkipLocalsInit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(LoadDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Check whether raw multiline string literals can be used (C# 11) @@ -223,7 +223,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax buildHlslStringMethod = BuildHlslSource.GetSyntax(item.Info.HlslSource, item.Info.Hierarchy.Hierarchy.Length, item.CanUseRawMultilineStringLiterals); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, buildHlslStringMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(BuildHlslSource)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(BuildHlslSource)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get a filtered sequence to enable caching for the HLSL source info, before the shader compilation step @@ -282,7 +282,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, loadBytecodeMethod, canUseSkipLocalsInit: false); SourceText text = fixup(compilationUnit); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(LoadBytecode)}.g.cs", text); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadBytecode)}.g.cs", text); }); // Get the GetOutputBuffer() info (hierarchy and output buffers) @@ -296,7 +296,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getOutputBufferMethod = GetOutputBuffer.GetSyntax(item.OutputBuffer); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getOutputBufferMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetOutputBuffer)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetOutputBuffer)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the LoadInputDescriptions() info (hierarchy and input descriptions) @@ -311,7 +311,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax loadInputDescriptionsMethod = LoadInputDescriptions.GetSyntax(item.Info.InputDescriptions); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, loadInputDescriptionsMethod, item.CanUseSkipLocalsInit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(LoadInputDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadInputDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the GetPixelOptions() info (hierarchy and pixel options) @@ -325,7 +325,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getPixelOptionsMethod = GetPixelOptions.GetSyntax(item.PixelOptions); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getPixelOptionsMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetPixelOptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetPixelOptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs index 1ebec150..30d69af3 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -26,12 +26,12 @@ partial class HlslKnownTypes /// public static partial string GetMappedName(INamedTypeSymbol typeSymbol) { - string typeName = typeSymbol.GetFullMetadataName(); + string typeName = typeSymbol.GetFullyQualifiedMetadataName(); // Special case for resource texture types if (IsResourceTextureType(typeName)) { - string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments[0]).GetFullMetadataName(); + string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments[0]).GetFullyQualifiedMetadataName(); // Get the HLSL name for the type argument (it can only be either float or float4) _ = KnownHlslTypes.TryGetValue(genericArgumentName, out string? mappedElementType); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index 58e6c35d..cecae13f 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -167,7 +167,7 @@ internal static partial class HlslKnownTypes /// The HLSL-compatible type name that can be used in an HLSL shader. public static string GetMappedElementName(IArrayTypeSymbol typeSymbol) { - string elementTypeName = ((INamedTypeSymbol)typeSymbol.ElementType).GetFullMetadataName(); + string elementTypeName = ((INamedTypeSymbol)typeSymbol.ElementType).GetFullyQualifiedMetadataName(); if (KnownHlslTypes.TryGetValue(elementTypeName, out string? mapped)) { @@ -227,7 +227,7 @@ internal static partial class HlslKnownTypes return; } - if (KnownHlslTypes.ContainsKey(type.GetFullMetadataName())) + if (KnownHlslTypes.ContainsKey(type.GetFullyQualifiedMetadataName())) { return; } @@ -314,7 +314,7 @@ internal static partial class HlslKnownTypes INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; - if (!KnownHlslTypes.ContainsKey(fieldType.GetFullMetadataName()) && + if (!KnownHlslTypes.ContainsKey(fieldType.GetFullyQualifiedMetadataName()) && !invalidTypes.Contains(fieldType)) { _ = dependencies.Add(fieldType); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs index db297fe4..ee44570d 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs @@ -112,7 +112,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter // Add explicit casts for matrix constructors to help the overload resolution if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol matrixType && - HlslKnownTypes.IsMatrixType(matrixType.GetFullMetadataName())) + HlslKnownTypes.IsMatrixType(matrixType.GetFullyQualifiedMetadataName())) { for (int i = 0; i < node.ArgumentList!.Arguments.Count; i++) { @@ -148,7 +148,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter // Add explicit casts like with the explicit object creation expressions above if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol matrixType && - HlslKnownTypes.IsMatrixType(matrixType.GetFullMetadataName())) + HlslKnownTypes.IsMatrixType(matrixType.GetFullyQualifiedMetadataName())) { for (int i = 0; i < node.ArgumentList.Arguments.Count; i++) { @@ -240,7 +240,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter if (SemanticModel.For(node).GetOperation(node) is IPropertyReferenceOperation operation) { - string propertyName = operation.Property.GetFullMetadataName(); + string propertyName = operation.Property.GetFullyQualifiedMetadataName(); // Rewrite texture resource indices taking individual indices a vector argument, as per HLSL spec. // For instance: texture[ThreadIds.X, ThreadIds.Y] will be rewritten as texture[int2(ThreadIds.X, ThreadIds.Y)]. @@ -261,7 +261,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter foreach (ArgumentSyntax argument in node.ArgumentList.Arguments) { if (SemanticModel.For(node).GetOperation(argument.Expression) is not IFieldReferenceOperation fieldReference || - !HlslKnownProperties.IsKnownMatrixIndex(fieldReference.Field.GetFullMetadataName())) + !HlslKnownProperties.IsKnownMatrixIndex(fieldReference.Field.GetFullyQualifiedMetadataName())) { Diagnostics.Add(NonConstantMatrixSwizzledIndex, argument); @@ -302,7 +302,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter // That is, do the following transformation: // // x *= y => x = (x, y) - if (HlslKnownOperators.TryGetMappedName(method.GetFullMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped)) + if (HlslKnownOperators.TryGetMappedName(method.GetFullyQualifiedMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped)) { return AssignmentExpression( @@ -330,7 +330,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter // That is, do the following transformation: // // x * y => (x, y) - if (HlslKnownOperators.TryGetMappedName(method.GetFullMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped)) + if (HlslKnownOperators.TryGetMappedName(method.GetFullyQualifiedMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped)) { return InvocationExpression(IdentifierName(mapped!)) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index c0b6bc9e..ee9544a2 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -369,7 +369,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // property access into an invocation of an autogenerated static helper method to get the target // dimension for the buffer in use. The helper method is added to the list of static helpers. if (operation is IPropertyReferenceOperation propertyOperation && - HlslKnownProperties.TryGetAccessorRankAndAxis(propertyOperation.Property.GetFullMetadataName(), out int rank, out int axis)) + HlslKnownProperties.TryGetAccessorRankAndAxis(propertyOperation.Property.GetFullyQualifiedMetadataName(), out int rank, out int axis)) { IMethodSymbol key = propertyOperation.Property.GetMethod!; @@ -427,7 +427,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter { if (method.IsStatic) { - string metadataName = method.GetFullMetadataName(); + string metadataName = method.GetFullyQualifiedMetadataName(); // If the invocation consists of invoking a static method that has a direct // mapping to HLSL, rewrite the expression in the current invocation node. @@ -460,7 +460,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // type as well, as they will be processed by the generator in a different path. if (!SymbolEqualityComparer.Default.Equals(this.shaderType, method.ContainingType)) { - string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); + string methodIdentifier = method.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); if (!this.staticMethods.ContainsKey(method)) { @@ -482,7 +482,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter } else { - string metadataName = method.GetFullMetadataName(includeParameters: true); + string metadataName = method.GetFullyQualifiedMetadataName(includeParameters: true); // Check whether this is a Sample(...) call on a normalized texture type if (HlslKnownMethods.TryGetMappedResourceSamplerAccessType(metadataName, out string? mapping)) @@ -505,7 +505,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter { DiscoveredTypes.Add(structTypeSymbol); - string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); + string methodIdentifier = method.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); // Same as for static methods, ensure the method is available in source, and process it if so if (!this.instanceMethods.ContainsKey(method)) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs index bdc85dff..7abe4fb7 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs @@ -101,7 +101,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter method.IsStatic) { // Rewrite HLSL intrinsic methods - if (HlslKnownMethods.TryGetMappedName(method.GetFullMetadataName(), out string? mapping, out bool requiresParametersMapping)) + if (HlslKnownMethods.TryGetMappedName(method.GetFullyQualifiedMetadataName(), out string? mapping, out bool requiresParametersMapping)) { if (requiresParametersMapping) { diff --git a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems index 05057cf3..1fa9c05e 100644 --- a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems +++ b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems @@ -13,6 +13,10 @@ + + + + diff --git a/src/ComputeSharp.SourceGeneration/Extensions/IFieldSymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/IFieldSymbolExtensions.cs new file mode 100644 index 00000000..92c3c869 --- /dev/null +++ b/src/ComputeSharp.SourceGeneration/Extensions/IFieldSymbolExtensions.cs @@ -0,0 +1,28 @@ +using System; +using ComputeSharp.SourceGeneration.Helpers; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.SourceGeneration.Extensions; + +/// +/// Extension methods for types. +/// +internal static class IFieldSymbolExtensions +{ + /// + /// Gets the fully qualified metadata name for a given instance. + /// + /// The input instance. + /// The fully qualified metadata name for . + public static string GetFullyQualifiedMetadataName(this IFieldSymbol symbol) + { + using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); + + symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder); + + builder.Add('.'); + builder.AddRange(symbol.Name.AsSpan()); + + return builder.ToString(); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Extensions/IMethodSymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/IMethodSymbolExtensions.cs new file mode 100644 index 00000000..fc01872c --- /dev/null +++ b/src/ComputeSharp.SourceGeneration/Extensions/IMethodSymbolExtensions.cs @@ -0,0 +1,54 @@ +using System; +using ComputeSharp.SourceGeneration.Helpers; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.SourceGeneration.Extensions; + +/// +/// Extension methods for types. +/// +internal static class IMethodSymbolExtensions +{ + /// + /// Gets the fully qualified metadata name for a given instance. + /// + /// The input instance. + /// Whether or not to also include parameter types. + /// The fully qualified metadata name for . + public static string GetFullyQualifiedMetadataName(this IMethodSymbol symbol, bool includeParameters = false) + { + using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); + + symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder); + + // Always add the method name after the containing type + builder.Add('.'); + builder.AddRange(symbol.Name.AsSpan()); + + if (includeParameters) + { + builder.Add('('); + + bool isFirstParameter = true; + + foreach (IParameterSymbol parameter in symbol.Parameters) + { + // Append the leading ', ' if needed + if (isFirstParameter) + { + isFirstParameter = false; + } + else + { + builder.AddRange(", ".AsSpan()); + } + + parameter.Type.AppendFullyQualifiedMetadataName(in builder); + } + + builder.Add(')'); + } + + return builder.ToString(); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Extensions/IPropertySymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/IPropertySymbolExtensions.cs new file mode 100644 index 00000000..57fc7661 --- /dev/null +++ b/src/ComputeSharp.SourceGeneration/Extensions/IPropertySymbolExtensions.cs @@ -0,0 +1,58 @@ +using System; +using ComputeSharp.SourceGeneration.Helpers; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.SourceGeneration.Extensions; + +/// +/// Extension methods for types. +/// +internal static class IPropertySymbolExtensions +{ + /// + /// Gets the fully qualified metadata name for a given instance. + /// + /// The input instance. + /// The fully qualified metadata name for . + public static string GetFullyQualifiedMetadataName(this IPropertySymbol symbol) + { + using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); + + symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder); + + if (symbol.IsIndexer) + { + // Add the ".this[...]" suffix (parameters will be added below) + builder.AddRange(".this[".AsSpan()); + + bool isFirstParameter = true; + + // If the property is an indexer, also includes the parameters + foreach (IParameterSymbol parameter in symbol.Parameters) + { + // Append the leading ', ' if needed + if (isFirstParameter) + { + isFirstParameter = false; + } + else + { + builder.AddRange(", ".AsSpan()); + } + + parameter.Type.AppendFullyQualifiedMetadataName(in builder); + } + + // Add the closing bracket for ".this[...]" + builder.Add(']'); + } + else + { + // For normal properties, just append the name after the containing type + builder.Add('.'); + builder.AddRange(symbol.Name.AsSpan()); + } + + return builder.ToString(); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs index 15f35756..fc24ec06 100644 --- a/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs +++ b/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs @@ -1,5 +1,3 @@ -using System.Linq; -using System.Text; using Microsoft.CodeAnalysis; namespace ComputeSharp.SourceGeneration.Extensions; @@ -29,130 +27,18 @@ internal static class ISymbolExtensions } /// - /// Checks whether or not a given type symbol has a specified full name. - /// - /// The input instance to check. - /// The full name to check. - /// Whether has a full name equals to . - public static bool HasFullyQualifiedName(this ISymbol symbol, string name) - { - return symbol.ToDisplayString(FullyQualifiedWithoutGlobalFormat) == name; - } - - /// - /// Gets a valid filename for a given instance. - /// - /// The input instance. - /// The full metadata name for that is also a valid filename. - public static string GetFullMetadataName(this ITypeSymbol symbol) - { - static StringBuilder BuildFrom(ISymbol? symbol, StringBuilder builder) - { - return symbol switch - { - INamespaceSymbol ns when ns.IsGlobalNamespace => builder, - INamespaceSymbol ns when ns.ContainingNamespace is { IsGlobalNamespace: false } - => BuildFrom(ns.ContainingNamespace, builder.Insert(0, $".{ns.MetadataName}")), - ITypeSymbol ts when ts.ContainingType is ISymbol containingType - => BuildFrom(containingType, builder.Insert(0, $"+{ts.MetadataName}")), - ITypeSymbol ts when ts.ContainingNamespace is ISymbol containingNamespace and not INamespaceSymbol { IsGlobalNamespace: true } - => BuildFrom(containingNamespace, builder.Insert(0, $".{ts.MetadataName}")), - ISymbol => BuildFrom(symbol.ContainingSymbol, builder.Insert(0, symbol.MetadataName)), - _ => builder - }; - } - - return BuildFrom(symbol, new StringBuilder(256)).ToString(); - } - - /// - /// Gets the full metadata name for a given instance. - /// - /// The input instance. - /// Whether or not to also include parameter types. - /// The full metadata name for . - public static string GetFullMetadataName(this IMethodSymbol symbol, bool includeParameters = false) - { - if (includeParameters) - { - string parameters = string.Join(", ", symbol.Parameters.Select(static p => ((INamedTypeSymbol)p.Type).GetFullMetadataName())); - - return $"{symbol.ContainingType.GetFullMetadataName()}.{symbol.Name}({parameters})"; - } - - return $"{symbol.ContainingType.GetFullMetadataName()}.{symbol.Name}"; - } - - /// - /// Gets the full metadata name for a given instance. - /// - /// The input instance. - /// The full metadata name for . - public static string GetFullMetadataName(this IPropertySymbol symbol) - { - string declaringTypeName = symbol.ContainingType.GetFullMetadataName(); - - if (symbol.IsIndexer) - { - string parameters = string.Join(", ", symbol.Parameters.Select(static p => ((INamedTypeSymbol)p.Type).GetFullMetadataName())); - - return $"{declaringTypeName}.this[{parameters}]"; - } - - return $"{declaringTypeName}.{symbol.Name}"; - } - - /// - /// Gets the full metadata name for a given instance. - /// - /// The input instance. - /// The full metadata name for . - public static string GetFullMetadataName(this IFieldSymbol symbol) - { - return $"{symbol.ContainingType.GetFullMetadataName()}.{symbol.Name}"; - } - - /// - /// Gets a valid filename for a target symbol and generator type. - /// - /// The symbol being processed. - /// A filename in the form "<SYMBOL_FULLNAME>" - public static string GetGeneratedFileName(this INamedTypeSymbol symbol) - { - return symbol.GetFullMetadataName().Replace('`', '-').Replace('+', '.'); - } - - /// - /// Checks whether or not a given symbol has an attribute with the specified full name. - /// - /// The input instance to check. - /// The attribute name to look for. - /// Whether or not has an attribute with the specified name. - public static bool HasAttributeWithFullyQualifiedName(this ISymbol symbol, string name) - { - foreach (AttributeData attribute in symbol.GetAttributes()) - { - if (attribute.AttributeClass?.HasFullyQualifiedName(name) == true) - { - return true; - } - } - - return false; - } - - /// - /// Tries to get an attribute with the specified full metadata name. + /// Tries to get an attribute with the specified fully qualified metadata name. /// /// The input instance to check. /// The attribute name to look for. /// The resulting attribute data, if found. /// Whether or not has an attribute with the specified name. - public static bool TryGetAttributeWithFullMetadataName(this ISymbol symbol, string name, out AttributeData? attributeData) + public static bool TryGetAttributeWithFullyQualifiedMetadataName(this ISymbol symbol, string name, out AttributeData? attributeData) { foreach (AttributeData attribute in symbol.GetAttributes()) { - if (attribute.AttributeClass?.GetFullMetadataName() == name) + if (attribute.AttributeClass is INamedTypeSymbol attributeSymbol && + attributeSymbol.HasFullyQualifiedMetadataName(name)) { attributeData = attribute; diff --git a/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs new file mode 100644 index 00000000..a9fd5b26 --- /dev/null +++ b/src/ComputeSharp.SourceGeneration/Extensions/ITypeSymbolExtensions.cs @@ -0,0 +1,89 @@ +using System; +using ComputeSharp.SourceGeneration.Helpers; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.SourceGeneration.Extensions; + +/// +/// Extension methods for types. +/// +internal static class ITypeSymbolExtensions +{ + /// + /// Checks whether or not a given type symbol has a specified fully qualified metadata name. + /// + /// The input instance to check. + /// The full name to check. + /// Whether has a full name equals to . + public static bool HasFullyQualifiedMetadataName(this ITypeSymbol symbol, string name) + { + using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); + + symbol.AppendFullyQualifiedMetadataName(in builder); + + return builder.WrittenSpan.SequenceEqual(name.AsSpan()); + } + + /// + /// Gets the fully qualified metadata name for a given instance. + /// + /// The input instance. + /// The fully qualified metadata name for . + public static string GetFullyQualifiedMetadataName(this ITypeSymbol symbol) + { + using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); + + symbol.AppendFullyQualifiedMetadataName(in builder); + + return builder.ToString(); + } + + /// + /// Appends the fully qualified metadata name for a given symbol to a target builder. + /// + /// The input instance. + /// The target instance. + public static void AppendFullyQualifiedMetadataName(this ITypeSymbol symbol, in ImmutableArrayBuilder builder) + { + static void BuildFrom(ISymbol? symbol, in ImmutableArrayBuilder builder) + { + switch (symbol) + { + // Namespaces that are nested also append a leading '.' + case INamespaceSymbol { ContainingNamespace.IsGlobalNamespace: false }: + BuildFrom(symbol.ContainingNamespace, in builder); + builder.Add('.'); + builder.AddRange(symbol.MetadataName.AsSpan()); + break; + + // Other namespaces (ie. the one right before global) skip the leading '.' + case INamespaceSymbol { IsGlobalNamespace: false }: + builder.AddRange(symbol.MetadataName.AsSpan()); + break; + + // Types with no namespace just have their metadata name directly written + case ITypeSymbol { ContainingSymbol: INamespaceSymbol { IsGlobalNamespace: true } }: + builder.AddRange(symbol.MetadataName.AsSpan()); + break; + + // Types with a containing non-global namespace also append a leading '.' + case ITypeSymbol { ContainingSymbol: INamespaceSymbol namespaceSymbol }: + BuildFrom(namespaceSymbol, in builder); + builder.Add('.'); + builder.AddRange(symbol.MetadataName.AsSpan()); + break; + + // Nested types append a leading '+' + case ITypeSymbol { ContainingSymbol: ITypeSymbol typeSymbol }: + BuildFrom(typeSymbol, in builder); + builder.Add('+'); + builder.AddRange(symbol.MetadataName.AsSpan()); + break; + default: + break; + } + } + + BuildFrom(symbol, in builder); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Models/HierarchyInfo.cs b/src/ComputeSharp.SourceGeneration/Models/HierarchyInfo.cs index 0a72429c..d2118b3e 100644 --- a/src/ComputeSharp.SourceGeneration/Models/HierarchyInfo.cs +++ b/src/ComputeSharp.SourceGeneration/Models/HierarchyInfo.cs @@ -11,11 +11,10 @@ namespace ComputeSharp.SourceGeneration.Models; /// /// A model describing the hierarchy info for a specific type. /// -/// The filename hint for the current type. /// The fully qualified metadata name for the current type. /// Gets the namespace for the current type. /// Gets the sequence of type definitions containing the current type. -internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQualifiedMetadataName, string Namespace, EquatableArray Hierarchy) +internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName, string Namespace, EquatableArray Hierarchy) { /// /// Creates a new instance from a given . @@ -37,8 +36,7 @@ internal sealed partial record HierarchyInfo(string FilenameHint, string FullyQu } return new( - typeSymbol.GetGeneratedFileName(), - typeSymbol.GetFullMetadataName(), + typeSymbol.GetFullyQualifiedMetadataName(), typeSymbol.ContainingNamespace.ToDisplayString(new(typeQualificationStyle: NameAndContainingTypesAndNamespaces)), hierarchy.ToImmutable()); } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index d17e02e8..d8fbbae0 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -134,7 +134,7 @@ partial class IShaderGenerator continue; } - string metadataName = typeSymbol.GetFullMetadataName(); + string metadataName = typeSymbol.GetFullyQualifiedMetadataName(); string typeName = HlslKnownTypes.GetMappedName(typeSymbol); _ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping); @@ -222,7 +222,7 @@ partial class IShaderGenerator // Constant properties must be of a primitive, vector or matrix type if (fieldSymbol.Type is not INamedTypeSymbol typeSymbol || - !HlslKnownTypes.IsKnownHlslType(typeSymbol.GetFullMetadataName())) + !HlslKnownTypes.IsKnownHlslType(typeSymbol.GetFullyQualifiedMetadataName())) { diagnostics.Add(InvalidShaderStaticFieldType, variableDeclarator, structDeclarationSymbol, fieldSymbol.Name, fieldSymbol.Type); @@ -460,7 +460,7 @@ partial class IShaderGenerator // Process the discovered types foreach (INamedTypeSymbol type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) { - string structType = type.GetFullMetadataName().ToHlslIdentifierName(); + string structType = type.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); StructDeclarationSyntax structDeclaration = StructDeclaration(structType); // Declare the fields of the current type @@ -474,9 +474,9 @@ partial class IShaderGenerator INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; // Convert the name to the fully qualified HLSL version - if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullMetadataName(), out string? mappedType)) + if (!HlslKnownTypes.TryGetMappedName(fieldType.GetFullyQualifiedMetadataName(), out string? mappedType)) { - mappedType = fieldType.GetFullMetadataName().ToHlslIdentifierName(); + mappedType = fieldType.GetFullyQualifiedMetadataName().ToHlslIdentifierName(); } // Get the field name as a valid HLSL identifier diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs index 4c432101..69e56563 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs @@ -45,7 +45,7 @@ partial class IShaderGenerator bool supportsDynamicShaders) { // Try to get the attribute that controls shader precompilation (has to be present when ComputeSharp.Dynamic is not referenced) - if (!structDeclarationSymbol.TryGetAttributeWithFullMetadataName(typeof(EmbeddedBytecodeAttribute).FullName, out AttributeData? attribute)) + if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName(typeof(EmbeddedBytecodeAttribute).FullName, out AttributeData? attribute)) { // Emit the diagnostics if dynamic shaders are not supported if (!supportsDynamicShaders) diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs index cb2604f7..d028a75b 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -54,7 +54,7 @@ partial class IShaderGenerator select fieldSymbol) { string fieldName = fieldSymbol.Name; - string typeName = fieldSymbol.Type.GetFullMetadataName(); + string typeName = fieldSymbol.Type.GetFullyQualifiedMetadataName(); // Disambiguates the name of target fields against the current input parameters if (fieldName is "loader" or "device" or "x" or "y" or "z") diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs index f5288781..384f8239 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs @@ -130,7 +130,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getDispatchIdMethod = GetDispatchId.GetSyntax(item.DispatchId.Delegates); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getDispatchIdMethod, canUseSkipLocalsInit: false); - context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetDispatchId)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetDispatchId)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the LoadDispatchData() info (hierarchy and dispatch data info) @@ -149,7 +149,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator item.Info.DispatchData.Root32BitConstantCount); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, loadDispatchDataMethod, item.CanUseSkipLocalsInit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(LoadDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Check whether raw multiline string literals can be used (C# 11) @@ -169,7 +169,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax buildHlslStringMethod = BuildHlslSource.GetSyntax(item.Info.HlslShaderSource, item.Options.SupportsDynamicShaders, item.Info.Hierarchy.Hierarchy.Length, item.Options.CanUseRawMultilineStringLiterals); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, buildHlslStringMethod, item.Options.CanUseSkipLocalsInit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(BuildHlslSource)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(BuildHlslSource)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Get the LoadDispatchMetadata() info (hierarchy and dispatch metadata info) @@ -184,7 +184,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax buildHlslStringMethod = LoadDispatchMetadata.GetSyntax(item.Info.DispatchMetadata); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, buildHlslStringMethod, item.CanUseSkipLocalsInit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(LoadDispatchMetadata)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadDispatchMetadata)}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Transform the raw HLSL source to compile (this step aggregates the HLSL source to ensure compilation is only done for actual HLSL changes) @@ -239,7 +239,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, tryGetBytecodeMethod, canUseSkipLocalsInit: false); SourceText text = fixup(compilationUnit); - context.AddSource($"{item.Info.Hierarchy.FilenameHint}.{nameof(LoadBytecode)}.g.cs", text); + context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadBytecode)}.g.cs", text); }); } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 5456019b..887e985b 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -141,12 +141,12 @@ partial class HlslKnownTypes return ""; } - string typeName = typeSymbol.GetFullMetadataName(); + string typeName = typeSymbol.GetFullyQualifiedMetadataName(); // Special case for the resource types if (IsTypedResourceType(typeName)) { - string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments.Last()).GetFullMetadataName(); + string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments.Last()).GetFullyQualifiedMetadataName(); // If the current type is a custom type, format it as needed if (!KnownHlslTypes.TryGetValue(genericArgumentName, out string? mappedElementType)) @@ -202,7 +202,7 @@ partial class HlslKnownTypes /// The HLSL-compatible type name that can be used in an HLSL shader. public static string GetMappedNameForPixelShaderType(INamedTypeSymbol typeSymbol) { - string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments.First()).GetFullMetadataName(); + string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments.First()).GetFullyQualifiedMetadataName(); // If the current type is a custom type, format it as needed if (!KnownHlslTypes.TryGetValue(genericArgumentName, out string? mappedElementType)) diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index 21e5888a..21297442 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -94,7 +94,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator diagnostics = builder.ToImmutable(); return new( - methodSymbol.GetFullMetadataName(includeParameters: true), + methodSymbol.GetFullyQualifiedMetadataName(includeParameters: true), entryPoint, definedTypes, definedConstants, diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 50a7c8aa..4d684730 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -53,7 +53,7 @@ partial class ShaderSourceRewriter // Mark which dispatch properties have been used, to optimize the declaration afterwards if (operation.Member.IsStatic) { - string typeName = operation.Member.ContainingType.GetFullMetadataName(); + string typeName = operation.Member.ContainingType.GetFullyQualifiedMetadataName(); if (mappedName == $"__{nameof(GroupIds)}__get_Index") { diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs index 0d4e2695..9abfa78d 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs @@ -15,7 +15,7 @@ partial class StaticFieldRewriter { if (operation.Member.IsStatic) { - string typeName = operation.Member.ContainingType.GetFullMetadataName(); + string typeName = operation.Member.ContainingType.GetFullyQualifiedMetadataName(); // Special dispatch types are not supported from static constants DiagnosticDescriptor? descriptor = typeName switch