-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Add] IEquatable
to WitnessCondition
#3572
[Add] IEquatable
to WitnessCondition
#3572
Conversation
…huchardt88/neo into fix/equals-witnessconditions
{ | ||
if (ReferenceEquals(this, other)) | ||
return true; | ||
if (other is null) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check before reference equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, because of
AndCondition a1 = null;
ReferenceEquals(a1, a1) = true;
a1.Equals(a1) = true;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your example, I think @Jim8y is right, if we will check null reference, it's better to do it in the first line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it should be this way? there are implementations in other classes that have the different order, should them be updated as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this actually wont matter, not really affect the functionality of neo.
return true; | ||
if (other is null) return false; | ||
return Type == other.Type && | ||
Size == other.Size && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this also be updated to is ?
LGTM, minor potential issues being commented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to move null checks to the first line, but if @neo-project/core is ok with that, i'm not against to
Size == other.Size; | ||
return | ||
Type == other.Type && | ||
Expression.Equals(other.Expression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should review this test, because it was wrong
Change Log
IEquatable
toWitnessCondition
,AndCondition
,BooleanCondition
,CalledByContractCondition
,CalledByEntryCondition
,CalledByGroupCondition
,GroupCondition
,NotCondition
,OrCondition
andScriptHashCondition
classesIEquatable
onWitnessCondition
,AndCondition
,BooleanCondition
,CalledByContractCondition
,CalledByEntryCondition
,CalledByGroupCondition
,GroupCondition
,NotCondition
,OrCondition
andScriptHashCondition
classesType of change
How Has This Been Tested?
Test Configuration:
Checklist: