Skip to content

Refactor TestClassInfo.cs: split 832-line class into focused partial files#8518

Merged
Evangelink merged 3 commits into
mainfrom
copilot/file-diet-refactor-testclassinfo
May 23, 2026
Merged

Refactor TestClassInfo.cs: split 832-line class into focused partial files#8518
Evangelink merged 3 commits into
mainfrom
copilot/file-diet-refactor-testclassinfo

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

TestClassInfo.cs had grown to 832 lines mixing initialization, cleanup, and reflection concerns in a single file. Splits it into four focused partial class files following the existing TestMethodInfo.*.cs convention.

File breakdown

File Lines Content
TestClassInfo.cs ~252 Core: constructor, properties, shared fields (_testClassExecuteSyncSemaphore, _classInitializeResult)
TestClassInfo.Initializer.cs ~323 RunClassInitializeAsync, GetResultOrRunClassInitializeAsync, TryGetClonedCachedClassInitializeResult, InvokeInitializeMethodAsync
TestClassInfo.Cleanup.cs ~249 ExecuteClassCleanupAsync, RunClassCleanupAsync, InvokeCleanupMethodAsync
TestClassInfo.TestContext.cs ~47 ResolveTestContext + TestContextPropertyName constant

Notes

  • Pure structural refactoring — no logic changes
  • Each file declares internal sealed partial class TestClassInfo with only the using directives it actually needs
  • _testClassExecuteSyncSemaphore stays in the core file since it's shared between initialization and cleanup
  • Each partial file carries its own #pragma warning disable CA1001 — required per partial declaration, not just once per type

Copilot AI requested review from Copilot and removed request for Copilot May 22, 2026 19:42
Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
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 requested review from Copilot and removed request for Copilot May 22, 2026 19:58
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
Copilot AI requested a review from Evangelink May 22, 2026 19:59
@Evangelink Evangelink marked this pull request as ready for review May 23, 2026 14:42
Copilot AI review requested due to automatic review settings May 23, 2026 14:42
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

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 TestClassInfo into core + lifecycle-focused partial files (initializer/cleanup/testcontext).
  • Reduced TestClassInfo.cs to 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>
@Evangelink Evangelink merged commit c84cfa0 into main May 23, 2026
23 of 25 checks passed
@Evangelink Evangelink deleted the copilot/file-diet-refactor-testclassinfo branch May 23, 2026 15:42
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 TestClassInfo.cs: Split 832-line class into focused modules

3 participants