Skip to content

Reduce enumerator boxing in ProjectElementContainer #11808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

Erarndt
Copy link
Contributor

@Erarndt Erarndt commented May 7, 2025

Fixes #

Context

Changes Made

Testing

Notes

@Copilot Copilot AI review requested due to automatic review settings May 7, 2025 23:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request aims to reduce boxing in the enumerators used within ProjectElementContainer by returning a custom struct Enumerator instead of the interface type.

  • Returns a custom Enumerator type for GetEnumerator() in ProjectElementContainer
  • Adjusts explicit interface implementations to work with the new Enumerator type
Comments suppressed due to low confidence (2)

src/Build/Construction/ProjectElementContainer.cs:861

  • Ensure that the custom Enumerator struct correctly implements IEnumerator to maintain compatibility with consumers of the IEnumerable interface.
public Enumerator GetEnumerator() => new Enumerator(_initial, _forwards);

src/Build/Construction/ProjectElementContainer.cs:953

  • Verify that returning the custom Enumerator directly meets all expected IEnumerator behaviors when used in explicit interface implementations.
public readonly Enumerator GetEnumerator() => _enumerator;

@SimaTian SimaTian merged commit 29add6d into dotnet:main May 12, 2025
10 checks passed
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.

3 participants