Switch D2D1 generation methods to use indented writer
このコミットが含まれているのは:
1 親
bc1fc17b21
コミット
6accd17c9f
14ファイル変更
+555
-1372
検索条件に一致するファイルはありません
+11
-33
@@ -1,9 +1,5 @@
|
||||
using ComputeSharp.D2D1.__Internals;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
@@ -14,38 +10,20 @@ partial class ID2D1ShaderGenerator
|
||||
partial class PixelOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>PixelOptions</c> property.
|
||||
/// Writes the <c>PixelOptions</c> property.
|
||||
/// </summary>
|
||||
/// <param name="pixelOptions">The pixel options for the shader.</param>
|
||||
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>PixelOptions</c> property.</returns>
|
||||
public static PropertyDeclarationSyntax GetSyntax(D2D1PixelOptions pixelOptions)
|
||||
/// <param name="info">The input <see cref="D2D1ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
ExpressionSyntax pixelOptionsExpression;
|
||||
|
||||
// Set the right expression if the pixel options are valid
|
||||
if (pixelOptions is D2D1PixelOptions.None or D2D1PixelOptions.TrivialSampling)
|
||||
string pixelOptionsExpression = (info.PixelOptions is D2D1PixelOptions.None or D2D1PixelOptions.TrivialSampling) switch
|
||||
{
|
||||
pixelOptionsExpression =
|
||||
MemberAccessExpression(
|
||||
SyntaxKind.SimpleMemberAccessExpression,
|
||||
IdentifierName("ComputeSharp.D2D1.D2D1PixelOptions"),
|
||||
IdentifierName(pixelOptions.ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise just return default (the analyzer will emit a diagnostic)
|
||||
pixelOptionsExpression = LiteralExpression(SyntaxKind.DefaultLiteralExpression, Token(SyntaxKind.DefaultKeyword));
|
||||
}
|
||||
true => $"global::ComputeSharp.D2D1.D2D1PixelOptions.{info.PixelOptions}",
|
||||
false => "default"
|
||||
};
|
||||
|
||||
// This code produces a property declaration as follows:
|
||||
//
|
||||
// readonly ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.__Internals.ID2D1Shader.PixelOptions => <PIXEL_OPTIONS>;
|
||||
return
|
||||
PropertyDeclaration(IdentifierName("ComputeSharp.D2D1.D2D1PixelOptions"), Identifier(nameof(PixelOptions)))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExpressionBody(ArrowExpressionClause(pixelOptionsExpression))
|
||||
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.__Internals.ID2D1Shader.PixelOptions => {pixelOptionsExpression};");
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする