diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
similarity index 96%
rename from src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs
rename to src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
index 0e194dc4..66612f3d 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
@@ -14,24 +14,26 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
///
- partial class GetInputType
+ partial class InputTypes
{
///
- /// Creates a instance for the GetInputTypeMethod method.
+ /// Creates a instance for the InputTypes property.
///
/// The input types for the shader.
- /// The resulting instance for the GetInputTypeMethod method.
- public static (MemberDeclarationSyntax Member, MemberDeclarationSyntax Type) GetSyntax(ImmutableArray inputTypes)
+ /// An additional instance needed by the generated code.
+ /// The resulting instance for the InputTypes property.
+ public static PropertyDeclarationSyntax GetSyntax(ImmutableArray inputTypes, out TypeDeclarationSyntax additionalType)
{
+ additionalType = GetMemoryManagerDeclaration(inputTypes);
+
// This code produces a method declaration as follows:
//
// readonly uint global::ComputeSharp.D2D1.__Internals.ID2D1Shader.InputTypes => InputTypesMemoryManager.Memory;
- MemberDeclarationSyntax member =
+ return
PropertyDeclaration(
GenericName(Identifier("global::System.ReadOnlyMemory"))
.AddTypeArgumentListArguments(IdentifierName("global::ComputeSharp.D2D1.Interop.D2D1PixelShaderInputType")),
- Identifier("InputTypes")) // TODO: use nameof()
+ Identifier(nameof(InputTypes)))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithExpressionBody(ArrowExpressionClause(
@@ -40,8 +42,6 @@ partial class ID2D1ShaderGenerator
IdentifierName("InputTypesMemoryManager"),
IdentifierName("Memory"))))
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
-
- return (member, GetMemoryManagerDeclaration(inputTypes));
}
///
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.cs
similarity index 98%
rename from src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs
rename to src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.cs
index 4d79a732..7b2d19a7 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateGetInputTypeMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.cs
@@ -12,9 +12,9 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
///
- /// A helper with all logic to generate the GetInputType method.
+ /// A helper with all logic to generate the InputTypes properties.
///
- private static partial class GetInputType
+ private static partial class InputTypes
{
///
/// Extracts the input info for the current shader.
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
index 9df520a3..289258ac 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
@@ -91,8 +91,8 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
token.ThrowIfCancellationRequested();
- // Get the input info for GetInputInfo()
- GetInputType.GetInfo(
+ // Get the input info for InputTypes
+ InputTypes.GetInfo(
diagnostics,
typeSymbol,
out int inputCount,
@@ -257,18 +257,18 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetInputCount)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
- // Get the GetInputType() info (hierarchy and input types)
+ // Get the InputTypes info (hierarchy and input types)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, InputTypesInfo InputTypes)> inputTypesInfo =
shaderInfoWithErrors
.Select(static (item, _) => (item.Hierarchy, item.InputTypes));
- // Generate the GetInputType() methods
+ // Generate the InputTypes properties
context.RegisterSourceOutput(inputTypesInfo, static (context, item) =>
{
- (MemberDeclarationSyntax property, MemberDeclarationSyntax type) = GetInputType.GetSyntax(item.InputTypes.InputTypes);
- CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, property, canUseSkipLocalsInit: false, additionalMemberDeclarations: type);
+ MemberDeclarationSyntax inputTypesProperty = InputTypes.GetSyntax(item.InputTypes.InputTypes, out TypeDeclarationSyntax additionalType);
+ CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, inputTypesProperty, canUseSkipLocalsInit: false, additionalMemberDeclarations: additionalType);
- context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetInputType)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
+ context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(InputTypes)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
// Get the LoadResourceTextureDescriptions() info (hierarchy and resource texture descriptions)
diff --git a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
index 861c1dd7..d826f0c6 100644
--- a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
+++ b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
@@ -80,7 +80,6 @@ public interface ID2D1Shader
///
/// Gets the input types for the current shader.
///
- /// The input types for the current shader.
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
ReadOnlyMemory InputTypes { get; }