fix: enable compiled Source binding to resolve XamlC XC0025 in TodoApp.MAUI#554
Merged
Merged
Conversation
…p.MAUI
MainPage.xaml's Entry.ReturnCommandParameter binds via an explicit
Source={x:Reference addItemEntry}, which XamlC does not compile by
default, producing a build warning (XC0025) and falling back to
slower reflection-based binding.
Enable MauiEnableXamlCBindingWithSourceCompilation project-wide and
annotate the binding with x:DataType=Entry so XamlC can compile it.
This is the only Source-based binding in the project, so no other
bindings are affected.
Fixes CommunityToolkit#517
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 #517.
MainPage.xaml'sEntry.ReturnCommandParameterbinds via an explicitSource={x:Reference addItemEntry}instead of the page'sBindingContext. By default, XamlC skips compiling any binding with an explicitSource, which produced this build warning (performance-only, no functional impact):Fix
Per current .NET MAUI docs on compiling
Sourcebindings:TodoApp.MAUI.csproj: opt in to<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>project-wide, with a comment explaining why and confirming this is the onlySource-based binding in the project (so there's no risk of newly-surfacedx:DataTypemismatches elsewhere, per the doc's own caution about this being an opt-in feature).MainPage.xaml: annotate the binding itself with the documented inlinex:DataType=Entryso XamlC has the type info it needs to compile it:{Binding Text, Source={x:Reference addItemEntry}, x:DataType=Entry}.This avoids any XAML restructuring — no
DataTemplate/binding-scope changes needed, since MAUI 9+ supports annotating theBindingmarkup extension directly.Verification
Local verification wasn't possible (macOS host, no MAUI workloads installed, no Windows target available), so I triggered
build-samples.ymlmanually viaworkflow_dispatchon the fork and inspected the raw job logs:todoapp-windows / build(the job that originally surfaced this warning): run — 0 occurrences ofXC0025in the build log; only the pre-existing, unrelatedCS0618 ListView is obsoletewarning remains (same warning present before this change).todoapp-maui / androidandtodoapp-maui / ios: also clean — noXC0025, no newXC00xxwarnings.build-samples.ymlrun passed.Related
TodoApp.MAUI.