File tree Expand file tree Collapse file tree 7 files changed +27
-38
lines changed
Confluent.SchemaRegistry.Encryption/Rest/DataContracts Expand file tree Collapse file tree 7 files changed +27
-38
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public override int GetHashCode()
90
90
var hashCode = ( Name != null ? Name . GetHashCode ( ) : 0 ) ;
91
91
hashCode = ( hashCode * 397 ) ^ ( KmsType != null ? KmsType . GetHashCode ( ) : 0 ) ;
92
92
hashCode = ( hashCode * 397 ) ^ ( KmsKeyId != null ? KmsKeyId . GetHashCode ( ) : 0 ) ;
93
- hashCode = ( hashCode * 397 ) ^ ( KmsProps != null ? KmsProps . GetHashCode ( ) : 0 ) ;
93
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( KmsProps ) ;
94
94
hashCode = ( hashCode * 397 ) ^ ( Doc != null ? Doc . GetHashCode ( ) : 0 ) ;
95
95
hashCode = ( hashCode * 397 ) ^ Shared . GetHashCode ( ) ;
96
96
hashCode = ( hashCode * 397 ) ^ Deleted . GetHashCode ( ) ;
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public override int GetHashCode()
60
60
{
61
61
unchecked
62
62
{
63
- var hashCode = ( KmsProps != null ? KmsProps . GetHashCode ( ) : 0 ) ;
63
+ var hashCode = Utils . IEnumerableHashCode ( KmsProps ) ;
64
64
hashCode = ( hashCode * 397 ) ^ ( Doc != null ? Doc . GetHashCode ( ) : 0 ) ;
65
65
hashCode = ( hashCode * 397 ) ^ Shared . GetHashCode ( ) ;
66
66
return hashCode ;
Original file line number Diff line number Diff line change @@ -66,9 +66,9 @@ public override int GetHashCode()
66
66
{
67
67
unchecked
68
68
{
69
- var hashCode = ( Tags != null ? Tags . GetHashCode ( ) : 0 ) ;
70
- hashCode = ( hashCode * 397 ) ^ ( Properties != null ? Properties . GetHashCode ( ) : 0 ) ;
71
- hashCode = ( hashCode * 397 ) ^ ( Sensitive != null ? Sensitive . GetHashCode ( ) : 0 ) ;
69
+ var hashCode = Utils . IEnumerableHashCode ( Tags ) ;
70
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( Properties ) ;
71
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( Sensitive ) ;
72
72
return hashCode ;
73
73
}
74
74
}
Original file line number Diff line number Diff line change @@ -116,8 +116,8 @@ public override int GetHashCode()
116
116
hashCode = ( hashCode * 397 ) ^ ( int ) Kind ;
117
117
hashCode = ( hashCode * 397 ) ^ ( int ) Mode ;
118
118
hashCode = ( hashCode * 397 ) ^ ( Type != null ? Type . GetHashCode ( ) : 0 ) ;
119
- hashCode = ( hashCode * 397 ) ^ ( Tags != null ? Tags . GetHashCode ( ) : 0 ) ;
120
- hashCode = ( hashCode * 397 ) ^ ( Params != null ? Params . GetHashCode ( ) : 0 ) ;
119
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( Tags ) ;
120
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( Params ) ;
121
121
hashCode = ( hashCode * 397 ) ^ ( Expr != null ? Expr . GetHashCode ( ) : 0 ) ;
122
122
hashCode = ( hashCode * 397 ) ^ ( OnSuccess != null ? OnSuccess . GetHashCode ( ) : 0 ) ;
123
123
hashCode = ( hashCode * 397 ) ^ ( OnFailure != null ? OnFailure . GetHashCode ( ) : 0 ) ;
Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ public override int GetHashCode()
77
77
{
78
78
unchecked
79
79
{
80
- return ( ( MigrationRules != null ? MigrationRules . GetHashCode ( ) : 0 ) * 397 ) ^
81
- ( DomainRules != null ? DomainRules . GetHashCode ( ) : 0 ) ;
80
+ return ( Utils . IEnumerableHashCode ( MigrationRules ) * 397 ) ^
81
+ Utils . IEnumerableHashCode ( DomainRules ) ;
82
82
}
83
83
}
84
84
}
Original file line number Diff line number Diff line change @@ -271,38 +271,13 @@ public override int GetHashCode()
271
271
unchecked
272
272
{
273
273
var hashCode = SchemaString . GetHashCode ( ) ;
274
- hashCode = ( hashCode * 397 ) ^ ( References != null ? GetListHashCode ( References ) : 0 ) ;
274
+ hashCode = ( hashCode * 397 ) ^ Utils . IEnumerableHashCode ( References ) ;
275
275
hashCode = ( hashCode * 397 ) ^ ( Metadata != null ? Metadata . GetHashCode ( ) : 0 ) ;
276
276
hashCode = ( hashCode * 397 ) ^ ( RuleSet != null ? RuleSet . GetHashCode ( ) : 0 ) ;
277
277
return hashCode ;
278
278
}
279
279
}
280
280
281
- /// <summary>
282
- /// Returns a hash code for a list of objects.
283
- /// </summary>
284
- /// <param name="list">
285
- /// The list to get the hash code for.
286
- /// </param>
287
- /// <returns>
288
- /// An integer that specifies a hash value for this instance.
289
- /// </returns>
290
- private int GetListHashCode < T > ( IList < T > list )
291
- {
292
- if ( list == null || list . Count == 0 )
293
- return 0 ;
294
-
295
- unchecked
296
- {
297
- int hash = 0 ;
298
- foreach ( var item in list )
299
- {
300
- hash += item ? . GetHashCode ( ) ?? 0 ;
301
- }
302
- return hash ;
303
- }
304
- }
305
-
306
281
/// <summary>
307
282
/// Compares this instance with another instance of this object type and indicates whether
308
283
/// this instance precedes, follows, or appears in the same position in the sort order
Original file line number Diff line number Diff line change 14
14
//
15
15
// Refer to LICENSE for more information.
16
16
17
- using System ;
18
- using System . Collections ;
19
17
using System . Collections . Generic ;
20
18
using System . Linq ;
21
- using Confluent . Kafka ;
22
19
23
20
#if NET8_0_OR_GREATER
24
21
using System . Buffers . Text ;
@@ -74,6 +71,23 @@ public static bool ListEquals<T>(IList<T> a, IList<T> b)
74
71
return a . SequenceEqual ( b ) ;
75
72
}
76
73
74
+ public static int IEnumerableHashCode < T > ( IEnumerable < T > items )
75
+ {
76
+ if ( items == null ) return 0 ;
77
+
78
+ var hash = 0 ;
79
+
80
+ using ( var enumerator = items . GetEnumerator ( ) )
81
+ {
82
+ while ( enumerator . MoveNext ( ) )
83
+ {
84
+ hash = ( hash * 397 ) ^ ( enumerator . Current ? . GetHashCode ( ) ?? 0 ) ;
85
+ }
86
+ }
87
+
88
+ return hash ;
89
+ }
90
+
77
91
internal static bool IsBase64String ( string value )
78
92
{
79
93
#if NET8_0_OR_GREATER
You can’t perform that action at this time.
0 commit comments