Skip to content

Make IntermediateNodeCollection implement IReadOnlyList<IntermediateNode> #12999

@chsienki

Description

@chsienki

Background

IntermediateNodeCollection is the collection type used for Children on all IR nodes. It currently doesn't implement IReadOnlyList<IntermediateNode>, which means code that needs to check types of all children (e.g., AreAllChildrenOfType<T>) requires custom helper methods instead of using standard LINQ/pattern matching.

What to change

Make IntermediateNodeCollection implement IReadOnlyList<IntermediateNode> (it likely already has the necessary indexer and Count).

Files to update

  • src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/IntermediateNodeCollection.cs
  • Verify no downstream compilation issues from the interface addition.

Notes

  • This is an additive change — existing code continues to work.
  • Enables patterns like children.All(c => c is HtmlIntermediateToken) and list pattern matching.
  • The collection is internal, so there are no public API concerns.

ref: PR #12957 review comment #12957 (comment)

Metadata

Metadata

Labels

area-compilerUmbrella for all compiler issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions