Remove unnecessary ArrayPoolStringBuilder public methods
このコミットが含まれているのは:
1 親
b0db306f57
コミット
c40bdf0a26
2ファイル変更
+37
-70
検索条件に一致するファイルはありません
@@ -486,31 +486,6 @@ namespace ComputeSharp.SourceGenerators
|
||||
List<StatementSyntax> statements = new();
|
||||
StringBuilder textBuilder = new();
|
||||
int capturedDelegates = 0;
|
||||
|
||||
foreach (var (fieldSymbol, fieldName, fieldType) in instanceFields)
|
||||
{
|
||||
if (fieldSymbol.Type.TypeKind == TypeKind.Delegate)
|
||||
{
|
||||
// ShaderMethodSourceAttribute __<DELEGATE_NAME>Attribute = ShaderMethodSourceAttribute.GetForDelegate(<DELEGATE_NAME>, "<DELEGATE_NAME>");
|
||||
statements.Add(
|
||||
LocalDeclarationStatement(VariableDeclaration(IdentifierName(nameof(ShaderMethodSourceAttribute)))
|
||||
.AddVariables(
|
||||
VariableDeclarator(Identifier($"__{fieldName}Attribute"))
|
||||
.WithInitializer(
|
||||
EqualsValueClause(
|
||||
InvocationExpression(
|
||||
MemberAccessExpression(
|
||||
SyntaxKind.SimpleMemberAccessExpression,
|
||||
IdentifierName(nameof(ShaderMethodSourceAttribute)),
|
||||
IdentifierName(nameof(ShaderMethodSourceAttribute.GetForDelegate))))
|
||||
.AddArgumentListArguments(
|
||||
Argument(IdentifierName(fieldName)),
|
||||
Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(fieldName)))))))));
|
||||
|
||||
capturedDelegates++;
|
||||
}
|
||||
}
|
||||
|
||||
int sizeHint = 64;
|
||||
|
||||
void AppendLF()
|
||||
@@ -558,6 +533,31 @@ namespace ComputeSharp.SourceGenerators
|
||||
}
|
||||
}
|
||||
|
||||
// Go through all existing delegate fields, if any
|
||||
foreach (var (fieldSymbol, fieldName, fieldType) in instanceFields)
|
||||
{
|
||||
if (fieldSymbol.Type.TypeKind == TypeKind.Delegate)
|
||||
{
|
||||
// ShaderMethodSourceAttribute __<DELEGATE_NAME>Attribute = ShaderMethodSourceAttribute.GetForDelegate(<DELEGATE_NAME>, "<DELEGATE_NAME>");
|
||||
statements.Add(
|
||||
LocalDeclarationStatement(VariableDeclaration(IdentifierName(nameof(ShaderMethodSourceAttribute)))
|
||||
.AddVariables(
|
||||
VariableDeclarator(Identifier($"__{fieldName}Attribute"))
|
||||
.WithInitializer(
|
||||
EqualsValueClause(
|
||||
InvocationExpression(
|
||||
MemberAccessExpression(
|
||||
SyntaxKind.SimpleMemberAccessExpression,
|
||||
IdentifierName(nameof(ShaderMethodSourceAttribute)),
|
||||
IdentifierName(nameof(ShaderMethodSourceAttribute.GetForDelegate))))
|
||||
.AddArgumentListArguments(
|
||||
Argument(IdentifierName(fieldName)),
|
||||
Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(fieldName)))))))));
|
||||
|
||||
capturedDelegates++;
|
||||
}
|
||||
}
|
||||
|
||||
// Header
|
||||
AppendLineAndLF("// ================================================");
|
||||
AppendLineAndLF("// AUTO GENERATED");
|
||||
@@ -568,11 +568,11 @@ namespace ComputeSharp.SourceGenerators
|
||||
// Group size constants
|
||||
AppendLF();
|
||||
AppendLine("#define __GroupSize__get_X ");
|
||||
AppendStatement("builder.AppendLine(threadsX.ToString());");
|
||||
AppendStatement("builder.Append(threadsX);");
|
||||
AppendLine("#define __GroupSize__get_Y ");
|
||||
AppendStatement("builder.AppendLine(threadsY.ToString());");
|
||||
AppendStatement("builder.Append(threadsY);");
|
||||
AppendLine("#define __GroupSize__get_Z ");
|
||||
AppendStatement("builder.AppendLine(threadsZ.ToString());");
|
||||
AppendStatement("builder.Append(threadsZ);");
|
||||
|
||||
// Define declarations
|
||||
foreach (var (name, value) in definedConstants)
|
||||
@@ -707,7 +707,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
if (fieldSymbol.Type.TypeKind == TypeKind.Delegate)
|
||||
{
|
||||
AppendLF();
|
||||
AppendStatement($"builder.AppendLine(__{fieldName}Attribute.{nameof(ShaderMethodSourceAttribute.GetMappedInvokeMethod)}(\"{fieldName}\"));");
|
||||
AppendStatement($"builder.Append(__{fieldName}Attribute.{nameof(ShaderMethodSourceAttribute.GetMappedInvokeMethod)}(\"{fieldName}\"));");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -9,6 +10,8 @@ namespace ComputeSharp.__Internals
|
||||
/// <summary>
|
||||
/// A helper type that implements a pooled buffer writer for <see cref="char"/> values.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This type is not intended to be used directly by user code")]
|
||||
[DebuggerTypeProxy(typeof(DebugView))]
|
||||
public ref struct ArrayPoolStringBuilder
|
||||
{
|
||||
@@ -59,49 +62,13 @@ namespace ComputeSharp.__Internals
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a character to the current buffer.
|
||||
/// Appends the text representation of the input value to the current buffer.
|
||||
/// </summary>
|
||||
public void Append(char character)
|
||||
/// <param name="value">The input value to write.</param>
|
||||
public void Append(int value)
|
||||
{
|
||||
EnsureCapacity(1);
|
||||
|
||||
this.array[this.index++] = character;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the input sequence of characters to the current buffer, with a trailing new line.
|
||||
/// </summary>
|
||||
/// <param name="value">The input characters to write.</param>
|
||||
public void AppendLine(string value)
|
||||
{
|
||||
EnsureCapacity(value.Length + 1);
|
||||
|
||||
value.AsSpan().CopyTo(this.array.AsSpan(this.index));
|
||||
|
||||
this.index += value.Length;
|
||||
|
||||
this.array[this.index++] = '\n';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a character and a new line to the current buffer.
|
||||
/// </summary>
|
||||
public void AppendLine(char character)
|
||||
{
|
||||
EnsureCapacity(2);
|
||||
|
||||
this.array[this.index++] = character;
|
||||
this.array[this.index++] = '\n';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a new line to the current buffer.
|
||||
/// </summary>
|
||||
public void AppendLine()
|
||||
{
|
||||
EnsureCapacity(1);
|
||||
|
||||
this.array[this.index++] = '\n';
|
||||
// TODO: switch to ISpanFormattable on .NET 6
|
||||
Append(value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする