.NET Compiler Platform
Hi. I'm ns
Source explorers (like source.roslyn.io) or compilers
Diagnostics and refactorings
Style checking tools
Project-specific solution wide analysis and refactorings (when regexps doesn't helps)
Integration to editors (like omnisharp.net)
Live coding (like comealive.io)
Or smth crazy
API is focused on speed & thread safety, so some things are hard to code
it's more easier to concatenate strings and parse them than use syntax creating API
Each node contains both AST and whitespace-trash
Document also has a concept of SemanticModel
SemanticModel is IntelliSense API
Some methods of SemanticModel has speculative overloads
There a lot of nice classes providing abstractions over SyntaxTrees & SemanticModels
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
var workspace = MSBuildWorkspace.Create();
var solutionInfo = SolutionInfo.Create(
SolutionId.CreateNewId(),
VersionStamp.Create(),
slnPath);
var solution = await workspace
.OpenSolutionAsync(slnPath);
var documents = solution.Projects
.SelectMany(p => p.Documents);Microsoft.CodeAnalysis.CSharp
Microsoft.CodeAnalysis.Editing
Microsoft.CodeAnalysis.Editing
Microsoft.CodeAnalysis.FindSymbols
Microsoft.CodeAnalysis.Rename
Microsoft.CodeAnalysis.Formatting
Microsoft.CodeAnalysis.Simplification
Microsoft.CodeAnalysis.CodeActions
Microsoft.CodeAnalysis.Classification
Microsoft.CodeAnalysis.FindSymbols