Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Custom schema definition for xaml base class [Bug] #10946

Open
ehsangfl opened this issue Jun 3, 2020 · 2 comments
Open

Custom schema definition for xaml base class [Bug] #10946

ehsangfl opened this issue Jun 3, 2020 · 2 comments
Assignees
Projects

Comments

@ehsangfl
Copy link

ehsangfl commented Jun 3, 2020

Hi
I defined base view

namespace StandardView.Views
{
    public abstract class BaseView : ContentView
    {
    }
}

and defined custom schema
[assembly: XmlnsDefinition("http://schemas.apadanasystems.com/xaml/Views", "StandardView.Views")]

Then I created a view that implement from BaseView class and i named it "Notification".
Xaml Code of "Notification" view is :

<Views:BaseView
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:Views="http://schemas.apadanasystems.com/xaml/Views"
             x:Class="StandardView.Views.Notification">

 <Views:BaseView.Content>
        <StackLayout BindingContext="{StaticResource ViewModel}">
            ........
        </StackLayout>
    </Views:BaseView.Content>
</Views:BaseView>

and in c# file

public partial class Notification : BaseView
   {
       public Notification()
       {
           InitializeComponent();
       }
   }

Unfortunately code generator for g.cs file could not find base class of xaml page.
and namespace definition in xaml must be declared in explicit way as

<Views:BaseView
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:Views="clr-namespace:StandardView.Views;assembly=Infrastructure.View"
             x:Class="StandardView.Views.GLB_VW_Notification">

then code generator can found xaml base class and generate the g.cs file
BR

@ehsangfl ehsangfl added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 3, 2020
@pauldipietro pauldipietro added this to New in Triage Jun 3, 2020
@jsuarezruiz jsuarezruiz moved this from New to Needs Estimate in Triage Jun 5, 2020
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Jun 5, 2020
@StephaneDelcroix StephaneDelcroix self-assigned this Jul 27, 2020
@StephaneDelcroix
Copy link
Member

It is known that the XamlGenerator can only lookup for XmlnsDefs in project references, and not in the current one. That feature is thus targeted at 3rd party control provider, more than directly to the users.

we plan to change this, but it will require rewriting XamlG over Roslyn, or Source Generators

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@ehsangfl
Copy link
Author

ehsangfl commented Dec 4, 2020

yes, but in sample description, base class is not defined in current assembly. base class is on Infrastructure assembly (Infrastructure,View,dll), and xmldef was added to it.
and I want to use this baseview on other assembly (like Common.View.dll), with reference of Infrastructure asssembly (Infrastructure,View,dll).
I think problem is on code generator of xaml. because if I replace codes handly, (implement g.cs file from baseview) , application run correctly. this means that xamldef define links correctly and code generator cannot generate .g.cs files.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Needs Estimate
Development

No branches or pull requests

4 participants