File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
src/Microsoft.OpenApi/Expressions
test/Microsoft.OpenApi.Tests/PublicApi Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -78,23 +78,29 @@ public static RuntimeExpression Build(string expression)
7878 /// </summary>
7979 public override int GetHashCode ( )
8080 {
81- return Expression . GetHashCode ( ) ;
81+ return StringComparer . Ordinal . GetHashCode ( Expression ) ;
8282 }
8383
8484 /// <summary>
8585 /// Equals implementation for IEquatable.
8686 /// </summary>
8787 public override bool Equals ( object ? obj )
8888 {
89- return Equals ( obj as RuntimeExpression ) ;
89+ if ( obj == null )
90+ {
91+ return false ;
92+ }
93+ if ( ReferenceEquals ( this , obj ) )
94+ {
95+ return true ;
96+ }
97+ return obj is RuntimeExpression runtimeExpression && Equals ( runtimeExpression ) ;
9098 }
9199
92- /// <summary>
93- /// Equals implementation for object of the same type.
94- /// </summary>
95- public bool Equals ( RuntimeExpression ? obj )
100+ /// <inheritdoc />
101+ public bool Equals ( RuntimeExpression ? other )
96102 {
97- return obj != null && obj . Expression == Expression ;
103+ return other is not null && StringComparer . Ordinal . Equals ( Expression , other . Expression ) ;
98104 }
99105
100106 /// <inheritdoc />
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ namespace Microsoft.OpenApi.Expressions
115115 public const string Prefix = "$";
116116 protected RuntimeExpression() { }
117117 public abstract string Expression { get; }
118- public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression? obj ) { }
118+ public bool Equals(Microsoft.OpenApi.Expressions.RuntimeExpression? other ) { }
119119 public override bool Equals(object? obj) { }
120120 public override int GetHashCode() { }
121121 public override string ToString() { }
You can’t perform that action at this time.
0 commit comments