In the same way it’s possible to await any type following a specific ‘trait’ (yes, we need them in C#), It’s now possible to return custom type from an async method: Return Any (Task-Like) Type From An Async Method | Bar Arnon. We can thanks corefx, Roslyn and Stephen Toub.
Awesome: Building strongly typed application configuration utility with Roslyn use Roselyn scripting engine to delegate to an external script filling a strongly typed instance.
The complete code is already very short but all is really made in only 3 lines :
- fill a ScriptOptions instance,
- creating a CSharpScript and
- running it asynchroniously.
For a production use, script error detection must be added and a way to add new references from script itself (and perhaps nuget references).
EDIT: I’ve neglected to follow a link about ConfigR: same needs but some step head. ConfigR use scriptcs on top of Roselyn to provide more possibilities: load sub script, add reference, use predefined packs (nuget packages but more script friendly using MEF) and debugging.
A simple example of what can be done with Visual Studio 2015 Preview thanks to compiler services API of Roslyn compiler: I Can Analyze Code, And So Can You | Didactic Code.