Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 9, 2022

Conversation

GGJason
Copy link
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
Member

tonyqus commented Nov 9, 2022

LGTM

@tonyqus tonyqus merged commit 6a4a479 into nissl-lab:master Nov 9, 2022
@tonyqus tonyqus added this to the NPOI 2.6.1 milestone Nov 9, 2022
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.

None yet

2 participants