Refactor TestClassInfo.cs: split 832-line class into focused partial files#8518
Merged
Conversation
7 tasks
Split the 832-line TestClassInfo.cs into 4 focused partial class files: - TestClassInfo.cs: Core class with properties/constructor/fields (~252 lines) - TestClassInfo.Initializer.cs: Initialization lifecycle methods (~323 lines) - TestClassInfo.Cleanup.cs: Cleanup lifecycle methods (~249 lines) - TestClassInfo.TestContext.cs: ResolveTestContext utility (~47 lines) Follows the existing TestMethodInfo.*.cs partial class convention. Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor TestClassInfo.cs into focused modules
Refactor TestClassInfo.cs: split 832-line class into focused partial files
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors TestClassInfo in the MSTest adapter platform services layer by splitting a large class into multiple focused partial files, following the existing TestMethodInfo.*.cs organization pattern.
Changes:
- Split
TestClassInfointo core + lifecycle-focused partial files (initializer/cleanup/testcontext). - Reduced
TestClassInfo.csto constructor/properties/shared fields, moving lifecycle logic to dedicated files. - Introduced new compilation units for initialization/cleanup/TestContext resolution logic.
Show a summary per file
| File | Description |
|---|---|
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestClassInfo.cs | Converted to partial and kept core fields/properties/constructor after extracting lifecycle helpers. |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestClassInfo.Initializer.cs | Added partial containing class-initialize execution, caching, and invocation helpers. |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestClassInfo.Cleanup.cs | Added partial containing class-cleanup execution and invocation helpers (includes CA1001 suppression). |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestClassInfo.TestContext.cs | Added partial containing TestContext property resolution helper and constant. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 3
For consistency with the existing TestClassInfo.cs and TestClassInfo.Cleanup.cs partial declarations, suppress CA1001 around the partial declarations in TestClassInfo.Initializer.cs and TestClassInfo.TestContext.cs. Addresses review feedback on PR #8518. Co-authored-by: Copilot <223556219+Copilot@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.
TestClassInfo.cshad grown to 832 lines mixing initialization, cleanup, and reflection concerns in a single file. Splits it into four focused partial class files following the existingTestMethodInfo.*.csconvention.File breakdown
TestClassInfo.cs_testClassExecuteSyncSemaphore,_classInitializeResult)TestClassInfo.Initializer.csRunClassInitializeAsync,GetResultOrRunClassInitializeAsync,TryGetClonedCachedClassInitializeResult,InvokeInitializeMethodAsyncTestClassInfo.Cleanup.csExecuteClassCleanupAsync,RunClassCleanupAsync,InvokeCleanupMethodAsyncTestClassInfo.TestContext.csResolveTestContext+TestContextPropertyNameconstantNotes
internal sealed partial class TestClassInfowith only theusingdirectives it actually needs_testClassExecuteSyncSemaphorestays in the core file since it's shared between initialization and cleanup#pragma warning disable CA1001— required per partial declaration, not just once per type