Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xUnit1031 is a temporary fix, we will need to pay this technical debt
and make everything fully async in the future
-->
<NoWarn>$(NoWarn);CS1591;xUnit1013;xUnit1031</NoWarn>
<NoWarn>$(NoWarn);CS1591;xUnit1013;xUnit1031;CS8632</NoWarn>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disables https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/nullable-warnings#configure-nullable-context - which is basically a warning that we have some non-nullable code calling code with nullable attributes. We're naturally going to encounter that since we're gradually moving code over to using nullable - so this cuts down on a fairly large and growing number of warnings.

<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<!-- Set the language version for C# if we're not inside an F# project -->
Expand Down
9 changes: 9 additions & 0 deletions src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

// Suppress CS8632 warnings about nullable reference type annotations
[assembly: SuppressMessage("Style", "CS8632:The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.", Justification = "Files with #nullable enable directives use nullable annotations correctly")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 changes: 1 addition & 1 deletion src/contrib/testkits/Akka.TestKit.Xunit/XunitAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class XunitAssertions : ITestKitAssertions
/// <param name="args">An optional object array that contains zero or more objects to format.</param>
public void Fail(string format = "", params object[] args)
{
Assert.True(false, string.Format(format, args));
Assert.Fail(string.Format(format, args));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleans up an xUnit warning

}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace Akka.Coordination
{
public LeaseTimeoutException(string message) { }
public LeaseTimeoutException(string message, System.Exception innerEx) { }
protected LeaseTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No inheritors for this class, so this eliminates that warning

}
public sealed class LeaseUsageSettings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace Akka.Coordination
{
public LeaseTimeoutException(string message) { }
public LeaseTimeoutException(string message, System.Exception innerEx) { }
protected LeaseTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
public sealed class LeaseUsageSettings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,6 @@ namespace Akka.Actor.Internal
public virtual bool IsTerminating { get; }
public System.Collections.Generic.IReadOnlyCollection<Akka.Actor.Internal.ChildRestartStats> Stats { get; }
public abstract Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats);
protected static void ChildStatsAppender(System.Text.StringBuilder sb, System.Collections.Generic.KeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
public bool Contains(Akka.Actor.IActorRef actor) { }
public abstract Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child);
public abstract Akka.Actor.Internal.IChildrenContainer Reserve(string name);
Expand Down Expand Up @@ -5032,6 +5031,7 @@ namespace Akka.Routing
public abstract Akka.Actor.ActorBase CreateRouterActor();
public bool Equals(Akka.Routing.RouterConfig other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public virtual bool IsManagementMessage(object message) { }
public virtual Akka.Actor.Props RoutingLogicController(Akka.Routing.RoutingLogic routingLogic) { }
public abstract Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,6 @@ namespace Akka.Actor.Internal
public virtual bool IsTerminating { get; }
public System.Collections.Generic.IReadOnlyCollection<Akka.Actor.Internal.ChildRestartStats> Stats { get; }
public abstract Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats);
protected static void ChildStatsAppender(System.Text.StringBuilder sb, System.Collections.Generic.KeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
public bool Contains(Akka.Actor.IActorRef actor) { }
public abstract Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child);
public abstract Akka.Actor.Internal.IChildrenContainer Reserve(string name);
Expand Down Expand Up @@ -5022,6 +5021,7 @@ namespace Akka.Routing
public abstract Akka.Actor.ActorBase CreateRouterActor();
public bool Equals(Akka.Routing.RouterConfig other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public virtual bool IsManagementMessage(object message) { }
public virtual Akka.Actor.Props RoutingLogicController(Akka.Routing.RoutingLogic routingLogic) { }
public abstract Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public class EventAdapters
{
Expand All @@ -952,6 +953,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public interface IAsyncRecovery
{
Expand Down Expand Up @@ -1121,6 +1123,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public struct Tagged
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public class EventAdapters
{
Expand All @@ -952,6 +953,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public interface IAsyncRecovery
{
Expand Down Expand Up @@ -1121,6 +1123,7 @@ namespace Akka.Persistence.Journal
public System.Collections.Generic.IEnumerable<object> Events { get; }
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
}
public struct Tagged
{
Expand Down
6 changes: 0 additions & 6 deletions src/core/Akka.Coordination/LeaseTimeoutException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@ public LeaseTimeoutException(string message, Exception innerEx)
: base(message, innerEx)
{
}

protected LeaseTimeoutException(SerializationInfo info, StreamingContext context)
: base(info, context)
{

}
}
}
41 changes: 4 additions & 37 deletions src/core/Akka.Persistence.Tests/AtLeastOnceDeliverySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Xunit;
using Xunit.Abstractions;
using FluentAssertions;
#pragma warning disable CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of the warning and fixed the problems instead. These are all related to the test messages themselves so no real impact on Akka.NET.


namespace Akka.Persistence.Tests
{
Expand Down Expand Up @@ -217,25 +216,17 @@ public ReqSelection(string message)
}

[Serializable]
sealed class ReqAck
sealed record ReqAck
{
public static readonly ReqAck Instance = new();
private ReqAck() { }
public override bool Equals(object obj)
{
return obj is ReqAck;
}
}

[Serializable]
sealed class InvalidReq
sealed record InvalidReq
{
public static readonly InvalidReq Instance = new();
private InvalidReq() { }
public override bool Equals(object obj)
{
return obj is InvalidReq;
}
}

interface IEvt { }
Expand Down Expand Up @@ -271,19 +262,7 @@ public AcceptedSelectionReq(string payload, string destinationPath)
}

[Serializable]
sealed class ReqDone : IEvt, IEquatable<ReqDone>
{
public ReqDone(long id)
{
Id = id;
}

public long Id { get; private set; }
public bool Equals(ReqDone other)
{
return other != null && other.Id == Id;
}
}
sealed record ReqDone(long Id) : IEvt;

[Serializable]
sealed class Action : IEquatable<Action>
Expand Down Expand Up @@ -318,19 +297,7 @@ public override int GetHashCode()
}

[Serializable]
sealed class ActionAck : IEquatable<ActionAck>
{
public ActionAck(long id)
{
Id = id;
}

public long Id { get; private set; }
public bool Equals(ActionAck other)
{
return other != null && other.Id == Id;
}
}
sealed record ActionAck(long Id);

[Serializable]
sealed class Boom { public static readonly Boom Instance = new(); }
Expand Down
10 changes: 6 additions & 4 deletions src/core/Akka.Persistence.Tests/PersistentActorSpec.Actors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,15 @@ protected override bool ReceiveCommand(object message)
if (cmd != null)
{
Sender.Tell(cmd.Data);
var events = new List<Evt>();
for (int i = 1; i <= 3; i++)
{
PersistAsync(new Evt(cmd.Data.ToString() + "-" + (++_counter)), evt =>
{
Sender.Tell("a" + evt.Data.ToString().Substring(1));
});
events.Add(new Evt(cmd.Data.ToString() + "-" + (++_counter)));
}
PersistAllAsync(events, evt =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed Akka.NET build warning here

{
Sender.Tell("a" + evt.Data.ToString().Substring(1));
});

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,12 @@ protected override bool ReceiveCommand(object message)
await Task.Delay(100);

Sender.Tell(cmd.Data);
var events = new List<Evt>();
for (int i = 1; i <= 3; i++)
{
PersistAsync(new Evt(cmd.Data.ToString() + "-" + (++_counter)),
evt => { Sender.Tell("a" + evt.Data.ToString().Substring(1)); });
events.Add(new Evt(cmd.Data.ToString() + "-" + (++_counter)));
}
PersistAllAsync(events, evt => { Sender.Tell("a" + evt.Data.ToString().Substring(1)); });
});

return true;
Expand Down
41 changes: 41 additions & 0 deletions src/core/Akka.Persistence/Journal/EventSequences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public override bool Equals(object obj)
{
return Equals(obj as IEventSequence);
}

/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return typeof(EmptyEventSequence).GetHashCode();
}
}

/// <summary>
Expand Down Expand Up @@ -91,6 +102,25 @@ public override bool Equals(object obj)
{
return Equals(obj as IEventSequence);
}

/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
unchecked
{
int hash = 17;
foreach (var item in _events)
{
hash = hash * 23 + (item?.GetHashCode() ?? 0);
}
return hash;
}
}
}

/// <summary>
Expand Down Expand Up @@ -127,6 +157,17 @@ public override bool Equals(object obj)
{
return Equals(obj as IEventSequence);
}

/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return _events[0]?.GetHashCode() ?? 0;
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.Tests/AckedDeliverySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public void SendBuffer_and_ReceiveBuffer_must_correctly_cooperate_with_each_othe
global::System.Diagnostics.Debug.WriteLine(string.Join(Environment.NewLine, log));
global::System.Diagnostics.Debug.WriteLine("Received: ");
global::System.Diagnostics.Debug.WriteLine(string.Join(Environment.NewLine, received.Select(x => x.ToString())));
Assert.True(false,"Not all messages were received");
Assert.Fail("Not all messages were received");
}

global::System.Diagnostics.Debug.WriteLine("All messages have been successfully delivered");
Expand Down
1 change: 0 additions & 1 deletion src/core/Akka.Streams.Tests/Akka.Streams.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<ItemGroup>
<Content Include="App.config" />
<ProjectReference Include="..\Akka.Remote\Akka.Remote.csproj" />
<ProjectReference Include="..\Akka.Streams\Akka.Streams.csproj" />
<ProjectReference Include="..\Akka.Streams.TestKit\Akka.Streams.TestKit.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams.Tests/Dsl/LazySinkSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static Func<TMat> Fallback<TMat>()
{
return () =>
{
Assert.True(false, "Must not call fallback function");
Assert.Fail("Must not call fallback function");
return default(TMat);
};
}
Expand Down
11 changes: 0 additions & 11 deletions src/core/Akka.Streams.Tests/ScriptedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,6 @@ protected ScriptedTest(ITestOutputHelper output = null) : base(output)
{
}

[Obsolete("Will be removed after async_testkit conversion is done. Use RunScriptAsync instead")]
protected void RunScript<TIn2, TOut2, TMat2>(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not called anywhere and we should have gotten rid of it in v1.5.0

Script<TIn2, TOut2> script,
ActorMaterializerSettings settings,
Func<Flow<TIn2, TIn2, NotUsed>, Flow<TIn2, TOut2, TMat2>> op,
int maximumOverrun = 3,
int maximumRequest = 3,
int maximumBuffer = 3)
=> RunScriptAsync(script, settings, op, maximumOverrun, maximumRequest, maximumBuffer)
.ConfigureAwait(false).GetAwaiter().GetResult();

protected async Task RunScriptAsync<TIn2, TOut2, TMat2>(
Script<TIn2, TOut2> script,
ActorMaterializerSettings settings,
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Tests.Shared.Internals/Helpers/XAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class XAssert
/// </summary>
public static void Fail(string reason)
{
Assert.True(false, reason);
Assert.Fail(reason);
}

/// <summary>
Expand Down
Loading
Loading