[net11.0] Use ElementHandlerAttribute instead of DI for built-in visual elements#32862
Conversation
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
|
@copilot I was thinking about changing |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Changed in c9486dc. Now using |
|
@copilot I don't see changes to the attribute itself? Implement those. Also, remove unnecessary comment changes and suppression attributes. |
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Removed unnecessary suppression attributes and simplified in a4914e1. The attribute changes from c9486dc are there (changed from generic |
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
|
/azp run MAUI-public,MAUI-DeviceTests-public |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
b1992d7
into
dev/simonrozsival/net10.0-use-element-handler-attributes
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Follow-up to #28357. Migrates ~80 built-in controls from DI registration to
[ElementHandler(typeof(THandler))]attribute-based resolution.Core changes:
[ElementHandler(typeof(THandler))]attributeAppHostBuilderExtensions.AddControlsHandlers()bulk registrations[ElementHandlerWithAndroidContext<THandler>]+IElementHandlerWithAndroidContext<THandler>for Android handlers requiring Context injection (FrameRenderer, ListViewRenderer, TableViewRenderer)MauiHandlersFactoryresolution order: exact DI match → ElementHandlerAttribute → inherited DI matchIsCssEnabledByDefaultruntime feature switch for CSS trimmabilityElementHandlerAttributefrom generic<THandler>to constructor parameter(Type handlerType)with[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]annotation for proper trimming supportActivator.CreateInstancefor handler instantiation with minimal IL2026 suppressions where neededExample usage:
What's not yet converted:
IContentViewhandler registration (interfaces can't have attributes)IElementHandlerWithAndroidContext<T>is internal—needs public API review if customers need itIssues Fixed
Fixes #29952
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.