Refactor SIP Regex usage for performance and clarity#1674
Open
paulomorgado wants to merge 2 commits into
Open
Conversation
Refactored SIP classes to use pre-compiled or source-generated Regex via [GeneratedRegex] for improved performance and maintainability. Introduced constants for Regex patterns and conditional compilation for .NET 7+ compatibility. Updated string operations and equality checks for consistency and modern C# style. Minor code cleanups included.
sipsorcery
requested changes
Jun 5, 2026
| } | ||
|
|
||
| public class SIPCallDescriptor | ||
| public partial class SIPCallDescriptor |
Member
There was a problem hiding this comment.
What's the reason to make these classes partial?
Contributor
Author
There was a problem hiding this comment.
Because that's how these source generators work.
| catch (Exception excp) | ||
| { | ||
| throw new SIPValidationException(SIPValidationFieldsEnum.ContactHeader, $"Contact header invalid, parse failed. {excp.Message}"); | ||
| throw new SIPValidationException(SIPValidationFieldsEnum.ContactHeader, "Contact header invalid, parse failed. " + excp.Message); |
Member
There was a problem hiding this comment.
Your previous PR's are going the other way and update to use string interpolation instead of concatentation. Why is this PR doing the opposite?
Contributor
Author
There was a problem hiding this comment.
OOPS! It was a bad rebase. Reverted!
| } | ||
|
|
||
| public static string[] SplitHeaders(string message) | ||
| { |
Member
There was a problem hiding this comment.
Was the NormalizeFoldedHeaderLines an error? Your PR only added it less than a week ago.
Contributor
Author
There was a problem hiding this comment.
OOPS! It was a bad rebase. Reverted!
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 SIP classes to use pre-compiled or source-generated Regex via [GeneratedRegex] for improved performance and maintainability. Introduced constants for Regex patterns and conditional compilation for .NET 7+ compatibility. Updated string operations and equality checks for consistency and modern C# style. Minor code cleanups included.