-
Notifications
You must be signed in to change notification settings - Fork 2
esolve MAUI XAML source generator error with nested markup extensions #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The Release mode build was failing with error MAUIG1001: "Value cannot be null.
(Parameter 'key')" on iOS, Android, and macCatalyst platforms.
Root cause: The MAUI XAML source generator cannot parse nested markup extensions
when a custom markup extension ({m:GetString}) is used inside another markup
extension ({OnPlatform}).
Fix: Changed the RefreshButtonStyle's Text property from inline nested syntax:
Value="{OnPlatform WinUI={m:GetString Refresh}}"
To expanded element syntax:
<OnPlatform x:TypeArguments="x:String">
<On Platform="WinUI" Value="{m:GetString Refresh}" />
</OnPlatform>
This allows the source generator to properly parse and defer the custom markup
extension evaluation to runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR resolves a MAUI XAML source generator error (MAUIG1001) that occurred during Release mode builds on iOS, Android, and macCatalyst platforms. The error was caused by nested markup extensions in the RefreshButtonStyle where a custom markup extension was used inside an OnPlatform markup extension.
Key Changes:
- Converted inline nested markup extension syntax to expanded element syntax for the RefreshButtonStyle's Text property
- This change enables proper parsing by the MAUI XAML source generator while maintaining identical runtime functionality
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
WalkthroughA XAML style definition was modified in the RefreshButtonStyle to restructure how the Text setter's platform-specific value is defined. The OnPlatform expression was moved from directly within the Value attribute to an explicit OnPlatform element nested inside a Setter.Value block, altering the XML structure without changing functional behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
samples/Sample.Maui/Resources/Styles/Style.xaml (1)
957-968: ExpandedSetter.ValuewithOnPlatformcleanly works around the source‑generator bugSwitching from the inline
Value="{OnPlatform WinUI={m:GetString Refresh}}"to theSetter.Value+<OnPlatform x:TypeArguments="x:String">element syntax is correct here and should avoid the MAUIG1001 issue while preserving behavior (only WinUI gets the localizedRefreshstring; other platforms still get the default value as before).If you intend to show a text label on non‑WinUI platforms as well, you could optionally add an additional
<On Platform="Default" ... />, but that’s outside the scope of this fix.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
samples/Sample.Maui/Resources/Styles/Style.xaml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: I-Synergy.Framework PR (Build Build, test and pack assemblies)
The Release mode build was failing with error MAUIG1001: "Value cannot be null. (Parameter 'key')" on iOS, Android, and macCatalyst platforms.
Root cause: The MAUI XAML source generator cannot parse nested markup extensions when a custom markup extension ({m:GetString}) is used inside another markup extension ({OnPlatform}).
Fix: Changed the RefreshButtonStyle's Text property from inline nested syntax:
Value="{OnPlatform WinUI={m:GetString Refresh}}"
To expanded element syntax:
This allows the source generator to properly parse and defer the custom markup extension evaluation to runtime.
Summary by CodeRabbit
Note: This release contains no user-facing changes.
✏️ Tip: You can customize this high-level summary in your review settings.