Change RazorSyntaxTree.Diagnostics from an IReadOnlyList<RazorDiagnostic> to an ImmutableArray<RazorDiagnostic>#10797
Merged
DustinCampbell merged 15 commits intoSep 4, 2024
Conversation
- Use pooled `ImmutableArray<RazorDiagnostic>.Builder` internally - Don't request pooled builder until first error is added - Make ErrorSink disposable to return builder to pool - Add GetErrorsAndClear() method to returns an `ImmutableArray<RazorDiagnostic>` and clears out the sink. - Add 'ParserContext.PushNewErrorScope(...)` to handle the temporary ErrorSinks used by CSharpCodeParser
This change cleans up ParserContext a bit and uses pooled collections within it.
davidwengier
approved these changes
Aug 30, 2024
| _inlineCount = 0; | ||
| } | ||
|
|
||
| public readonly ImmutableArray<T> ToImmutableOrdered() |
Member
There was a problem hiding this comment.
I was looking for these methods just yesterday, and I couldn't find them, but knew I'd seem them somewhere. The mystery is solved! :D
chsienki
approved these changes
Aug 30, 2024
chsienki
left a comment
Member
There was a problem hiding this comment.
LGTM. I think every time I saw something I wanted to comment on, you fixed it in the next commit :)
333fred
approved these changes
Aug 30, 2024
333fred
left a comment
Member
There was a problem hiding this comment.
Thanks as always for the meticulous commit history Dustin, it significantly helps make these reviews easy. Only one small testing comment, otherwise everything LGTM.
It is perfectly legal for a PooledArrayBuilder<T> to be drained via one of the DrainToImmutable* methods and then continue adding items to the builder. However, if the inner ImmutableArray<T>.Builder's capacity was set to 0 during the drain, its capacity will not be reset to any specified value when adding new items. This change fixes that.
333fred
approved these changes
Sep 3, 2024
This was referenced Sep 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request represents several changes with the ultimate goal of exposing
RazorSyntaxTree.Diagnosticsas anImmutableArray<RazorDiagnostic>rather than anIReadOnlyList<RazorDiagnostic>:RazorSyntaxTreeand get rid ofDefaultRazorSyntaxTree.(Drain)ToImmutableOrdered*methods toPooledArrayBuilder<T>. Note that this change also includes a refactoring to the various unit tests for ordering to share test data that I've isolated to a single commit.ErrorSinkto no longer greedily create a newList<T>before any errors are encountered.ParserContextand make it used pooled collections.RazorSyntaxTree.Diagnostics.