Monthly Archives: February 2013

Introducing TPL Async Generator

I am playing with Azure last months. I love Azure. Really breath of fresh air last days… But there is small funny issue… Client libraries are async. But async is implement with old IAsyncResult model. Uuuu. Ugly. Let’s fix this.

I implemented small T4 template that actually

  1. looks for all methods with Begin
  2. and generate extension methods with TPL async implementation

Usage is simple,

  1. Install from nuget
  2. Modify example template
  3. Press save
  4. Enjoy!


For example QueueClient, it have methods like:

public IAsyncResult BeginReceive(
	TimeSpan serverWaitTime,
	AsyncCallback callback,
	Object state

AsyncGenerator will generate:

public static Task<BrokeredMessage> ReceiveAsync(this MessageReceiver @this
                                            ,TimeSpan serverWaitTime)
      if (@this == null) throw new ArgumentNullException("this");
      return Task<BrokeredMessage>.Factory.FromAsync(
                @this.BeginReceive, @this.EndReceive,
                serverWaitTime, null);

Now you can use azure in normal C# 5.0 way:

var message = await queue.ReceiveAsync();
if (message != null)
     await message.CompleteAsync();



Tagged , , , , ,

SharePoint + TypeScript = Love

Few months ago I became SherePoint developer, and this is like developing in damn stone age. No async, no SignalR, no .. , actually there almost nothing from last years. Mad. If you need something post 2008, you are out of lack. But this is like 8-bit game. You know this feeling of playing games on ZX-Spectrum? So let’s play.

  • Obviously, you need install TypeScript. It will ask restart everything, I also restarted few servers, just in case.
  • Create new TS file (for example in Layouts folder), you need to use Add New Item dialog, because otherwise VisualStudio will not assign (and will not allow you)  TypeScriptCompile to Build Action property of the file. image
  • Try to compile. File.js under File.ts should be JavaScript compiled from TypeScript. For me it does not work however. Fix is here.  You just need to add BeforeBuild target to call compiler. Make sure that path to compiler is correct.
  • Try compile another time. This time it should work.
  • After I got this working, level of impression raised exponentially. Writing JavaScriptTypeScript became much more pleasant.

    Some missing points:

    1. Somehow I need remove TS files from result WSP file.
    2. I need better way to manage TypeScript definition files in solution, but this is general problem of how integrate NuGet content packages to SharePoint project.

    Overall impression is 4.5 from 5