Skip to content

Refactor TestMethodInfo.cs into focused partial class files#7985

Merged
Evangelink merged 3 commits into
mainfrom
copilot/refactor-test-method-info
May 11, 2026
Merged

Refactor TestMethodInfo.cs into focused partial class files#7985
Evangelink merged 3 commits into
mainfrom
copilot/refactor-test-method-info

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

TestMethodInfo.cs had grown to 1113 lines, making it hard to navigate. Splits it into focused partial class files using idiomatic C#.

File split

File Lines Contents
TestMethodInfo.cs 202 Fields, constructor, properties, InvokeAsync, GetTestMethodAttribute, GetRetryAttribute
TestMethodInfo.ArgumentResolution.cs 85 SetArguments, ResolveArguments
TestMethodInfo.Execution.cs 368 ExecuteInternalAsync, ExecuteInternalWithTimeoutAsync, GetTestTimeout, ThrowMultipleAttributesException, GetRealException, CreateTestClassInstance
TestMethodInfo.ExceptionHandling.cs 92 HandleMethodException
TestMethodInfo.Lifecycle.cs 373 All TestInitialize/TestCleanup fixture invocation methods
TestMethodInfo.TestContext.cs 56 SetTestContext

Notes

  • Pure reorganization — no logic changes, no signature changes, no access modifier changes
  • Each partial file carries only the using directives it actually needs
  • Also fixes a pre-existing typo in a comment: UwnrapUnwrap

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet restore test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj --ignore-failed-sources (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet restore test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj --ignore-failed-sources (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested review from Copilot and removed request for Copilot May 1, 2026 22:13
Copilot AI linked an issue May 1, 2026 that may be closed by this pull request
5 tasks
Copilot AI requested review from Copilot and removed request for Copilot May 1, 2026 22:39
Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/dd544e32-680d-4df7-b737-2aedee7ec043

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 1, 2026 22:40
Copilot AI changed the title [WIP] Refactor TestMethodInfo.cs into smaller files Refactor TestMethodInfo.cs into focused partial class files May 1, 2026
Copilot AI requested a review from Evangelink May 1, 2026 22:40
@Evangelink Evangelink marked this pull request as ready for review May 11, 2026 09:00
Copilot AI review requested due to automatic review settings May 11, 2026 09:00
@Evangelink Evangelink merged commit 8d729bb into main May 11, 2026
11 checks passed
@Evangelink Evangelink deleted the copilot/refactor-test-method-info branch May 11, 2026 09:00
Copy link
Copy Markdown
Contributor

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 PR refactors TestMethodInfo in the MSTest adapter execution layer by splitting a large implementation into multiple focused partial class files, improving navigation and maintainability while keeping behavior and signatures unchanged.

Changes:

  • Split TestMethodInfo into focused partial files (argument resolution, execution, lifecycle/fixtures, exception handling, and test context).
  • Kept each partial file’s dependencies localized via per-file using directives.
  • Fixed a pre-existing typo in a comment (“Uwnrap” → “Unwrap”).
Show a summary per file
File Description
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.cs Converted TestMethodInfo to partial and retained the core surface (constructor/properties/InvokeAsync/attribute retrieval).
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.ArgumentResolution.cs Moved argument resolution (SetArguments/ResolveArguments) into a dedicated partial.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.Execution.cs Moved core execution/timeout logic (ExecuteInternal*, timeout helpers, instance creation) into a dedicated partial.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.Lifecycle.cs Moved fixture lifecycle execution (init/cleanup and global fixtures) into a dedicated partial.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.ExceptionHandling.cs Moved test-method exception processing into a dedicated partial.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.TestContext.cs Moved TestContext injection logic into a dedicated partial.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment on lines +84 to +86
// TODO remove dry violation with TestMethodRunner
bool setTestContextSucessful = false;
if (_executionContext is null)
/// Reference to instance of <see cref="TestResult"/>.
/// </param>
/// <returns>
/// True if there no exceptions during set context operation.
Evangelink added a commit that referenced this pull request May 12, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
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.

🏋️ File Diet: Refactor TestMethodInfo.cs (1113 lines) into focused modules

3 participants