Simplify creating source generator builder types
このコミットが含まれているのは:
1 親
26934553f6
コミット
7506cab338
27ファイル変更
+58
-88
検索条件に一致するファイルはありません
@@ -16,7 +16,7 @@ internal static class IFieldSymbolExtensions
|
||||
/// <returns>The fully qualified metadata name for <paramref name="symbol"/>.</returns>
|
||||
public static string GetFullyQualifiedMetadataName(this IFieldSymbol symbol)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> builder = new();
|
||||
|
||||
symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ internal static class IMethodSymbolExtensions
|
||||
/// <returns>The fully qualified metadata name for <paramref name="symbol"/>.</returns>
|
||||
public static string GetFullyQualifiedMetadataName(this IMethodSymbol symbol, bool includeParameters = false)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> builder = new();
|
||||
|
||||
symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ internal static class IPropertySymbolExtensions
|
||||
/// <returns>The fully qualified metadata name for <paramref name="symbol"/>.</returns>
|
||||
public static string GetFullyQualifiedMetadataName(this IPropertySymbol symbol)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> builder = new();
|
||||
|
||||
symbol.ContainingType!.AppendFullyQualifiedMetadataName(in builder);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ internal static class ITypeSymbolExtensions
|
||||
/// <returns>Whether <paramref name="symbol"/> has a full name equals to <paramref name="name"/>.</returns>
|
||||
public static bool HasFullyQualifiedMetadataName(this ITypeSymbol symbol, string name)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> builder = new();
|
||||
|
||||
symbol.AppendFullyQualifiedMetadataName(in builder);
|
||||
|
||||
@@ -50,7 +50,7 @@ internal static class ITypeSymbolExtensions
|
||||
/// <returns>The fully qualified metadata name for <paramref name="symbol"/>.</returns>
|
||||
public static string GetFullyQualifiedMetadataName(this ITypeSymbol symbol)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> builder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> builder = new();
|
||||
|
||||
symbol.AppendFullyQualifiedMetadataName(in builder);
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -24,7 +24,7 @@ internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName,
|
||||
/// <returns>A <see cref="HierarchyInfo"/> instance describing <paramref name="typeSymbol"/>.</returns>
|
||||
public static HierarchyInfo From(INamedTypeSymbol typeSymbol)
|
||||
{
|
||||
using ImmutableArrayBuilder<TypeInfo> hierarchy = ImmutableArrayBuilder<TypeInfo>.Rent();
|
||||
using ImmutableArrayBuilder<TypeInfo> hierarchy = new();
|
||||
|
||||
for (INamedTypeSymbol? parent = typeSymbol;
|
||||
parent is not null;
|
||||
@@ -115,7 +115,7 @@ internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName,
|
||||
/// <returns>The fully qualified type name for the current instance.</returns>
|
||||
public string GetFullyQualifiedTypeName()
|
||||
{
|
||||
using ImmutableArrayBuilder<char> fullyQualifiedTypeName = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> fullyQualifiedTypeName = new();
|
||||
|
||||
fullyQualifiedTypeName.AddRange("global::".AsSpan());
|
||||
fullyQualifiedTypeName.AddRange(Namespace.AsSpan());
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする