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

Two-Way x:Bind to MVVM Toolkit generated properties broken in 5.4 release (5.4.5) #18320

Closed
mikernet opened this issue Sep 27, 2024 · 5 comments · Fixed by #18326
Closed

Two-Way x:Bind to MVVM Toolkit generated properties broken in 5.4 release (5.4.5) #18320

mikernet opened this issue Sep 27, 2024 · 5 comments · Fixed by #18326
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@mikernet
Copy link
Contributor

mikernet commented Sep 27, 2024

Current behavior

TwoWay x:Bind to a bool property generated by MVVM tookit now results in the following error:

error UXAML0001: Unable to find member [IsEnabled] on type [bool]
error UXAML0001: Processing failed for file P:\YourProject\YourControl.xaml (Uno.UI.SourceGenerators.XamlGenerator.XamlParsingException: An error was found in UserControl ---> Uno.UI.SourceGenerators.XamlGenerator.XamlParsingException: An error was found in StackPanel ---> System.InvalidOperationException: Unable to find member [IsEnabled] on type [bool]

OneWay bind works fine.

Expected behavior

Should work as it always did in version <= 5.3.x.

How to reproduce it (as minimally and precisely as possible)

public partial class SomeModel : ObservableObject
{
    [ObservableProperty]
    private bool _isEnabled;
}
<ToggleSwitch IsOn="{x:Bind Model.IsEnabled, Mode=TwoWay}" OnContent="Enabled" OffContent="Disabled"/>

Workaround

Don't use MVVM toolkit generated properties

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

5.4.5, 5.5.0-dev.66

Affected platforms

WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK)

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@mikernet mikernet added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Sep 27, 2024
@jeromelaban jeromelaban added the area/code-generation Categorizes an issue or PR as relevant to code generation label Sep 27, 2024
@jeromelaban
Copy link
Member

Thanks for the report. Can you provide a full repro? The snippet you provided is not enough to replicate the behavior.

@mikernet
Copy link
Contributor Author

@jeromelaban Oh, the issue appears to be that the Uno source generator "hack" that makes it work with MVVM Toolkit generated properties is broken. Use this for the model to see the problem:

public partial class SomeModel : ObservableObject
{
    [ObservableProperty]
    private bool _isEnabled;
}

@mikernet
Copy link
Contributor Author

Repro project:
Uno5NewProjectTest.zip

@mikernet mikernet changed the title Two-Way bool x:Bind broken in 5.4 release (5.4.5) Two-Way x:Bind to MVVM Toolkit generated properties broken in 5.4 release (5.4.5) Sep 27, 2024
@jeromelaban
Copy link
Member

Note that this is related to a workaround Uno has to support this feature, coming from a missing feature from roslyn dotnet/roslyn#57239, also tracked here: #14409.

@agneszitte
Copy link
Contributor

@jeromelaban, is additional QA needed for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation Categorizes an issue or PR as relevant to code generation difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants