Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[code-simplifier] Simplify BuildEvaluators with Array.ConvertAll method group#9100

Draft
Evangelink wants to merge 1 commit into
main from
simplify/member-condition-guard-clauses-7c58f8035778946e
Draft

[code-simplifier] Simplify BuildEvaluators with Array.ConvertAll method group #9100
Evangelink wants to merge 1 commit into
main from
simplify/member-condition-guard-clauses-7c58f8035778946e

Conversation

@Evangelink

@Evangelink Evangelink commented Jun 13, 2026

Copy link
Copy Markdown
Member

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 in BuildEvaluators with Array.ConvertAll + method group

Improvement Made

Replaced manual array-fill loop with Array.ConvertAll

The BuildEvaluators method allocated a new Func<bool>[], then filled it with a for-loop. Array.ConvertAll expresses the same intent in one line using a method group:

// Before (9 lines)
private Func<bool>[] BuildEvaluators()
{
 var evaluators = new Func<bool>[_conditionMemberNames.Length];
 for (int i = 0; i < _conditionMemberNames.Length; i++)
 {
 evaluators[i] = BuildEvaluator(_conditionMemberNames[i]);
 }
 return evaluators;
}
// After (2 lines)
private Func<bool>[] BuildEvaluators()
 => Array.ConvertAll(_conditionMemberNames, BuildEvaluator);

Array.ConvertAll is available on netstandard2.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

  • ✅ Build succeeds (dotnet build src/TestFramework/TestFramework/TestFramework.csproj)
  • ✅ No IDE0046 or other style-rule violations
  • ✅ No functional changes — behavior is identical (same array output, same exception paths)

Review Focus

Please verify:

  • Array.ConvertAll output is equivalent to the for-loop
  • Method group BuildEvaluator correctly binds to Func<bool> BuildEvaluator(string)
  • No unintended side effects

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Code Simplifier workflow. · 1.7K AIC · ⌖ 34 AIC · [◷]( · )

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on Jun 14, 2026, 2:05 PM UTC

...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>
Copilot AI review requested due to automatic review settings June 13, 2026 14:05
@Evangelink Evangelink added type/automation Created or maintained by an agentic workflow. type/tech-debt Code health, refactoring, simplification. labels Jun 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 + for loop in BuildEvaluators() with Array.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

type/automation Created or maintained by an agentic workflow. type/tech-debt Code health, refactoring, simplification.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /