Most of the functionality provided by MSBuild project tools is implemented by an LSP-compliant language service.
Note: this documentation is a work-in-progress; if you have questions, feel free to create an issue.
The extension for VS Code extension communicates with this service using vscode-languageclient over STDIN/STDOUT.
The server is implemented in several layers.
- Protocol
- We use OmniSharp's LSP and JSON-RPC implementation.
- Everything is tied together by the LanguageServer.
- Server
- We use Autofac for dependency-injection and Serilog for logging (including a custom logger that forwards log entries to the LSP client, e.g. VS Code, for diplay).
- A Workspace handles all projects for a given base directory.
- Most of the state for each open MSBuild project is held by a ProjectDocument (see MasterProjectDocument and SubProjectDocument for further details).
- Document state is protected by an
AsyncReaderWriterLock
(it is the caller's responsibility to callXXXLock
/XXXLockAsync
as required).
- Document state is protected by an
- Handlers
- The DocumentSyncHandler handles synchronisation of document state with the client. We expect a
textDocument/didOpen
notification as the trigger to open and load a project. - The CompletionHandler calls multiple completion providers in parallel.
- If all completion providers return
null
, then theCompletionHandler
will return null to the caller (indicating no completions are available). - If only some completion providers return
null
, then theCompletionHandler
will ignore them and return non-null
completions. - If any provider indicates that their completion list is incomplete, then the composite completion list will be marked as incomplete.
- If all completion providers return
- The DocumentSyncHandler handles synchronisation of document state with the client. We expect a
- At the lowest level, we have
Microsoft.Language.Xml
andMicrosoft.Build.Construction
. - Above that we have
MSBuildProjectTools.SemanticModel.Xml
,MSBuildProjectTools.SemanticModel.MSBuild
, andMicrosoft.Build.Evaluation
.
The semantic models build on the syntax models to create a more high-level API for evaluating project contents.