Microsoft.Bcl.Async
enables developers to use async/await
keywords without .NET Framework 4.5 that they are supposed to target to use them.
Tha
async/await
is nothing but C# 5.0 compiler transformation. There is no async/await
at IL
level.
One simple example would be the using() { }
statement which is also a compiler transformation. It just converts the using
statement to try/finally
block. However, there is a dependency on existence of IDisposable
interface which is defined in .NET 1.1.
Similarly, the async/await
transformation depends on certain types like IAsyncStateMachine
interface which are defined in .NET 4.5. The Microsoft.Bcl.Async
gets those type definitions to .NET 4.0.
EDIT
How does the Microsoft.Bcl.Async assembly cause the compiler to recognize a new keyword (async/await)?
No it does not. C# 5.0 compiler already knows about the keywords and what to do with them. However, it can't find the required types as project is targeted to .NET 4.0. The Microsoft.Bcl.Async
package brings in those types.
MS2012 is installing .net 4.5 so you cannot get 'compile errors with 4.0' as you described