Honor inherited AssetPath attributes on component parameters - #85171
Merged
Conversation
AssetPathAttribute applies to property overrides, but tag helper discovery only checks attributes declared directly on the selected property. Follow the overridden-property chain so derived component parameters retain the opt-in without affecting hidden properties. Add integration coverage for an override that redeclares Parameter while inheriting AssetPath. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dd15ad81-c929-4d0c-91de-354c0c777533
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The override-chain attribute resolution change is narrowly scoped and is covered by an integration regression test with baselines validating the expanded output.
Pull request overview
This PR fixes component-parameter asset-path opt-in detection so [AssetPath] applied on a base virtual parameter is still honored when a derived component overrides the property and redeclares only [Parameter], ensuring ~/ literals are expanded as intended.
Changes:
- Update component parameter discovery to treat
[AssetPath]as inherited across theOverriddenPropertychain. - Add an integration regression test + baselines covering
[AssetPath]on a base virtual parameter with a derived override that redeclares[Parameter]. - Preserve prior behavior for hidden (
new) properties by only following true overrides.
File summaries
| File | Description |
|---|---|
| src/Razor/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/TagHelpers/Producers/ComponentTagHelperProducer.cs | Detects [AssetPath] by walking OverriddenProperty to honor attribute inheritance for overrides. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs | Adds TildePath_ComponentParam_InheritedAssetPath regression test validating the new behavior end-to-end. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.mappings.txt | New baseline for source↔generated mappings for the inherited-[AssetPath] scenario. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.ir.txt | New baseline validating IR contains Assets[@"..."] expansion for the component parameter. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.decl.ir.txt | New baseline for declaration IR for the scenario. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.decl.codegen.cs | New baseline for declaration codegen output. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.codegen.cs | New baseline for implementation codegen output showing the expanded Assets[@"..."] expression. |
| src/Razor/src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentCodeGenerationTest/TildePath_ComponentParam_InheritedAssetPath/TestComponent.builder.txt | New baseline for the render-tree builder steps reflecting the expanded value. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 0
- Review effort level: Lite
davidwengier
approved these changes
Sep 6, 2026
This was referenced Sep 10, 2026
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.
AssetPathAttributehasInherited = true, but component parameter discovery only inspects attributes declared directly on the selected property. An override that redeclares[Parameter]therefore loses the base property's asset-path opt-in and leaves~/literals unexpanded.Follow the
OverriddenPropertychain when resolving[AssetPath]. This preserves attribute inheritance for overrides without applying the opt-in to hidden properties. Add an integration baseline covering a base virtual parameter with[AssetPath]and a derived override that redeclares only[Parameter].Addresses #84796 (comment)
Microsoft Reviewers: Open in CodeFlow