Skip to content

fix: NativeAOT - replace reflection-based XAML bindings in SettingsPage#117

Merged
nlogozzo merged 2 commits intofeat/aotfrom
copilot/sub-pr-116
Mar 20, 2026
Merged

fix: NativeAOT - replace reflection-based XAML bindings in SettingsPage#117
nlogozzo merged 2 commits intofeat/aotfrom
copilot/sub-pr-116

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

DisplayMemberPath="Label" on the Theme and TranslationLanguage ComboBoxes uses reflection at runtime, which is trimmed in NativeAOT builds, causing WMC1510 warnings and a crash when opening the settings page.

Changes

  • SettingsPage.xaml: Replace DisplayMemberPath="Label" with compiled ItemTemplates using x:Bind and x:DataType="desktopapp:ISelectionItem" (Nickvision.Desktop.Application.ISelectionItem), generating property access code at build time instead of via reflection.
<!-- Before -->
<ComboBox x:Name="CmbTheme" DisplayMemberPath="Label" SelectionChanged="Cmb_SelectionChanged"/>

<!-- After -->
<ComboBox x:Name="CmbTheme" SelectionChanged="Cmb_SelectionChanged">
    <ComboBox.ItemTemplate>
        <DataTemplate x:DataType="desktopapp:ISelectionItem">
            <TextBlock Text="{x:Bind Label}"/>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…NativeAOT compatibility

Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 20, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.nuget.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix crash in WinUI settings page for NativeAOT app fix: NativeAOT - replace reflection-based XAML bindings in SettingsPage Mar 20, 2026
Copilot AI requested a review from nlogozzo March 20, 2026 16:56
@nlogozzo nlogozzo marked this pull request as ready for review March 20, 2026 17:06
@nlogozzo nlogozzo merged commit 3733bca into feat/aot Mar 20, 2026
@nlogozzo nlogozzo deleted the copilot/sub-pr-116 branch March 20, 2026 17:06
@nlogozzo
Copy link
Copy Markdown
Member

@copilot I merged in this change, but seeing System.ArgumentException: 'Value does not fall within the expected range.' now on line 28 of SettingsPage.xaml.cs

nlogozzo added a commit that referenced this pull request Mar 21, 2026
* feat: Update deps

* Fix IL3050 NativeAOT warnings in WinUI and GNOME Program.cs (#115)

* Initial plan

* Fix IL3050 NativeAOT warnings by adding RequiresDynamicCode attribute to Main methods

Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>

* fix: Sources

* fix: NativeAOT - replace reflection-based XAML bindings in SettingsPage (#117)

* Initial plan

* fix: replace DisplayMemberPath with compiled x:Bind ItemTemplate for NativeAOT compatibility

Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>

* feat: Update license

* fix: Missing sources

* feat: Bindable item

* feat: Update deps

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nlogozzo <17648453+nlogozzo@users.noreply.github.com>
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.

2 participants