Fix indentation of HLSL source expression

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-28 00:37:45 +02:00
1 親 e69f083b29
コミット 0780345ef9
3ファイル変更
+9 -9

検索条件に一致するファイルはありません

@@ -23,7 +23,8 @@ partial class ID2D1ShaderGenerator
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>HlslSource</c> property.</returns>
public static PropertyDeclarationSyntax GetSyntax(string hlslSource, int hierarchyDepth)
{
SyntaxToken hlslSourceLiteralExpression = SyntaxTokenHelper.CreateRawMultilineStringLiteral(hlslSource, hierarchyDepth);
// The indentation level is the current depth + 1 (for the property)
SyntaxToken hlslSourceLiteralExpression = SyntaxTokenHelper.CreateRawMultilineStringLiteral(hlslSource, hierarchyDepth + 1);
// This code produces a property declaration as follows:
//
+5 -7
ファイルの表示
@@ -17,13 +17,11 @@ internal static class SyntaxTokenHelper
/// <returns>A <see cref="SyntaxToken"/> representing a raw multiline string literal with the value of <paramref name="text"/>.</returns>
public static SyntaxToken CreateRawMultilineStringLiteral(string text, int indentationLevel)
{
// Create a token to represent the raw multiline string literal expression. Here some spaces are
// also added to properly align the resulting text with one indentation below the declaring string constant.
// The spaces are: 4 for each containing type, 4 for the containing method, and 4 for the one additional indentation.
// An extra newline and indentation has to be added to the raw text when there is no trailing newline, as not doing
// so would otherwise case the terminating """ token to fall on the same line, which is invalid syntax. This is only
// needed to make the code valid, as the actual literal context of the string is not affected and remains the same.
string indentation = new(' ', (4 * indentationLevel) + 4 + 4);
// Create a token to represent the raw multiline string literal expression. An extra newline and indentation
// has to be added to the raw text when there is no trailing newline, as not doing so would otherwise case
// the terminating """ token to fall on the same line, which is invalid syntax. This is only needed to make
// the code valid, as the actual literal context of the string is not affected and remains the same.
string indentation = new(' ', 4 * indentationLevel);
return Token(
TriviaList(),
@@ -119,7 +119,8 @@ partial class IShaderGenerator
sizeHint += textBuilder.Length;
SyntaxToken hlslSourceLiteralExpression = SyntaxTokenHelper.CreateRawMultilineStringLiteral(hlslSource, hierarchyDepth);
// The indentation level is the current depth + 2 (the method, and the return expression)
SyntaxToken hlslSourceLiteralExpression = SyntaxTokenHelper.CreateRawMultilineStringLiteral(hlslSource, hierarchyDepth + 2);
statements.Add(
ExpressionStatement(