Engineering

Fix All, Rule Enforcement & Leaner .NET LSP in SharpLsp 0.38

Minimalist ivory ceramic blocks aligned neatly beside emerald green precision markers on an off-white studio surface

Between SharpLsp 0.35.0 and 0.38.2, we shipped two big workflow features—Fix All with build enforcement and vulnerable NuGet remediation—and went after every megabyte of idle RAM and every millisecond of typing latency we could measure across both the F# (F# Compiler Service) and C# (Roslyn) sidecars.

Every number in this post was measured directly on SharpLsp's own test fixtures and release bundles, and every bug fix started with a failing end-to-end test against real .sln, .slnx, .csproj, and .fsproj files.

What changed by the numbers

Area Before After Release
F# completion latency (p50) 172 ms 32 ms (122 ms p95) v0.36.0
Unloaded .cs edit beside a file-based app (1.1 MB file, Roslyn 5.9.0) 53 ms / keystroke 0.002 ms / keystroke v0.38.1
F# sidecar settled memory (SharpLsp sidecar solution) 1,087 MB 798 MB (shared idle GC now on C# too) v0.36.0–v0.37.0
File-based C# app metadata references (209 apps) 38,016 MetadataReaders (2.8 GB) 1 shared reference per assembly path v0.38.0
Sidecars started in single-language or non-.NET workspace Both (~70 MB idle F# sidecar with no F#) Only languages present (0 if no .NET) v0.38.0
Default idle host logs ~95% 5 s health-check pings & request noise Lifecycle and user actions only (RUST_LOG=debug restores all) v0.36.0–v0.38.0

F# first: Fix All, .editorconfig severities, and build enforcement

Fixing one unused open or one explicit var at a time does not scale across a solution, and fixing it without turning the rule on lets the next commit drift right back. SharpLsp now offers one Fix all: <title>… code action (sharplsp.fixAll) on every fix-all-capable F# and C# diagnostic, instead of flooding the lightbulb with one entry per scope.

Picking it walks through a single flow: choose Containing member / type, Document, Project, or Solution scope, then choose Fix only or Fix and enforce. SharpLsp computes the edits under cancellable progress, sends one atomic workspace/applyEdit with needsConfirmation: true preview annotations on project- and solution-wide changes, re-pulls diagnostics, and reports Fixed N occurrences of <rule> in M files; K remain.

F# batch fixes and .editorconfig support

F# leads the pipeline. SharpLsp's F# analyzers (SLSPF0101–SLSPF0103) now evaluate dotnet_diagnostic.<id>.severity from .editorconfig—including root = true, glob sections, and none—using Roslyn's own .editorconfig evaluator so editor severity matches dotnet build.

Rule F# batch fix Enforced in build
SLSPF0102 Remove unused open dotnet_diagnostic.SLSPF0102.severity = error in [*.{fs,fsi,fsx}]
SLSPF0103 Simplify redundant qualified name dotnet_diagnostic.SLSPF0103.severity = error in [*.{fs,fsi,fsx}]
SLSPF0101 Remove unused declaration dotnet_diagnostic.SLSPF0101.severity = error; sharplsp.toml [diagnostics] dead_code = true
FS1182 Prefix unused value with _ Directory.Build.props OtherFlags += --warnon:1182, WarningsAsErrors += FS1182
FS0760 Add new for IDisposable Directory.Build.props WarningsAsErrors += FS0760

C# Fix All, opposing rules, and lossless config writes

Every Roslyn CodeFixProvider with a FixAllProvider works through the same command. Promoted code-style diagnostics (IDE0007, IDE0008, IDE0160, IDE0161) now advertise the quickfix kind so both single-site fixes and Fix All show up directly in hover Quick Fix and the lightbulb.

When you enforce a rule, SharpLsp automatically turns off its opposing rule so your build never contradicts itself:

Config edits never rewrite your files with string concatenation or regex. .editorconfig updates go through a lossless CST writer that keeps comments, key ordering, BOM, CRLF line endings, and unrelated settings intact, while Directory.Build.props merges list properties (WarningsAsErrors, OtherFlags, EnforceCodeStyleInBuild) through an XML DOM. If an existing config file cannot be read, enforcement refuses to touch it.

For automatic document-scoped fixes on save without modifying rules, wire up source.fixAll.sharplsp (deduplicated to one action per fix key):

{
  "editor.codeActionsOnSave": {
    "source.fixAll.sharplsp": "explicit"
  }
}

Read the full matrix in Fix All & Rule Enforcement and Refactoring and Code Actions.

Vulnerable NuGet package diagnostics and one-click upgrades

Security advisories should appear where you edit dependencies, not only in a CI log after you push. SharpLsp now surfaces NuGet vulnerability diagnostics (NU1901–NU1904) directly on .fsproj, .csproj, Directory.Packages.props, and shared .props files, evaluating MSBuild audit policy with MSBuild semantics (last unconditional assignment, project over props).

By default, critical (NU1904) and high (NU1903) advisories are red errors, moderate (NU1902) are warnings, and low (NU1901) are informational. You can customize the mapping in sharplsp.toml:

[nuget.vulnerabilities]
critical = "error"
high = "error"
moderate = "warning"
low = "information"
enforce_in_build = false

Running source.fixAll.sharplsp or sharplsp.nuget.fixAllVulnerable upgrades every vulnerable package in the project or solution to its lowest known-good version—preferring a parent package upgrade over pinning a transitive dependency directly—and optionally writes NU1903;NU1904 into WarningsAsErrors in Directory.Build.props. See NuGet Package Manager and Configuration.

Cutting .NET language server RAM: language-gated sidecars and idle compaction

Language servers stay running all day, often across three or four editor windows at once. Two changes in v0.37.0 and v0.38.0 directly cut steady-state memory usage.

No unused compiler processes

Measured on a live workstation with three VS Code windows open (including a non-F# repo), every window previously ran both the C# and F# sidecars—spending ~70 MB per window on idle F# processes where zero F# code existed. Four paths were leaking startups: eager workspace open, non-.NET file routing (.md, .rs, .json), cold cross-language fallback, and workspace diagnostic enumeration.

All four are now gated by language:

Quiet-time heap compaction for both sidecars

Loading and warming a solution leaves Gen 2 full of dead compiler structures, and an idle language server never allocates enough to trigger a full compacting collection on its own. Shared QuietCompaction now runs in both the F# and C# sidecars: every 30 seconds a sidecar checks its total allocated bytes, and once it goes quiet (under 16 MB allocated over 30 seconds after at least 256 MB since the last compaction), it runs one blocking compacting GC across all generations.

On SharpLsp's own sidecar solution, settled F# sidecar memory dropped from 1,087 MB to 798 MB, and v0.37.0 brought the same shared compaction to the C# Roslyn sidecar. See Architecture for how host supervision, Salsa memoization, and automatic crash recovery fit together.

.NET 10 file-based C# apps without the RAM spike or typing lag

.NET 10 file-based apps let you run standalone .cs files with #:package and #:sdk directives and no .csproj boilerplate. In v0.38.0 and v0.38.1, we fixed three major scaling and reliability issues for them:

Faster F# responsiveness and sharper day-to-day reliability

Several targeted fixes between v0.35 and v0.38.2 removed subtle freezes and noisy edge cases:

FAQ

Does SharpLsp support .NET 10 file-based C# apps in VS Code? Yes. SharpLsp 0.38.1 loads standalone .NET 10 file-based C# apps (.cs files with or without #:package and #:sdk directives) both when a project-less folder is open and when no folder is open, sharing reference assemblies across apps and parsing only leading trivia on unloaded file edits.

How do I enforce C# or F# code style rules in dotnet build from VS Code? Put the cursor on a fixable F# or C# diagnostic, open Quick Fix (Ctrl+. or Cmd+.), pick Fix all, choose Document, Project, or Solution scope, and select Fix and enforce. SharpLsp updates .editorconfig through a lossless CST writer, merges Directory.Build.props via an XML DOM, and turns off opposing rules automatically.

How does SharpLsp reduce C# and F# language server memory usage? SharpLsp gates sidecar startup by language so workspaces without F# never start the F# sidecar and workspaces without C# never start Roslyn, compacts both sidecars' heaps automatically during idle windows (cutting settled F# sidecar memory from 1,087 MB to 798 MB on SharpLsp's own solution), and shares metadata references across file-based C# apps.

Can SharpLsp fix vulnerable NuGet packages automatically? Yes. SharpLsp reports NU1901–NU1904 advisories directly in .fsproj, .csproj, Directory.Packages.props, and shared .props files using MSBuild audit semantics. Running source.fixAll.sharplsp or sharplsp.nuget.fixAllVulnerable upgrades vulnerable packages to their lowest known-good versions—preferring parent package updates over pins—and can enforce NU1903 and NU1904 in WarningsAsErrors.

Does SharpLsp work in VSCodium, Cursor, Windsurf, and Zed as an open-source C# Dev Kit alternative? Yes. SharpLsp is MIT licensed with no proprietary core or subscription. Install the extension from the VS Code Marketplace or Open VSX for VS Code, Cursor, Windsurf, and VSCodium, or run the standalone Rust host and sidecars in Zed and any LSP 3.17 editor.

Try SharpLsp 0.38.2

Install or update SharpLsp from the VS Code Marketplace, from Open VSX in Cursor, Windsurf, and VSCodium, or download standalone binaries and the Rider plugin from GitHub Releases. Read the Fix All & Rule Enforcement guide to get started, and if anything misbehaves on your solution, open an issue.