Skip to content

[Net11] Fix Maui.Controls.Sample build fails with MAUIG2045 - #36882

Merged
kubaflo merged 1 commit into
dotnet:net11.0from
devanathan-vaithiyanathan:fix-36827
Jul 28, 2026
Merged

kubaflo merged 1 commit into
dotnet:net11.0from
devanathan-vaithiyanathan:fix-36827

Conversation

@devanathan-vaithiyanathan

Copy link
Copy Markdown
Contributor

Issue Details

After merging regression PR #32905 – [XSG] Improve diagnostic reporting during binding compilation, XAML bindings that were previously ignored during source-generated binding compilation started failing the build. The issue was observed in bindings that used:

AncestorType={x:Type ContentPage}

The build now fails with MAUIG2045, which is treated as an Error.

Previously, the source generator silently skipped unsupported or invalid bindings without reporting diagnostics, so these bindings did not block the build.

Description of Change

PR #32905 updated the binding source generator to report diagnostics instead of silently ignoring invalid bindings.

Previous behavior

// In CompiledBindingMarkup.cs
return false; // TODO report diagnostic

Updated behavior

context.ReportDiagnostic(
    Diagnostic.Create(Descriptors.BindingPropertyNotFound, ...));

The PR introduced six new MAUIG diagnostics that align with the older XamlC XC* diagnostics, improving diagnostic visibility during binding compilation.

Because MAUIG2045 is emitted as an Error, bindings using AncestorType={x:Type ContentPage} now fail compilation. To resolve the issue, the bindings were updated to use the correct view type:

AncestorType={x:Type views:BasePage}

This change restores successful compilation while preserving the new diagnostic behavior introduced by PR #32905.

Issues Fixed

Fixes #36827

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36882

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36882"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 28, 2026
@github-actions github-actions Bot added the area-xaml XAML, CSS, Triggers, Behaviors label Jul 28, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review July 28, 2026 15:10
Copilot AI review requested due to automatic review settings July 28, 2026 15:10
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the MAUI Controls sample pages to avoid MAUIG2045 build failures introduced by stricter compiled-binding diagnostics, by ensuring RelativeSource AncestorType points to the concrete page type (views:BasePage) that actually defines SelectedItem/NavigateCommand (instead of the base ContentPage type which the source generator cannot attribute those members to).

Changes:

  • Replaced AncestorType={x:Type ContentPage} with AncestorType={x:Type views:BasePage} for SelectedItem and SelectionChangedCommand bindings across multiple sample pages.
  • Minor XAML formatting cleanups (indentation/self-closing tag spacing) in the touched pages.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Controls/samples/Controls.Sample/Pages/UserInterfacePage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/PlatformSpecificsPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml Update RelativeSource ancestor type to views:BasePage and apply minor XAML formatting in the footer section.
src/Controls/samples/Controls.Sample/Pages/MainPage.xaml Update SelectedItem binding to use views:BasePage as the RelativeSource ancestor type.
src/Controls/samples/Controls.Sample/Pages/LayoutsPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings and minor formatting.
src/Controls/samples/Controls.Sample/Pages/CustomFlyoutPage.xaml Update RelativeSource ancestor type to views:BasePage within the flyout page content.
src/Controls/samples/Controls.Sample/Pages/CorePage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/Core/GesturesPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/ControlsPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/CompatibilityPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings.
src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewPage.xaml Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings (the reported failure site).

@kubaflo
kubaflo merged commit f191d33 into dotnet:net11.0 Jul 28, 2026
31 of 38 checks passed
@github-actions github-actions Bot added this to the .NET 11.0-preview7 milestone Jul 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 28, 2026
@sheiksyedm sheiksyedm added the community ✨ Community Contribution label Oct 1, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — c6bf1444 Deployed Jul 28, 2026 by devanathan-vaithiyanathan via conclusion #1001
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants