Fixes #5561 - Make TuiConfigurationBuilder flat-key binding trim/AOT-safe#5562
Merged
Conversation
ConvertValue fell back to TypeDescriptor.GetConverter (RequiresUnreferencedCode / RequiresDynamicCode) for non-scalar settings, breaking NativeAOT/trimmed consumers (e.g. tui-cs/Editor's `ted`) with IL2026/IL3050. Regression from #5411. - ConvertValue: replace the TypeDescriptor.GetConverter fallback with an explicit Key fast path (Key.TryParse). Key was the only non-scalar/non-enum type bound via flat dotted keys (MenuBar.DefaultKey, PopoverMenu.DefaultKey); all other settings are string/bool/int/Rune/enum and already had fast paths. The public binding path now has no RequiresUnreferencedCode/RequiresDynamicCode dependency. - BindSection<T>/BindFlatDottedKeys<T>: annotate T with [DynamicallyAccessedMembers(PublicProperties)] so typeof(T).GetProperties() is trim-safe (fixes IL2090). Callers pass concrete settings types, so it is satisfiable; this preserves the properties the trimmer would otherwise drop. - Drop the now-unused System.ComponentModel using and the no-longer-needed IL2026 suppression on BindFlatDottedKeys. Verified with a trimmed publish of a consumer app: TuiConfigurationBuilder now produces zero IL trim/AOT warnings (previously IL2026 + IL2090). Adds a regression test that PopoverMenu.DefaultKey (a Key-typed flat dotted key) binds via the new fast path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 29, 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.
Summary
Fixes #5561 —
TuiConfigurationBuilder's flat-dotted-key binding broke NativeAOT/trimmed consumers (regression from #5411).ConvertValuefell back toTypeDescriptor.GetConverter(annotated[RequiresUnreferencedCode]/[RequiresDynamicCode]) with no annotation, producingIL2026/IL3050; downstream AOT publishes (e.g.tui-cs/Editor'sted) failed on all RIDs.Changes
ConvertValue— replace theTypeDescriptor.GetConverterfallback with an explicitKeyfast path (Key.TryParse).Keywas the only non-scalar/non-enum type reachable via flat dotted keys (MenuBar.DefaultKey,PopoverMenu.DefaultKey); everything else isstring/bool/int/Rune/enumand already had fast paths. The public binding path now has noRequiresUnreferencedCode/RequiresDynamicCodedependency.BindSection<T>/BindFlatDottedKeys<T>— annotateTwith[DynamicallyAccessedMembers(PublicProperties)]sotypeof(T).GetProperties()is trim-safe (fixesIL2090, which the issue'sTrimmerSingleWarndefault had collapsed behind theIL2026). All callers pass concrete settings types, so the annotation is satisfiable and preserves exactly the properties the trimmer would otherwise drop.using System.ComponentModel;and the no-longer-neededIL2026suppression onBindFlatDottedKeys.Verification
Reproduced the issue with a trimmed publish of a small consumer app that calls
new TuiConfigurationBuilder().ApplyToStaticFacades():IL2026(ConvertValue →GetConverter) andIL2090(BindFlatDottedKeys→GetProperties).TuiConfigurationBuilder.Added a regression test (
MecDottedKeyTests.ApplyToStaticFacades_BindsFlatDottedKeyTypedProperty) confirmingPopoverMenu.DefaultKey(aKey-typed flat dotted key) still binds via the new fast path. Full MEC test suite passes.Design note
The fallback is removed deliberately (issue option 2 — the stronger guarantee for a public, AOT-advertised API). Any future non-scalar settings property type must be added to
ConvertValueexplicitly; unsupported types returnnulland are skipped, the same as before for unconvertible values.Fixes #5561
🤖 Generated with Claude Code