Skip to content
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

XamlC XC0022 warning : Binding could be compiled if x:DataType is specified after upgrade to 8.0.7 #21288

Closed
ChristianRiedl opened this issue Mar 18, 2024 · 5 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 platform/windows 🪟 s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@ChristianRiedl
Copy link

Description

After upgrade to 8.0.7 I get a warning XC0022 and XAML is not compiled.

Steps to Reproduce

Create a ContentPage like (line with ToolbarItem produces the error) :

<ContentPage
    x:Class="MediaApp.Views.EpgPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:MediaApp.ViewModels"
    x:DataType="vm:EpgViewModel">


    <ContentPage.ToolbarItems>
        <ToolbarItem Text="{Binding PrevText}" IconImageSource="previous.png" >


```...
...


### Link to public reproduction project repository

_No response_

### Version with bug

8.0.7 SR2

### Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

### Last version that worked well

8.0.6 SR1

### Affected platforms

Android, Windows

### Affected platform versions

Windows SDK 10.0.22621.0, Android 34.0

### Did you find any workaround?

Adding x:DataType solved the problem, but this behavior is not as intended I think.

    <ContentPage.ToolbarItems>
        <ToolbarItem x:DataType="vm:EpgViewModel" Text="{Binding PrevText}" IconImageSource="previous.png" >
...

### Relevant log output

```shell
Views\EpgPage.xaml(19,22): XamlC XC0022 warning : Binding could be compiled if x:DataType is specified.
1>Views\EpgPage.xaml(19,75): XamlC XC0022 warning : Binding could be compiled if x:DataType is specified.
1>Views\EpgPage.xaml(20,22): XamlC XC0022 warning : Binding could be compiled if x:DataType is specified.
1>Views\EpgPage.xaml(20,79): XamlC XC0022 warning : Binding could be compiled if x:DataType is specified.
1>Views\EpgPage.xaml(21,22): XamlC XC0022 warning : Binding could be compiled if x:DataType is specified.
...
@ChristianRiedl ChristianRiedl added the t/bug Something isn't working label Mar 18, 2024
@PureWeen
Copy link
Member

Duplicate of #20568

@PureWeen PureWeen marked this as a duplicate of #20568 Mar 18, 2024
@ChristianRiedl
Copy link
Author

ChristianRiedl commented Mar 18, 2024 via email

@PureWeen PureWeen reopened this Mar 19, 2024
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Mar 19, 2024
@simonrozsival
Copy link
Member

@ChristianRiedl I could not reproduce the issue with the following minimal repro:

<ContentPage
    x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui21288"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
    x:DataType="local:ViewModel21288">

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="{Binding PrevText}" />
    </ContentPage.ToolbarItems>
</ContentPage>

I'm not getting any warning.

One more thing I noticed is that the warnings that you included refer to lines 19, 20, and 21. None of these lines are shown in the code snippet that you provided. Can you share a snippet that includes those lines?

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label Mar 19, 2024
@ChristianRiedl
Copy link
Author

ChristianRiedl commented Mar 19, 2024 via email

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Mar 19, 2024
@simonrozsival
Copy link
Member

@ChristianRiedl thanks for testing this with the latest release of MAUI. It is likely that the original issue was fixed by #20742

@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 platform/windows 🪟 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants