Lookup.ExplicitModifications switch to concrete dictionary type for enumerator.#11985
Merged
YuliiaKovalova merged 4 commits intodotnet:mainfrom Oct 13, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the ExplicitModifications property in Lookup.cs to return a concrete Dictionary instead of an IEnumerable, optimizing performance by leveraging a struct enumerator to prevent boxing.
- Changed the ExplicitModifications property return type from IEnumerable<KeyValuePair<string, MetadataModification>> to Dictionary<string, MetadataModification>.
- Aims to reduce allocations during enumeration by avoiding boxing.
Comments suppressed due to low confidence (1)
src/Build/BackEnd/Components/RequestBuilder/Lookup.cs:1183
- The XML documentation summary for ExplicitModifications still mentions 'an enumeration of the explicit metadata modifications'. Consider updating the summary to reflect that a Dictionary is returned, which may improve clarity for other developers.
public Dictionary<string, MetadataModification> ExplicitModifications
YuliiaKovalova
approved these changes
Oct 13, 2025
This was referenced Oct 15, 2025
This was referenced Feb 23, 2026
Merged
Open
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.
Context
When building a smaller solution we can see the boxing to IEnumerator pop up for 0.1% allocations

Changes Made
Switched from returning IEnumerator to the underlying dictionary type to allow usage of the struct enumerator to prevent boxing.