Awesome - James Montemagno https://staging.montemagno.com/tag/awesome/ https://staging.montemagno.com/content/images/2017/08/MonogramIcon_Orange_NoBuffer.png Awesome - James Montemagno https://staging.montemagno.com/tag/awesome/ Hugo -- gohugo.io Tue, 13 Oct 2026 23:21:57 GMT 60 Convert Json to C# (and More) with quicktype https://staging.montemagno.com/convert-json-to-any-language-with-quicktype/ 59bfff08cb369f002e34f0d2 Mon, 18 Sep 2017 18:30:00 GMT

How often do you run into the situation where you are reading data from a json file or hitting a RESTful endpoint and pulling down a huge json file that you then need to deserialize? I bet pretty often as I know I do all the time. The next issue of course is that you have this bug json file, but you need to generate the actual data types, POCOs, inside of your C# code. This can be extremely tedious if you try to do it by hand and other websites give you lack luster C# files where you have to add in JsonProperty attributes, Serializers, and Converters. Well not any more with quicktype.io, which just launched today.

QuickType

What is quicktype?

When you head to quicktype.io you are greeted with a nice and friendly layout where you can input your json on the left and output to any language on the right. The site gives you some very nice default json types such as reddit and a pokedex to get started and then you pick what language:

Quicktypelanguage

Once you select your language it will remember it for future use, but they already support C#, TypeScript, Go, Java, Elm, and Swift in addition to a Schema and Simple Type output.

At any point you can just delete the json that is displayed and enter anything yourself. Modifying the Top-level type will update the code with whatever you want the base class to be. #MindBlown

Who is it by?

Awesome amazing people that I have worked with for many years. Mark Probst and David Siegel have been working on this project for some time now and have been developing it completely in the open on GitHub. I have to tip my hats as they have solved a problem that just about every developer runs into on a daily basis.

quicktype in Action

]]>
My Favorite C# 7 Feature: More expression-bodied members PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); This is amazing! However, in C# 7 things get even better. Take our good old friend property …]]> https://staging.montemagno.com/my-favorite-c-7-feature-more-expression-bodied/ 598df8f2c121b60019bf2fc7 Fri, 09 Jun 2017 19:33:37 GMT I can’t help myself, I love Expression-Bodied Members from C# 6! Combined with other powerful C# features it took this code:

public void OnPropertyChanged(string name)
{
  var changed = PropertyChanged;
  if(changed == null)
    return;

  changed(this, new PropertyChangedEventArgs(name));
}

to this:

public void OnPropertyChanged(string name)=>
  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));

This is amazing! However, in C# 7 things get even better. Take our good old friend property setters and getters:

public string Subtitle
{
  get { return subtitle; }
  set { SetProperty(ref subtitle, value); }
}

Look at all of those { and }, well no more! Here is some C# 7 for you:

public string Subtitle
{
    get => subtitle;
    set => SetProperty(ref subtitle, value);
}

You can even use our lambda friend on constructors and finalizers!!

// Expression-bodied constructor
public ExpressionMembersExample(string label) => this.Label = label;

// Expression-bodied finalizer
~ExpressionMembersExample() => Console.Error.WriteLine("Finalized!");

Mind Blown!! It is the small things that make me so happy. There are tons more great C# 7 features that you can now access in VS 2017 and VS for Mac and Frank and I discuss all of them on our podcast Merge Conflict that I hope you subscribe to!

Merge Conflict 47: You Got Some F# in My C#

]]>
Build Apps Faster with Plugins for Xamarin! https://staging.montemagno.com/build-apps-faster-with-plugins-for-xamarin/ 598df8f2c121b60019bf2ff7 Tue, 01 Dec 2015 22:03:50 GMT One of my favorite parts of mobile development with Xamarin is that I am not only creating fully native mobile application on iOS and Android, but that I also have 100% API access on those platforms. That means if I want to do something I can do something. However, after four years of mobile development I found myself doing the same things over and over again to access native APIs from shared code. If I wanted to adjust a setting, vibrate the device, or check connectivity I would abstract out an interface and then implent it on each platform. More than likely I would be copying from another application that I had created in the past. My good friend Luke Karrys once said if you ever have to write the same code twice it should be packaged up, and that is how Plugins for Xamarin were born.

A community effort to abstract away common APIs across iOS, Android, and Windows and package them up into small bitesize NuGet packages giving all developers a way to access these native APIs from shared code. In the last years (or so) since we started our original Plugins push nearly 100+ plugins have been created and are out there on NuGet and we have put together a hand currated list to browse through.

On my front I have created and worked on nearly 15 plugins that have gone through a lot of changes over the last year with nearly 100 GitHub issues squashed and plenty of updates along the way. Today, I am happy to announce updates to all of my plugins and some substantial changes that you will find when updating, that I am calling Plugins for Xamarin!

New Plugins!

That is right! In the last few weeks I have worked on a few new plugins and also with some amazing developers to update their plugins to align with the Plugins theming:

  • Compass: Easily access compass heading 0-360 degrees.
  • Local Notifications: Easily show and schedule local notifications.
  • Permissions: Check and request runtime permissions.
  • Share: Easily share text or open a browser.

Updated Plugins

Each and every plugin has been updated with new features, platforms, and yes some breaking changes, which you can read about a bit later on.

Here is a list of what I personally have created and updated:

  • Battery Status: Get battery level, how it is getting charged, and get notified when it changes.
  • Connectivity: See if device is connected to the internet and through what connection type.
  • Contacts: Currently in Beta to gather and query contacts
  • Device Information: Base information about each device such as OS and version.
  • Extended Maps: Launch navigation directions in default map app on each OS
  • Geolocator: Easy way of querying GPS location
  • Media: Take or pick photos/videos
  • Settings: Fully cross platform settings for your application.
  • Text To Speech: Turn your text into a vocal symphony on mobile devices.
  • Vibrate: Make that device rumble!

All of the new and updated plugins have a lot of awesome updates that aim to shorten development time for creating mobile apps. Here are a few enhancements that you will find.

Android Runtime Permissions

Last week I blogged about my new Permissions Plugin, which I beleive is one of my finest pieces of work when it comes to plugins, that solves the problem of checking and request runtime permissons from shared code (all asynce). This plugin was actually created so I could integrate it deeply into all of my other plugins. So now, if any plugin requires an Android runtime permission it will handle automatically requesting it for you, or you can using the Permission plugin to prompt when necessary. This incldes Contacts, Geoloator, and Media are all updated and ready to go.

Windows 10 UWP Support!

Windows 10 hasn’t been out long and Windows 10 Mobile is finally hitting some devices, but demand for plugin support has been high especially with the release of Xamarin.Forms 2.0 and its UWP preview. I am happy to announce that each and every one of my plugins that I have listed have been update with full Windows 10 UWP support in addition to Windows 8.1 RT support!

Lessons Learned

You will notice that all of the udpated plugins are officially 2.0.0! Yes that means there was a major number bump and that is because in the last year I have learned a lot about how developers are using the plugins and how they should have been structured from the beginning.

Don’t require Xamarin.Forms

This might have been the biggest mistakes when I setup the Plugins Templates was that I had the idea that Plugins could be used specifically only with Xamarin.Forms and not with traditional iOS, Android, and Windows apps. This is fine for controls or a specific framework that needs to deeply integrate with Xamarin.Forms, but not for Plugins. Plugins should simply NEVER require Xamarin.Forms. There are easy ways to access the Application Conetxt, ViewControllers, and I even released an amazing Current Activity plugin to get the current Activity in Android!

I have worked already with a few developers to update their plugins to remove the Xamarin.Forms restrictions and open them up to everyone. While it is a breaking change, it is for the best and I encourage everyone to follow suite if you have created a plugin or ping me and I will help out :)

Unified Namespaces

I was so close to perfection when I setup the templates for plugins that you could bring in a plugin and then type out “CrossFEATURE_NAME” to get access to it. However, there was one missign piece, which was that the namespaces for each plugin were completely different. I originally thought that this was a good idea, however talking with Mike James he said wouldn’t it be nice to type in “using Plugin.” and see all the plugins come up. He is right! So I made this change to each and every plugin I had access to :) This means that yes, I have broke all the plugins, but I promise never to do it again, and it is an simple change. I have also update the templates to reflect this.

Required Permissions by Default

This is a very small one, but in general I used to have a readme file with each plugin (still do for some) that told you which permissions you need to set for the different platforms. Little did I know that if a permission is required I should just set it and I can do so from the plugin itself. This means any plugin that requires an Android permission will automatically add itself to your Android Manifest :)

Get The Plugins!

So go forth and update the plugins now that you areaware of the changes as they have all been pushed to NuGet. Or start using some plugins and browse all of Plugins for Xamarin and Windows. In addition, I worked with the Xamarin University team to open up my Guest Lecture on plugins to be FREE for everyone!

Get Involved

If you are a library creator I urge you to take a look at all of the changes I have made to my plugins and make similar updates to really enhance the entire Xamarin development ecosystem. I have updated the Plugins for Xamarin templates with a lot of these changes already and would love to start highlighting even more amazing plugins, so please email or tweet at me about the plugins you have created.

]]>
Debug with the Xamarin Android Player from Visual Studio in VMWare or Parallels https://staging.montemagno.com/debug-with-the-xamarin-android-player-from-visual/ 598df8f2c121b60019bf3024 Thu, 23 Oct 2014 08:04:00 GMT I simply love using my Mac when combined with VMWare for development. I consider it the ultimate setup for mobile development with Visual Studio. Since everything is on the same machine the iOS simulator and Build Host just work. For Windows Phone nested virtualization with Hyper-V seems to just work (as long as you you follow the special setup guide from Nokia).

However, my favorite platform, Android, seems to have fallen by the wayside. If you are inside of VMWare or Parallels it might seem like all hope is lost. You are either stuck with an ARM emulator, always needing to plug in a device, or attempting to do some crazy ssh tunnel to your Mac and maybe get things connected to an x86 emulator running on the Mac. Recently we the brand new Xamarin Android Player, which is a blazing fast emulator that run on Mac or PC.

Now, you will still have an issue that you can’t actually run it in nested virtualization inside of VMWare, so don’t do that. If you have the Android Player installed on your Mac it is easier than ever to get it connected and working with Visual Studio inside of VMWare for a delightful experience. Just follow these simple steps:

**Update: Simply now you can pull out the Settings of you Xamarin Android Player and the IP will be visible!**

1.) Download my MonoDroid Toolkit APK from Github (direct link).

2.) Drag and drop this onto your Xamarin Android Player

3.) Launch app and click Networks Utils

4.) You will see a series of IP addresses listed. We will want to find the last one in the list.

*Notice mine wraps around and is actually 10.71.34.101

5.) Go to Visual Studio and launch the Android ADB command prompt from the toolbar.

6.) Type in “adb connect ipaddressfromapp”

7.) Boom! You are all done! verify with “adb devices” and you should see the device listed.

If for some reason you don’t see it in Visual Studio simply reboot. Here is a video walkthrough.

Can’t connect? Ensure your VM is on a Shared Connection to your Mac:

Need more help, leave comments below or join in on the conversation on the Xamarin Forums.

]]>
Xamarin Studio + NuGet PCL Support! https://staging.montemagno.com/xamarin-studio-nuget-pcl-support/ 598df8f2c121b60019bf303e Sun, 15 Dec 2013 22:05:10 GMT From @SharpDevelop comes a long awaited update to the Xamarin Studio NuGet Manager Plugin. I wrote about this plugin before, but with this update brings updated support for NuGet including PCLs for Xamarin.Android and Xamarin.iOS. It is extremely easy to add this functionality to Xamarin Studio and I made a short video to get you going.

Unable to display content. Adobe Flash is required.

]]>
Azure Mobile Services + Xamarin + PCL https://staging.montemagno.com/azure-mobile-services-xamarin-pcl/ 598df8f2c121b60019bf303f Sun, 15 Dec 2013 02:56:00 GMT You might have noticed that both @ChrisNTR and myself have been on the .NET Rocks Roadshow. We have been talking to awesome devs all over the US about Xamarin, PCL, and Azure all wrapped up into an amazing demo (full source code there). One common question that has come up is that while a lot of people have the demo up and running they are having a hard time getting Azure + PCL integrated into their own project. So let’s set one up from scratch.

Pre-requisites: I am going to be using VS 2013 and making an Android App based on the Azure sample. You should:

  1. Read through the Android Setup Guide for Azure

  2. Ensure your Azure Database is setup

  3. Ensure your Azure Table named “TodoItem” is setup

Step 1: New PCL

Select new project in VS2013 and select Portable Class Library. Name your solution “TodoList” and your project: “TodoList.Portable”:

When prompted to select targets select: .NET 4.5, Windows Store, Xamarin.Android, Xamarin.iOS. *NOTE: Windows Phone is not supported in the Azure Mobile Services PCL.

Step 2: Add Azure Mobile Services Nuget

UPDATE 12/16 Don’t actually use the nuget file here, we want to actually reference our component directly. There are a few reasons for this after talking with Paul Batum from Microsoft.

You will want to go to the component store and download the azure mobile service: https://components.xamarin.com/view/azure-mobile-services and then reference both “Netonsont.Json.dll” and “Microsoft.WindowsAzure.Mobile.dll”. You could reference these from the download component later on as well.

**Don’t do this:

Next up is to add the AMS nuget. Simply right click on References and click “Manage Nuget Packages”. Search for “Azure Mobile Services” and click Install.

Such as: Install-Package WindowsAzure.MobileServices -ProjectName TodoList.Portable -Version 1.1.0

Step 3: TodoItem + AzureWebService

Next up let’s first delete Class1.cs and create the TodoItem.cs:

Now our AzureWebService.cs will have a helper to “GetTodoItems” and “AddTodoItem”:

Make sure you fill in your specific Azure Settings.

Step 4: Android Project Setup

Next add a new Android ICS Project named “TodoList.Droid”. Once the project is created add a reference to you “TodoList.Portable” project. After that right click on the Components folder and hit “Get More Components”. Search for Azure Mobile Services and hit Add to App.

Step 5: Add in the UI

The next part is to add an EditText and Button to the UI that will add new items. Under it will be a ListView that we will populate with all of our TodoItems.

Step 6: Hook it all up

Last thing is to tie into this UI and the Azure Mobile Services. We will create our adapter and then get the current TodoItems. When our user clicks to add a TodoItem we will send it up to Azure and add it to the UI if successful:

There you have it. The same can be done for Xamarin.iOS as well.

Cheers!

]]>