fix: replace duplicate typeof(long) with typeof(ushort) in BaseSerializer.GetSize(T)#8714
Open
Evangelink wants to merge 2 commits into
Open
fix: replace duplicate typeof(long) with typeof(ushort) in BaseSerializer.GetSize(T)#8714Evangelink wants to merge 2 commits into
Evangelink wants to merge 2 commits into
Conversation
… switch The GetSize<T> switch expression had an unreachable duplicate arm for typeof(long). The second arm should be typeof(ushort) to properly cover the ushort type in the switch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a dead switch arm in BaseSerializer.GetSize<T>() by replacing the duplicate typeof(long) case with typeof(ushort), aligning size calculation coverage with the serializer’s ushort read/write helpers.
Changes:
- Adds
ushortsize handling inGetSize<T>(). - Removes the unreachable duplicate
longswitch arm.
Show a summary per file
| File | Description |
|---|---|
src/Platform/Microsoft.Testing.Platform/IPC/Serializers/BaseSerializer.cs |
Updates primitive size mapping used by IPC serialization helpers. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Youssef1313
reviewed
May 31, 2026
| Type type when type == typeof(bool) => sizeof(bool), | ||
| Type type when type == typeof(byte) => sizeof(byte), | ||
| Type type when type == typeof(long) => sizeof(long), | ||
| _ => 0, |
Member
There was a problem hiding this comment.
Shouldn't this throw unreachable?
Member
Author
There was a problem hiding this comment.
Good catch — fixed in 6e4ca9b. Replaced _ => 0, with _ => throw ApplicationStateGuard.Unreachable(), to make the invariant explicit (GetSize<T> is private and only called by WriteSize<T> with a known closed set of primitive types).
Addresses review feedback from @Youssef1313: the default arm should throw to make the invariant explicit, since GetSize<T> is private and only invoked from WriteSize<T> with a fixed set of supported primitive types. 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.
Summary
The
GetSize<T>()switch expression inBaseSerializerhad a duplicatetypeof(long)arm that was unreachable dead code. The second arm should betypeof(ushort)to properly cover all the numeric types used in the IPC serializers.Before:
After:
No behavioral change —
WriteSize<ushort>is not currently called, so this fix adds completeness while removing dead code.Add this agentic workflows to your repo
To install this agentic workflow, run