Skip to content

Simplify ComponentFactory property injection and add subtype validation tests#64750

Merged
javiercn merged 2 commits intojaviercn/component-property-injectionfrom
copilot/sub-pr-64595
Dec 12, 2025
Merged

Simplify ComponentFactory property injection and add subtype validation tests#64750
javiercn merged 2 commits intojaviercn/component-property-injectionfrom
copilot/sub-pr-64595

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Simplify ComponentFactory property injection and add subtype validation tests

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Remove redundant conditional and validate subtype property injection

Description

Addresses feedback from #64595 to simplify property injection logic and ensure correctness when component activators return subtypes.

Code simplification

  • Removed redundant if-else in ComponentFactory.InstantiateComponent that had identical behavior in both branches
  • Both paths called the property activator with the actual component type, making the conditional check unnecessary

Test coverage

  • Added InstantiateComponent_WhenActivatorReturnsSubtype_InjectsAllSubtypeProperties - validates base and derived type properties are injected when activator returns a subtype
  • Added InstantiateComponent_WhenActivatorReturnsExactType_InjectsPropertiesIdenticallyToSubtype - confirms behavior is identical regardless of type matching
  • Updated existing test to verify derived type properties with [Inject] attribute

All 22 tests pass.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@dotnet-policy-service
Copy link
Contributor

Greetings! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo!

…ction tests

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on IComponentPropertyActivator for simplification Simplify ComponentFactory property injection and add subtype validation tests Dec 12, 2025
Copilot AI requested a review from javiercn December 12, 2025 15:23
@javiercn javiercn marked this pull request as ready for review December 12, 2025 16:07
@javiercn javiercn requested a review from a team as a code owner December 12, 2025 16:07
@javiercn javiercn merged commit d33dcd0 into javiercn/component-property-injection Dec 12, 2025
17 of 25 checks passed
@javiercn javiercn deleted the copilot/sub-pr-64595 branch December 12, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants