Skip to content

Optimize data-driven test display names - #11019

Merged
Amaury Levé (Evangelink) merged 3 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/mtp-performance-analysis
Sep 4, 2026
Merged

Optimize data-driven test display names#11019
Amaury Levé (Evangelink) merged 3 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/mtp-performance-analysis

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Filtrace analysis identified repeated reflection, resource lookup locking, StringBuilder growth, and array enumeration as hotspots when generating data-driven test display names.

Cache immutable method metadata and localized formats, reuse bounded thread-local StringBuilder instances, and iterate object arrays directly while preserving culture-sensitive behavior.

BenchmarkDotNet MediumRun results:

  • Mixed arguments: 423.0 ns / 768 B to 254.3 ns / 328 B
  • Object-array argument: 451.6 ns / 792 B to 245.6 ns / 352 B

TestFramework unit tests pass on net48, net8.0, net8.0-windows, and net9.0.

Cache method metadata and localized formats, reuse bounded thread-local builders, and avoid array enumerator allocations in data-row display-name generation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dbdc5d12-fd8e-4443-96e3-55161b6ee867
Copilot AI balanced review requested due to automatic review settings September 3, 2026 17:05

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.

Copilot review overview

🟡 Changes recommended

Add coverage verifying localized-format cache refresh after changing CurrentUICulture on the same thread.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​TestFramework/​TestFramework/​Internal/​TestDataSourceUtilities.cs — Add a test that invokes display-name generation twice on the same thread, switches…
What changed in this PR

Optimizes data-driven test display-name generation while preserving culture-sensitive formatting.

Changes:

  • Caches method metadata and localized formats.
  • Reuses bounded thread-local StringBuilder instances.
  • Iterates object arrays directly.
File Description
src/​TestFramework/​TestFramework/​Internal/​TestDataSourceUtilities.cs Adds reflection, resource, builder, and array-processing optimizations.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/TestFramework/TestFramework/Internal/TestDataSourceUtilities.cs
Verify consecutive display-name generation on one thread refreshes the cached format when CurrentUICulture changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dbdc5d12-fd8e-4443-96e3-55161b6ee867
Copilot AI review requested due to automatic review settings September 3, 2026 17:17

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.

Copilot review overview

🟢 Approval recommended

The reviewed optimizations preserve expected behavior and have no unresolved issues.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity src/​TestFramework/​TestFramework/​Internal/​TestDataSourceUtilities.cs — Add a test that invokes display-name generation twice on the same thread, switches… View resolved comment

@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Sep 3, 2026
The replacement Azure pipeline passed all stages, but its result was not attached to the pull request's required check.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dbdc5d12-fd8e-4443-96e3-55161b6ee867
@Evangelink
Amaury Levé (Evangelink) merged commit 42c8100 into microsoft:main Sep 4, 2026
33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/mtp-performance-analysis branch September 4, 2026 10:09
@Evangelink
Amaury Levé (Evangelink) restored the dev/amauryleve/mtp-performance-analysis branch September 4, 2026 10:09
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/mtp-performance-analysis branch September 4, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants