Skip to content

Fixes #5561 - Make TuiConfigurationBuilder flat-key binding trim/AOT-safe#5562

Merged
tig merged 1 commit into
developfrom
fix/5561-convertvalue-aot
Jun 28, 2026
Merged

Fixes #5561 - Make TuiConfigurationBuilder flat-key binding trim/AOT-safe#5562
tig merged 1 commit into
developfrom
fix/5561-convertvalue-aot

Conversation

@tig

@tig tig commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #5561TuiConfigurationBuilder's flat-dotted-key binding broke NativeAOT/trimmed consumers (regression from #5411). ConvertValue fell back to TypeDescriptor.GetConverter (annotated [RequiresUnreferencedCode]/[RequiresDynamicCode]) with no annotation, producing IL2026/IL3050; downstream AOT publishes (e.g. tui-cs/Editor's ted) failed on all RIDs.

Changes

  • ConvertValue — replace the TypeDescriptor.GetConverter fallback with an explicit Key fast path (Key.TryParse). Key was the only non-scalar/non-enum type reachable via flat dotted keys (MenuBar.DefaultKey, PopoverMenu.DefaultKey); everything else is 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, which the issue's TrimmerSingleWarn default had collapsed behind the IL2026). All callers pass concrete settings types, so the annotation is satisfiable and preserves exactly the properties the trimmer would otherwise drop.
  • Drop the now-unused using System.ComponentModel; and the no-longer-needed IL2026 suppression on BindFlatDottedKeys.

Verification

Reproduced the issue with a trimmed publish of a small consumer app that calls new TuiConfigurationBuilder().ApplyToStaticFacades():

  • Before: IL2026 (ConvertValue → GetConverter) and IL2090 (BindFlatDottedKeysGetProperties).
  • After: zero IL trim/AOT warnings from TuiConfigurationBuilder.

Added a regression test (MecDottedKeyTests.ApplyToStaticFacades_BindsFlatDottedKeyTypedProperty) confirming PopoverMenu.DefaultKey (a Key-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 ConvertValue explicitly; unsupported types return null and are skipped, the same as before for unconvertible values.

Fixes #5561

🤖 Generated with Claude Code

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>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TuiConfigurationBuilder.ConvertValue breaks NativeAOT/trim: unannotated TypeDescriptor.GetConverter (IL2026/IL3050) — regression from #5411

1 participant