Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Metaprogramming in .NET

Microsoft® “Roslyn” CTP

by @AkimBoyko

GitHub repository

μετά: after, beyond, self, adjacent

metaprogramming: The classic definition for a metaprogram is “a computer program that writes new computer programs”
by @KevinHazzard and @JasonBock

JavaScript eval() as metaprogramming example

from Metaprogramming in .Net by @KevinHazzard and @JasonBock

Initial state

JavaScript Metaprogramming via Scripting

Simple multiplication

Use Function Dynamicly

Injection values into local execution scope

Injection Values into Local Execution Scope

C# is multiparadigm language

"Languages are losing their classifications. No longer can we say that a language is just an object-oriented language, or just a dynamic language, because so many of them borrow from lots of different ideas

Anders Hejlsberg talk about C# 3.0

Microsoft® “Roslyn” CTP

Traditionally, compilers are black boxes.Source code goes in one end, magic happens in the middle, and object files or assemblies come out the other end.

As compilers perform their magic, they build up deep understanding of the code they are processing, but that knowledge is unavailable to anyone but the compiler implementation wizards.

The core mission of the Roslyn project: opening up the black boxes and allowing tools and end users to share in the wealth of information compilers have about our code.

Bootstrapping for compilers

Bootstrapping is the process of writing a compiler in the target programming language which it is intended to compile.

Applying this technique leads to a self-hosting compiler.

Compiler as a Service

Demo #01

Syntax trees

Microsoft Roslyn vs. CodeDom

CodeDom is a precursor to Roslyn, but is only marginally related.

Metaprogramming by …

Demo #02

Scripting: `eval()`-like for C# using Roslyn

Demo #03

Scripting: Roslyn Script vs. IronPython

Demo #04

Code-as-Data: Roslyn and T4

Demo #05

Code-as-Data: Convert code written in one language to another

VB → C# and back again

Note about "Code-as-Data"

Note about "Dynamic" programming

Demo #06

Reflection/Inspection: Cyclomatic complexity

Corner cases

Use a spacebar or arrow keys to navigate