Skip to content

Commit 8fe603f

Browse files
Cleanup build warnings (#7700)
Co-authored-by: Aaron Stannard <[email protected]>
1 parent bf6da82 commit 8fe603f

File tree

9 files changed

+46
-8
lines changed

9 files changed

+46
-8
lines changed

src/contrib/cluster/Akka.DistributedData/Durable/Messages.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public sealed class LoadAll : IEquatable<LoadAll>
6161
private LoadAll() { }
6262
public bool Equals(LoadAll other) => true;
6363
public override bool Equals(object obj) => obj is LoadAll;
64+
public override int GetHashCode() => 761;
6465
}
6566

6667
public sealed class LoadData
@@ -79,6 +80,7 @@ public sealed class LoadAllCompleted : IEquatable<LoadAllCompleted>
7980
private LoadAllCompleted() { }
8081
public bool Equals(LoadAllCompleted other) => true;
8182
public override bool Equals(object obj) => obj is LoadAllCompleted;
83+
public override int GetHashCode() => 769;
8284
}
8385

8486
public sealed class LoadFailedException : AkkaException

src/contrib/cluster/Akka.DistributedData/ORDictionary.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,14 @@ public override bool Equals(object obj)
478478

479479
public Type KeyType { get; } = typeof(TKey);
480480
public Type ValueType { get; } = typeof(TValue);
481+
482+
public override int GetHashCode()
483+
{
484+
var hash = KeyType.GetHashCode();
485+
hash = (hash * 397) ^ ValueType.GetHashCode();
486+
hash = (hash * 397) ^ Underlying?.GetHashCode() ?? 0;
487+
return hash;
488+
}
481489
}
482490

483491
internal sealed class PutDeltaOperation : AtomicDeltaOperation, ORDictionary.IPutDeltaOp

src/contrib/cluster/Akka.DistributedData/ReplicatedData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ public interface IRemovedNodePruning<T> : IRemovedNodePruning, IReplicatedData<T
7575
/// changes from that node will be pruned by collapsing the data entries
7676
/// to another node.
7777
/// </summary>
78-
T Prune(UniqueAddress removedNode, UniqueAddress collapseInto);
78+
new T Prune(UniqueAddress removedNode, UniqueAddress collapseInto);
7979

8080
/// <summary>
8181
/// Remove data entries from a node that has been removed from the cluster
8282
/// and already been pruned.
8383
/// </summary>
84-
T PruningCleanup(UniqueAddress removedNode);
84+
new T PruningCleanup(UniqueAddress removedNode);
8585
}
8686

8787
/// <summary>
@@ -130,7 +130,7 @@ public interface IDeltaReplicatedData<T, TDelta> : IDeltaReplicatedData, IReplic
130130
/// `modify` function shall still return the full state in the same way as
131131
/// <see cref="IReplicatedData{T}"/> without support for deltas.
132132
/// </summary>
133-
TDelta Delta { get; }
133+
new TDelta Delta { get; }
134134

135135
/// <summary>
136136
/// When delta is merged into the full state this method is used.
@@ -149,7 +149,7 @@ public interface IDeltaReplicatedData<T, TDelta> : IDeltaReplicatedData, IReplic
149149
/// <see cref="Replicator"/> has grabbed the <see cref="Delta"/> it will invoke this method
150150
/// to get a clean data instance without the delta.
151151
/// </summary>
152-
T ResetDelta();
152+
new T ResetDelta();
153153
}
154154

155155
/// <summary>

src/contrib/cluster/Akka.DistributedData/Replicator.Messages.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,8 @@ public override bool Equals(object obj)
992992
{
993993
return obj is FlushChanges;
994994
}
995+
996+
public override int GetHashCode() => 809;
995997
}
996998

997999
/// <summary>

src/contrib/cluster/Akka.DistributedData/Replicator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ namespace Akka.DistributedData
220220
/// A deleted key cannot be reused again, but it is still recommended to delete unused
221221
/// data entries because that reduces the replication overhead when new nodes join the cluster.
222222
/// Subsequent <see cref="Delete"/>, <see cref="Update"/> and <see cref="Get"/> requests will be replied with <see cref="DataDeleted"/>.
223-
/// Subscribers will receive <see cref="Deleted"/>.
224223
///
225224
/// In the <see cref="Delete"/> message you can pass an optional request context in the same way as for the
226225
/// <see cref="Update"/> message, described above. For example the original sender can be passed and replied

src/contrib/cluster/Akka.DistributedData/VersionVector.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Collections.Immutable;
1212
using System.Diagnostics;
1313
using System.Linq;
14+
using System.Runtime.CompilerServices;
1415
using Akka.Cluster;
1516
using Akka.Util.Internal;
1617

@@ -105,6 +106,17 @@ public bool Equals(VersionVector other)
105106

106107
public override bool Equals(object obj) => obj is VersionVector vector && Equals(vector);
107108

109+
public override int GetHashCode()
110+
{
111+
var hash = 373;
112+
foreach (var (addr, ver) in InternalVersions)
113+
{
114+
hash = hash * 31 + addr.GetHashCode();
115+
hash = hash * 31 + ver.GetHashCode();
116+
}
117+
return hash;
118+
}
119+
108120
/// <summary>
109121
/// Returns true if this VersionVector has the same history
110122
/// as the <paramref name="y"/> VersionVector else false.
@@ -162,14 +174,17 @@ private Ordering CompareOnlyTo(VersionVector other, Ordering order)
162174
{
163175
if (ReferenceEquals(this, other)) return Ordering.Same;
164176

165-
return Compare(InternalVersionEnumerator, other.InternalVersionEnumerator,
166-
order == Ordering.Concurrent ? Ordering.FullOrder : order);
177+
using var ie1 = InternalVersionEnumerator;
178+
using var ie2 = other.InternalVersionEnumerator;
179+
return Compare(ie1, ie2, order == Ordering.Concurrent ? Ordering.FullOrder : order);
167180
}
168181

182+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
169183
private static T NextOrElse<T>(IEnumerator<T> enumerator, T defaultValue) =>
170184
enumerator.MoveNext() ? enumerator.Current : defaultValue;
171185

172-
private Ordering Compare(IEnumerator<(UniqueAddress addr, long version)> i1,
186+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
187+
private static Ordering Compare(IEnumerator<(UniqueAddress addr, long version)> i1,
173188
IEnumerator<(UniqueAddress addr, long version)> i2, Ordering requestedOrder)
174189
{
175190
var nt1 = NextOrElse(i1, EndMarker);

src/contrib/cluster/Akka.DistributedData/WriteAggregator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public override bool Equals(object obj)
193193
return obj != null && obj is WriteLocal;
194194
}
195195

196+
public override int GetHashCode() => 811;
197+
196198
private WriteLocal() { }
197199

198200
public override string ToString() => "WriteLocal";

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveDistributedData.DotNet.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ namespace Akka.DistributedData
155155
{
156156
public static readonly Akka.DistributedData.FlushChanges Instance;
157157
public override bool Equals(object obj) { }
158+
public override int GetHashCode() { }
158159
}
159160
public sealed class GCounter : Akka.DistributedData.FastMerge<Akka.DistributedData.GCounter>, Akka.DistributedData.IDeltaReplicatedData, Akka.DistributedData.IDeltaReplicatedData<Akka.DistributedData.GCounter, Akka.DistributedData.GCounter>, Akka.DistributedData.IRemovedNodePruning, Akka.DistributedData.IRemovedNodePruning<Akka.DistributedData.GCounter>, Akka.DistributedData.IReplicatedData, Akka.DistributedData.IReplicatedDataSerialization, Akka.DistributedData.IReplicatedData<Akka.DistributedData.GCounter>, Akka.DistributedData.IReplicatedDelta, System.IEquatable<Akka.DistributedData.GCounter>
160161
{
@@ -910,6 +911,7 @@ namespace Akka.DistributedData
910911
public static Akka.DistributedData.VersionVector Create(System.Collections.Immutable.ImmutableDictionary<Akka.Cluster.UniqueAddress, long> versions) { }
911912
public bool Equals(Akka.DistributedData.VersionVector other) { }
912913
public override bool Equals(object obj) { }
914+
public override int GetHashCode() { }
913915
public abstract Akka.DistributedData.VersionVector Increment(Akka.Cluster.UniqueAddress node);
914916
public bool IsAfter(Akka.DistributedData.VersionVector y) { }
915917
public bool IsBefore(Akka.DistributedData.VersionVector y) { }
@@ -948,6 +950,7 @@ namespace Akka.DistributedData
948950
public static readonly Akka.DistributedData.WriteLocal Instance;
949951
public System.TimeSpan Timeout { get; }
950952
public override bool Equals(object obj) { }
953+
public override int GetHashCode() { }
951954
public override string ToString() { }
952955
}
953956
public sealed class WriteMajority : Akka.DistributedData.IWriteConsistency, System.IEquatable<Akka.DistributedData.WriteMajority>
@@ -998,12 +1001,14 @@ namespace Akka.DistributedData.Durable
9981001
public static readonly Akka.DistributedData.Durable.LoadAll Instance;
9991002
public bool Equals(Akka.DistributedData.Durable.LoadAll other) { }
10001003
public override bool Equals(object obj) { }
1004+
public override int GetHashCode() { }
10011005
}
10021006
public sealed class LoadAllCompleted : System.IEquatable<Akka.DistributedData.Durable.LoadAllCompleted>
10031007
{
10041008
public static readonly Akka.DistributedData.Durable.LoadAllCompleted Instance;
10051009
public bool Equals(Akka.DistributedData.Durable.LoadAllCompleted other) { }
10061010
public override bool Equals(object obj) { }
1011+
public override int GetHashCode() { }
10071012
}
10081013
public sealed class LoadData
10091014
{

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveDistributedData.Net.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ namespace Akka.DistributedData
155155
{
156156
public static readonly Akka.DistributedData.FlushChanges Instance;
157157
public override bool Equals(object obj) { }
158+
public override int GetHashCode() { }
158159
}
159160
public sealed class GCounter : Akka.DistributedData.FastMerge<Akka.DistributedData.GCounter>, Akka.DistributedData.IDeltaReplicatedData, Akka.DistributedData.IDeltaReplicatedData<Akka.DistributedData.GCounter, Akka.DistributedData.GCounter>, Akka.DistributedData.IRemovedNodePruning, Akka.DistributedData.IRemovedNodePruning<Akka.DistributedData.GCounter>, Akka.DistributedData.IReplicatedData, Akka.DistributedData.IReplicatedDataSerialization, Akka.DistributedData.IReplicatedData<Akka.DistributedData.GCounter>, Akka.DistributedData.IReplicatedDelta, System.IEquatable<Akka.DistributedData.GCounter>
160161
{
@@ -910,6 +911,7 @@ namespace Akka.DistributedData
910911
public static Akka.DistributedData.VersionVector Create(System.Collections.Immutable.ImmutableDictionary<Akka.Cluster.UniqueAddress, long> versions) { }
911912
public bool Equals(Akka.DistributedData.VersionVector other) { }
912913
public override bool Equals(object obj) { }
914+
public override int GetHashCode() { }
913915
public abstract Akka.DistributedData.VersionVector Increment(Akka.Cluster.UniqueAddress node);
914916
public bool IsAfter(Akka.DistributedData.VersionVector y) { }
915917
public bool IsBefore(Akka.DistributedData.VersionVector y) { }
@@ -948,6 +950,7 @@ namespace Akka.DistributedData
948950
public static readonly Akka.DistributedData.WriteLocal Instance;
949951
public System.TimeSpan Timeout { get; }
950952
public override bool Equals(object obj) { }
953+
public override int GetHashCode() { }
951954
public override string ToString() { }
952955
}
953956
public sealed class WriteMajority : Akka.DistributedData.IWriteConsistency, System.IEquatable<Akka.DistributedData.WriteMajority>
@@ -998,12 +1001,14 @@ namespace Akka.DistributedData.Durable
9981001
public static readonly Akka.DistributedData.Durable.LoadAll Instance;
9991002
public bool Equals(Akka.DistributedData.Durable.LoadAll other) { }
10001003
public override bool Equals(object obj) { }
1004+
public override int GetHashCode() { }
10011005
}
10021006
public sealed class LoadAllCompleted : System.IEquatable<Akka.DistributedData.Durable.LoadAllCompleted>
10031007
{
10041008
public static readonly Akka.DistributedData.Durable.LoadAllCompleted Instance;
10051009
public bool Equals(Akka.DistributedData.Durable.LoadAllCompleted other) { }
10061010
public override bool Equals(object obj) { }
1011+
public override int GetHashCode() { }
10071012
}
10081013
public sealed class LoadData
10091014
{

0 commit comments

Comments
 (0)