Code completions in VS Code

C# completions powered by Roslyn in the alpha VS Code extension.

Code Completions

SharpLsp provides C# code completions through Roslyn. Completions are routed through the C# sidecar, keeping the Rust host free for fast syntax operations.

Performance Targets

Metric Target
p50 latency <100ms
p95 latency <200ms
Cached (unchanged document) <1ms

C# Completions (Roslyn)

The C# sidecar uses Roslyn's CompletionService to generate completions, so the feature is built on the same compiler platform used by the wider .NET tooling ecosystem.

What Gets Completed

  • Types and namespaces β€” classes, interfaces, structs, enums, delegates
  • Members β€” methods, properties, fields, events, indexers
  • Keywords β€” all C# keywords with correct contextual filtering
  • Snippets β€” common code patterns (for, foreach, if, try, etc.)
  • Import completions β€” unimported types from referenced assemblies
  • Override completions β€” abstract/virtual members to implement
  • XML doc completions β€” /// trigger completes <summary>, <param>, etc.
  • var inference β€” shows the inferred type in the completion tooltip

Trigger Characters

Completions trigger automatically after:

Character Context
. Member access
( Parameter hints
< Generic type arguments
[ Array indexer, attribute
{ Object initializer
Keyword completions
@ Verbatim identifiers

Import Completions

Types that are not yet using-imported appear in the completion list with a dimmed indicator. Selecting one automatically adds the correct using directive at the top of the file.

// Before: no using for JsonSerializer
var json = JsonSerializer.Serialize(obj);
//         ↑ completion adds: using System.Text.Json;

LSP Protocol

SharpLsp advertises:

{
  "completionProvider": {
    "resolveProvider": true,
    "triggerCharacters": [".", "(", "<", "[", "{", " ", "@"]
  }
}

completionItem/resolve is supported β€” full documentation and additional edits (e.g., import insertion) are added on resolve, keeping the initial list fast.