Skip to content

Refactor VideoRecorderSessionHandler.cs into partial class files#9618

Open
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/split-videorecorder-handler
Open

Refactor VideoRecorderSessionHandler.cs into partial class files#9618
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/split-videorecorder-handler

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Overview

Splits the 656-line VideoRecorderSessionHandler.cs into focused partial-class files, matching the pattern already used by FfmpegVideoRecorder in the same directory. This is a pure file reorganization — partial classes compile to the same type, so there are no logic or API changes.

Fixes #9592

Changes

File Lines Responsibility
VideoRecorderSessionHandler.cs 172 Fields, constructor, interface properties, session lifecycle (OnTestSessionStarting/Finishing)
VideoRecorderSessionHandler.DataConsumer.cs 102 ConsumeAsync, ResolveTiming, IsTerminal, OutcomeText
VideoRecorderSessionHandler.VideoProduction.cs 179 ProduceVideosAsync, per-test/session production, chapter metadata, EscapeMetadata
VideoRecorderSessionHandler.SegmentPruning.cs 102 TryPruneOldSegments, WarnBufferDropOnce, OverlapsAnyFailedWindow
VideoRecorderSessionHandler.Helpers.cs 143 BuildFileName, Sanitize, PublishArtifactAsync, DeleteDirectoryQuietly, ApplyCommandLineOverrides, nested TestRecord

Verification

  • Builds cleanly across netstandard2.0, net8.0, and net9.0 with 0 warnings, 0 errors (including IDE0005 unused-using checks — usings were trimmed per file).
  • Each file is under 300 lines.
  • Type remains internal sealed partial — no public/internal API surface change.

Acceptance Criteria

  • Original file split into focused partial-class files (matching FfmpegVideoRecorder)
  • Each new file is under 300 lines
  • No breaking changes to internal or public API
  • File naming follows the existing TypeName.Concern.cs convention

Split the 656-line VideoRecorderSessionHandler.cs into focused partial
files matching the FfmpegVideoRecorder pattern:
- VideoRecorderSessionHandler.cs (wiring + lifecycle)
- VideoRecorderSessionHandler.DataConsumer.cs
- VideoRecorderSessionHandler.VideoProduction.cs
- VideoRecorderSessionHandler.SegmentPruning.cs
- VideoRecorderSessionHandler.Helpers.cs

No logic changes; each file is under 300 lines.

Fixes #9592

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 5, 2026 09:30
@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 5, 2026
@Evangelink Evangelink enabled auto-merge (squash) July 5, 2026 09:31
@Evangelink

Copy link
Copy Markdown
Member Author

/backport to rel/4.3

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Started backporting to rel/4.3: https://github.com/microsoft/testfx/actions/runs/28736336631

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.

Pull request overview

This PR is a pure file reorganization that splits the 656-line VideoRecorderSessionHandler.cs into five focused partial-class files, mirroring the existing FfmpegVideoRecorder split in the same directory. Because partial classes compile to the same type, there are no logic or API changes. It resolves issue #9592.

Changes:

  • Split VideoRecorderSessionHandler into per-concern partial files (data consumption, video production, segment pruning, helpers) while the primary file retains fields, constructor, interface properties, and session lifecycle.
  • Trimmed using directives per file and added the partial keyword; removed the now-unused Microsoft.Testing.Platform import from the primary file.
  • No behavioral, public, or internal API changes.
Show a summary per file
File Description
VideoRecorderSessionHandler.cs Reduced to fields, constructor, interface properties, and session lifecycle; declaration made partial; unused using removed.
VideoRecorderSessionHandler.DataConsumer.cs New partial holding ConsumeAsync, ResolveTiming, IsTerminal, OutcomeText.
VideoRecorderSessionHandler.VideoProduction.cs New partial holding video-production methods and EscapeMetadata.
VideoRecorderSessionHandler.SegmentPruning.cs New partial holding TryPruneOldSegments, WarnBufferDropOnce, OverlapsAnyFailedWindow.
VideoRecorderSessionHandler.Helpers.cs New partial holding file-name/artifact helpers, CLI overrides, and nested TestRecord.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions github-actions Bot 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.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

22/22 dimensions clean — no findings.

This is a well-executed pure file reorganization:

  • Partial class split matches the existing FfmpegVideoRecorder.{cs,ProcessManagement.cs,WindowCapture.cs} convention in the same directory.
  • No logic changes — code was relocated verbatim; the only functional edit is adding the partial keyword and trimming usings per file (e.g., using Microsoft.Testing.Platform; moved to Helpers.cs where RoslynString is used).
  • Thread safety preserved_stateGate locking pattern spans partial files correctly since they compile to the same type.
  • No API surface change — type remains internal sealed partial.
  • Cross-TFM #if NET9_0_OR_GREATER for Lock stays in the main file with the field declarations.
  • File sizes all under 180 lines — well within the stated 300-line cap.
  • Build glob picks up the new .cs files automatically — no .csproj edits needed.

Clean refactoring, no issues.

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.

[file-diet] Refactor VideoRecorderSessionHandler.cs into partial class files

3 participants