unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.63k stars 697 forks source link

[XamlCodeGenerator] `Binding.ElementName.Name` returns `null` instead of name #8532

Open HavenDV opened 2 years ago

HavenDV commented 2 years ago

Current behavior

https://github.com/unoplatform/uno/blob/8134e5eb7459883a08c60a8aac4cbac2aeb8487a/src/Uno.UI.Tests/Windows_UI_Xaml_Data/BindingTests/Given_Binding.cs#L137-L167

ElementNameSubject.Name returns null because the generated code for initialization uses a constructor without parameters:

private global::Windows.UI.Xaml.Data.ElementNameSubject _topLevelSubject = new global::Windows.UI.Xaml.Data.ElementNameSubject();
public global::Windows.UI.Xaml.Controls.TextBlock topLevel
{
    get
    {
        return (global::Windows.UI.Xaml.Controls.TextBlock)_topLevelSubject.ElementInstance;
    }
    set
    {
        _topLevelSubject.ElementInstance = value;
    }
}

Expected behavior

constructor call must contain arguments

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

No response

Workaround

No response

Works on UWP/WinUI

No response

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Youssef1313 commented 1 month ago

ElementName should actually be a string, not object. It's currently object as we commonly use ElementNameSubject for it. But that's not the ideal behavior.