Project Roslyn Exposing the C# and Visual Basic compilers’ code analysis Dustin Campbell Senior Program Manager Microsoft
Project Codename “Roslyn” • Scope • Managed compilers & language services • Code analysis APIs • Scripting APIs • Language service extensibility • Read-Eval-Print-Loop (REPL) • Ship Date • v.Next + n, where n > 0
IL Emitter Emit API Edit and Continue Go To Definition Binding and Flow Analysis Extract Method Signature Help Binder APIs Quick Info Rename Find All References Completion List Symbol API Metadata Symbols Import Object Browser Navigate To Syntax Tree API Outlining Parser Colorizer Formatter Compiler API Compiler Language Pipeline Service
Design Choices Immutable Complete Resilient Efficient
Demo: Compiler APIs
Major Players class C { Syntax Nodes void M() { } GetRoot CompilationUnit SyntaxTree }// C ▫ TypeDeclaration MethodDeclaration ParameterList Block
Major Players class C { Syntax Tokens void M() { } GetRoot CompilationUnit SyntaxTree }// C ▫ TypeDeclaration EOF class C { MethodDeclaration } void M ParameterList Block ( ) { }
Major Players class ∙ C { ∙∙∙∙ void ∙ M() Syntax Tokens ∙∙∙∙ { ∙∙∙∙ } class C }// C ▫ { M ( ) void { } } EOF
Major Players class ∙ C { ∙∙∙∙ void ∙ M() Syntax “Trivia” ∙∙∙∙ { ∙∙∙∙ } class SP C EOL }// C ▫ EOL { EOL SPx4 SP M ( ) void SPx4 { EOL SPx4 } EOL } EOL // C EOF
Major Players Compilations, References and Symbols SyntaxTrees Compilation • Symbols • Diagnostics • Emit References
Major Players Semantics GetSemanticModel(tree) SemanticModel • Binding Information • Conversion Classification Compilation • Flow Analysis • Overload Resolution • Etc.
Major Players Workspace, Solutions, Projects and Documents Events (e.g. key presses) Apply Edit Edit Compilation SyntaxTree
Demo: Building a Quick Fix
Next Steps • Install the Roslyn CTP • Try out the APIs • Give us feedback! Dev Center: http://msdn.com/roslyn Forum: http://social.msdn.microsoft.com/forums/en-us/roslyn Email: dustinca@microsoft.com
Recommend
More recommend