KEMBAR78
[XC] Fix detection of x:DataType from outer scope by simonrozsival · Pull Request #30083 · dotnet/maui · GitHub
Skip to content

Conversation

@simonrozsival
Copy link
Member

Description of Change

XamlC reported the following warning for every single binding it compiled:

XamlC warning XC0024: Binding might be compiled incorrectly since the x:DataType annotation comes from an outer scope. Make sure you annotate all DataTemplate XAML elements with the correct x:DataType. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information.

This was caused by an incorrect condition changed #29579. Since this is just a warning and not an error, it wasn't caught in code review.

@Copilot Copilot AI review requested due to automatic review settings June 20, 2025 08:34
@simonrozsival simonrozsival requested a review from a team as a code owner June 20, 2025 08:34
Copy link
Contributor

Copilot AI left a 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 corrects the condition that detects when an x:DataType comes from an outer DataTemplate scope to eliminate spurious warnings.

  • Simplified the if check by using nameof(DataTemplate) and restricting the namespace to MauiUri.
  • Removed the incorrect global URI branch that previously caused all elements in the global namespace to be flagged.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@PureWeen
Copy link
Member

Failing tests are unrelated

@PureWeen PureWeen merged commit 3903efe into net10.0 Jun 22, 2025
127 of 129 checks passed
@PureWeen PureWeen deleted the dev/srozsival/fix-xamlc-binding-datatype-in-outer-scope branch June 22, 2025 15:35
@StephaneDelcroix StephaneDelcroix linked an issue Jun 24, 2025 that may be closed by this pull request
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XAML xmlns simplifications

4 participants