Skip to content

Conversation

@greco-salvatore
Copy link
Contributor

this is a draft that worked for me but there can be other things to check

@sipsorcery
Copy link
Member

Thanks for the PR. Conceptually it looks fine (ConcurrentDictionary was not available when that class was written).

It is causing 7 failing unit tests though and those will need to be fixed before the PR can be merged.

image

public void RemoveAll()
{
m_dictionary = new Dictionary<string, string>();
m_dictionary = new ConcurrentDictionary<string, string>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of instantiating a new instance keep the existing one and clear it:

Suggested change
m_dictionary = new ConcurrentDictionary<string, string>();
m_dictionary.Clear();

SIPParameters copy = new SIPParameters();
copy.TagDelimiter = this.TagDelimiter;
copy.m_dictionary = (this.m_dictionary != null) ? new Dictionary<string, string>(this.m_dictionary) : new Dictionary<string, string>();
copy.m_dictionary = (this.m_dictionary != null) ? new ConcurrentDictionary<string, string>(this.m_dictionary) : new ConcurrentDictionary<string, string>();
Copy link
Contributor

Choose a reason for hiding this comment

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

m_dictionary is never null:

Suggested change
copy.m_dictionary = (this.m_dictionary != null) ? new ConcurrentDictionary<string, string>(this.m_dictionary) : new ConcurrentDictionary<string, string>();
copy.m_dictionary = (!this.m_dictionary.IsEmpty) ? new ConcurrentDictionary<string, string>(this.m_dictionary) : new ConcurrentDictionary<string, string>();


//[DataMember]
private Dictionary<string, string> m_dictionary;
private ConcurrentDictionary<string, string> m_dictionary;
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the other comments, m_dictionary can be read-only:

Suggested change
private ConcurrentDictionary<string, string> m_dictionary;
private readonly ConcurrentDictionary<string, string> m_dictionary;

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.

3 participants