GeneratorApp Xamarin Documentation

The Xamarin Framework enforces separation of the code in different layers, so my Generator Tool outputs writes something in every one of then – model, service, database access, control layer (ViewModel) and view. So in Xamarin Frameworks case the tool currently supports Mobile App (Xamarin Forms) -> Master Detail, Shared Project options that shares even the UI.

The other option is to write using the native APIs using C# programming language. This option gives greater control but will lead to more code.

Visual Studio outputs a standardized and recomended directory structure that my generator uses to output its stuff.

The directory you need to give to my tool is the one – containing the directories Models, Services, Views, ViewModels, <YourApp>.Android, <YourApp>.iOS,  <YourApp>.UDP.

After you generate some code you need to add the newly generated files (currently – for  version 15 of my app – manually), because Visual Studio does not automatically synchronizes files that are not listed in its configuration.

For view files it is not enough to just add them visually from the file system. They also need to be changed from the properties view:

  • Build action to “Embedded resource”
  • Custom Tool to “MSBuild:UpdateDesignTimeXaml”:

https://stackoverflow.com/questions/41370397/unknown-type-contentpage-in-xml-namespace-http-xamarin-com-schemas-2014-for

My tool (v15) currently doesn’t touches Visual Studio configuration files but I may add this in the future so the above two action may become unnesesary – if eventually executed by my tool.

Another thing that is required to be able to compile and run the app is to include SQLite dependencies. This can be done visualy throuth NuGet Package Manager.

  • Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.
  • Then search “sqlite-net” and install “sqlite-net”, “SQLite-Net-PCL”,  “sqlite-net-pcl”.

All the missing sql dependencies should be available after that.

For “Hello World” stage of application you could go to MainPage.xml,
add your package namespace to the root of the xml :
xmlns:app=”clr-namespace:myapp.Views”
and add the view containing the list of your domain object items:

and you’ll have your items.

I have marked the generator as early alpha. It needs a lot more improvement and bugfixing and I’ll do that when  I pick one idea to test Xamarin Framework inreal project and the Generator for it. I have several ideas on top of my head. The time will tell how I will sort them out and for which of them I will find time.

P.S. I’ll update this article after any future changes.

Share
Add comment