maui: XamlC Compilation errors when upgrading to Microsoft.Maui.Controls 8.0.20
Description
Update the Nuget packages and compile the app, various compilation errors are reported for things like this…
<Style x:Key="Separator" TargetType="{x:Type BoxView}">
<Setter Property="Color" Value="{StaticResource Gray-200}"/>
<Setter Property="HeightRequest" Value="1"/>
<Setter Property="Margin" Value="0,6"/>
<Setter Property="HorizontalOptions" Value="FillAndExpand"/>
</Style>
Error XFC0040 XamlC: Cannot convert value “Color” to “Microsoft.Maui.Controls.BindableProperty”
Other xaml files get comilation error…
Error XamlC: Input string was not in a correct format. Failure to parse near offset 69. Unexpected closing brace without a corresponding opening brace.
Despite them being perfectly valid Xaml and compiling correctly with 8.0.14
Steps to Reproduce
- Update Nuget packages to 8.0.20
- Compile app (Android/iOS)
Link to public reproduction project repository
No response
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
8.0.14 SR3.1
Affected platforms
iOS, Android
Affected platform versions
No response
Did you find any workaround?
No, removing the code presented as errors results in a new error reported in another file that was previously not reported.
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 23 (14 by maintainers)
I can confirm removing {x:Type} resolves the issues in both styles and xaml Content pages.
As of 8.0.40 I’m still getting the problem. 8.0.14 works fine.
@cat0363 thanks for the repro, I opened a bugfix PR: https://github.com/dotnet/maui/pull/23043
@simonrozsival , I found a condition that causes a build error. An error occurs with the TargetType of DataTrigger, but it was a case where the DataTrigger existed inside the DataTemplate.
[MainPage.xaml]
By changing the TargetType of the above DataTrigger from
{x:Type Grid}toGrid, the build will pass.The code for MainPage.xaml.cs is shown below.
[MainPage.xaml.cs]
When I investigated the location where the build error occurred, I found that it was when there was a DataTrigger in the DataTemplate as shown above.
@cat0363 I’m only getting
MainPage.xaml(36,18): XamlC error XFC0009: No property, BindableProperty, or event found for "Children", or mismatching type between value and property.which is caused by missing<Grid.DataTriggers>, this fixed snippet works correctly:I take it back! The workaround does work. I had multiple DataTemplates on the same page.
Updated code: