Simplify creating source generator builder types
このコミットが含まれているのは:
1 親
26934553f6
コミット
7506cab338
27ファイル変更
+58
-88
検索条件に一致するファイルはありません
@@ -25,21 +25,11 @@ internal struct ImmutableArrayBuilder<T> : IDisposable
|
||||
private Writer? writer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ImmutableArrayBuilder{T}"/> value with a pooled underlying data writer.
|
||||
/// Creates a new <see cref="ImmutableArrayBuilder{T}"/> object.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ImmutableArrayBuilder{T}"/> instance to write data to.</returns>
|
||||
public static ImmutableArrayBuilder<T> Rent()
|
||||
public ImmutableArrayBuilder()
|
||||
{
|
||||
return new(SharedObjectPool.Allocate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ImmutableArrayBuilder{T}"/> object with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="writer">The target data writer to use.</param>
|
||||
private ImmutableArrayBuilder(Writer writer)
|
||||
{
|
||||
this.writer = writer;
|
||||
this.writer = SharedObjectPool.Allocate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -27,21 +27,11 @@ internal struct ImmutableHashSetBuilder<T> : IDisposable
|
||||
private HashSet<T>? set;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ImmutableHashSetBuilder{T}"/> value with a pooled underlying data writer.
|
||||
/// Creates a new <see cref="ImmutableHashSetBuilder{T}"/> object.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ImmutableHashSetBuilder{T}"/> instance to write data to.</returns>
|
||||
public static ImmutableHashSetBuilder<T> Rent()
|
||||
public ImmutableHashSetBuilder()
|
||||
{
|
||||
return new(SharedObjectPool.Allocate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ImmutableHashSetBuilder{T}"/> object with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="set">The target <see cref="HashSet{T}"/> instance to use.</param>
|
||||
private ImmutableHashSetBuilder(HashSet<T> set)
|
||||
{
|
||||
this.set = set;
|
||||
this.set = SharedObjectPool.Allocate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -45,21 +45,11 @@ internal sealed class IndentedTextWriter : IDisposable
|
||||
private string[] availableIndentations;
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IndentedTextWriter"/> instance with a pooled underlying data writer.
|
||||
/// Creates a new <see cref="IndentedTextWriter"/> object.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IndentedTextWriter"/> instance to write data to.</returns>
|
||||
public static IndentedTextWriter Rent()
|
||||
public IndentedTextWriter()
|
||||
{
|
||||
return new(ImmutableArrayBuilder<char>.Rent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="IndentedTextWriter"/> object with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="builder">The target <see cref="ImmutableArrayBuilder{T}"/> instance to use.</param>
|
||||
private IndentedTextWriter(ImmutableArrayBuilder<char> builder)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.builder = new ImmutableArrayBuilder<char>();
|
||||
this.currentIndentationLevel = 0;
|
||||
this.currentIndentation = "";
|
||||
this.availableIndentations = new string[4];
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする