Skip to content

Refactor switch cases and improve string formatting#1659

Merged
sipsorcery merged 3 commits into
sipsorcery-org:masterfrom
paulomorgado:strings-8
Jun 1, 2026
Merged

Refactor switch cases and improve string formatting#1659
sipsorcery merged 3 commits into
sipsorcery-org:masterfrom
paulomorgado:strings-8

Conversation

@paulomorgado

Copy link
Copy Markdown
Contributor

Refactored switch-case statements in RTCPFeedback.cs to use the Header property directly for pattern matching, enhancing clarity. Updated exception message in RTCPHeader.cs to use string interpolation. Simplified ToString() in RTCPTWCCFeedback.cs to use a single interpolated string for better readability.

Split of #1639

Comment thread src/SIPSorcery/net/RTCP/RTCPFeedback.cs
Comment thread src/SIPSorcery/net/RTCP/RTCPFeedback.cs Outdated
// PLI feedback reports do no have any additional parameters.
break;
case var x when x.PacketType == RTCPReportTypesEnum.RTPFB:
case var _ when Header.PacketType == RTCPReportTypesEnum.RTPFB:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this one was missed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOPS! Done!

Refactored switch-case statements in RTCPFeedback.cs to use the Header property directly for pattern matching, enhancing clarity. Updated exception message in RTCPHeader.cs to use string interpolation. Simplified ToString() in RTCPTWCCFeedback.cs to use a single interpolated string for better readability.
Renamed the pattern variable in switch cases from '_' to 'h' to improve readability and allow direct access to the matched object. No logic changes were made.
Updated the switch statement to use pattern matching (case var h when h.PacketType == RTCPReportTypesEnum.RTPFB), enabling access to the matched variable within the case block for improved clarity and maintainability.
@sipsorcery sipsorcery merged commit 92044d7 into sipsorcery-org:master Jun 1, 2026
6 checks passed
@paulomorgado paulomorgado deleted the strings-8 branch June 1, 2026 17:43
This was referenced Jun 5, 2026
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.

2 participants