[file-diet] Refactor oversized NamedPipeServer.cs (565 lines) into focused files
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- testing-qa
Direzione di ricerca
Start with src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs and read the static pipe-naming helpers (GetPipeName, ResolvePipeDirectory, EnsurePathLengthWithinLimit) before the connection loop. Check every project that compiles this file via shared sources, and confirm the class can become partial without breaking them. Done means the split files each stay under 300 lines, behavior is unchanged, and the relevant MTP tests and builds pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Overview
The file src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs has grown to 565 lines, making it harder to navigate and maintain. This task involves refactoring it into smaller, more focused files.
Current State
- File:
src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs - Size: 565 lines
- Language: C#
Structural Analysis
The file defines a single internal sealed class NamedPipeServer : NamedPipeConnectionBase, IServer, mixing several distinct responsibilities:
- Construction / stream creation: multiple public constructor overloads,
RequiresExplicitSecurity, andCreateServerStream, which build the underlyingNamedPipeServerStream, optionally hardening it with security identities on Windows. - Connection lifecycle:
WaitConnectionAsync,InternalLoopAsync(the read/dispatch/write request loop),WaitForDisconnectAsync, and the smallTryLogDebugAsynclogging helper used during graceful shutdown. - Pipe path resolution (static, OS-specific):
GetPipeName,ResolvePipeDirectory(both overloads),EnsureDirectoryIsWritable, andEnsurePathLengthWithinLimit— this cluster deals with computing/validating the Unix domain socket or Windows pipe name, including theTESTINGPLATFORM_PIPE_DIRECTORYoverride and thesun_pathbyte-length limit. - Disposal:
Dispose()andDisposeAsync()at the end of the file (not fully inspected in this bounded sample, but visibly part of the instance lifecycle group).
Refactoring Strategy
Proposed File Splits
Based on the bounded structural sample, investigate these proposed splits. Confirm their safety during implementation preflight before moving code. Because the class is sealed and not currently partial, each new file would need NamedPipeServer to be declared partial — verify this does not conflict with source generation, reflection-based name lookups, or other partial declarations elsewhere.
-
NamedPipeServer.cs(retained core)- Contents: class declaration, constants/fields, all public constructors,
RequiresExplicitSecurity,CreateServerStream,PipeNameproperty,WasConnected,WaitConnectionAsync,InternalLoopAsync,TryLogDebugAsync - Responsibility: instance construction and the core connect/read/dispatch/write request loop
- Contents: class declaration, constants/fields, all public constructors,
-
NamedPipeServer.PipeNaming.cs- Contents:
GetPipeName,ResolvePipeDirectory(both overloads),EnsureDirectoryIsWritable,EnsurePathLengthWithinLimit - Responsibility: static, OS-specific pipe name/path computation and validation (Windows naming vs. Unix domain socket directory resolution,
TESTINGPLATFORM_PIPE_DIRECTORYoverride, writability probe,sun_pathlength limit)
- Contents:
-
NamedPipeServer.Lifecycle.cs(if needed)- Contents:
WaitForDisconnectAsync,Dispose(),DisposeAsync() - Responsibility: connection-disconnection waiting and resource disposal
- Contents:
Implementation Guidelines
- Establish Equivalence: Follow
.github/skills/behavior-preserving-refactor/SKILL.md. Before editing, read the complete affected bodies, inventory baseline behavior and relevant tests, and identify distinguishing cases. - Preserve Selection and Evaluation: Keep iteration order, short-circuit evaluation, exact type selection, first/last-match semantics, defaults, exceptions, and side effects. Cover reachable duplicate and malformed inputs; similar-looking helpers are not automatically interchangeable.
- Trace All Consumers: Check partial declarations, source-linked consumers, owning/consuming project includes, target-framework guards, and tracked public/internal API surfaces. Keep names, accessibility, attributes, and native interop contracts unchanged. Note this file is referenced from multiple platform/extension projects via shared compilation (
#if MTP_MSBUILD_TASKS, etc.) — confirm every consuming project's includes/links are updated for any new file. - Move Before Modernizing: Move bodies unchanged first, one coherent responsibility at a time. Preserve allocation and performance behavior on hot paths (this type is on the IPC hot path); do not mix adjacent modernization or bug fixes into the split.
- Use Focused Checks: Run the smallest affected project/TFM builds and relevant tests before and after each coherent split. Add distinguishing equivalence cases where coverage is missing; a pure file move does not require the full solution. Report exact checks and outcomes, including unavailable checks.
- Surface Constraints: Measure resulting line counts. If a safe structural split cannot meet the size goal without changing semantics, report the remaining size and blocker rather than forcing behavior changes.
Acceptance Criteria
- Original file is split into focused modules
- Each new file is under 300 lines, or a concrete behavior-preservation blocker and remaining size are reported
- Baseline semantics, including reachable duplicate/malformed cases and evaluation order, are preserved by focused equivalence checks
- Relevant builds and tests pass for affected consumers/TFMs; exact checks and any validation gaps are reported
- Public and tracked internal API contracts, attributes, and conditional compilation are preserved
- Project includes, source links, and package layout still include the moved code for every affected consumer
Priority: Medium
Effort: Medium
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts
🤖 Automated content by GitHub Copilot. Generated by the Daily File Diet workflow. · copilot · auto · 41.7 AIC · ⌖ 6.61 AIC · ⊞ 13.1K · [◷]( · ◷)
- expires on Oct 16, 2026, 6:59 PM UTC
- Lingua principale
- C#
- Stelle
- 1k
- Fork
- 314
- Merge medio
- 9h 30m
- PR unite (30g)
- 424
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/testfx
-
type/automation type/tech-debt
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
type/automation type/tech-debt
Difficoltà 5/5 Più di una settimana Idoneità per principianti 5/100
I maintainer di solito rispondono entro 1 giorno
-
[msbuild-quality] Test TitleForse già presa @YuliiaKovalova l’ha presa 1 giorno fa. Apertaarea/mtp-msbuild type/automation type/tech-debt
microsoft/testfx#11937 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[quality-improver] Browser/WASM Blocking-Wait Contract Compliance: FileLoggerProvider.Dispose() IsBrowser() branch still blocksForse già presa @Evangelink l’ha presa 1 giorno fa. Apertatype/automation type/tech-debt
Difficoltà 3/5 Mezza giornata Idoneità per principianti 45/100
microsoft/testfx#11934 · 1 reazione · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
area/server-mode-jsonrpc
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/testfx
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted ready-for-human
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Attention: a throwing permission check on one contributor fails the whole aggregation requestApertaready-for-agent size:S status:todo
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
elsa-workflows/elsa-foundation#2830 ·
I maintainer di solito rispondono entro 1 giorno
-
MessagePack negotiation treats any q=0.x Accept value as a refusalForse già presa @AndreaCuneo l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Review - Maintainer WG-Maintainers-Build
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
PowerShell/PowerShell#28220 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno