The types Task and Task<> should be serializable, including continuation delegates created by 'async' methods.
This would enable us to use continuation passing style programming for long-running methods, such as workflow engines, or for ASP.NET apps using state servers!
The compiler should mark the delegate objects holding the captured variables as serializable if all captured variables are serializable.
Therefore, the types AsyncMethodBuilder and TaskAwaiter would have to be serializable too.
- There could be a syntax to tell the compiler to make delegates serializable, such as an attribute on the async method.
- The compiler could choose to always mark them as serializable. Rationale: These types are only visible at run-time anyway, and serialization might actually succeed due to a serialization surrogate only registered at run-time.
This is similar to https://connect.microsoft.com/VisualStudio/feedback/details/278510/support-serialization-of-iterator-state