Presentation is loading. Please wait.

Presentation is loading. Please wait.

Roslyn: el futuro de C# Rodolfo Finochietti

Similar presentations


Presentation on theme: "Roslyn: el futuro de C# Rodolfo Finochietti"— Presentation transcript:

1 Roslyn: el futuro de C# Rodolfo Finochietti rodolfof@lagash.com

2 Construir un compilador es complejo

3 Fundamentos de un compilador
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 ? Compilador CSC - VBC program.exe class Program { void Main() } } ▫
4/11/2017 Compilador CSC - VBC ? class Program { void Main() } } ▫ program.exe © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Fases Se pueden agrupar en Front-end: sintaxis == “gramática“
Back-end: semántica == “significado"

6 Fases

7 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

8 Demo Reflection Emit

9 4/11/2017 9:22 AM Roslyn © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 Roslyn – .NET Compiler Platform
4/11/2017 Roslyn – .NET Compiler Platform Completa reescritura de los compiladores C# y Visual Basic Open Source Language Services Code Analysis APIs Extensibilidad Read-Eval-Print-Loop (REPL) Scripting © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Azure and Windows Server
4/11/2017 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 Native ASP.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 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 Compiler APIs

13 Binding and Flow Analysis APIs
API Layers Editor Services Code Actions Classification Completion Outlining Code Formatting Find All References Name Simplification Services Workspace API Syntax Tree API Symbol API Binding and Flow Analysis APIs Emit API Scripting API Compiler

14 Syntax Tree API – Nodes class C { void M() } }// C ▫ CompilationUnit
4/11/2017 Syntax Tree API – Nodes class C { void M() } }// C CompilationUnit TypeDeclaration MethodDeclaration ParameterList Block var tree = CSharpSyntaxTree.ParseText("..."); © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Syntax Tree API – Tokens
class C { void M() } }// C CompilationUnit TypeDeclaration EOF class C { MethodDeclaration } void M ParameterList Block ( ) { }

16 Syntax Tree API – Trivia
class∙C { ∙∙∙∙void∙M() ∙∙∙∙{ ∙∙∙∙} }// C CompilationUnit TypeDeclaration EOF class SP C EOL { EOL MethodDeclaration } // C EOL SPx4 void SP M ParameterList Block ( ) EOL SPx4 { EOL SPx4 } EOL

17 Demo Syntax Tree API Symbol API Syntax Transformation Compilation API

18 Workspace API Host Environment Workspace Solution Solution2 Solutionn
Events (e.g. key presses) Apply Workspace Edit Edit Solution Solution2 Solutionn Compilation Project Project Document Document SyntaxTree

19 Demo Diagnostics and Code Fix

20 4/11/2017 9:22 AM C# 6 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Primary Constructor Auto-Property Initializer
4/11/2017 Primary Constructor Auto-Property Initializer public 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); } © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

22 Exception Filtering try { Task[] tasks = new Task[10];
4/11/2017 Exception Filtering try { Task[] tasks = new Task[10]; for (int i = 0; i < 10; i++) tasks[i] = Task.Factory.StartNew(() => DoSomeWork( )); } var res = await Task.WhenAll(tasks); catch (AggregateException e) if (e.InnerExceptions.Count > 2) await WriteStatus(“filtered exception"); finally await WriteStatus(“finished"); © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Null propagating operator
4/11/2017 Null propagating operator © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

24 Using static members 4/11/2017
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

25 Lista completa http://goo.gl/4vtQfr 4/11/2017
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

26 Demo C# 6

27 4/11/2017 9:22 AM ¿Preguntas? © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

28 4/11/2017 Referencias Libros Compilers: Principles, Techniques, and Tools – Aho et all Compiling for the .NET Common Language Runtime (CLR) - John Gough Web © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

29 ¡ Gracias! rodolfof@lagash.com @rodolfof http://shockbyte.net
4/11/2017 9:22 AM ¡ Gracias! @rodolfof © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Roslyn: el futuro de C# Rodolfo Finochietti"

Similar presentations


Ads by Google