Roslyn: el futuro de C#
Rodolfo [email protected]@rodolfofhttp://shockbyte.net
Se pueden agrupar en Front-end: sintaxis == “gramática“ Back-end: semántica == “significado"
5
Fases
Compiladores en .NET .NET siempre fue una plataforma amigable para la construcción de compiladores Intermediate Language (IL)
Stack de Pila Operaciones de alto nivel
Optimizaciones de bajo nivel via la plataforma Reflection Emit
Tools para construcción de compiladores http://irony.codeplex.com
Roslyn – .NET Compiler PlatformCompleta reescritura de los compiladores C# y Visual BasicOpen Source
Language ServicesCode Analysis APIsExtensibilidadRead-Eval-Print-Loop (REPL)Scripting
Ecosistema .NET
Core .NET
Next gen JIT (“RyuJIT”)
SIMD
Runtime Compilers .NET Compiler Platform (“Roslyn”)
Languages innovation
Windows Desktop
Azure and Windows Server
Universal projects
.NET NativeASP.NET updates
Windows Convergence
Native compilation
Web apps
.NET support for Azure Mobile Services
Cloud Services
Openness
Windows Store iOS and Android
.NET in devices and services
Symbol API
API Layers
Services
Compiler Syntax Tree API
Binding and Flow Analysis
APIs
Emit API
Scripting API
Workspace API
Code FormattingFind All
ReferencesName
Simplification …
Editor Services
Code Actions Classification Completion …Outlining
Syntax Tree API – NodesCompilationUnit
TypeDeclaration
MethodDeclaration
class C{ void M() { }}// C▫
ParameterList
Block
var tree = CSharpSyntaxTree.ParseText("...");
Syntax Tree API – TokensCompilationUnit
TypeDeclaration
class
C {MethodDeclaratio
n}
EOF
void MParameterLi
stBlock
( ) { }
class C{ void M() { }}// C▫
Syntax Tree API – TriviaCompilationUnit
TypeDeclaration
class
C {MethodDeclaratio
n}
EOF
void MParameterLi
stBlock
( )
{ }
SP EOL EOL // C
SPx4 SP
EOL
EOL
EOLSPx4 EOL SPx4
class∙C{∙∙∙∙void∙M()∙∙∙∙{∙∙∙∙}}// C▫
Workspace APIHost Environment
Workspace
Solution
Project Project
Document
Document
Solution2 Solutionn
Apply
Edit Edit
SyntaxTree
Compilation
Events (e.g. key presses)
Primary ConstructorAuto-Property Initializerpublic class Point(int x, int y){ public int X { get; } = x; public int Y { get; } = y; public double R { get; } = Math.Sqrt(x ^ x + y ^ y);
public Point() : this(0, 0) { }
public override string ToString() { return string.Format("({0},{1},{2})", X, Y, R); }}
Exception Filteringtry{
Task[] tasks = new Task[10]; for (int i = 0; i < 10; i++) { tasks[i] = Task.Factory.StartNew(() => DoSomeWork(10000000)); } var res = await Task.WhenAll(tasks);}catch (AggregateException e) if (e.InnerExceptions.Count > 2){
await WriteStatus(“filtered exception");}finally{
await WriteStatus(“finished");}
ReferenciasLibros
Compilers: Principles, Techniques, and Tools – Aho et all
Compiling for the .NET Common Language Runtime (CLR) - John Gough
Webhttp://irony.codeplex.comhttp://roslyn.codeplex.com