Simplify creating source generator builder types
このコミットが含まれているのは:
1 親
26934553f6
コミット
7506cab338
27ファイル変更
+58
-88
検索条件に一致するファイルはありません
@@ -87,7 +87,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
|
||||
string assemblyName = typeSymbol.ContainingAssembly?.Name ?? string.Empty;
|
||||
|
||||
using ImmutableArrayBuilder<char> charBuffer = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> charBuffer = new();
|
||||
|
||||
// Format the fully qualified name into a pooled builder to avoid the string allocation
|
||||
typeSymbol.AppendFullyQualifiedMetadataName(in charBuffer);
|
||||
|
||||
+7
-7
@@ -105,8 +105,8 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
out ImmutableArray<(string Name, string HlslType)> valueFields,
|
||||
out ImmutableArray<(string Name, string HlslType, int Index)> resourceTextureFields)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string)> values = ImmutableArrayBuilder<(string, string)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string, int)> resourceTextures = ImmutableArrayBuilder<(string, string, int)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string)> values = new();
|
||||
using ImmutableArrayBuilder<(string, string, int)> resourceTextures = new();
|
||||
|
||||
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
|
||||
{
|
||||
@@ -198,7 +198,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
out bool needsD2D1RequiresScenePosition)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string, string?)> builder = ImmutableArrayBuilder<(string, string, string?)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string, string?)> builder = new();
|
||||
|
||||
needsD2D1RequiresScenePosition = false;
|
||||
|
||||
@@ -279,7 +279,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
|
||||
string? entryPoint = null;
|
||||
|
||||
using ImmutableArrayBuilder<(string, string)> methods = ImmutableArrayBuilder<(string, string)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string)> methods = new();
|
||||
|
||||
needsD2D1RequiresScenePosition = false;
|
||||
|
||||
@@ -357,7 +357,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
/// <returns>A sequence of discovered constants to declare in the shader.</returns>
|
||||
private static ImmutableArray<(string Name, string Value)> GetDefinedConstants(IReadOnlyDictionary<IFieldSymbol, string> constantDefinitions)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string)> builder = new();
|
||||
|
||||
foreach (KeyValuePair<IFieldSymbol, string> constant in constantDefinitions)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
IEnumerable<INamedTypeSymbol> types,
|
||||
IReadOnlyDictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent();
|
||||
using ImmutableArrayBuilder<(string, string)> builder = new();
|
||||
|
||||
IReadOnlyCollection<INamedTypeSymbol> invalidTypes;
|
||||
|
||||
@@ -526,7 +526,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
ImmutableArray<int> inputComplexIndices,
|
||||
bool requiresScenePosition)
|
||||
{
|
||||
using ImmutableArrayBuilder<char> hlslBuilder = ImmutableArrayBuilder<char>.Rent();
|
||||
using ImmutableArrayBuilder<char> hlslBuilder = new();
|
||||
|
||||
void AppendLF()
|
||||
{
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
|
||||
using (writer.WriteBlock())
|
||||
{
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> dataMembers = ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>>.Rent();
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> dataMembers = new();
|
||||
|
||||
RegisterAdditionalDataMemberSyntax(info, dataMembers);
|
||||
ResourceTextureDescriptions.RegisterAdditionalDataMemberSyntax(info, dataMembers);
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
int inputCount = 0;
|
||||
|
||||
using ImmutableArrayBuilder<InputDescription> inputDescriptionsBuilder = ImmutableArrayBuilder<InputDescription>.Rent();
|
||||
using ImmutableArrayBuilder<InputDescription> inputDescriptionsBuilder = new();
|
||||
|
||||
foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes())
|
||||
{
|
||||
|
||||
+3
-3
@@ -41,8 +41,8 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
|
||||
inputCount = 0;
|
||||
|
||||
using ImmutableArrayBuilder<int> inputSimpleIndicesBuilder = ImmutableArrayBuilder<int>.Rent();
|
||||
using ImmutableArrayBuilder<int> inputComplexIndicesBuilder = ImmutableArrayBuilder<int>.Rent();
|
||||
using ImmutableArrayBuilder<int> inputSimpleIndicesBuilder = new();
|
||||
using ImmutableArrayBuilder<int> inputComplexIndicesBuilder = new();
|
||||
|
||||
foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes())
|
||||
{
|
||||
@@ -154,7 +154,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
}
|
||||
|
||||
// Build the combined input types list now that inputs have been validated
|
||||
using ImmutableArrayBuilder<uint> combinedBuilder = ImmutableArrayBuilder<uint>.Rent();
|
||||
using ImmutableArrayBuilder<uint> combinedBuilder = new();
|
||||
|
||||
for (int i = 0; i < inputCount; i++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
// each row needs to be at a multiple of 16 bytes (a float4 register).
|
||||
if (HlslKnownTypes.IsNonLinearMatrixType(typeName, out string? elementName, out int rows, out int columns))
|
||||
{
|
||||
using ImmutableArrayBuilder<int> builder = ImmutableArrayBuilder<int>.Rent();
|
||||
using ImmutableArrayBuilder<int> builder = new();
|
||||
|
||||
for (int j = 0; j < rows; j++)
|
||||
{
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
int inputCount,
|
||||
out ImmutableArray<ResourceTextureDescription> resourceTextureDescriptions)
|
||||
{
|
||||
using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = ImmutableArrayBuilder<(int? Index, int Rank)>.Rent();
|
||||
using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = new();
|
||||
|
||||
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
|
||||
{
|
||||
@@ -72,7 +72,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
}
|
||||
|
||||
// Extract the resource texture descriptions for the rest of the pipeline
|
||||
using (ImmutableArrayBuilder<ResourceTextureDescription> resourceTextureDescriptionsBuilder = ImmutableArrayBuilder<ResourceTextureDescription>.Rent())
|
||||
using (ImmutableArrayBuilder<ResourceTextureDescription> resourceTextureDescriptionsBuilder = new())
|
||||
{
|
||||
foreach ((int? index, int rank) in resourceTextureInfos.WrittenSpan)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = ImmutableArrayBuilder<DiagnosticInfo>.Rent();
|
||||
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = new();
|
||||
|
||||
// LoadDispatchData() info
|
||||
ImmutableArray<FieldInfo> fieldInfos = LoadConstantBuffer.GetInfo(
|
||||
@@ -201,7 +201,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
// Generate the source files, if any
|
||||
context.RegisterSourceOutput(outputInfo, static (context, item) =>
|
||||
{
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> declaredMembers = ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>>.Rent();
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> declaredMembers = new();
|
||||
|
||||
declaredMembers.Add(EffectId.WriteSyntax);
|
||||
declaredMembers.Add(EffectMetadata.WriteEffectDisplayNameSyntax);
|
||||
@@ -224,15 +224,15 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
declaredMembers.Add(CreateFromConstantBuffer.WriteSyntax);
|
||||
declaredMembers.Add(LoadConstantBuffer.WriteSyntax);
|
||||
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> additionalTypes = ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>>.Rent();
|
||||
using ImmutableHashSetBuilder<string> usingDirectives = ImmutableHashSetBuilder<string>.Rent();
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> additionalTypes = new();
|
||||
using ImmutableHashSetBuilder<string> usingDirectives = new();
|
||||
|
||||
LoadConstantBuffer.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
InputDescriptions.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
InputTypes.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
HlslBytecode.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
|
||||
using IndentedTextWriter writer = IndentedTextWriter.Rent();
|
||||
using IndentedTextWriter writer = new();
|
||||
|
||||
item.Hierarchy.WriteSyntax(
|
||||
state: item,
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
|
||||
MethodDeclarationSyntax methodDeclaration = (MethodDeclarationSyntax)context.TargetNode;
|
||||
IMethodSymbol methodSymbol = (IMethodSymbol)context.TargetSymbol;
|
||||
|
||||
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = ImmutableArrayBuilder<DiagnosticInfo>.Rent();
|
||||
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = new();
|
||||
|
||||
// Get the remaining info for the current shader
|
||||
ImmutableArray<ushort> modifiers = methodDeclaration.Modifiers.Select(token => (ushort)token.Kind()).ToImmutableArray();
|
||||
@@ -89,7 +89,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
|
||||
// Generate the shader bytecode methods
|
||||
context.RegisterSourceOutput(outputInfo, static (context, item) =>
|
||||
{
|
||||
using IndentedTextWriter writer = IndentedTextWriter.Rent();
|
||||
using IndentedTextWriter writer = new();
|
||||
|
||||
item.Hierarchy.WriteSyntax(
|
||||
state: item,
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする