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

ResolvePageModel throws Exception if Page and/or ViewModel are in "sub" namespaces #149

Closed
t4lm1d opened this issue Mar 3, 2017 · 4 comments

Comments

@t4lm1d
Copy link

t4lm1d commented Mar 3, 2017

When calling FreshMvvm.FreshPageModelResolver.ResolvePageModel(), the page cannot be resolved (the view/page model resolves) unless both the page and the page/view model are in the root namespace. Is this desired functionality?

ex.

These resolve:
namespace CSI
{
public partial class WelcomePage : ContentPage
{
public WelcomePage()
{
InitializeComponent();
}
}
}

namespace CSI
{
public class WelcomeViewModel : FreshBasePageModel
{
public WelcomeViewModel()
{

    }
}

}

The Page does NOT resolve:
namespace CSI.ViewModel
{
public partial class WelcomePage : ContentPage
{
public WelcomePage()
{
InitializeComponent();
}
}
}

namespace CSI (or changing this namespace)
{
public class WelcomeViewModel : FreshBasePageModel
{
public WelcomeViewModel()
{

    }
}

}

@Ebsan
Copy link

Ebsan commented Apr 7, 2017

I've had issues with the ViewModel naming conventions. Could you try to rename the classes and namespace with PageModel and see if that helps?

@t4lm1d
Copy link
Author

t4lm1d commented Apr 7, 2017

For now I put everything at the root. As soon as I get to a place where I can pause, I'll see if the error goes away with a name change.

@agarbutt
Copy link

@WiteCastle @t4lm1d FYI, the issue you are encountering is because of the simple approach to resolving page types from their page models.
Have a look at here and you will see if you place your page models / view models in a name space with the word "ViewModel" or "PageModel" it will be replace with the word "Page" and therefore the type resolution will fail.

Seems like picking any other namespace naming convention should work. Best of luck.

@t4lm1d
Copy link
Author

t4lm1d commented Nov 27, 2017

@WiteCastle Thanks! I haven't had time to look into this so I appreciate your response. Seeing that link you sent, makes sense. I will close this issue.

@t4lm1d t4lm1d closed this as completed Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants