Repository navigation
msbuild: MSBuildAllProjects reads inexact after the property pass (#1131) - #1142
Merged
Merged
Conversation
) Between its property pass and its item pass, MSBuild's evaluator prepends the most recently written of the project and its imports to `MSBuildAllProjects` (`Evaluator.SetAllProjectsProperty`, 18.9). It chooses that file by file times the walk does not read. The walk kept the documents' last write, so an item reading the name, and the final table's value, were committed and wrong. At the start of the item pass, `MSBuildAllProjects` goes stale (`PropertyMap::mark_stale`) under a cause naming that write, so every later read is inexact. A read during the property pass, before the write, stays exact. An unbound name already reads inexact (the `msbuild` prefix). Test first: `all_projects_property_diff` writes nothing, an empty value, a value, or the SDK's append, in two spellings. It reads the name from a property during the property pass, from a `Compile` item, and from the final table, each against design-time MSBuild. The two later reads failed in 8 cases before the fix. The property pass's read must stay committed wherever the write reads nothing. Decline cost: the msbuild corpus differential and the SDK chain attribution do not move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 1 of review: a stale value reached `Compile` items and the final table, but not the dependency items. `ProjectReference` and `PackageReference` gates leave staleness out, so a reference gated on `'$(MSBuildAllProjects)' == 'off'` was committed where MSBuild excludes it. Staleness also withdrew the whole `Compile` list for a gate another operand decides. MSBuild's write between the passes is now modelled as a write the walk refuses to compute (`State::write_all_projects`). The binding goes and the name is marked refused, as for a document's write that cannot be evaluated, so every later read is an undefined read that is not exact. Each consumer already judges that (a reference's spec and gate, a `Compile` spec, the final table), deciding without the name where another operand settles the decision. Tests: - `all_projects_property_diff` adds a `ProjectReference` and a `PackageReference` gated on the name, and a write of the value they test. It compares `Compile` in order. It checks the final value and the property pass's read with every exact outcome (`Value`, and `Unset` against MSBuild's undefined), declining only `UnsetInexact` and `Untrusted`. - `a_gate_another_operand_decides_keeps_compile_certain`: a `Compile` item under `false And '$(MSBuildAllProjects)' == 'off'` keeps the list certain. - A `boundaries.tsv` row for the grid. Without the write, the grid fails with 16 wrong commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 2 of review: the grid's reference gates all compare the name with `off`, which the rewritten value never equals, so a walk that took the unbound name for an exact empty one would still pass them. - `all_projects_property_diff` adds a `ProjectReference` and a `PackageReference` behind `'$(MSBuildAllProjects)' != ''`, which MSBuild opens in every row. The reference list's contract tolerates a missing edge behind a gate the walk cannot decide, so a certain list is held to no phantom edge. And the walk's own read of the list, the one an `@(ProjectReference)` in it takes (`ItemRead::exact`), must hold MSBuild's references whenever it is exact. Without the write, that read is exact and empty where MSBuild holds `Q.fsproj`. Mutation-checking the write showed its refused mark and its drop from the project-written map change nothing: an unbound `msbuild` name already reads inexact (`is_toolset_initial_property_name`), and the written map publishes only bound names. `State::write_all_projects` now just unbinds the name, and asserts the prefix judgement it rests on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its own Round 3 of review: both reference gates sat in one project, so a decline of the `== 'off'` gate made the whole list uncertain and hid a wrong decision of the `!= ''` one. The package list had the same blind spot. `all_projects_property_diff` now writes one `ProjectReference` and one `PackageReference` per project, under one of `GATES`. A mutation that takes the `!= ''` gate's unbound read for an exact one, while the `== 'off'` gate still declines, passes the old grid and fails this one with 16 wrong commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim
Every read of
MSBuildAllProjectsafter the property pass is exact against MSBuild or declined. Between its property pass and its item pass, MSBuild's evaluator prepends the most recently written of the project and its imports toMSBuildAllProjects(Evaluator.SetAllProjectsProperty, MSBuild 18.9). It picks that file by file times the walk does not read. Before this PR, the walk kept the documents' last write, and committed what rested on it: the final value, aCompileitem's spec, and the gates ofProjectReferences andPackageReferences.Domain
MSBuildAllProjects, in any spelling, from the item pass on: item specs, item and item-group gates, reference gates, and the final property table.Change
At the start of the item pass,
State::write_all_projectsunbinds the name. A read of an unbound name then gets the judgement every undefined read gets (undefined_read_is_exact). Anmsbuildname is one MSBuild may define where no document does (is_toolset_initial_property_name), so the read is not exact. Each consumer already declines such a read, and decides without it where another operand settles the decision. The function asserts the prefix judgement it rests on.Tests
all_projects_property_diffruns against design-time MSBuild:off(the value the gates test), and the SDK's append.Compileitem's spec, compared in order;ProjectReferenceand aPackageReferencebehind the project's gate: one the rewritten value closes (== 'off') or one it opens (!= '').ItemRead::exact, the read that an@(ProjectReference)in the walk takes) must hold MSBuild's references whenever it is exact.a_gate_another_operand_decides_keeps_compile_certain: aCompileitem underfalse And '$(MSBuildAllProjects)' == 'off'keeps the list certain.Mutation checks:
@(ProjectReference)read of[]where MSBuild holds a reference.!= '') fails the grid with 16 wrong commits. The same mutation passes the round 2 grid, which held both gates in one project.The fix is just the unbind. Two earlier versions of it did more, and are gone:
Decline cost
None measured. Each of these is unchanged:
fsproj_msbuild_corpus_diff);restore_cone_reads_*.txt);The real-SDK must-commit lists in
fsproj_global_perturbation_diffandfsproj_sdk_import_graph_generative_diffstill pass.Review and gate
Codex ran four rounds against origin/main
193c28caa. Each finding is fixed with a test that fails without its fix.Round 1:
ProjectReferenceand aPackageReferencegated on== 'off'were committed where MSBuild excludes them.Compilelist for a gate another operand decides.Unsetwas not graded as an exact claim.Compilewas compared as a set.boundaries.tsvrow for the grid.All five are fixed in
ab1affabdby modelling MSBuild's write as one the walk does not compute.Round 2:
off, which the rewritten value never equals, so a walk that took the unbound name for an exact empty one would pass. Fixed in0e65b17bdwith a!= ''gate and theItemRead::exactcheck. Mutation-checking that fix is what showed the refused mark was redundant.Round 3:
94b21a940.Round 4: no findings.
The full gate ran locally on
0e65b17bd, because the build box is unreachable: fmt, clippy, doc, the msbuild corpus and SDK chain sweeps,cargo test --workspace, and every step oftools/ci/project-corpus-gate.sh. All are green, and the load average was 60–80. The #1132 sema wedge did not occur.94b21a940changes onlyall_projects_property_diff.rs. On it, fmt, clippy (borzoi-msbuild, all targets) and that test were rerun, all green. No other step reads that file.Closes #1131
🤖 Generated with Claude Code