Refactor string handling and Contact header logic#1679
Merged
Conversation
sipsorcery
requested changes
Jun 8, 2026
Member
|
Thanks for the fixes in the SIPDialogue class but this PR now contains new changes to STUN, DTLS and other classes. Can the new additions go into a separate PR. |
Refactored DialogueName and SIPHeader formatting to use StringBuilder and explicit appends for efficiency and code consistency. Improved null checks and replaced string interpolation as per user preferences. Reformatted unit tests for style consistency without changing functionality.
sipsorcery
requested changes
Jun 8, 2026
| if (RemoteUserField?.URI is { } remoteUserFieldUri && !remoteUserFieldUri.User.IsNullOrBlank()) | ||
| { | ||
| dialogueName += $"R({RemoteUserField.URI.ToString()})"; | ||
| dialogueNameBuilder.Append("R(").Append(RemoteUserField).Append(')'); |
Member
There was a problem hiding this comment.
It should be Append(RemoteUserField.URI) here.
Contributor
Author
There was a problem hiding this comment.
Fixed! Added unit tests!
Updated SIPDialogue to use URI for remote user in DialogueName. Added unit tests to verify DialogueName formatting for cases with missing or present local/remote user information.
sipsorcery
approved these changes
Jun 8, 2026
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.
Refactored string concatenation in SIPDialogue and SIPHeader to use StringBuilder for better performance and maintainability. Updated Contact header handling in SIPTransport with a helper function and improved null checks to enhance robustness and reduce code duplication.