From be780a1a6da4ea8fc900b606613e0f84f91ca04d Mon Sep 17 00:00:00 2001
From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com>
Date: Fri, 20 Nov 2026 12:25:45 +1100
Subject: [PATCH 1/4] The C# dead-code e2e starts from no configuration file
and waits for the diagnostic refresh each monorepo switch sends; ticks the
default-config and refresh rows
---
.../DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md | 10 +++---
.../tests/e2e_modules/configuration_live.rs | 33 ++++++++++++++++---
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
index a1f6441f..cef6a11d 100644
--- a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
+++ b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
@@ -23,10 +23,12 @@ Implements [ANALYZERS-MONOREPO-GATE] and [ANALYZERS-SOLUTION-SCOPE].
- [x] Hot-reload workspace/static-analyzer config through
`workspace/didChangeConfiguration` (shipped as `[analyzers] dead_code`/`monorepo`) — `configuration_live.rs` `reconfigure`;
e2e `analyzer_settings_from_the_editor_or_the_file_apply_to_the_next_pull` (editor and on-disk edits).
-- [ ] Bump `global_state_version` and send `workspace/diagnostic/refresh` when
- monorepo/static-analyzer settings change.
-- [ ] Full-stack test: default config produces no unused-public-code
- diagnostics.
+- [x] Bump `global_state_version` and send `workspace/diagnostic/refresh` when
+ monorepo/static-analyzer settings change — `configuration_live.rs` `reconfigure` →
+ `pull_diagnostics::state::configure` invalidates the store (its revision) and schedules the
+ refresh; `csharp_unused_public_types_are_dead_only_in_a_monorepo` waits for it after each switch.
+- [x] Full-stack test: default config produces no unused-public-code
+ diagnostics — same test, step 1: no `sharplsp.toml`, only the internal type is reported.
- [x] Full-stack test: `repository_kind = "standard"` suppresses the analyzer
even when `unused_public_symbols = true` (shipped as `[analyzers] dead_code`/`monorepo`) — same e2e, step 2: `dead_code` on,
no monorepo, the public F# function is not reported.
diff --git a/src/sharplsp/tests/e2e_modules/configuration_live.rs b/src/sharplsp/tests/e2e_modules/configuration_live.rs
index 1664c443..9a269307 100644
--- a/src/sharplsp/tests/e2e_modules/configuration_live.rs
+++ b/src/sharplsp/tests/e2e_modules/configuration_live.rs
@@ -60,23 +60,29 @@ fn csharp_unused_public_types_are_dead_only_in_a_monorepo() {
let (workspace, source) = dead_csharp_workspace();
let mut session = LiveSession::start(workspace.path(), &source, "SLSPC0101");
- // 1. A standard repository: the internal type is dead, a warning; the public one is API.
+ // 1. No configuration at all: the default is a standard repository, so the
+ // internal type is dead, a warning, and the public one is possible API.
session.await_dead(&[("Hidden", 2)]);
- // 2. The file declares a monorepo: the public type is dead too, and both are errors.
+ // 2. The file declares a monorepo: the public type is dead too, and both are
+ // errors — and the editor is told to pull again rather than left stale.
+ let refreshes = session.count("workspace/diagnostic/refresh");
write_configuration(
workspace.path(),
"[analyzers]\ndead_code = true\nmonorepo = true\n",
);
session.await_dead(&[("Hidden", 1), ("Orphan", 1)]);
+ session.await_refresh_after(refreshes, "a monorepo switch");
- // 3. Back to a standard repository: the public type is API again.
+ // 3. Back to a standard repository: the public type is API again, refreshed again.
+ let refreshes = session.count("workspace/diagnostic/refresh");
write_configuration(workspace.path(), "[analyzers]\ndead_code = true\n");
session.await_dead(&[("Hidden", 2)]);
+ session.await_refresh_after(refreshes, "leaving monorepo mode");
session.client.shutdown_and_exit();
}
-/// A C# project with dead types, and a `sharplsp.toml` turning the dead-code analyzer on.
+/// A C# project with dead types and no `sharplsp.toml`: the defaults apply.
fn dead_csharp_workspace() -> (tempfile::TempDir, PathBuf) {
let workspace = tempfile::tempdir().expect("real C# workspace");
let project = workspace.path().join("Dead");
@@ -89,7 +95,6 @@ fn dead_csharp_workspace() -> (tempfile::TempDir, PathBuf) {
)
.expect("write the project");
std::fs::write(project.join("Dead.cs"), DEAD_CS).expect("write the source");
- write_configuration(workspace.path(), "[analyzers]\ndead_code = true\n");
(workspace, project.join("Dead.cs"))
}
@@ -200,6 +205,24 @@ impl LiveSession {
self.restart_warning().expect("the restart warning arrived")
}
+ /// How many messages of `method` the server has sent so far.
+ fn count(&self, method: &str) -> usize {
+ self.traffic
+ .iter()
+ .filter(|message| message["method"] == method)
+ .count()
+ }
+
+ /// Wait, within [`NOTICED`], for a `workspace/diagnostic/refresh` beyond the
+ /// `seen` already counted: the server debounces it after a settings change.
+ fn await_refresh_after(&mut self, seen: usize, change: &str) {
+ self.wait_for(
+ NOTICED,
+ &format!("a diagnostic refresh after {change}"),
+ |session| session.count("workspace/diagnostic/refresh") > seen,
+ );
+ }
+
/// The last notification of `method` the server sent.
fn received(&self, method: &str) -> Option<&Value> {
self.traffic
From 38cb4f978e104c8c473b11e9b9b26ed2f3faaddb Mon Sep 17 00:00:00 2001
From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com>
Date: Fri, 20 Nov 2026 12:26:00 +1100
Subject: [PATCH 2/4] DIAGNOSTICS-STATIC-ANALYZERS-PLAN: tick the summary rows
whose phase rows the suites now prove
---
docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
index cef6a11d..ebdaafbb 100644
--- a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
+++ b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
@@ -162,7 +162,7 @@ Implements the cross-language part of [ANALYZERS-REFERENCE-MODEL].
- [ ] Add `WorkspaceConfig.repository_kind` defaulting to `"standard"`.
- [ ] Add `DiagnosticsConfig.static_analyzers`.
-- [ ] Hot-reload monorepo/static-analyzer settings.
+- [x] Hot-reload monorepo/static-analyzer settings. (see the matching phase row)
- [ ] Update example config through a TOML parser/serializer.
### Pipeline
@@ -175,17 +175,17 @@ Implements the cross-language part of [ANALYZERS-REFERENCE-MODEL].
### C#
-- [ ] Collect public C# symbols via Roslyn.
-- [ ] Count solution-wide Roslyn semantic references.
+- [x] Collect public C# symbols via Roslyn. (see the matching phase row)
+- [x] Count solution-wide Roslyn semantic references. (see the matching phase row)
- [ ] Emit `SLSPC0101`.
-- [ ] Add C# monorepo/non-monorepo full-stack tests.
+- [x] Add C# monorepo/non-monorepo full-stack tests. (see the matching phase row)
### F#
- [ ] Collect public F# symbols via FCS and `.fsi` public surface.
-- [ ] Count solution-wide FCS semantic references.
+- [x] Count solution-wide FCS semantic references. (see the matching phase row)
- [ ] Emit `SLSPF0101`.
-- [ ] Add F# monorepo/non-monorepo full-stack tests.
+- [x] Add F# monorepo/non-monorepo full-stack tests. (see the matching phase row)
### Cross-Language
From b0bd077501a36cf7774c2a1c11c138f3779db6c5 Mon Sep 17 00:00:00 2001
From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com>
Date: Fri, 20 Nov 2026 12:26:47 +1100
Subject: [PATCH 3/4] Full-stack test: in a monorepo solution, a public C# type
another project uses is live and only the unused one is dead
---
.../DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md | 5 +-
.../tests/e2e_modules/configuration_live.rs | 57 +++++++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
index ebdaafbb..1a8c16e9 100644
--- a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
+++ b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
@@ -89,8 +89,9 @@ Implements [ANALYZERS-UNUSED-PUBLIC], [ANALYZERS-REFERENCE-MODEL], and
severity Information, and tag `Unnecessary`.
- [x] Full-stack test: unused public C# type in a monorepo solution is reported —
`configuration_live.rs` `csharp_unused_public_types_are_dead_only_in_a_monorepo`, step 2.
-- [ ] Full-stack test: public C# type referenced by another project is not
- reported.
+- [x] Full-stack test: public C# type referenced by another project is not
+ reported — `configuration_live.rs` `a_public_csharp_type_another_project_uses_is_not_dead_in_a_monorepo`
+ (a two-project `.slnx`: only the unused `Orphan` is reported).
- [ ] Full-stack test: public C# member used by reflection/framework attribute is
suppressed.
- [x] Full-stack test: non-monorepo config reports no C# unused-public-code
diff --git a/src/sharplsp/tests/e2e_modules/configuration_live.rs b/src/sharplsp/tests/e2e_modules/configuration_live.rs
index 9a269307..6d38c5bb 100644
--- a/src/sharplsp/tests/e2e_modules/configuration_live.rs
+++ b/src/sharplsp/tests/e2e_modules/configuration_live.rs
@@ -82,6 +82,63 @@ fn csharp_unused_public_types_are_dead_only_in_a_monorepo() {
session.client.shutdown_and_exit();
}
+/// [ANALYZERS-REFERENCE-MODEL] solution-wide: in a monorepo, a public C# type
+/// another project of the solution uses is live, and only the one nobody uses
+/// is dead.
+#[test]
+fn a_public_csharp_type_another_project_uses_is_not_dead_in_a_monorepo() {
+ require_dotnet();
+ let workspace = tempfile::tempdir().expect("real C# solution");
+ let root = workspace.path();
+ let library = write_csharp_project(
+ root,
+ "Lib",
+ "Library",
+ "",
+ "namespace Lib;\n\npublic sealed class Used { }\n\npublic sealed class Orphan { }\n",
+ );
+ let _app = write_csharp_project(
+ root,
+ "App",
+ "Exe",
+ r#""#,
+ "internal static class Program\n{\n private static void Main() => _ = new Lib.Used();\n}\n",
+ );
+ std::fs::write(
+ root.join("Mono.slnx"),
+ "\n \n \n\n",
+ )
+ .expect("write the solution");
+ write_configuration(root, "[analyzers]\ndead_code = true\nmonorepo = true\n");
+ let mut session = LiveSession::start(root, &library, "SLSPC0101");
+
+ // `Used` is referenced from App, so only `Orphan` is dead — an error in a monorepo.
+ session.await_dead(&[("Orphan", 1)]);
+ session.client.shutdown_and_exit();
+}
+
+/// Write `/.csproj` with `properties` and `items`, and `/.cs`; returns the source.
+fn write_csharp_project(
+ root: &Path,
+ name: &str,
+ properties: &str,
+ items: &str,
+ source: &str,
+) -> PathBuf {
+ let project = root.join(name);
+ std::fs::create_dir_all(&project).expect("project directory");
+ std::fs::write(
+ project.join(format!("{name}.csproj")),
+ format!(
+ "\n net10.0{properties}\n {items}\n"
+ ),
+ )
+ .expect("write the project");
+ let file = project.join(format!("{name}.cs"));
+ std::fs::write(&file, source).expect("write the source");
+ file
+}
+
/// A C# project with dead types and no `sharplsp.toml`: the defaults apply.
fn dead_csharp_workspace() -> (tempfile::TempDir, PathBuf) {
let workspace = tempfile::tempdir().expect("real C# workspace");
From cceecac0a6d0f8e394936c3c978dc3331c77d828 Mon Sep 17 00:00:00 2001
From: Christian Findlay <16697547+MelbourneDeveloper@users.noreply.github.com>
Date: Fri, 20 Nov 2026 12:28:29 +1100
Subject: [PATCH 4/4] Full-stack test: a public F# value another project of the
solution uses is live in a monorepo; the dead-code e2e builds every project
through one write_project
---
.../DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md | 6 +-
.../tests/e2e_modules/configuration_live.rs | 105 +++++++++++-------
2 files changed, 67 insertions(+), 44 deletions(-)
diff --git a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
index 1a8c16e9..83659ddc 100644
--- a/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
+++ b/docs/plans/DIAGNOSTICS-STATIC-ANALYZERS-PLAN.md
@@ -121,8 +121,10 @@ Implements [ANALYZERS-UNUSED-PUBLIC], [ANALYZERS-REFERENCE-MODEL], and
severity Information, and tag `Unnecessary`.
- [x] Full-stack test: unused public F# function in a monorepo solution is
reported — `configuration_live.rs` step 3: `unusedPublic` reported as an error.
-- [ ] Full-stack test: public F# value referenced by another project is not
- reported.
+- [x] Full-stack test: public F# value referenced by another project is not
+ reported —
+ `configuration_live.rs` `a_public_fsharp_value_another_project_uses_is_not_dead_in_a_monorepo`
+ (a two-project `.slnx`: only the unused `orphan` is reported).
- [ ] Full-stack test: `.fsi` public-surface declarations receive diagnostics at
the signature declaration where possible.
- [x] Full-stack test: non-monorepo config reports no F# unused-public-code
diff --git a/src/sharplsp/tests/e2e_modules/configuration_live.rs b/src/sharplsp/tests/e2e_modules/configuration_live.rs
index 6d38c5bb..eed75830 100644
--- a/src/sharplsp/tests/e2e_modules/configuration_live.rs
+++ b/src/sharplsp/tests/e2e_modules/configuration_live.rs
@@ -90,18 +90,14 @@ fn a_public_csharp_type_another_project_uses_is_not_dead_in_a_monorepo() {
require_dotnet();
let workspace = tempfile::tempdir().expect("real C# solution");
let root = workspace.path();
- let library = write_csharp_project(
+ let library = write_project(
root,
"Lib",
- "Library",
- "",
+ "cs",
+ ["Library", ""],
"namespace Lib;\n\npublic sealed class Used { }\n\npublic sealed class Orphan { }\n",
);
- let _app = write_csharp_project(
- root,
- "App",
- "Exe",
- r#""#,
+ let _app = write_project(root, "App", "cs", ["Exe", r#""#],
"internal static class Program\n{\n private static void Main() => _ = new Lib.Used();\n}\n",
);
std::fs::write(
@@ -117,24 +113,62 @@ fn a_public_csharp_type_another_project_uses_is_not_dead_in_a_monorepo() {
session.client.shutdown_and_exit();
}
-/// Write `/.csproj` with `properties` and `items`, and `/.cs`; returns the source.
-fn write_csharp_project(
- root: &Path,
- name: &str,
- properties: &str,
- items: &str,
- source: &str,
-) -> PathBuf {
+/// The F# twin: a public F# value another project of the solution uses is
+/// live in a monorepo, and only the one nobody uses is dead.
+#[test]
+fn a_public_fsharp_value_another_project_uses_is_not_dead_in_a_monorepo() {
+ require_dotnet();
+ let workspace = tempfile::tempdir().expect("real F# solution");
+ let root = workspace.path();
+ let library = write_project(
+ root,
+ "Lib",
+ "fs",
+ ["Library", ""],
+ "module Lib.Values\n\nlet used () = 1\n\nlet orphan () = 2\n",
+ );
+ let _app = write_project(
+ root,
+ "App",
+ "fs",
+ [
+ "Exe",
+ r#""#,
+ ],
+ "module App.Program\n\n[]\nlet main _ = Lib.Values.used ()\n",
+ );
+ std::fs::write(
+ root.join("Mono.slnx"),
+ "\n \n \n\n",
+ )
+ .expect("write the solution");
+ write_configuration(root, "[analyzers]\ndead_code = true\nmonorepo = true\n");
+ let mut session = LiveSession::start(root, &library, "SLSPF0101");
+
+ // `used` is called from App, so only `orphan` is dead — an error in a monorepo.
+ session.await_dead(&[("orphan", 1)]);
+ session.client.shutdown_and_exit();
+}
+
+/// Write `/.proj` with `properties` and `items`, and its one
+/// source `.` (`cs` or `fs`; F# lists it in compile order); returns the source.
+fn write_project(root: &Path, name: &str, ext: &str, settings: [&str; 2], source: &str) -> PathBuf {
+ let [properties, items] = settings;
let project = root.join(name);
std::fs::create_dir_all(&project).expect("project directory");
+ let compile = if ext == "fs" {
+ format!("")
+ } else {
+ String::new()
+ };
std::fs::write(
- project.join(format!("{name}.csproj")),
+ project.join(format!("{name}.{ext}proj")),
format!(
- "\n net10.0{properties}\n {items}\n"
+ "\n net10.0{properties}\n {compile}\n {items}\n"
),
)
.expect("write the project");
- let file = project.join(format!("{name}.cs"));
+ let file = project.join(format!("{name}.{ext}"));
std::fs::write(&file, source).expect("write the source");
file
}
@@ -142,35 +176,22 @@ fn write_csharp_project(
/// A C# project with dead types and no `sharplsp.toml`: the defaults apply.
fn dead_csharp_workspace() -> (tempfile::TempDir, PathBuf) {
let workspace = tempfile::tempdir().expect("real C# workspace");
- let project = workspace.path().join("Dead");
- std::fs::create_dir_all(&project).expect("project directory");
- std::fs::write(
- project.join("Dead.csproj"),
- r#"
- net10.0Library
-"#,
- )
- .expect("write the project");
- std::fs::write(project.join("Dead.cs"), DEAD_CS).expect("write the source");
- (workspace, project.join("Dead.cs"))
+ let source = write_project(
+ workspace.path(),
+ "Dead",
+ "cs",
+ ["Library", ""],
+ DEAD_CS,
+ );
+ (workspace, source)
}
/// An F# project with dead code, and a `sharplsp.toml` turning the dead-code analyzer off.
fn dead_code_workspace() -> (tempfile::TempDir, PathBuf) {
let workspace = tempfile::tempdir().expect("real F# workspace");
- let project = workspace.path().join("Dead");
- std::fs::create_dir_all(&project).expect("project directory");
- std::fs::write(
- project.join("Dead.fsproj"),
- r#"
- net10.0
-
-"#,
- )
- .expect("write the project");
- std::fs::write(project.join("Dead.fs"), DEAD_FS).expect("write the source");
+ let source = write_project(workspace.path(), "Dead", "fs", ["", ""], DEAD_FS);
write_configuration(workspace.path(), "[analyzers]\ndead_code = false\n");
- (workspace, project.join("Dead.fs"))
+ (workspace, source)
}
/// Replace the workspace's `sharplsp.toml`.