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

AttachedProperty setter is not called in XAML when named Uid #19069

Open
AndrewKeepCoding opened this issue Dec 13, 2024 · 4 comments
Open

AttachedProperty setter is not called in XAML when named Uid #19069

AndrewKeepCoding opened this issue Dec 13, 2024 · 4 comments
Assignees
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

@AndrewKeepCoding
Copy link
Contributor

Current behavior

As it's mentioned in the title, AttachedProperty setter is not called in XAML when named Uid
This happens on:

  • Android
  • WASM
  • Desktop
  • MacOS

It works as expected

  • on WASDK
  • the AttachedProperty has other name
  • the setter is called on C# code

For example:

Uids.cs

public static class Uids
{
    public static readonly DependencyProperty UidProperty =
        DependencyProperty.RegisterAttached(
            "Uid",
            typeof(string),
            typeof(Uids),
            new PropertyMetadata(default));

    public static string GetUid(DependencyObject obj) => (string)obj.GetValue(UidProperty);

    public static void SetUid(DependencyObject obj, string value) => obj.SetValue(UidProperty, value);
}

MainPage.xaml

<Button
    x:Name="GoToSecondButton"
    AutomationProperties.AutomationId="SecondPageButton"
    local:Uids.Uid="ButtonUid"
    Command="{Binding GoToSecond}"
    Content="Go to Second Page" />

MainPage.xaml.cs

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    var buttonUid = Uids.GetUid(GoToSecondButton);
    // butonUid is null.
    GoToSecondButton.Content = buttonUid;
}

Expected behavior

The AttatchedProperty setter should be called even if it's name is Uid.

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

Here is a reproducible repo:
https://github.com/AndrewKeepCoding/UnoPlatformAttatchedPropertyDemo

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

Uno.Sdk v5.5.32

Affected platforms

WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

It might be related to x:Uid.

@AndrewKeepCoding AndrewKeepCoding 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 Dec 13, 2024
@jeromelaban
Copy link
Member

Thanks for the report!

It looks like we're handling x:Uid incorrectly, most likely not filtering on the namespace:

It should be modified to read the attributes like this:

else if (member.Member.Name == "DefaultBindMode"
&& member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace)

@Xiaoy312 Xiaoy312 added the area/code-generation Categorizes an issue or PR as relevant to code generation label Dec 16, 2024
@AndrewKeepCoding
Copy link
Contributor Author

Thanks @jeromelaban! Is this a case I can just create a PR? or a case I should leave it to the team?

@jeromelaban
Copy link
Member

@AndrewKeepCoding if you're up for it, go ahead! You can also add a test in this file:

@AndrewKeepCoding
Copy link
Contributor Author

@jeromelaban Thanks!

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

No branches or pull requests

3 participants