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 { /// partial class GetPixelOptions { /// /// Creates a instance for the GetPixelOptions method. /// /// The pixel options for the shader. /// The resulting instance for the GetPixelOptions method. public static MethodDeclarationSyntax GetSyntax(D2D1PixelOptions pixelOptions) { // This code produces a method declaration as follows: // // readonly uint global::ComputeSharp.D2D1.__Internals.ID2D1Shader.GetPixelOptions() // { // return ; // } return MethodDeclaration(PredefinedType(Token(SyntaxKind.UIntKeyword)), Identifier(nameof(GetPixelOptions))) .WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}"))) .AddModifiers(Token(SyntaxKind.ReadOnlyKeyword)) .WithBody(Block(ReturnStatement(LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)pixelOptions))))); } } }