[file-diet] Refactor BaseSerializer.cs (546 lines) into focused files
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 43/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- backend, testing-qa
Direzione di ricerca
Start with src/Platform/Microsoft.Testing.Platform/IPC/Serializers/BaseSerializer.cs and read the complete class, then trace its [Embedded] source consumers, project includes, target framework guards, and relevant tests. The proposed split points are the nested BoundedReadStream, primitive helpers, and string helpers. Preserve their bodies and conditional branches; done means focused files under 300 lines where safe, with affected builds and tests passing and any blocker reported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Overview
The file src/Platform/Microsoft.Testing.Platform/IPC/Serializers/BaseSerializer.cs has grown to 546 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/Serializers/BaseSerializer.cs - Size: 546 lines
- Language: C#
Structural Analysis
Based on a bounded sample (first 100 lines plus a member grep), the file contains the [Embedded] internal abstract class BaseSerializer with:
- Debug/diagnostic helpers (
DebugAssert,Unreachable) - String read/write helpers (
ReadString,ReadStringValue,WriteString) with#if NETCOREAPPpooled-buffer paths - Primitive read/write helpers (
WriteInt/ReadInt/WriteLong/ReadLong/WriteUShort/ReadUShort,WritePrimitive<T>,ReadExactly), with separate#if NETCOREAPPand down-level implementations - Size/collection validation (
GetSize<T>,ValidatePayloadSize,MaximumCollectionLength) - A nested
BoundedReadStream(Streamsubclass, from around line 390)
The file is [Embedded], i.e. shared as source, so consumers must be checked.
Refactoring Strategy
Proposed File Splits (provisional)
Based on the bounded structural sample, investigate these splits. Confirm their safety during implementation preflight before moving code:
-
BaseSerializer.BoundedReadStream.cs(partial class)- Contents: nested
BoundedReadStream - Responsibility: bounded stream wrapper for payload reads
- Contents: nested
-
BaseSerializer.Primitives.cs(partial class)- Contents: Int/Long/UShort read/write,
WritePrimitive,ReadExactly,GetSize<T>, with their#ifbranches - Responsibility: primitive IPC encoding
- Contents: Int/Long/UShort read/write,
-
BaseSerializer.Strings.cs(if needed) (partial class)- Contents:
ReadString,ReadStringValue,WriteString,ValidatePayloadSize - Responsibility: string and payload-size handling
- Contents:
The core file would keep the debug helpers and constants.
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 (the
[Embedded]shared source and any project linking this file by path or glob), owning/consuming project includes, target-framework guards, and tracked public/internal API surfaces. Keep names, accessibility, attributes, and native interop contracts unchanged. - Move Before Modernizing: Move bodies unchanged first, one coherent responsibility at a time. Preserve allocation and performance behavior on hot paths (pooled buffers); 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: Small-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 · 27.4 AIC · ⌖ 0.583 AIC · ⊞ 7.3K · [◷]( · ◷)
- expires on Oct 31, 2026, 6:53 PM UTC
- Lingua principale
- C#
- Stelle
- 1.1k
- Fork
- 312
- Merge medio
- 10h 19m
- PR unite (30g)
- 360
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
-
[file-diet] Split UseProperAssertMethodsAnalyzer.Collection.cs (614 lines) into focused filesApertatype/automation type/tech-debt
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
[AzureDevOpsReport] ` --publish-azdo-test-results ` shows the wrong display name for DataRow resultsForse già presa @Evangelink l’ha presa oggi. Apertaarea/mtp-azdo-report area/parameterized-tests priority/2
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
microsoft/testfx#12143 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
needs/triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
The productive version of Microsoft.Testing.Extensions.HangDump must not reference to a preview version of Microsoft.Diagnostics.NETCore.ClientForse già presa @Evangelink l’ha presa 4 giorni fa. Apertaarea/dump external/other
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
microsoft/testfx#11981 · 6 commenti · 1 assegnatario ·
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
Tutte le issue di microsoft/testfx
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni
-
bug effort:S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
nightscout/nocturne#3093 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 3 giorni
-
Add 'upm' tag on githubAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno