Saturday, December 14, 2013

v3.1.1 beta

The first beta of the first Net4.5 only release of MvvmCross is uploaded to nuget and binaries are on github too - https://github.com/MvvmCross/MvvmCross-Binaries/tree/v3.1.



The changes since v3.0.14 are big:
  • Switch to profile 158 for all portable assemblies
  • Switch to WP8 for all WindowsPhone projects - plus System.Windows.Interactivity dependency updated to 3.9.5
  • Fragging now uses the Google Xamarin.Android v4 support library rather than the Mono.Android one.
  • Html email fix for Android
  • Changes to nuget referencing (especially WP8 and SL5)
  • To avoid angst, the existing SQLite plugin is no longer marked "obsolete" - I still encourage everyone to switch to the new community plugin as it is the better plugin (and I encourage people to step forwards to take over the admin of this too!)
  • Improved helper method for subscribing to Interaction events
  • A draft IMvxComposeEmailTaskEx interface has been added to the mail plugin allowing attachments and multiple addresses on some platforms. More work is still needed here



Further notes:
  • General MvvmCross user consensus seemed to be that profile 78 was preferred to profile 158. Given this, we'll definitely continue to look at how/when/if to switch to 78 in the near future. However, right now today I wanted to start getting releases out, and the switch of reflection API for profile 78 would have caused too long a delay in this (especially in testing/debugging/fixing on all platforms).

  • In the v3.1 branch, there are also ongoing changes and improvements to both MonoMac and XamMac support - especially with heroic inputs from tofutim. However, these inputs are not today included in the released nuget stream or in the binary packages.

Saturday, December 07, 2013

NDC London Talk - Data-Bind Everything

I spoke at the first NDC London conference this week.


It was a great conference - really good to see and meet so many devs here in my home city.


I gave a talk on the opening morning about how we'd created and extended a data-binding engine for MvvmCross.


Sadly, there's no recording of this talk available, but I've put the slides and the code online - I hope they make some sense to someone :)


Slides:



Code: https://github.com/slodge/BindingTalk

Saturday, November 16, 2013

MvvmCross 3.0.14

After 3 betas, I've now pushed 3.0.14 to nuget and to the binary repo :)


This is probably the last 3.0.x release


The next release will hopefully be 3.1.x - for this next version we will drop Windows Phone 7.x support and aim to more fully support the new releases from Xamarin/Microsoft (Xamasoft?)


For my latest on how to use nuget with Xamarin, please see the run-through in http://slodge.blogspot.co.uk/2013/11/quick-run-through-using-pcls-in.html



The changes in 3.0.14 over 3.0.13 are:
  • Changes to nuspec files for more generic targets (I believe switching nuget to the latest 2.7.2 release will also help some users)
  • Improvements in intrinsic boolean conversions
  • Optimisation in nested bindings - changes to reduce the number of times source properties are fetched during updates
  • Fix for spinner which caches the DataContext when a child window is switched off of the screen and then back in again (without going through an Adapter GetView)
  • Virtual keyword additions to allow additional overrides for CreatingBinding and for GetIoCParameterValues
  • Changes to ValueCombiners to allow them to better support UnsetValue - these now return the UnsetValue if any child is Unset
  • Redirecting the Progress value in the Seekbar so that reflection is not used (very minor optimisation)
  • Refactoring of Android layout inflation code - allowing custom view creation if required
  • Provision of some Folder methods for the MvvmCross File plugin on WindowsStore (Win8/WinRT)
  • A fix for MvxLinearLayout refresh issues
  • A change of protected API for CreateBindingView in MvxAdapter - it now returns an IMvxListItem instead of an MvxListItem (this method is seldom overridden - but is a breaking change if you did override it)
  • A fix for ThreadUtils - Wpf Package
  • A fix for ViewModel creation for activities displayed via external Intents - e.g. from Mail or push links
  • Change to Droid and Touch collections/lists - nullify the datacontexts of individual listview items when removed
  • Wpf ThreadUtils assembly has been added
  • Improvements in binding parsing of properties beginning with and containing underscores
  • Improved error messages when binding fails
  • Binding for Android RatingBar control
  • ShouldReturn binding for iOS
  • Fix to Or logic in ValueCombiner
  • Provision for default parameters in ViewModel Init methods
  • Inclusion of additional LinkerPleaseInclude entries for Android
  • Trace optimisation - no messages shown for null datacontexts


Any problems/issues, please do report them via forums, stackoverflow or via github issues

Thursday, November 14, 2013

Quick run through - using PCLs in Xamarin.Android and Xamarin.iOS with mvvmcross

Following up from yesterday's annoucements, I've just recorded a quick "new project" run-through for PCLs with iOS and Android.


This run-through shows that the process isn't perfect right now - there are a few tweaks along the way - but overall it's a HUGE step in the right direction and you should hopefully be able to get your projects up and running quite quickly.



The source of what I built is on: https://github.com/slodge/Demo


Note that I am using the latest nuget - 2.7.2 - downloaded from http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c


The video is on:






If you've got questions, ideas, suggestions please do start a conversations somewhere - maybe on the MSDN or Xamarin forums, or maybe on Stackoverflow. Please do this in public somewhere - it's great to have open source conversations in public :)


Please do also write your own blog posts and make your own videos - it's fab seeing what others are doing :)

Profiles in the new Portable World

There was lots of great news yesterday - including Microsoft shipping lots of their PCL libraries under a new permissive license and Xamarin working with Microsoft and shipping working PCL support to stable




For those of you who are already ahead of the curve and working with PCLs across all the modern platforms, then this is all really great news. It really reaffirms the direction MvvmCross has been following for the last 18 months.


However, there are some teething problem right now and I'm afraid solid information about what has shipped and how it works is a bit thin on the ground right now.


Right now, if you want to carry on working with PCLs and MvvmCross, then I think some of the steps you may need to take are:

  • If you want to build on Mac, then you may need to change the profile of your PCL from 104 to something newer - with many people currently seeming to choose profile 158. To do this is as simple as editing the csproj file. However, please be aware that doing this will remove support for Windows Phone 7.5 - profile 158 only supports Windows Phone 8 and higher
  • If building Droid projects outside of Visual Studio, you may also need to remove the assembly references to the MvvmCross System.Windows.dll and System.Net.dll - and you may instead need to use the assemblies of the same names that now ship from Xamarin
  • If using nuget, then you may need to update to the latest release (2.7.2) and you may need to use the latest prerelease 3.0.14-beta3 packages from MvvmCross - these are available if you select "include prereleases" inside nuget


Obviously these instructions are "a little sketchy" right now. Sorry - we're doing are best to work with the information that's available. It's not yet really clear what the current state is - how stable the released things are. Hopefully, we'll all learn a lot in the coming days :)


It does seem like Microsoft have forced the retirement of WP7.x development - so it does look likely that we will retire WP7.x support from MvvmCross


It may also be that the future of MvvmCross (v3.1?) lies in one of the 4.5 profiles - like profile 78 - rather than in the 4.0 profiles like 104 or 158. However, this depends a bit on how well the new open Bcl packages can work with Xamarin - and it depends on how we find a way to continue our Silverlight and Unity3D support.


I'll be back with more definitive news real soon :)


The future is portable... and it's now? :)

Wednesday, November 13, 2013

3.0.14-beta3 pushed to nuget

Have updated the build


Have pushed to nuget


Have also pushed VS2012 only binaries to the binaries repo (in theory the XS-built binaries are no longer needed)

In addition to Beta2, Beta3 has:


  • Changes to nuspec files for more generic targets (I believe switching nuget to the latest 2.7.2 release may also help some users)
  • Optimisation in nested bindings - changes to reduce the number of times source properties are fetched during updates
  • Fix for spinner which caches the DataContext when a child window is switched off of the screen and then back in again (without going through an Adapter GetView)
  • Virtual keyword additions to allow additional overrides for CreatingBinding and for GetIoCParameterValues
  • Changes to ValueCombiners to allow them to better support UnsetValue - these now return the UnsetValue if any child is Unset
  • Redirecting the Progress value in the Seekbar so that reflection is not used (very minor optimisation)
  • Refactoring of Android layout inflation code - allowing custom view creation if required
  • Provision of some Folder methods for the MvvmCross File plugin on WindowsStore (Win8/WinRT)





Beyond this, the features included in 3.0.14 beyond 3.0.13 remain:


  • A fix for MvxLinearLayout refresh issues
  • A change of protected API for CreateBindingView in MvxAdapter - it now returns an IMvxListItem instead of an MvxListItem (this method is seldom overridden - but is a breaking change if you did override it)
  • A fix for ThreadUtils - Wpf Package
  • A fix for ViewModel creation for activities displayed via external Intents - e.g. from Mail or push links
  • Change to Droid and Touch collections/lists - nullify the datacontexts of individual listview items when removed
  • Wpf ThreadUtils assembly has been added
  • Improvements in binding parsing of properties beginning with and containing underscores
  • Improved error messages when binding fails
  • Binding for Android RatingBar control
  • ShouldReturn binding for iOS
  • Fix to Or logic in ValueCombiner
  • Provision for default parameters in ViewModel Init methods
  • Inclusion of additional LinkerPleaseInclude entries for Android
  • Trace optimisation - no messages shown for null datacontexts

Portable support is changing within Xamarin right now - but the news is mainly at the "announcement" level right now - as we get details through then we will update MvvmCross to make sure we can all get on with doing dev work instead of setup :)

Thursday, November 07, 2013

N=42 - Is my ViewModel visible? Can I kill it?

Today's N+1 is all about whether or not your ViewModel is Visible - and about how to kill it when it gets removed from the screen.


This is a fairly FAQ topic - see questions like http://stackoverflow.com/questions/15961664/viewmodel-lifecycle-when-does-it-get-disposed and http://stackoverflow.com/questions/19816819/how-are-views-and-viewmodels-freed-up-in-mvvmcross


MvvmCross doesn't provide any built-in event notification - but it is easy to add it for your app.


In this video, I show how to add and invoke interfaces like these to some view models which are shown by a standard MvvmCross presenter:




If you have custom presentation, then you'll need to adapt this technique to suit your needs - but, since it is your custom presentation, then you should hopefully be in the best place to do this.


The source for today's video is in https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/tree/master/N-42-Lifecycles


The video itself is:




The audio skips in the first few seconds - making me sound even odder than normal ;)


For a full N+1 index, please see Aboo's fabulous work on http://mvvmcross.wordpress.com

Wednesday, November 06, 2013

Why you should always Dispose your HttpWebResponse objects

I very recently came across a "hard to solve" issue.


Well, it certainly felt like one...


The problem showed itself via all my HttpWebRequest's blocking - they didn't timeout, they didn't exception - they just blocked.


I couldn't work out what was causing this - and the situation was complicated because the servers I were talking to were quite complicated - they were PHP apps running on Apache, but hiding behind nginx running node.js middleware.


The one thing I could see was that just before things went wrong, these servers were returning "chunked" HTTP 1.1 responses.


The problem also looked more complicated because when I used Fiddler to try to debug the issue, then the problem disappeared (this is because Fiddler alterred the way the responses were received - it doesn't quite mirror responses perfectly - for chunked responses it concatenates them)


Some research led me to various blog posts, stackoverflow answers, etc which all suggested issues - e.g. things like http://blog.degree.no/2011/06/webclient-httpwebresponse-problems-with-chunked-transfer-encoding/


I wrote a test harness, got the case reproducible and then reached out to some friends in MS to see if I had found a genuine issue.


I had, of course, not found one....


Instead, one of the MS guys answered quickly and from his gut:

my gut feel is that you aren’t emptying the body of the first request when using HttpWebRequest.  Can you ensure you are reading the entire body of the first request before sending the second one with HttpWebRequest?


I checked all our calls....


... and in one of them we weren't reading the response at all.


... so I added a `Dispose()` to the response there (instead of reading its stream)


... and that caused the Http stack to start behaving again


... :)


So, it seems like what was happening was that when this "Chunked Transfer Encoding" occurred, then the HttpWebRequest stack got "stuck" waiting for code to read the incomplete response - and this prevented future calls from working.


So the moral of the story is: Dispose() your HttpWebResponse objects - or, if not, at least read them in their entirety.


It's also worth noting: this problem didn't really show up when we switched the code to the newer HttpClient - so, if you are looking at new code, then please do use HttpClient instead!


Thanks especially and hugely to @dsplaisted and @theesj for pointing out (using just their guts) the error. Hopefully by posting this here, it will help others.... 

Monday, November 04, 2013

3.0.14-beta2 on nuget

Have updated the build

In addition to Beta1, Beta2 has:

  • A fix for MvxLinearLayout refresh issues
  • A change of protected API for CreateBindingView in MvxAdapter - it now returns an IMvxListItem instead of an MvxListItem (this method is seldom overridden - but is a breaking change if you did override it)
  • A fix for ThreadUtils - Wpf Package
  • A fix for ViewModel creation for activities displayed via external Intents - e.g. from Mail or push links


Overall, the features included in 3.0.14 beyond 3.0.13 remain:


  • Change to Droid and Touch collections/lists - nullify the datacontexts of individual listview items when removed
  • Wpf ThreadUtils assembly has been added
  • Improvements in binding parsing of properties beginning with and containing underscores
  • Improved error messages when binding fails
  • Binding for Android RatingBar control
  • ShouldReturn binding for iOS
  • Fix to Or logic in ValueCombiner
  • Provision for default parameters in ViewModel Init methods
  • Inclusion of additional LinkerPleaseInclude entries for Android
  • Trace optimisation - no messages shown for null datacontexts

Saturday, November 02, 2013

3.0.14 Beta1 on nuget

The latest build - 3.0.14-Beta1 - has survived some preliminary testing and is now on nuget


There is one significant change which may break client apps in this build.


The change is to do with the way that collection items have their DataContext set to null when the bindings are cleared. It should help prevent a problem that Blewzman reported when he used long-living nested static collections in his viewmodels.



This change may effect your existing views, valueconverters and bindings if they don't cope well with null DataContexts.



For example, in the ApiExamples project this required me to add a check for null to the Convert method:

         protected override string Convert(string value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
         {
             if (value == null)
                 return null;
             return value.Replace((string)parameter, string.Empty);
         }
 

Overall, the features included in 3.0.14 beyond 3.0.13 are:

  • Change to Droid and Touch collections/lists - nullify the datacontexts of individual listview items when removed
  • Wpf ThreadUtils assembly has been added
  • Improvements in binding parsing of properties beginning with and containing underscores
  • Improved error messages when binding fails
  • Binding for Android RatingBar control
  • ShouldReturn binding for iOS
  • Fix to Or logic in ValueCombiner
  • Provision for default parameters in ViewModel Init methods
  • Inclusion of additional LinkerPleaseInclude entries for Android
  • Trace optimisation - no messages shown for null datacontexts

Saturday, October 26, 2013

An awesome alternative i18n implementation - opcode bags badge #2

Earlier this year, Stefan posted an article about how to integrate resx files with the MvvmCross localisation framework - http://opendix.blogspot.ch/2013/05/using-resx-files-for-localization-in.html


Recently Andrei - opcode - has taken the same resx files and pushed them in a different direction.


He looked at the existing Json code and he didn't like it... As he said, "I went through the N+1 video and tried to understand localization using the Json localization plugin but it almost made me cry"... so instead of crying he went off and created an alternative implementation - using resx files directly from ViewModels to allow i18n text bindings like:



"Text [UsernameText]"
android:layout_width="wrap_content" android:layout_height="wrap_content" />


This alternative option is awesome. It fits exactly with one of the fundamental principles of MvvmCross - that people should write the code they want to write - the app is the king!


If you want to learn more about this approach then the blog post and code is at: http://enginecore.blogspot.co.uk/2013/09/localization-in-xamarin-mvvmcross_18.html


Awesome!



Friday, October 25, 2013

An Awesome Detroit Mobile MvvmCross presentation from Rob Gibbens

Rob Gibbens recently gave a full MvvmCross introduction to the @DetMobileNet group.


I don't know much about this... but from the feedback it sure looks awesome!





Well deserving of a shiny badge of awesomeness - great work Rob!



MvvmCross.Mac awesomeness from Tim and Kevin

One of the goals for MvvmCross v3 was support for MonoMac and Xamarin.Mac


Kevin - @deapsquatter - at CentraStage has been pushing this work forwards for over 6 months now and has blogged about specific parts like Mac NSTableView support


More recently, Tim - @tofutim - at loqu8 has been pushing forwards with PCL code from the tip of v3.


Together, they've got our .mac support into a good state - as you can see:





This is .... of course.... awesome - doubly so! And I'm delighted to give Tim a first badge of awesomeness and Kevin his 4th


 

Thursday, October 24, 2013

More more more more awesome plugins from the big Cheese - badge #5

Regular MvvmCross users will already know Cheesebaron - he's already got **4** badges of awesomeness...


And today he gets number **5**!


The reason - he's posted lots of new plugins to his github repo - https://github.com/cheesebaron/Cheesebaron.MvxPlugins/


Beyond the Azure Access Control plugin I blogged about last month, these include:


  • an SMS plugin
  • a Settings plugin (with a notable assist for James M)
  • a basic phone info plugin
  • a Connectivity plugin



Beyond these, Cheesebaron's also really proactive and helpful on the MvvmCross Github issues, on Stackoverflow and on the Xamarin forums - applying skill and expertise to help lots of devs every day. So as well as badge #5 I'm delighted to say that Cheesebaron's now also a full admin on the MvvmCross repos.


Awesome NYC Code Camp samples from Greg Shackles - badge #2 !

In September Greg Shackles gave an awesome talk about multi-platform C# development at the New York Code Camp





The code for this talk is particularly awesome - it uses file linking rather than PCLs and it fully takes advantage of Task and of lots of the awesome async features in C#5 and Xamarin 2.0 - take a look at it on https://github.com/gshackles/NycCodeCamp8



It's a huge pleasure to announce badge #2 for Greg - thanks Greg - awesome code and awesome presenting!





A UserInteraction plugin - from Brian Chance - awesome again!

One of the common questions when writing Mvvm ViewModel code is "How do I show a MessageBox?"


There are a few answers around to this on StackOverflow - e.g. using an interaction helper or using a dialog service


However, for simple message boxes or for a simple message prompt, BrianChance has provided this open source plugin - https://github.com/brianchance/MvvmCross-UserInteraction


So now showing a message is as easy as:




This is awesome - and it happily earns Brian badge #2 - thanks Brian!



Using the Infragistics Nuclios Grid control with MvvmCross binding - awesome from Blake Davidson

Recently, Blake Davidson - @davidsonblake86 - has posted this blog post -
http://davidsonblake.wordpress.com/2013/10/15/single-row-gridview-using-mvvmcross-infragistics-nuclios-and-xamarin-ios/ - showing how monkeys can easily be databound into an Infragistics grid from an MvvmCross ViewModel.





Infragistics have been long-term supporters of MvvmCross and it's really awesome to see their controls databound this way!


Blake - thank you hugely for his awesomeness - an awesome badge of thanks!



Developers Developers Developers - awesome up North from Ross Dargan

Ross Dargan gave this presentation at DDD North recently:



It covers lots of MvvmCross topics - including file sharing, PCLs, IoC and Mvvm - and it comes with lots of awesome samples in https://github.com/rossdargan/Talks


Awesome stuff - and well deserving of a badge of awesomeness - thanks, Ross!



Awesome profiling and optimising from Miha Markic

Earlier this month we shipped 3.0.13 - this included lots of improvements - including a couple of speed optimisations for Android binding.


These came from some work Miha Markic has done in profiling Xamarin.Android using high frequency counters - see his excellent blog post on the topic about it on http://blog.rthand.com/post/2013/09/12/Poor-mans-performance-profiling.aspx


This is awesome work - really helping MvvmCross to keep improving - and hugely deserving of a first badge of awesomeness - thanks Mika!




Hawkes Bay awesomeness from Sean Cross

Sean Cross recently gave this Hot Tuna talk in Hawkes Bay, NZ:





It's awesome! And well deserving of a badge of awesomeness - top talking Sean!