@@ -11,25 +11,39 @@ public class LabelValues
1111 private readonly string [ ] _values ;
1212 internal readonly List < LabelPair > WireLabels = new List < LabelPair > ( ) ;
1313
14-
15- public LabelValues ( IReadOnlyCollection < string > names , string [ ] values )
14+ public LabelValues ( IReadOnlyCollection < string > names , IReadOnlyList < string > values )
1615 {
17- if ( names . Count != values . Length )
16+ if ( values == null )
17+ throw new InvalidOperationException ( "Label values is null" ) ;
18+
19+ if ( names . Count != values . Count )
1820 throw new InvalidOperationException ( "Label values must be of same length as label names" ) ;
19- _values = values ;
20- WireLabels . AddRange ( names . Zip ( values , ( s , s1 ) => new LabelPair { name = s , value = s1 } ) ) ;
21+
22+ _values = new string [ values . Count ] ;
23+ for ( var i = 0 ; i < values . Count ; i ++ )
24+ _values [ i ] = values [ i ] ?? "" ;
25+
26+ WireLabels . AddRange ( names . Zip ( values , ( s , s1 ) => new LabelPair { name = s , value = s1 } ) ) ;
2127 }
2228
2329
2430 public override bool Equals ( object obj )
2531 {
26- if ( ReferenceEquals ( null , obj ) ) return false ;
27- if ( ReferenceEquals ( this , obj ) ) return true ;
28- if ( obj . GetType ( ) != GetType ( ) ) return false ;
29- var other = ( LabelValues ) obj ;
32+ if ( ReferenceEquals ( null , obj ) )
33+ return false ;
34+
35+ if ( ReferenceEquals ( this , obj ) )
36+ return true ;
37+
38+ if ( obj . GetType ( ) != GetType ( ) )
39+ return false ;
40+
41+ var labelValues = ( LabelValues ) obj ;
42+
43+ if ( labelValues . _values . Length != _values . Length )
44+ return false ;
3045
31- if ( other . _values . Length != _values . Length ) return false ;
32- return ! _values . Where ( ( t , i ) => t != other . _values [ i ] ) . Any ( ) ;
46+ return ! _values . Where ( ( t , i ) => t != labelValues . _values [ i ] ) . Any ( ) ;
3347 }
3448
3549 public override int GetHashCode ( )
0 commit comments