Refactor TestMethodInfo.cs into focused partial class files#7985
Merged
Conversation
5 tasks
Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/dd544e32-680d-4df7-b737-2aedee7ec043 Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
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
changed the title
[WIP] Refactor TestMethodInfo.cs into smaller files
Refactor TestMethodInfo.cs into focused partial class files
May 1, 2026
Contributor
There was a problem hiding this comment.
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
TestMethodInfointo focused partial files (argument resolution, execution, lifecycle/fixtures, exception handling, and test context). - Kept each partial file’s dependencies localized via per-file
usingdirectives. - 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>
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.
TestMethodInfo.cshad grown to 1113 lines, making it hard to navigate. Splits it into focusedpartial classfiles using idiomatic C#.File split
TestMethodInfo.csInvokeAsync,GetTestMethodAttribute,GetRetryAttributeTestMethodInfo.ArgumentResolution.csSetArguments,ResolveArgumentsTestMethodInfo.Execution.csExecuteInternalAsync,ExecuteInternalWithTimeoutAsync,GetTestTimeout,ThrowMultipleAttributesException,GetRealException,CreateTestClassInstanceTestMethodInfo.ExceptionHandling.csHandleMethodExceptionTestMethodInfo.Lifecycle.csTestMethodInfo.TestContext.csSetTestContextNotes
usingdirectives it actually needsUwnrap→UnwrapWarning
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/usr/bin/dotnet dotnet restore test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj --ignore-failed-sources(dns block)jd4vsblobprodcus366.vsblob.vsassets.io/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: