using ComputeSharp.D2D1.__Internals;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.SourceGenerators;
///
partial class ID2D1ShaderGenerator
{
///
/// A helper with all logic to generate the GetInputCount method.
///
private static partial class GetInputCount
{
///
/// Creates a instance for the GetInputCount method.
///
/// The number of inputs for the shader.
/// The resulting instance for the GetInputCount method.
public static MethodDeclarationSyntax GetSyntax(int inputCount)
{
// This code produces a method declaration as follows:
//
// readonly uint global::ComputeSharp.D2D1.__Internals.ID2D1Shader.GetInputCount()
// {
// return ;
// }
return
MethodDeclaration(PredefinedType(Token(SyntaxKind.UIntKeyword)), Identifier(nameof(GetInputCount)))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithBody(Block(ReturnStatement(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(inputCount)))));
}
}
}