[code-simplifier] Simplify BuildEvaluators with Array.ConvertAll method group#9100
Draft
Evangelink wants to merge 1 commit into
Draft
[code-simplifier] Simplify BuildEvaluators with Array.ConvertAll method group#9100Evangelink wants to merge 1 commit into
Evangelink wants to merge 1 commit into
Conversation
…od group Replace the manual for-loop in BuildEvaluators with Array.ConvertAll and a method group reference to BuildEvaluator. Array.ConvertAll is available on netstandard2.0+, avoids a separate array allocation followed by index assignment, and expresses the intent (convert each element) more directly than an explicit loop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs a small refactor in the MSTest MemberConditionAttribute implementation (TestFramework) by simplifying BuildEvaluators() to use Array.ConvertAll, preserving the existing evaluator-building behavior while making the intent more direct.
Changes:
- Replaced a manual array allocation +
forloop inBuildEvaluators()withArray.ConvertAll(_conditionMemberNames, BuildEvaluator). - Preserved the same exception paths and per-member evaluator construction via the existing
BuildEvaluator(string)method.
Show a summary per file
| File | Description |
|---|---|
src/TestFramework/TestFramework/Attributes/TestMethod/MemberConditionAttribute.cs |
Simplifies BuildEvaluators() by converting member-name strings to evaluator delegates via Array.ConvertAll using a method group. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
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.
Code Simplification — 2026-06-13
This PR simplifies code introduced in #9071 (
MemberConditionAttribute) to improve clarity and conciseness while preserving all functionality.File Simplified
src/TestFramework/TestFramework/Attributes/TestMethod/MemberConditionAttribute.cs— Replace manual for-loop inBuildEvaluatorswithArray.ConvertAll+ method groupImprovement Made
Replaced manual array-fill loop with
Array.ConvertAllThe
BuildEvaluatorsmethod allocated a newFunc<bool>[], then filled it with a for-loop.Array.ConvertAllexpresses the same intent in one line using a method group:Array.ConvertAllis available onnetstandard2.0, uses a method group instead of a lambda (avoids a delegate wrapper allocation), and makes the transform intent immediately clear.Changes Based On
Recent changes from:
Testing
dotnet build src/TestFramework/TestFramework/TestFramework.csproj)Review Focus
Please verify:
Array.ConvertAlloutput is equivalent to the for-loopBuildEvaluatorcorrectly binds toFunc<bool> BuildEvaluator(string)Add this agentic workflows to your repo
To install this agentic workflow, run