Background
PR #12957 introduced the deferred tag helper lowering pipeline which changed how RewrittenSyntaxTree is used. The resolution phase (DefaultTagHelperResolutionPhase) no longer accesses the syntax tree directly — it works purely with IR nodes. However, the RewrittenSyntaxTree property on RazorCodeDocument is still set and checked in ways that feel inconsistent after the refactoring.
What to change
- Review the naming of
RewrittenSyntaxTree — now that the resolution phase doesn't use the syntax tree, the name may be misleading about when/why it's set.
- Review the null handling: if the resolution phase runs on the pre-rewrite tree,
RewrittenSyntaxTree being null at certain points should either be an error (assert) or handled gracefully with a new/empty tree — not silently allowed.
- Update invariants/comments to reflect the new pipeline architecture.
Files to update
src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/DefaultTagHelperResolutionPhase.cs
src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorCodeDocument.cs (or wherever RewrittenSyntaxTree is defined)
Notes
- This is a naming/documentation/invariant cleanup — behavioral changes should be minimal.
- Be careful with null semantics: the current null-means-fallback behavior may be load-bearing.
ref: PR #12957 review comment #12957 (comment)
Background
PR #12957 introduced the deferred tag helper lowering pipeline which changed how
RewrittenSyntaxTreeis used. The resolution phase (DefaultTagHelperResolutionPhase) no longer accesses the syntax tree directly — it works purely with IR nodes. However, theRewrittenSyntaxTreeproperty onRazorCodeDocumentis still set and checked in ways that feel inconsistent after the refactoring.What to change
RewrittenSyntaxTree— now that the resolution phase doesn't use the syntax tree, the name may be misleading about when/why it's set.RewrittenSyntaxTreebeing null at certain points should either be an error (assert) or handled gracefully with a new/empty tree — not silently allowed.Files to update
src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/DefaultTagHelperResolutionPhase.cssrc/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorCodeDocument.cs(or whereverRewrittenSyntaxTreeis defined)Notes
ref: PR #12957 review comment #12957 (comment)