Repository navigation
Simplify property provider lookup contracts - #15352
Conversation
There was a problem hiding this comment.
🟢 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
There was a problem hiding this comment.
✅ 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
def30b8 to
d0b940f
Compare
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.
d0b940f to
3953efd
Compare
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 relateddocumentation.
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-freePropertyDictionary<T>.Getoverload 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.