Jonathan Peppers


Xamarin, C# nerd, at Microsoft

Xamarin 3 and Healed Cuts

After updating to Xamarin 3, I am definitely impressed with the work Xamarin is doing to improve their products. Xamarin Studio 5.0 has a nice UI refresh among other things, and many other awesome improvements like NuGet support, iOS designer available on the stable channel, and Xamarin.Forms.

Last year I wrote an article about Xamarin’s tiny cuts, and I have been meaning for quite some time to write a follow up about it. After posting that article, I got numerous emails from Xamarin employees and heard that Miguel distributed my blog post for all of Xamarin to see. After a couple weeks, I started seeing my suggestions getting fixed/added in updates of Xamarin Studio, Xamarin.iOS, and Xamarin.Android.

Just to name a few:

  • Xamarin account login is now native (or appears to be)
  • Xamarin.iOS in Visual Studio is a lot better across the board
  • You can pick the device for the iOS simulator inside Xamarin Studio
  • Visual Studio update process goes through the standard icon tray now
  • The line endings warning for documents in Xamarin Studio is way better
  • PCL support is complete
  • Xamarin.Android has an NUnit project template
  • NuGet is fully supported in Xamarin 3
  • Free Xamarin license for open source projects

Now I’m sure Xamarin was already working on some of these (or got the idea from other developers), but I think my blog post sped up the process to get them fixed. It also reinforces that Xamarin really listens to and cares about developers using their platform.

So enough about that, let’s take a look at some of the awesome stuff in Xamarin 3.

NuGet

NuGet support in Xamarin Studio 5.0 so far seems pretty much on par with Visual Studio on Windows:

  • In general it is way better than the unofficial extension we used to have to use. The unofficial one, was basically just good enough to get the job done.
  • NuGet package restore actually works when opening a project. This is pretty huge, since a lot of time starting on a solution created on Windows was messing with NuGet packages until things would build on the Mac.
  • There is a nice Packages folder that is unique to Xamarin Studio similar to the Components folder (Xamarin Component Store). This let’s you see NuGet packages in the solution tree.

Some things missing:

  • I don’t see a way to right click on the solution and “Enable NuGet Package Restore” like in Visual Studio. However, I don’t know if this is needed or not on the Mac. Opening a project in Xamarin Studio might auto-restore on its own. However, it would be helpful if you plan on opening the solution on Windows in Visual Studio or trying to compile and run tests with CI.
  • There is a Package Manager Console that shows NuGet output, but there doesn’t seem to be a command line option for NuGet. I know we don’t have powershell on the Mac, but it’s nice to use this feature occasionally in Visual Studio. I have used it to downgrade certain packages, and I don’t currently see a way to do that in Xamarin Studio. I guess you would have to run NuGet on the command line to do it (typing ‘nuget’ in a console is already in my path by default, so maybe a non issue).

Xamarin.Forms

I played with an early preview version of this feature earlier this year (then named QuickUI) and was pretty underwhelmed. However, the final product seems amazing in comparison to that first version I saw. After a quick trial run, I feel like we might start using this for all cross-platform apps we build at Hitcents.

The good stuff:

  • You can use XAML - we were loosely talking about having this one day cross platform on .Net Rocks. I’m not sure any of us knew how close this was coming.
  • It has data binding - I have been wanting this on iOS and Android for a long time. I have strayed away from frameworks like MvvmCross and ReactiveUI, just because I would have a hard time getting my full team up to speed using complicated frameworks like these. We have mostly done MVVM by hand, and this is going to be a monumental help to have it built in.
  • There is a built in Command class for setting up ICommand with Action<object> or Command<T> and Action<T>

So what’s missing?

Some easy stuff:

  • Failed binding expressions still need to print to the console when BindingContext isn’t set. I think this will especially help out existing XAML developers, since DataContext is renamed to BindingContext. Maybe the default value for the BindingContext should be the ContentPage (or associated view) itself.
  • Add an overload for Command that just takes an Action
  • It would be cool if a version of Command could take a Func<T, Task> and automatically invalidate CanExecute while the task is running. This would disable the control until the Task completes.
  • {Binding} doesn’t seem to work when trying to use it as a ToString() of the BindingContext. Not a huge deal, but veteran XAML guys might try to use this.
  • Is there any functionality in DependencyService to automatically hook a ViewModel to a Page? It would be cool if you could setup a convention to automatically inject SearchViewModel as a BindingContext of SearchPage based on class naming or namespaces. Or is there a way to easily plugin that functionality? [assembly: BindMyStuffLikeABossWithConventions]
  • @ConceptDev tweeted how you can write custom XAML markup extensions. Can we get a documentation page on the built-in ones?

The hard stuff (I know these are a bit of work):

  • A XAML designer w/ options toggle between platforms - let’s shoot for the moon right off the bat.
  • The XAML code editor is a little weak, it’s basically the same XML editor that’s been in MonoDevelop for a long time. It would be nice if we had some code completion for markup extensions like {Binding}, so that this experience is closer to Visual Studio.
  • Needs to definitely support WinRT (WPF would be nice, but it might not be relevant enough). At the very least a standard way to reuse your ViewModels in Xamarin.Forms on other Xaml platforms would be great.

Overall Xamarin.Forms seems pretty awesome. Sadly, I already want to port all our existing apps to use it...

Miscellaneous “good stuff” in Xamarin 3

  • There is now an option to “Unload” projects in a solution tree. I think this might have slipped in there a bit before Xamarin 3, however.
  • Shared Projects (from Visual Studio 2013) are now supported
  • The Xamarin Studio icon isn’t girly pastel colors anymore.

Miscellaneous issues in Xamarin 3

  • There are a few minor bugs with having to clean existing projects (not a huge deal). See more here.
  • The NUnit runner inside Xamarin Studio still can’t run async tests. I think it’s NUnit library just needs upgraded. (Note that these work in the iOS test project template, the test project I attempted this against was a .Net 4.5 project that we run in CI)
  • If you debug an iOS project on a device and lock the screen on the device, there is still no visual UI cue that the debugger is detached. As soon as you move the mouse, you see it’s detached.

comments powered by Disqus