3. When, what, why
● .NET compiler platform
● Compiler as a service, csc.exe API
● Started 2008 (PDC, Los Angeles, CA)
● Codeplex -> Github
● Now in beta RC on nuget
● VS 2015
4. What, when, why cont.
● “Poor” csc architecture
o Different compiler forks for different tasks
o clear C# and VB separation
● C++ vs. .NET languages
Have you ever tried cat food?
8. Roslyn must
● Have great throughput
● Be error insensitive
● Have great sense of error scope
● Support REPL-like scenarios
● be VS-agnostic
9. Getting started
● VS 2015 CTP6
o watch out for side-by-side installation!
● VS SDK
● Install-Package Microsoft.CodeAnalysis -Pre
● Optional:
o .NET Compiler Platform SDK Templates
o Syntax Visualizer extension
12. Syntax cont.
● SyntaxTree - base abstraction, immutable
● Building ST
o from source
o using factory methods
● Navigating ST
o Members and casting
o OfType<>
o CSharpSyntaxWalker
16. Semantics
Yesterday a parrot will drive a bitter,
encrypted car.
● english words
● punctuation
● yet it doesn’t make sense…
● binding
17. Semantics cont.
● Get the real meaning of the abstract content
● Linking to a Symbol
● Needs context:
o user defined (your code!)
o external metadata (ex. mscorlib)
● Reflection on steroids (not at runtime)
o GetSymbolInfo(), GetEnclosingSymbol()
o Control flow analysis
o Can be speculative
18. Semantics is smart too!
“Property is inaccessible due to its protection level”
● GetSpeculativeSymbolInfo()
● ISymbolInfo.CandidateSymbols
20. Analyzers, code fixes
● VS project templates
● Derive from DiagnosticAnalyzer and apply
DiagnosticAnalyzer attribute
● Derive from CodeFixProvider and apply
ExportCodeFixProvider attribute
● Use “Add analyzer” in VS, nuget or csc.exe
23. What to expect after Roslyn ships?
● Better vanilla VS user experience
● Alternative IDEs Editors (OmniSharp)
● Even richer toolset (CI, metrics, diagnostics)
● Scripting (sciptcs)
● Exciting community and commercial projects
o code mutation
o ConfigR