Skip to content

Commit 5793a6b

Browse files
chore: clean up build warnings (#7522)
* fix: replace Assert.True(false) with Assert.Fail to address xUnit2020 warnings * fix: add ConfigureAwait(false) to async calls in LazySinkSpec to address xUnit1030 warnings * fix: add ConfigureAwait(false) to async calls in FlowZipSpec to address xUnit1030 warnings * remove configure await calls * remove obsolete member * fix `RouterConfig` warning * Fix AK1006 warnings by replacing PersistAsync in loops with PersistAllAsync * API approvals * used `new` keyword to avoid API hiding warning * fixed build warnings with `ChildrenContainer` removed tons of useless XML-DOCs too * fixed `Volatile.Read` warnings in `Mailbox` * fix build warnings Fix CS0659 and CS0420 warnings in core Akka libraries This commit addresses two types of build warnings: 1. CS0659: Missing GetHashCode implementation - Added GetHashCode implementations to classes in EventSequences.cs - Converted test classes in AtLeastOnceDeliverySpec.cs to C# records 2. CS0420: Volatile field access warning - Removed redundant 'volatile' keyword from _statusDotNotCallMeDirectly field in Mailbox.cs - Kept explicit Volatile.Read/Write method calls for proper memory barriers These changes maintain the original behavior while eliminating the warnings, improving code quality and maintainability. * Suppress CS8632 warnings about nullable reference type annotations This commit addresses the CS8632 warnings that occur when nullable reference type annotations (like string?) are used in files with #nullable enable directives but in projects where nullable reference types are not enabled at the project level. Changes: 1. Added CS8632 to the NoWarn property in src/Directory.Build.props to suppress these warnings during build 2. Created a GlobalSuppressions.cs file with a SuppressMessage attribute for CS8632 with a clear justification This approach preserves the intent of the code by keeping the #nullable enable directives and nullable annotations intact, while eliminating the build warnings. It also maintains forward compatibility if the project later decides to fully enable nullable reference types across all projects. * fixed Akka.Coordination API warning * added API approvals
1 parent 04a98d3 commit 5793a6b

27 files changed

+174
-327
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xUnit1031 is a temporary fix, we will need to pay this technical debt
1111
and make everything fully async in the future
1212
-->
13-
<NoWarn>$(NoWarn);CS1591;xUnit1013;xUnit1031</NoWarn>
13+
<NoWarn>$(NoWarn);CS1591;xUnit1013;xUnit1031;CS8632</NoWarn>
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
</PropertyGroup>
1616
<!-- Set the language version for C# if we're not inside an F# project -->

src/GlobalSuppressions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
// Suppress CS8632 warnings about nullable reference type annotations
9+
[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")]

src/contrib/testkits/Akka.TestKit.Xunit/XunitAssertions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class XunitAssertions : ITestKitAssertions
2323
/// <param name="args">An optional object array that contains zero or more objects to format.</param>
2424
public void Fail(string format = "", params object[] args)
2525
{
26-
Assert.True(false, string.Format(format, args));
26+
Assert.Fail(string.Format(format, args));
2727
}
2828

2929
/// <summary>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace Akka.Coordination
4444
{
4545
public LeaseTimeoutException(string message) { }
4646
public LeaseTimeoutException(string message, System.Exception innerEx) { }
47-
protected LeaseTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
4847
}
4948
public sealed class LeaseUsageSettings
5049
{

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace Akka.Coordination
4444
{
4545
public LeaseTimeoutException(string message) { }
4646
public LeaseTimeoutException(string message, System.Exception innerEx) { }
47-
protected LeaseTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
4847
}
4948
public sealed class LeaseUsageSettings
5049
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,6 @@ namespace Akka.Actor.Internal
20782078
public virtual bool IsTerminating { get; }
20792079
public System.Collections.Generic.IReadOnlyCollection<Akka.Actor.Internal.ChildRestartStats> Stats { get; }
20802080
public abstract Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats);
2081-
protected static void ChildStatsAppender(System.Text.StringBuilder sb, System.Collections.Generic.KeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
20822081
public bool Contains(Akka.Actor.IActorRef actor) { }
20832082
public abstract Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child);
20842083
public abstract Akka.Actor.Internal.IChildrenContainer Reserve(string name);
@@ -5032,6 +5031,7 @@ namespace Akka.Routing
50325031
public abstract Akka.Actor.ActorBase CreateRouterActor();
50335032
public bool Equals(Akka.Routing.RouterConfig other) { }
50345033
public override bool Equals(object obj) { }
5034+
public override int GetHashCode() { }
50355035
public virtual bool IsManagementMessage(object message) { }
50365036
public virtual Akka.Actor.Props RoutingLogicController(Akka.Routing.RoutingLogic routingLogic) { }
50375037
public abstract Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,6 @@ namespace Akka.Actor.Internal
20762076
public virtual bool IsTerminating { get; }
20772077
public System.Collections.Generic.IReadOnlyCollection<Akka.Actor.Internal.ChildRestartStats> Stats { get; }
20782078
public abstract Akka.Actor.Internal.IChildrenContainer Add(string name, Akka.Actor.Internal.ChildRestartStats stats);
2079-
protected static void ChildStatsAppender(System.Text.StringBuilder sb, System.Collections.Generic.KeyValuePair<string, Akka.Actor.Internal.IChildStats> kvp, int index) { }
20802079
public bool Contains(Akka.Actor.IActorRef actor) { }
20812080
public abstract Akka.Actor.Internal.IChildrenContainer Remove(Akka.Actor.IActorRef child);
20822081
public abstract Akka.Actor.Internal.IChildrenContainer Reserve(string name);
@@ -5022,6 +5021,7 @@ namespace Akka.Routing
50225021
public abstract Akka.Actor.ActorBase CreateRouterActor();
50235022
public bool Equals(Akka.Routing.RouterConfig other) { }
50245023
public override bool Equals(object obj) { }
5024+
public override int GetHashCode() { }
50255025
public virtual bool IsManagementMessage(object message) { }
50265026
public virtual Akka.Actor.Props RoutingLogicController(Akka.Routing.RoutingLogic routingLogic) { }
50275027
public abstract Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ namespace Akka.Persistence.Journal
931931
public System.Collections.Generic.IEnumerable<object> Events { get; }
932932
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
933933
public override bool Equals(object obj) { }
934+
public override int GetHashCode() { }
934935
}
935936
public class EventAdapters
936937
{
@@ -952,6 +953,7 @@ namespace Akka.Persistence.Journal
952953
public System.Collections.Generic.IEnumerable<object> Events { get; }
953954
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
954955
public override bool Equals(object obj) { }
956+
public override int GetHashCode() { }
955957
}
956958
public interface IAsyncRecovery
957959
{
@@ -1121,6 +1123,7 @@ namespace Akka.Persistence.Journal
11211123
public System.Collections.Generic.IEnumerable<object> Events { get; }
11221124
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
11231125
public override bool Equals(object obj) { }
1126+
public override int GetHashCode() { }
11241127
}
11251128
public struct Tagged
11261129
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ namespace Akka.Persistence.Journal
931931
public System.Collections.Generic.IEnumerable<object> Events { get; }
932932
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
933933
public override bool Equals(object obj) { }
934+
public override int GetHashCode() { }
934935
}
935936
public class EventAdapters
936937
{
@@ -952,6 +953,7 @@ namespace Akka.Persistence.Journal
952953
public System.Collections.Generic.IEnumerable<object> Events { get; }
953954
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
954955
public override bool Equals(object obj) { }
956+
public override int GetHashCode() { }
955957
}
956958
public interface IAsyncRecovery
957959
{
@@ -1121,6 +1123,7 @@ namespace Akka.Persistence.Journal
11211123
public System.Collections.Generic.IEnumerable<object> Events { get; }
11221124
public bool Equals(Akka.Persistence.Journal.IEventSequence other) { }
11231125
public override bool Equals(object obj) { }
1126+
public override int GetHashCode() { }
11241127
}
11251128
public struct Tagged
11261129
{

src/core/Akka.Coordination/LeaseTimeoutException.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,5 @@ public LeaseTimeoutException(string message, Exception innerEx)
3232
: base(message, innerEx)
3333
{
3434
}
35-
36-
protected LeaseTimeoutException(SerializationInfo info, StreamingContext context)
37-
: base(info, context)
38-
{
39-
40-
}
4135
}
4236
}

0 commit comments

Comments
 (0)