Fix All, Rule Enforcement & Leaner .NET LSP in SharpLsp 0.38
SharpLsp Team
Nimblesite Engineering
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:
- Enforcing
IDE0007(usevar) setsIDE0008(use explicit type) tonone, and vice versa. - Enforcing
IDE0161(file-scoped namespaces) setsIDE0160(block-scoped) tonone, and vice versa. - Enforcing
IDE0003(removethis.) setsIDE0009(requirethis.) tonone.
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:
- No F# code means no F# sidecar; no C# code means no C# sidecar. A workspace with no
.NETcode starts neither. - Cross-folder solutions still load completely. When you pick or configure a
.slnor.slnx, SharpLsp reads its listed project extensions first so a solution in a C#-only folder that references../lib/Lib.fsprojstarts both compilers immediately. - Lazy start stays instant. Opening an
.fsxor.csfile in a workspace that did not have that language starts its sidecar on demand. Switching solutions drops the previous solution's diagnostics cleanly.
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:
- Shared reference assemblies. Previously each settled file-based app built its own private copy of the reference pack—our profiler measured 38,016
MetadataReaders and 2.8 GB of memory across 209 apps.SharedMetadataReferencesnow reuses onePortableExecutableReferenceper assembly path (invalidated by last-write time). - Reliable loading with or without a folder open. Opening a folder of loose
.csfiles or opening multiple single files with no folder open now loads every file-based app cleanly, preserves apps after a failed pick, and keeps file-based apps separate when a project-owned.csfile is opened beside them. - Leading-trivia directive checks (53 ms → 0.002 ms). Editing an unloaded
.csfile beside a picked file-based app used to re-parse the entire file on every keystroke just to look for a shebang or#:directive. Because directives only count before the first token, SharpLsp now checksSyntaxFactory.ParseLeadingTriviainstead—still using the real Roslyn syntax tree, dropping per-keystroke time on a 1.1 MB source from 53 ms to 0.002 ms.
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:
- F# completion p50 from 172 ms to 32 ms. Filtering unopened F# entities by the typed prefix before handing them to FCS brought median completion latency down to 32 ms (122 ms at p95).
- No more F# edit hangs on unchecked projects (v0.38.2). Editing an F# file in a project FCS had not checked yet previously built that project's incremental builder synchronously on the request pump (stalling up to 120 seconds on Windows CI). Edits now invalidate only builds the checker already holds, while later checks read the live editor buffer.
- Cross-language F# ↔ C# accuracy. Cross-language reference lookups now resolve C# constructor calls and field-type uses from F#, and cross-language dead-code checks no longer flag symbols used from the other language.
- Quieter logs by default. Five-second health-check pings (~95% of idle logs), per-document open/change lines, and profiler process polling moved to
debug/warn(info,salsa=warn,lsp_profiler::process=warn). SetRUST_LOG=debug(orsharplsp.logging.levelin VS Code) whenever you want the full trace. - Cleaner everyday workflows. Moving a source folder out of the workspace retires its stale diagnostics;
sharplsp.openSolutionopens a file picker when run from the Command Palette; the$sharplsp-msCompilebuild matcher ownssharplsp-buildinstead of leaving stalecpp(IDE0007)squiggles; and watcher reloads no longer retire fresh code actions before you apply them.
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.