Skip to content

Avoid LINQ Count method - #13545

Merged
Rob Holt (rjmholt) merged 7 commits into
PowerShell:masterfrom
xtqqczze:remove-linq-count
Nov 11, 2020
Merged

Avoid LINQ Count method#13545
Rob Holt (rjmholt) merged 7 commits into
PowerShell:masterfrom
xtqqczze:remove-linq-count

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Aug 30, 2020

Copy link
Copy Markdown
Contributor

PR Summary

  • Refactor code to avoid LINQ Count method.

    • Full refactor of DoesCurrentRunspaceIncludeCoreHelpCmdlet method
  • Refactor method parameters to a type that implements ICollection<T> (for the Count property)

    • IEnumerable<TypeMemberData> -> Dictionary<string, TypeMemberData>.ValueCollection
    • IEnumerable<PropertySetData> -> List<PropertySetData>

    I choose not to use a ICollection<T> type because the enumerator may result in a heap allocation.

PR Context

PR Checklist

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Sep 2, 2020
@ghost ghost added the Stale label Sep 17, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@ghost ghost closed this Sep 27, 2020
@iSazonov

Copy link
Copy Markdown
Collaborator

xtqqczze Is it still draft?

@ghost ghost removed the Stale label Oct 16, 2020
@xtqqczze xtqqczze changed the title WIP: Avoid LINQ Count method Avoid LINQ Count method Oct 22, 2020
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 22, 2020
@xtqqczze
xtqqczze marked this pull request as ready for review October 22, 2020 13:54
@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Oct 22, 2020
Comment thread src/System.Management.Automation/engine/TypeTable.cs Outdated
Comment thread src/System.Management.Automation/help/HelpCommands.cs Outdated
@ghost ghost added the Review - Needed The PR is being reviewed label Oct 30, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@xtqqczze

Copy link
Copy Markdown
Contributor Author

Rob Holt (@rjmholt) Can you review the changes since your last review?

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

xtqqczze you didn't make the changes I asked for last time, your new refactor incorrectly changes the behaviour of the code, and there's no testing added to ensure lack of regressions.

Given the quantity of open PRs you have on PowerShell right now, I would ask that you:

  • Refocus your contributions for quality rather than quantity
  • Add tests in your contributions to enable us as maintainers to make the case that your contributions won't cause regressions

Please understand that this is a large and relatively old codebase, and due to its use as a programming language and library platform that's reflection-intensive, it is a lot more sensitive to regressions than many other .NET projects, meaning the maintainers try to be conservative with code mutations that aren't strictly necessary.

I'm happy to accept your contributions, but those contributions should:

  • Be well-scoped, both in terms of the domain and the code
  • Make a strong case for the proposed change in the PR description, about improving some factor like performance, code complexity or testing coverage, and ideally make it in a quantitative way
  • Add tests or identify in the PR description where testing pre-exists to identify regressions

For this PR, please:

  • Change the GetEnumerator() usage to a foreach
  • Add a test for the code path you're refactoring

Comment thread src/System.Management.Automation/help/HelpCommands.cs Outdated
@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Review - Needed The PR is being reviewed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 30, 2020
Address @rjmholt review

Co-Authored-By: Robert Holt <rjmholt_msft@outlook.com>
@ghost ghost added the Review - Needed The PR is being reviewed label Nov 9, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@rjmholt
Rob Holt (rjmholt) merged commit 1386d00 into PowerShell:master Nov 11, 2020
@ghost ghost removed the Review - Needed The PR is being reviewed label Nov 11, 2020
@xtqqczze
xtqqczze deleted the remove-linq-count branch November 11, 2020 17:43
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.1 milestone Nov 11, 2020
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants