Skip to content

NuGet audit policy evaluates like MSBuild: last unconditional assignment, project over props - #609

Merged
MelbourneDeveloper merged 2 commits into
mainfrom
fix/nuget-audit-last-wins
Nov 19, 2026
Merged

MelbourneDeveloper merged 2 commits into
mainfrom
fix/nuget-audit-last-wins

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Collaborator

TLDR

The NuGet audit settings (NuGetAudit, NuGetAuditLevel, CentralPackageTransitivePinningEnabled) are now read the way MSBuild evaluates them, so SharpLsp's vulnerability warnings match what dotnet restore reports.

Details

  • nuget/vulnerability/settings.rs:
    • Within one file, the last assignment wins. property returned the FIRST <NuGetAuditLevel>, so low followed by high reported low-level advisories that NuGet hides.
    • A conditioned value is skipped. This applies to a PropertyGroup, When or property with a Condition. The host cannot evaluate the condition, and assuming it true let a CI-only value override the real one.
    • The project's value wins over its props files. MSBuild imports Directory.Build.props and Directory.Packages.props before the project body. Before, the project was read first and the props overrode it, and a NuGetAudit=false in a props file could never be re-enabled by the project. The new evaluation_order reads the props first and the project last.
    • pins_transitives_centrally uses the same order and takes the last value.
    • policy_files keeps its order, because audited_files depends on it.
  • Found by the regression review of main against v0.33.0. The bug is in code added since the release, so no issue was filed.

How Do The Automated Tests Prove It Works?

  • audit_settings_follow_msbuild_last_assignment_and_project_precedence (new) uses real files in a temporary folder:
    1. low then high in one file gives High. Before the fix it failed with left: Some(Low) right: Some(High).
    2. A conditioned PropertyGroup, and separately a conditioned property, set to critical leave Low.
    3. A project with NuGetAudit=true and moderate overrides a props file with false and critical: auditing is on, at Moderate.
  • The existing audit_settings_are_read_from_the_props_chain still passes, along with all 94 nuget:: tests.
  • cargo clippy --all-targets is clean.

…ody so the project's value wins, the last unconditional assignment in a file wins, and a conditioned group or property never overrides it
@MelbourneDeveloper
MelbourneDeveloper enabled auto-merge (squash) November 19, 2026 17:26
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…sts flake) (#610)

## TLDR
A cancelled Test Explorer Debug gesture no longer leaves a leftover
"SharpLsp Test Debug" terminal beside the next debug run. This is the
cause of the repeated Linux `debug-tests` failures (`the cancelled
gesture leaves no ghost terminal beside the live debug run`, `2 !== 1`).

## Details
- `test-debug.ts`:
- **An already-cancelled gesture opens no terminal.** It runs nothing
worth showing.
- **A run's end disposes its terminal window.** Firing the pty's close
event alone only reaches a terminal VS Code has opened. On headless
Linux, VS Code may never open the pty of a short-lived run, so its
terminal stayed open.
- #607's open-time close stays, for a run that ends while its terminal
is opening.
- Live runs are unchanged: the terminal still opens, stays live while
the debugger attaches, and closes when the run ends.

## How Do The Automated Tests Prove It Works?
- `debug-test-stop-e2e.test.ts` *Stop ends its host and terminal, never
retries, and the next Debug starts clean* (F# and C#, VSTest and MTP)
asserts exactly one test-debug terminal after a pre-cancelled gesture.
- It failed on Linux CI on the first run of #606, #607 and #609 with `2
!== 1`.
- CI on this PR is the proof, because it always passed locally on macOS.
- Locally: the `debug-test-mtp`, `debug-test-stop`,
`debug-terminal-cancel` and `debug-test-debugging` suites pass, 35
tests.
- `test-explorer-outcomes.test.ts` still asserts that the Debug profile
opens exactly one live terminal for a real run.
@MelbourneDeveloper
MelbourneDeveloper merged commit 7c074c7 into main Nov 19, 2026
117 of 119 checks passed
@MelbourneDeveloper
MelbourneDeveloper deleted the fix/nuget-audit-last-wins branch November 19, 2026 19:40
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…ile watcher (Windows F# add-file hover) (#613)

## TLDR
Adding an F# file from the Solution Explorer now reloads the F# project
right away. Before, the reload waited for the file watcher to notice the
host's own `.fsproj` write; on Windows it sometimes didn't, and the new
file stayed unowned, with no hover or diagnostics.

## Details
- **Symptom:** the Windows `workspace` leg failed on #607, #609 and #612
in *Solution Explorer — Add F# Source File: project node: adds .fs
before the last Compile item and FCS owns it*. A hover on the new file
stayed `[]` for the test's 90-second polling limit. Each failure passed
on re-run.
- **Mechanism, from the uploaded host and sidecar logs of a passing
run:**
- `sharplsp/project/addCompileItem` edits the `.fsproj` through the C#
sidecar's MSBuild editing.
- Nothing then told the F# sidecar. Its reload ("F# loaded …fsproj,
which owns …NewLogic.fs") came about 1.8 s later, only because the
native watcher noticed the write.
- The Windows logs show watcher `EPERM` and "watcher shutdown" errors.
When the event is lost, the project is never reloaded.
- **Fix:**
- `pull_diagnostics/monitor.rs` gains `written(paths)`. It posts the
same `workspace/didChangeWatchedFiles` notification the native watcher
sends (type Changed, `sharplspRescan: false`) onto the foreground
dispatch queue.
- `project_edit.rs` calls it after any compile-item edit that modified
the project.
- A watcher event that also arrives is merged into the same reload by
the existing reload worker.
- `pull_diagnostics/state.rs` exposes the dispatch queue (`inbound()`).
Both files stay under 500 lines.

## How Do The Automated Tests Prove It Works?
-
`written_tests::a_project_file_the_host_writes_is_announced_as_a_watched_change`
(new) checks three cases:
  1. Before the dispatch queue exists, the call is a no-op.
2. Once the queue exists, one `didChangeWatchedFiles` arrives, carrying
exactly `[{ uri: <project>, type: 2 }]` with `sharplspRescan: false`.
  3. Writing no paths sends no notification.
- All 371 host unit tests pass (`--test-threads=1`), and clippy is
clean.
- On this PR, the Windows `workspace` leg runs the Add F# Source File
suite end to end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant