A quick post to introduce a new Resharper plugin for Visual Studio to hopefully help when writing code using the Reactive Extensions libraries.
The background to how I came to developing this plugin is simple - @leeoades, @hamishdotnet & I were looking into a regression bug we introduced where the app completely froze - a classic blocking issue on the UI thread. We knew this because the host for the app (web browser) was complete unresponsive, the app (which happened to be Silverlight) had completely locked up the UI thread, leaving even the browser chrome useless - the only thing left was to kill the process.
We do a lot of asynchronous stream processing using Rx and we knew one of the extension method from the Rx libraries was causing synchronization dead lock by scheduling work onto the UI thread. Now we knew the issue wasn't with the actual methods from the Rx libraries but how they were being used. We weren't using an overload for one of the Rx extension methods which can take an IScheduler parameter correctly, we were relying on the implicit version which used either the immediate or current thread scheduler.
I knew there wasn't a documented list of the methods in the Rx libraries which could take an IScheduler instance and I'm not even sure it would have helped, because we had our own methods (and extension methods) returning IObservable<T> which had optional IScheduler parameters.
I thought wouldn't it be great if you got a
And that's how I eventually got to writing this post :)
Now when I write something like the following it will add a R# hint to any method which could take an IScheduler parameter either as an explicit or optional parameter.
With the plugin installed you get:
And when the scheduler has been defined no more Rx hints:
With this initial beta release there is another R# hint for missing usages of the AsObservable() Rx method.
Installer - http://reactiveresharper.codeplex.com
Code - https://github.com/oriches/Resharper.ReactivePlugin
If you've got any thing to add to the plugin I'd be interested to hear about it...
Comments
Post a Comment