A few months ago I started to write a replacement for Windows Live Writer for Windows 10 using the new Universal Windows Platform, calling it Net Writer and putting it on the Windows Store in Preview.
A few weeks later Scott Hanselman announces that Windows Live Writer has finally been open sourced as Open Live Writer licensed under MIT. It was time to throw away my code and use that!
Scott was not joking when he said:
IMPORTANT HISTORICAL NOTE: Much of the code in Open Live Writer is nearly 10 years old. The coding conventions, styles, and idioms are circa .NET 1.0 and .NET 1.1. You may find the code unusual or unfamiliar, so keep that in mind when commenting and discussing the code. Before we start adding a bunch of async and await and new .NET 4.6isms, we want to focus on stability and regular updates.
Windows 10 apps use a subset of .NET called Windows Runtime (or WinRT for short) – vast swathes of .NET are missing. Some of the stuff I had to change includes:
- Ripping out everything apart from the connectivity code. This was not easy as there were UI dependencies everywhere.
- Removing System.Net.HttpWebResponse and replacing it with the much better HttpClient. It almost looked like I wasn’t going to have to do this until I realised that the backwards compatible System.Net interface was not handling gzip responses correctly. HttpClient however is async only, therefore;
- All methods need to be async and non-blocking. Windows Live Writer used some classic .NET 2.0 era background threading tricks that are unnecessary today and Windows 10 apps are expected to be async all the way through.
- The XML API has changed quite a bit and now wraps around what I assume is a C++ implementation underneath. System.Xml has been replaced with Windows.Data.Xml.Dom. There is a bizarre new way of querying with XML Namespaces that StackOverflow saved my bacon on.
It took days of staring at 1000+ compiler errors but I managed to get a subset of Open Live Writer working. Net Writer currently only supports WordPress blogs (like this one) but I will be gradually turning on the other supported blog engines as I test them out. This also means that Open Live Writer code now works on Mobile – however the user interface is a bit of a hack job at the moment.
You can try Net Writer out for free from the Windows Store. I update the Preview when time allows and love getting feedback.
Leave a Reply