icsharpcode/NRefactory — pull request #121 by erik-kallen (2012-09-25 15:27:08+00:00)
Title: Await

This patch introduces a specialized ResolveResult for await expressions, and can also find references to the implicitly called methods in such expressions.
I could not find a C#5 language specification, so I do not know exactly how things are supposed to work, but the following things are worth mentioning

* If you have a GetAwaiter method with only default arguments, MS C# (RC) will refuse to use the method and will also refuse to use any GetAwaiter extension methods. I could not find an easy way to implement this obscure case (and I don't know if it's speced), so I added two failing, ignored tests.
* The RC of VS2012 (I don't know about the final release) has interfaces INotifyCompleted and ICriticalNotifyCompleted that declare the methods OnCompleted/UnsafeOnCompleted. I only implemented the OnCompleted method, and I only require a method that can be invoked with an Action argument. Perhaps this should be changed.
* Perhaps the AwaitResolveResult should be an OperatorResolveResult. I opted to not do this because in that case, I think, the operand would need to be the GetAwaiterInvocation. Not making it an OperatorResolveResult is a breaking change, but it was not useful anyway because it was only identifiable as an await expression by checking if the node type was "Extension", which seems unintuitive.

And, btw, OperatorResolveResult representing Dereference and AddressOf operators are indistinguishable (I think, unless doing some fancy type comparison between the operand type and the result type) because they both map to OperatorResolveResult with an "Extension" operand type.