AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.06k stars 2.25k forks source link

Add AssemblyName support into XmlnsDefinition attribute #17498

Open wieslawsoltes opened 1 week ago

wieslawsoltes commented 1 week ago

Is your feature request related to a problem? Please describe.

I want to include types into https://github.com/avaloniaui namespace and to do that I want to use XmlnsDefinition but it does not support AssemblyName (you can add AssemblyName when using xmlns inside xaml file e.g. xmlns:sys="clr-namespace:System;assembly=mscorlib")

Describe the solution you'd like

Instead defining each time xmlns in xaml files like xmlns:sys="clr-namespace:System;assembly=mscorlib" I want to include them in Avalonia namespace via XmlnsDefinition

[assembly: XmlnsDefinition("https://github.com/avaloniaui ", "System", AssemblyName = "mscorlib")]

Describe alternatives you've considered

No response

Additional context

Instead:

xmlns:sys="clr-namespace:System;assembly=mscorlib"
<sys:Tuple x:TypeArguments="sys:Int32, sys:String"
           xmlns:sys="clr-namespace:System;assembly=mscorlib"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <x:Arguments>
        <sys:Int32>42</sys:Int32>
        <sys:String>Hello World</sys:String>
    </x:Arguments>
</sys:Tuple>

we could have clean xaml syntax:

    <Tuple x:Key="Tuple" x:TypeArguments="Int32, String">
      <x:Arguments>
        <Int32>42</Int32>
        <String>Hello World</String>
      </x:Arguments>
    </Tuple>
maxkatz6 commented 1 week ago

In Avalonia you can write xmlns:sys="using:System" without specifying any assembly, which I use often for this namespace. Doesn't the same work for [assembly: XmlnsDefinition("https://github.com/avaloniaui ", "System")] ?

wieslawsoltes commented 1 week ago

In Avalonia you can write xmlns:sys="using:System" without specifying any assembly, which I use often for this namespace. Doesn't the same work for [assembly: XmlnsDefinition("https://github.com/avaloniaui ", "System")] ?

[assembly: XmlnsDefinition("https://github.com/avaloniaui ", "System")] does not work

wieslawsoltes commented 1 week ago

Here is my test project https://github.com/wieslawsoltes/TupleDemo