You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Hot Reload] PreserveSmartEnumConversionsStep: emit root-descriptor XML instead of modifying user assemblies #26073
Part of #26069. Depends on #26072 ($(HotReloadCompatibleBuild) property).
Problem
PreserveSmartEnumConversionsStep is the only preservation step that lacks an AssemblyAction.Link gate — its IsActiveFor checks only IsOrReferencesProductAssembly (tools/dotnet-linker/PreserveSmartEnumConversionsStep.cs:29-45). When a user (Copy) assembly uses [BindAs] with a smart enum whose conversion methods (GetConstant/GetValue) live in a trimmed framework assembly, the step calls AppBundleRewriter.AddDynamicDependencyAttribute to inject a [DynamicDependency] attribute into the user assembly (PreserveSmartEnumConversionsStep.cs:53-60), which modifies it and breaks Hot Reload.
This is the exact case flagged in #26069 and in the code comment at PreserveSmartEnumConversionsStep.cs:37-38 ("Hot Reload: we can't modify user assemblies ... emit xml definition instead maybe?").
Proposed solution
When $(HotReloadCompatibleBuild) is enabled, do not write [DynamicDependency] attributes into user/reloadable assemblies. Instead emit an external ILLink root-descriptor XML — consumed by the subsequent trimmer pass — that preserves the framework-side smart-enum conversion methods (GetConstant/GetValue).
Add the descriptor-XML code path, gated on $(HotReloadCompatibleBuild).
Keep the current attribute-injection behaviour when the property is disabled (release builds), so app size is unaffected.
Note: the descriptor preserves unconditionally (can't be conditional on the referencing user method being kept), which is an acceptable minor trimming trade-off in the debug/Hot Reload configuration.
Wire the generated descriptor into the trimmer inputs (TrimmerRootDescriptor).
Add/extend a test that a user assembly using [BindAs] smart enums is left byte-unmodified under a Hot-Reload-compatible build.
Activity
[tools] PreserveSmartEnumConversionsStep: emit root-descriptor XML in…