-
Notifications
You must be signed in to change notification settings - Fork 1.9k
SourceGen warning MAUIG2045 with RelayCommand and Async postfix #34029
Copy link
Copy link
Closed
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowsregressed-in-10.0.40s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't workingxsgXaml sourceGenXaml sourceGen
Milestone
Description
Description
The latest 10.0.40 release has a regression bug where the XAML source generator doesn't play nice with the source generator of CommunityToolkit.Mvvm.
Consider the following viewmodel where the command DoSomethingCommand is generated:
public partial class MainViewModel : ObservableObject
{
[RelayCommand]
private Task DoSomethingAsync()
{
return Task.CompletedTask;
}
}
And the following XAML button binding the command:
<Button Command="{Binding DoSomethingCommand}" />
Enable SourceGen in csproj:
<MauiXamlInflator>SourceGen</MauiXamlInflator>
With MAUI 10.0.40 the following build warning is emitted:
Warning MAUIG2045 : Binding: Property "DoSomethingCommand" not found on "global::xx.MainViewModel". The binding will use slower reflection-based binding at runtime. If this property is generated by another source generator, consider reporting this at https://github.com/dotnet/maui/issues to help us improve source generator interoperability.
With warning-as-error, this results in an error.
Steps to Reproduce
- Clone the repro project
- Build
- Observe the build error (TreatWarningsAsError is enabled)
Link to public reproduction project repository
https://github.com/zwikk/maui-playground/tree/main/Source/SourceGenCommand
Version with bug
10.0.40
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
10.0.30
Affected platforms
iOS, Android, macOS
Affected platform versions
Any
Did you find any workaround?
There are 3 workarounds I know of.
- Remove the Async suffix
- Disable SourceGen
- Revert back to 10.0.30
Relevant log output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionplatform/androidplatform/iosplatform/macosmacOS / Mac CatalystmacOS / Mac Catalystplatform/windowsregressed-in-10.0.40s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't workingxsgXaml sourceGenXaml sourceGen