Skip to content

Fix PackageRelationship.GetHashCode Exception because the source can be null#948

Merged
tonyqus merged 1 commit into
nissl-lab:masterfrom
GGJason:master
Nov 9, 2022
Merged

Fix PackageRelationship.GetHashCode Exception because the source can be null#948
tonyqus merged 1 commit into
nissl-lab:masterfrom
GGJason:master

Conversation

@GGJason
Copy link
Copy Markdown
Contributor

@GGJason GGJason commented Nov 2, 2022

The source can be null. I was stuck by the exception when I want to copy a table row.
To fix the problem, I add a null-condition when getting the hashcode of source.And anohter null-coalescing operator to return 0 when the hashcode result is null.

public override int GetHashCode()
{
    return this.id.GetHashCode() + this.relationshipType.GetHashCode()
        + this.source?.GetHashCode() ?? 0 + this.targetMode.GetHashCode()
        + this.targetUri.GetHashCode();
}

@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Nov 9, 2022

LGTM

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