Skip to content

IL Trim attributes with a feature flag in all assemblies#126094

Draft
pavelsavara wants to merge 2 commits intodotnet:mainfrom
pavelsavara:trim_hot_reload
Draft

IL Trim attributes with a feature flag in all assemblies#126094
pavelsavara wants to merge 2 commits intodotnet:mainfrom
pavelsavara:trim_hot_reload

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Mar 25, 2026

  • Trim attributes with a feature flag in all assemblies, not just corelib
  • test it on MetadataUpdateHandlerAttribute

DebuggableAttribute
DebuggerBrowsableAttribute
DebuggerDisplayAttribute
DebuggerHiddenAttribute
DebuggerNonUserCodeAttribute
DebuggerStepperBoundaryAttribute
DebuggerStepThroughAttribute
DebuggerTypeProxyAttribute
DebuggerVisualizerAttribute
Tracing.EventAttribute
Tracing.EventDataAttribute
Tracing.EventFieldAttribute
Tracing.EventIgnoreAttribute
Tracing.EventSourceAttribute
Tracing.NonEventAttribute
MetadataUpdateHandlerAttribute
ClassInterfaceAttribute
ComDefaultInterfaceAttribute
ComEventInterfaceAttribute
ComSourceInterfacesAttribute
ComVisibleAttribute
DispIdAttribute
InterfaceTypeAttribute
ProgIdAttribute
TypeMapAssemblyTargetAttribute
TypeMapAssociationAttribute
TypeMapAttribute

@pavelsavara pavelsavara added this to the 11.0.0 milestone Mar 25, 2026
@pavelsavara pavelsavara self-assigned this Mar 25, 2026
@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Mar 25, 2026
Copilot AI review requested due to automatic review settings March 25, 2026 15:39
@pavelsavara pavelsavara added area-System.Reflection.Metadata size-reduction Issues impacting final app size primary for size sensitive workloads os-browser Browser variant of arch-wasm labels Mar 25, 2026
@dotnet-policy-service dotnet-policy-service bot added linkable-framework Issues associated with delivering a linker friendly framework labels Mar 25, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection-metadata
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds ILLink link-attributes to remove MetadataUpdateHandlerAttribute instances (and enable trimming of their referenced handler types) when System.Reflection.Metadata.MetadataUpdater.IsSupported is disabled, and adds a trimming test to validate the behavior.

Changes:

  • Add per-library ILLink.LinkAttributes.xml files to remove MetadataUpdateHandlerAttribute instances when the feature switch is false.
  • Wire the new link-attributes files into the affected library projects via ILLinkLinkAttributesXmls.
  • Add a new System.Runtime trimming test console app that disables the feature switch and verifies the attribute + handler types are absent.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Text.Json/src/System.Text.Json.csproj Embeds ILLink link-attributes for conditional removal of MetadataUpdateHandlerAttribute instances.
src/libraries/System.Text.Json/src/ILLink/ILLink.LinkAttributes.xml Removes MetadataUpdateHandlerAttribute instances when MetadataUpdater.IsSupported is disabled.
src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj Adds a new trimming test app and disables the MetadataUpdater.IsSupported feature switch for it.
src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/MetadataUpdateHandlerTrimmed.cs New trimming test app validating attribute + handler types are trimmed under the disabled switch.
src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj Embeds ILLink link-attributes for conditional removal of MetadataUpdateHandlerAttribute instances.
src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.LinkAttributes.xml Removes MetadataUpdateHandlerAttribute instances when MetadataUpdater.IsSupported is disabled.
src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/Microsoft.Extensions.DependencyInjection.Abstractions.csproj Embeds ILLink link-attributes for conditional removal of MetadataUpdateHandlerAttribute instances.
src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ILLink/ILLink.LinkAttributes.xml Removes MetadataUpdateHandlerAttribute instances when MetadataUpdater.IsSupported is disabled.

Copilot AI review requested due to automatic review settings March 26, 2026 07:55
@pavelsavara pavelsavara changed the title IL trim MetadataUpdateHandlerAttribute and types which it keeps alive IL Trim attributes with a feature flag in all assemblies Mar 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Reflection.Metadata linkable-framework Issues associated with delivering a linker friendly framework os-browser Browser variant of arch-wasm size-reduction Issues impacting final app size primary for size sensitive workloads

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants