Wednesday, February 27, 2013

No ZipArchive in WP8, Pain level 4

Every 6 hours or so there’s a wonderful new compatibility puzzle to solve.  Win8 has ZipArchive.  WP8 has none! 

What should I choose as a substitute? ZipCompress (solo developer, recent updates, but not spending much time on the project), DotNetZip (no updates for over a year), SharpZipLib-WP7 (no updates for 2 years), or something completely different?

The GetResourceStream() method shown here doesn’t seem to work for large .zip files, presumably because it’s using a MemoryStream internally leading to OutOfMemoryExceptions.

Tuesday, February 26, 2013

GeoPosition and GeoLocator, Pain level 5

Of course you needed to rework the WP7 GeoPosition and GeoCoordinate structures for Win8 and WP8, breaking all of our existing code!  

Fortunately Adam Denning wrote a nice blog post explaining the differences but why-oh-why did you need to make all the replacement classes sealed with no setters?  Now it’s impossible to serialize and deserialize these objects, forcing everyone to invent a duplicate replacement class for persisting routes and courses.

DOH!

Portable Class Libraries, Pain level 5

While Portable Class Libraries are great in theory for sharing code across Win8 and WP8, in practice they’re severely limited by the classes which can be referenced.   The BCL should be segmented at a lower level to make simple non UI classes like Point and Rect available.

IValueConverter incompatible, Pain level 3

Win8 seems to randomly break IValueConverter by making the last parameter a string instead of CultureInfo!  I haven’t found the correct way to fix this, but at least this compiles Win8 and WP8:

public class BooleanConverter<T> : IValueConverter
{
    public BooleanConverter(T trueValue, T falseValue)
    {
        True = trueValue;
        False = falseValue;
    }
 
    public T True { get; set; }
    public T False { get; set; }
 
    public virtual object Convert(object value, Type targetType, object parameter, string language)
    {
        return value is bool && ((bool)value) ? True : False;
    }
 
    public virtual object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        return value is T && EqualityComparer<T>.Default.Equals((T)value, True);
    }
 
#if !WINFX_CORE
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return Convert(value, targetType, parameter, "");
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ConvertBack(value, targetType, parameter, "");
    }
#endif
}

Platform fragmentation, Pain level 7

Sure, any platform over time will begin to fragment, but Microsoft seems hell bent on ensuring minimal portability of source code across their recent platforms. Whereas 1992 source code written for Win32 can be recompiled and run without modification throughout the intervening years, the same cannot be said of code written for Silverlight, WPF, WP7 and now Win8 and WP8.  

The half life of supported development platforms has fallen precipitously.  Silverlight, dead.  WPF ailing, WP7 obsolete, and the newcomers Win8 and WP8 proclaiming themselves the new shining path going forward. 

But developers are now gunshy and looking elsewhere, having learned through painful experience that Microsoft seems unable to commit to a coherent, long term development strategy.  Presumably this is an outcome of the org chart from the last decade:

One would have hoped that C# and the painfully verbose XAML would form the foundation of the future, but then COM and  C++ were confusingly resurrected, and we’re all invited to enjoy sprinkle our code with pointy hats:

 task<IVectorView<StorageFile^>^>(picker->PickMultipleFilesAsync())
.then([this, uri] (IVectorView<StorageFile^>^ files)
 

Or we can learn the joys of non-typesafe code by switching to javascript and CSS for coding our Win8 UI (but not WP8!).

Since C#, javascript, and C++ and associated controls and libraries aren’t compatible for developing applications across Win8 and WP8, the future for Windows developers will be one of continued pain. 

…none of the crazy you get from too much choice.

Windows 8 and Windows Phone 8 Pain Log

I’ve been a Windows developer for just about forever, and since my pain threshold has just been exceeded attempting to port existing code to these new platforms, I’ve decided to share my agonies as a form of therapy.

Each item will have an associated numeric Pain value of  1 to 10, with 10 being extreme, out of one’s mind pain.

This should be fun!