Skip to content

Simplify property provider lookup contracts - #15352

Merged
JanProvaznik merged 3 commits into
mainfrom
dustinca/property-provider-covariance
Oct 23, 2026
Merged

JanProvaznik merged 3 commits into
mainfrom
dustinca/property-provider-covariance

Conversation

@DustinCampbell

Copy link
Copy Markdown
Member

Context

Property lookup APIs used a mixture of inclusive end indexes and lengths to identify ranges within
strings. These inconsistent contracts were easy to misuse and caused immutable global property lookups
to pass a length to an API that interpreted it as an end index.

Changes Made

Make IPropertyProvider<T> covariant, annotate property lookups as nullable, and update the related
documentation.

Standardize property lookup, expansion, and read-tracking APIs on start index and length ranges,
matching comparer and retrievable-set APIs and avoiding repeated conversions.

Remove the unused IConstrainableDictionary<T> abstraction while retaining the allocation-free
PropertyDictionary<T>.Get overload used by immutable global property conversion.

Compatibility

These are internal API changes with no changes to public APIs, diagnostics, defaults, or protocols.
Existing property expansion behavior is preserved except for correcting lookup ranges that were
previously interpreted using the wrong convention.

Testing

A full repository build and the complete unit test suite passed.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The internal range changes are consistent across the reviewed code, with no unresolved findings; the reported build and test results were not independently verified.

No open issues 🎉

What changed in this PR

This PR simplifies MSBuild’s internal property lookup contracts by consistently using start index and length, correcting the range mismatch affecting immutable global property lookups.

Changes:

  • Makes IPropertyProvider<T> covariant and explicitly documents nullable lookup results.
  • Aligns property providers, expansion, and read tracking on start-and-length ranges.
  • Removes the unused dictionary interface and updates tests for both dictionary lookup overloads.
File Description
src/​Build/​Microsoft.Build.csproj Removes the deleted interface from compilation.
src/​Build/​Instance/​ProjectInstance.cs Forwards lookups using start and length.
src/​Build/​Instance/​ImmutableProjectCollections/​ImmutableGlobalPropertiesCollectionConverter.cs Adds inherited documentation to the ranged lookup.
src/​Build/​Evaluation/​PropertyTrackingEvaluatorDataWrapper.cs Aligns lookup and tracking ranges; annotates nullable results.
src/​Build/​Evaluation/​LazyItemEvaluator.EvaluatorData.cs Updates ranged lookup forwarding.
src/​Build/​Evaluation/​IPropertyProvider.cs Defines covariance, nullable results, and the consistent range contract.
src/​Build/​Evaluation/​Expander.PropertyExpander.cs Removes the conversion to an inclusive end index.
src/​Build/​Definition/​Project.cs Updates property lookup forwarding and documentation.
src/​Build/​Collections/​PropertyDictionary.cs Uses lengths directly and retains the allocation-free Get overload.
src/​Build/​Collections/​IConstrainableDictionary.cs Deletes the unused abstraction.
src/​Build/​BackEnd/​Components/​RequestBuilder/​Lookup.cs Aligns scoped and whole-name lookups with the new contract.
src/​Build.UnitTests/​Collections/​MSBuildNameIgnoreCaseComparer_Tests.cs Updates range arguments and checks both lookup overloads.

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 24/24 dimensions clean — no findings.

Scope note: this review evaluated Backwards Compatibility Vigilance (dimension 1) only, as requested. The modified contracts and removed interface are internal; range API callers/implementations were consistently migrated from inclusive end-index to start+length; and the only observable behavior change fixes immutable global-property lookup by using the full property-name length. No public API, default, warning, CLI alias, protocol, or output-format change was found, and no concrete previously valid customer scenario was identified as broken.

Generated by Expert Code Review (on open) for #15352 · copilot · gpt56 · 930.1 AIC · ⌖ 0.525 AIC · ⊞ 25.3K

Base automatically changed from dustinca/property-expansion-optimizations to main October 23, 2026 09:05
Annotate property lookups as nullable and refresh the interface
documentation. Propagate the nullable contract through the property
tracking evaluator wrapper.
Replace inclusive end indexes with lengths throughout property lookup,
expansion, and read tracking. Align the provider and dictionary
contracts with comparer and retrievable-set APIs, which already use a
start index and length.

The mixed conventions were easy to misuse and caused immutable global
property lookups to pass a length to an API that interpreted it as an
end index. Threading the length through the expander removes repeated
conversions and reduces off-by-one risk.
The interface had no consumers and only restated a concrete
PropertyDictionary operation. Keep the allocation-free Get overload on
PropertyDictionary, where it is symmetric with Set and used by
immutable global property conversion.

Removing the interface and its project entry eliminates an unnecessary
abstraction without changing lookup behavior.
@JanProvaznik
JanProvaznik force-pushed the dustinca/property-provider-covariance branch from d0b940f to 3953efd Compare October 23, 2026 09:05
@JanProvaznik
JanProvaznik merged commit ad616f4 into main Oct 23, 2026
14 checks passed
@JanProvaznik
JanProvaznik deleted the dustinca/property-provider-covariance branch October 23, 2026 11:48
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.

5 participants