maui: XamlC XC0022 error : Binding could be compiled if x:DataType is specified.
Description
MAUI 8.0.7 reports the Errors XC0022 and XC0023 as errors, not as warnings.
I have treat warnings as error active, but <WarningsNotAsErrors>XC0022,XC0023</WarningsNotAsErrors> does not help.
Steps to Reproduce
Create a Binding, leave out x:DataType or set x:DataType to {x:Null}
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, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
Stay with 8.0.6 for the moment
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 23 (11 by maintainers)
Commits related to this issue
- [XC] split warnings on ',' and ';' - fixes #20568 — committed to dotnet/maui by StephaneDelcroix 3 years ago
- [XC] split warnings on ',' and ';' - fixes #20568 — committed to dotnet/maui by StephaneDelcroix 3 years ago
- [XC] split warnings on ',' and ';' (#20578) - fixes #20568 — committed to dotnet/maui by StephaneDelcroix 3 years ago
We are facing the same issue, and it is breaking our previously successful builds, since we also treat warnings as errors to keep our code base clean.
Lots of warnings with this error message. For me, no error code is displayed, so I dont know how you know that these are XC0022 and XC0023, @pijnappel.
We have no way to fix or ignore this warning via project file or editorconfig.
We can not fix all instances, as we often bind to ViewModels which use generics like
MyViewModel<T>, where binding with x:DataType is not really feasible, or not documented how to do it. If anybody has useful links/hints for this, please share.Very bold decision to just unleash hundreds of warnings without an error code that makes it configurable.
@StephaneDelcroix - based on example provided by @Hottemax … wouldn’t the syntax be:
x:DataType="viewmodels:BoViewModel(models:BoArticle)"@StephaneDelcroix, I agree that this is a useful finding and would be better not to ignore, but is there a way in Maui xaml to specify a datatype for a generic type?