Roslyn

43
Roslyn TALENTSOFT R&D Academy 27/03/2014 Compilateur as A Service

Transcript of Roslyn

Roslyn

TALENTSOFT R&D Academy 27/03/2014

Compilateur as A Service

► [Introduction]Compilateur et méta programmation

► Roslyn

► [Coding]Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

► [Introduction]Compilateur et méta programmation

► Roslyn

► [Coding]Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

Compilateur et meta-programmation

Définition

La métaprogrammation désigne l'écriture de programmes qui manipulent des données décrivant elles-mêmes des programmes.

Wikipédia

Compilateur et meta-programmation

Compilateurs

Compilateur et meta-programmation

Compilateurs

var x = 10; var y = 20; if(x == y) {}

IL_0001: ldc.i4.s 0A IL_0003: stloc.0 IL_0004: ldc.i4.s 14 IL_0006: stloc.1 IL_0007: ldloc.0 IL_0008: ldloc.1 IL_0009: ceqIL_000B: ldc.i4.0 IL_000C: ceqIL_000E: stloc.2 IL_000F: ldloc.2 IL_0010: brtrue.s IL_0014 IL_0012: nop

► [Introduction]Compilateur et méta programmation

► Roslyn

► [Coding]Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

Roslyn

Octobre 2011

CommunityTechnology Preview

Evangélisation(MVP Matthieu Mezil)

2012 Février

Major Updates & Breakingchanges

Septembre 2012

Roslyn

Octobre 2011

CommunityTechnology Preview

Evangélisation(MVP Matthieu Mezil)

2012 Février

Major Updates & Breakingchanges

Septembre 2012

Eric Lippert « Principal Developer » quitte

Microsoft pour Coverity

Novembre 2012

Novembre 2012

Eric Lippert « Principal Developer » quitte

Microsoft pour Coverity

Dogfooding de Roslyn

Décembre 2013

Dogfooding de Roslyn

Décembre 2013

Roslyn

Ressources

Api & templates téléchargeables pour VS 2012.

Exemple format Word

Packages NuGetDisponible pour les autres versions de Visual Studio.

Roslyn

Compilateur As A Service

Compiler APIs

Scripting APIs

Services APIsEditor Services

APIs

4APIs

Roslyn

Compiler APIs

Scripting APIs

Services APIsEditor Services

APIs

4APIs

Roslyn

Compiler APIs

Scripting APIs

Services APIsEditor Services

APIs

4APIs

Roslyn

Compiler APIs

Scripting APIs

Services APIsEditor Services

APIs

4APIs

Roslyn

Compiler APIs

Scripting APIs

Services APIsEditor Services

APIs

4APIs

Roslyn

Roslyn

Templates VS 2012

► [Introduction] Compilateur et méta programmation

► Roslyn

► [Coding] Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

[Coding] Syntaxe et Sémantique

Workspace

[Coding] Syntaxe et Sémantique

Prérequis

[Coding] Syntaxe et Sémantique

Grammaire & langage

Grammaire (Arbre syntaxique)

ArgumentListSyntax paramètre de méthode ClassDeclarationSyntax déclaration d’une classe ExpressionStatementSyntax ligne de code UsingDirectiveSyntax using d’un namespace ...

Sémantique (Symbol) SemanticModel

GetTypeInfo() résultat de l’expression

(struct) CommonSymbolKind.Event .Field .Property

[Coding] Syntaxe et Sémantique

Syntax

SyntaxNode: Blue

SyntaxToken: Green

SyntaxTrivia: Red

using System;

using System.Collections.Generic;

using System.Linq;

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Hello, World");

}

}

<Live Coding>

[Coding] Syntaxe et Sémantique

[Coding] Syntaxe et Sémantique

[Coding] Syntaxe et Sémantique

ExpressionStatementSyntax

BinaryExpressionSyntax

IdentifierNameSyntax InvocationExpressionSyntax

[Coding] Syntaxe et Sémantique

InvocationExpressionSyntax

MemberAccessExpressionSyntax

ArgumentListSyntax

IdentifierNameSyntax IdentifierNameSyntax

</Live Coding>

► [Introduction] Compilateur et méta programmation

► Roslyn

► [Coding] Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

[Demo] Scripting et Compilation

Script CS

scriptcs makes it easy to write and execute C# with a simple text editor.

C:\> scriptcs scriptcs (ctrl-c or blank to exit)

> var message = "Hello, world!"; > Console.WriteLine(message); Hello, world! >

[Demo] Scripting et Compilation

Demo

► [Introduction] Compilateur et méta programmation

► Roslyn

► [Coding] Syntaxe et Sémantique

► [Demo] Scripting et Compilation

► Le projet et son avenir

Agenda

Le projet et son avenir

Actuellement

Dogfooding

Build 2014

Balbutiement dans la communauté

Le projet et son avenir

Wish-list

Meilleur documentation (à jour!)

Full-Compatible avec VS 2013

Le retour de l’analyseur syntaxique

AOP