File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/Elastic.Clients.Elasticsearch/Core/Infer/Metric Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 44
55using System ;
66using System . Collections . Generic ;
7- using System . Linq ;
87using Elastic . Transport ;
98
109namespace Elastic . Clients . Elasticsearch ;
@@ -53,8 +52,8 @@ public bool Equals(Metrics other)
5352 {
5453 if ( other is null ) return false ;
5554
56- // Equality is true when the metrics names in both instances are equal, regardless of their order in the set .
57- return Values . OrderBy ( t => t ) . SequenceEqual ( other . Values . OrderBy ( t => t ) ) ;
55+ // Equality is true when both instances have the same metric names .
56+ return Values . SetEquals ( other . Values ) ;
5857 }
5958
6059 string IUrlParameter . GetString ( ITransportConfiguration settings ) => GetString ( ) ;
@@ -71,7 +70,16 @@ private string GetString()
7170 }
7271
7372 /// <inheritdoc />
74- public override int GetHashCode ( ) => Values != null ? Values . GetHashCode ( ) : 0 ;
73+ public override int GetHashCode ( )
74+ {
75+ // Lifting the minimal target framework to .NET Standard 2.1
76+ // would be the best solution ever due to the HashCode type.
77+ var hashCode = 0 ;
78+ foreach ( var metric in Values )
79+ hashCode = ( hashCode * 397 ) ^ metric . GetHashCode ( ) ;
80+
81+ return hashCode ;
82+ }
7583
7684 public static bool operator == ( Metrics left , Metrics right ) => Equals ( left , right ) ;
7785 public static bool operator != ( Metrics left , Metrics right ) => ! Equals ( left , right ) ;
You can’t perform that action at this time.
0 commit comments