Remove post-generation fixup for effect id
このコミットが含まれているのは:
1 親
c3b64a90cd
コミット
f832e242f3
2ファイル変更
+10
-24
検索条件に一致するファイルはありません
+8
-21
@@ -1,11 +1,7 @@
|
|||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using ComputeSharp.D2D1.__Internals;
|
using ComputeSharp.D2D1.__Internals;
|
||||||
using ComputeSharp.SourceGeneration.Helpers;
|
using ComputeSharp.SourceGeneration.Helpers;
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
|
||||||
#pragma warning disable CS0618
|
#pragma warning disable CS0618
|
||||||
@@ -22,13 +18,17 @@ partial class ID2D1ShaderGenerator
|
|||||||
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>EffectId</c> property.
|
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>EffectId</c> property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">The input <see cref="EquatableArray{T}"/> instance with the effect GUID.</param>
|
/// <param name="info">The input <see cref="EquatableArray{T}"/> instance with the effect GUID.</param>
|
||||||
/// <param name="fixup">An opaque <see cref="Func{TResult}"/> instance to transform the final tree into text.</param>
|
|
||||||
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>EffectId</c> property.</returns>
|
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>EffectId</c> property.</returns>
|
||||||
public static PropertyDeclarationSyntax GetSyntax(EquatableArray<byte> info, out Func<SyntaxNode, SourceText> fixup)
|
public static PropertyDeclarationSyntax GetSyntax(EquatableArray<byte> info)
|
||||||
{
|
{
|
||||||
|
// Prepare the initialization text
|
||||||
|
string effectIdLiterals = SyntaxFormattingHelper.BuildByteArrayInitializationExpressionString(info.AsSpan());
|
||||||
|
|
||||||
|
ExpressionSyntax effectIdExpression = ParseExpression($$"""new byte[] { {{effectIdLiterals}} }""");
|
||||||
|
|
||||||
// Create the local declaration:
|
// Create the local declaration:
|
||||||
//
|
//
|
||||||
// global::System.ReadOnlySpan<byte> bytes = new byte[] { __EMBEDDED_EFFECT_ID_BYTES };
|
// global::System.ReadOnlySpan<byte> bytes = new byte[] { <EMBEDDED_EFFECT_ID_BYTES> };
|
||||||
LocalDeclarationStatementSyntax guidBytesDeclaration =
|
LocalDeclarationStatementSyntax guidBytesDeclaration =
|
||||||
LocalDeclarationStatement(
|
LocalDeclarationStatement(
|
||||||
VariableDeclaration(
|
VariableDeclaration(
|
||||||
@@ -37,20 +37,7 @@ partial class ID2D1ShaderGenerator
|
|||||||
.AddVariables(
|
.AddVariables(
|
||||||
VariableDeclarator(Identifier("bytes"))
|
VariableDeclarator(Identifier("bytes"))
|
||||||
.WithInitializer(
|
.WithInitializer(
|
||||||
EqualsValueClause(
|
EqualsValueClause(effectIdExpression))));
|
||||||
ArrayCreationExpression(
|
|
||||||
ArrayType(PredefinedType(Token(SyntaxKind.ByteKeyword)))
|
|
||||||
.AddRankSpecifiers(ArrayRankSpecifier(SingletonSeparatedList<ExpressionSyntax>(OmittedArraySizeExpression()))))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ArrayInitializerExpression,
|
|
||||||
SingletonSeparatedList<ExpressionSyntax>(IdentifierName("__EMBEDDED_EFFECT_ID_BYTES"))))))));
|
|
||||||
|
|
||||||
// Prepare the initialization text
|
|
||||||
string effectIdLiterals = SyntaxFormattingHelper.BuildByteArrayInitializationExpressionString(info.AsSpan());
|
|
||||||
|
|
||||||
// Set the fixup function
|
|
||||||
fixup = tree => SourceText.From(tree.ToFullString().Replace("__EMBEDDED_EFFECT_ID_BYTES", effectIdLiterals), Encoding.UTF8);
|
|
||||||
|
|
||||||
// Prepare the return statement:
|
// Prepare the return statement:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -198,11 +198,10 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
|||||||
// Generate the EffectId properties
|
// Generate the EffectId properties
|
||||||
context.RegisterSourceOutput(effectIdInfo, static (context, item) =>
|
context.RegisterSourceOutput(effectIdInfo, static (context, item) =>
|
||||||
{
|
{
|
||||||
PropertyDeclarationSyntax effectDisplayNameProperty = EffectId.GetSyntax(item.EffectId, out Func<SyntaxNode, SourceText> fixup);
|
PropertyDeclarationSyntax effectDisplayNameProperty = EffectId.GetSyntax(item.EffectId);
|
||||||
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectDisplayNameProperty, skipLocalsInit: false);
|
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectDisplayNameProperty, skipLocalsInit: false);
|
||||||
SourceText text = fixup(compilationUnit);
|
|
||||||
|
|
||||||
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(EffectId)}.g.cs", text);
|
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(EffectId)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the EffectDisplayName info (hierarchy and effect display name)
|
// Get the EffectDisplayName info (hierarchy and effect display name)
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする