Rename and update source generator files
このコミットが含まれているのは:
1 親
a6b87b551c
コミット
41ca3a0b1d
4ファイル変更
+18
-19
検索条件に一致するファイルはありません
+9
-9
@@ -14,24 +14,26 @@ namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
partial class ID2D1ShaderGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class GetInputType
|
||||
partial class InputTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>GetInputTypeMethod</c> method.
|
||||
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>InputTypes</c> property.
|
||||
/// </summary>
|
||||
/// <param name="inputTypes">The input types for the shader.</param>
|
||||
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c
|
||||
/// >GetInputTypeMethod</c> method.</returns>
|
||||
public static (MemberDeclarationSyntax Member, MemberDeclarationSyntax Type) GetSyntax(ImmutableArray<uint> inputTypes)
|
||||
/// <param name="additionalType">An additional <see cref="TypeDeclarationSyntax"/> instance needed by the generated code.</param>
|
||||
/// <returns>The resulting <see cref="MemberDeclarationSyntax"/> instance for the <c>InputTypes</c> property.</returns>
|
||||
public static PropertyDeclarationSyntax GetSyntax(ImmutableArray<uint> 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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
+2
-2
@@ -12,9 +12,9 @@ namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
partial class ID2D1ShaderGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>GetInputType</c> method.
|
||||
/// A helper with all logic to generate the <c>InputTypes</c> properties.
|
||||
/// </summary>
|
||||
private static partial class GetInputType
|
||||
private static partial class InputTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Extracts the input info for the current shader.
|
||||
@@ -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)
|
||||
|
||||
@@ -80,7 +80,6 @@ public interface ID2D1Shader
|
||||
/// <summary>
|
||||
/// Gets the input types for the current shader.
|
||||
/// </summary>
|
||||
/// <returns>The input types for the current shader.</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
ReadOnlyMemory<D2D1PixelShaderInputType> InputTypes { get; }
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする