Switch CodeRenderingContext.LinePragmas to an ImmutableArray

This commit is contained in:
Dustin Campbell 2024-08-09 13:44:53 -07:00
Родитель 25acc07be2
Коммит d00b1ffab8
3 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -30,7 +30,7 @@ public sealed class CodeRenderingContext : IDisposable
private readonly PooledObject<Stack<IntermediateNode>> _pooledAncestors;
private readonly PooledObject<Stack<ScopeInternal>> _pooledScopeStack;
private readonly PooledObject<ImmutableArray<SourceMapping>.Builder> _pooledSourceMappings;
private readonly PooledObject<List<LinePragma>> _pooledLinePragmas;
private readonly PooledObject<ImmutableArray<LinePragma>.Builder> _pooledLinePragmas;
public CodeRenderingContext(
IntermediateNodeWriter nodeWriter,
@ -51,7 +51,7 @@ public sealed class CodeRenderingContext : IDisposable
Diagnostics = [];
Items = [];
_pooledSourceMappings = ArrayBuilderPool<SourceMapping>.GetPooledObject();
_pooledLinePragmas = ListPool<LinePragma>.GetPooledObject();
_pooledLinePragmas = ArrayBuilderPool<LinePragma>.GetPooledObject();
var diagnostics = _documentNode.GetAllDiagnostics();
for (var i = 0; i < diagnostics.Count; i++)
@ -81,7 +81,7 @@ public sealed class CodeRenderingContext : IDisposable
public ImmutableArray<SourceMapping>.Builder SourceMappings => _pooledSourceMappings.Object;
internal List<LinePragma> LinePragmas => _pooledLinePragmas.Object;
internal ImmutableArray<LinePragma>.Builder LinePragmas => _pooledLinePragmas.Object;
public IntermediateNodeWriter NodeWriter => Current.Writer;

Просмотреть файл

@ -51,7 +51,7 @@ internal class DefaultDocumentWriter : DocumentWriter
_options,
allOrderedDiagnostics.ToArray(),
context.SourceMappings.DrainToImmutable(),
context.LinePragmas.ToArray());
context.LinePragmas.DrainToImmutable());
}
private class Visitor : IntermediateNodeVisitor

Просмотреть файл

@ -15,7 +15,7 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
public RazorCodeGenerationOptions Options { get; }
public IReadOnlyList<RazorDiagnostic> Diagnostics { get; }
public ImmutableArray<SourceMapping> SourceMappings { get; }
internal IReadOnlyList<LinePragma> LinePragmas { get; }
internal ImmutableArray<LinePragma> LinePragmas { get; }
public RazorCSharpDocument(
RazorCodeDocument codeDocument,
@ -23,7 +23,7 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
RazorCodeGenerationOptions options,
RazorDiagnostic[] diagnostics,
ImmutableArray<SourceMapping> sourceMappings,
LinePragma[] linePragmas)
ImmutableArray<LinePragma> linePragmas)
{
ArgHelper.ThrowIfNull(codeDocument);
ArgHelper.ThrowIfNull(generatedCode);
@ -33,8 +33,8 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
Options = options;
Diagnostics = diagnostics ?? [];
SourceMappings = sourceMappings;
LinePragmas = linePragmas ?? [];
SourceMappings = sourceMappings.NullToEmpty();
LinePragmas = linePragmas.NullToEmpty();
}
public static RazorCSharpDocument Create(
@ -56,12 +56,12 @@ public sealed class RazorCSharpDocument : IRazorGeneratedDocument
RazorCodeGenerationOptions options,
IEnumerable<RazorDiagnostic> diagnostics,
ImmutableArray<SourceMapping> sourceMappings,
IEnumerable<LinePragma> linePragmas)
ImmutableArray<LinePragma> linePragmas)
{
ArgHelper.ThrowIfNull(generatedCode);
ArgHelper.ThrowIfNull(options);
ArgHelper.ThrowIfNull(diagnostics);
return new(codeDocument, generatedCode, options, diagnostics.ToArray(), sourceMappings, linePragmas.ToArray());
return new(codeDocument, generatedCode, options, diagnostics.ToArray(), sourceMappings, linePragmas);
}
}