Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ namespace Akka.Actor
}
public class static ActorRefExtensions
{
public static Akka.Actor.IActorRef GetOrElse(this Akka.Actor.IActorRef actorRef, System.Func<Akka.Actor.IActorRef> elseValue) { }
public static Akka.Actor.IActorRef GetOrElse([System.Runtime.CompilerServices.NullableAttribute(2)] this Akka.Actor.IActorRef actorRef, System.Func<Akka.Actor.IActorRef> elseValue) { }
public static bool IsNobody(this Akka.Actor.IActorRef actorRef) { }
}
public class static ActorRefFactoryExtensions
Expand Down Expand Up @@ -1409,15 +1409,10 @@ namespace Akka.Actor
}
public sealed class Nobody : Akka.Actor.MinimalActorRef
{
public static Akka.Actor.Nobody Instance;
public static readonly Akka.Actor.Nobody Instance;
Copy link
Member Author

Choose a reason for hiding this comment

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

Never should have been mutable

public override Akka.Actor.ActorPath Path { get; }
public override Akka.Actor.IActorRefProvider Provider { get; }
public override Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system) { }
public class NobodySurrogate : Akka.Util.ISurrogate
Copy link
Member Author

Choose a reason for hiding this comment

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

Never needed to be part of the public API - just the ISurrogate interface is enough.

{
public NobodySurrogate() { }
public Akka.Util.ISurrogated FromSurrogate(Akka.Actor.ActorSystem system) { }
}
}
public class OneForOneStrategy : Akka.Actor.SupervisorStrategy, System.IEquatable<Akka.Actor.OneForOneStrategy>
{
Expand Down Expand Up @@ -3175,19 +3170,23 @@ namespace Akka.Dispatch.MessageQueues
}
namespace Akka.Dispatch.SysMsg
{
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class ActorTask : Akka.Dispatch.SysMsg.SystemMessage
{
public ActorTask(System.Threading.Tasks.Task task) { }
public System.Threading.Tasks.Task Task { get; }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Create : Akka.Dispatch.SysMsg.SystemMessage
{
public Create(Akka.Actor.ActorInitializationException failure = null) { }
[System.Runtime.CompilerServices.NullableAttribute(2)]
public Akka.Actor.ActorInitializationException Failure { get; }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class DeathWatchNotification : Akka.Dispatch.SysMsg.SystemMessage, Akka.Event.IDeadLetterSuppression
{
public DeathWatchNotification(Akka.Actor.IActorRef actor, bool existenceConfirmed, bool addressTerminated) { }
Expand All @@ -3196,13 +3195,15 @@ namespace Akka.Dispatch.SysMsg
public bool ExistenceConfirmed { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Escalate : Akka.Dispatch.SysMsg.SystemMessage
{
public Escalate(System.Exception reason) { }
public System.Exception Reason { get; }
public override string ToString() { }
}
[Akka.Annotations.InternalApiAttribute()]
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Failed : Akka.Dispatch.SysMsg.SystemMessage
{
public Failed(Akka.Actor.IActorRef child, System.Exception cause, long uid) { }
Expand All @@ -3217,17 +3218,20 @@ namespace Akka.Dispatch.SysMsg
public NoMessage() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Recreate : Akka.Dispatch.SysMsg.SystemMessage
{
public Recreate(System.Exception cause) { }
public System.Exception Cause { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class RegisterTerminationHook
{
public static Akka.Dispatch.SysMsg.RegisterTerminationHook Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Resume : Akka.Dispatch.SysMsg.SystemMessage
{
public Resume(System.Exception causedByFailure) { }
Expand All @@ -3239,12 +3243,14 @@ namespace Akka.Dispatch.SysMsg
public Stop() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class StopChild
{
public StopChild(Akka.Actor.IActorRef child) { }
public Akka.Actor.IActorRef Child { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Supervise : Akka.Dispatch.SysMsg.SystemMessage
{
public Supervise(Akka.Actor.IActorRef child, bool async) { }
Expand All @@ -3269,16 +3275,19 @@ namespace Akka.Dispatch.SysMsg
public Terminate() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class TerminationHook
{
public static Akka.Dispatch.SysMsg.TerminationHook Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class TerminationHookDone
{
public static Akka.Dispatch.SysMsg.TerminationHookDone Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Unwatch : Akka.Dispatch.SysMsg.SystemMessage
{
public Unwatch(Akka.Actor.IInternalActorRef watchee, Akka.Actor.IInternalActorRef watcher) { }
Expand All @@ -3288,12 +3297,13 @@ namespace Akka.Dispatch.SysMsg
public override int GetHashCode() { }
public override string ToString() { }
}
public class Watch : Akka.Dispatch.SysMsg.SystemMessage
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Watch : Akka.Dispatch.SysMsg.SystemMessage
{
public Watch(Akka.Actor.IInternalActorRef watchee, Akka.Actor.IInternalActorRef watcher) { }
public Akka.Actor.IInternalActorRef Watchee { get; }
public Akka.Actor.IInternalActorRef Watcher { get; }
protected bool Equals(Akka.Dispatch.SysMsg.Watch other) { }
public bool Equals(Akka.Dispatch.SysMsg.Watch other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ namespace Akka.Actor
}
public class static ActorRefExtensions
{
public static Akka.Actor.IActorRef GetOrElse(this Akka.Actor.IActorRef actorRef, System.Func<Akka.Actor.IActorRef> elseValue) { }
public static Akka.Actor.IActorRef GetOrElse([System.Runtime.CompilerServices.NullableAttribute(2)] this Akka.Actor.IActorRef actorRef, System.Func<Akka.Actor.IActorRef> elseValue) { }
public static bool IsNobody(this Akka.Actor.IActorRef actorRef) { }
}
public class static ActorRefFactoryExtensions
Expand Down Expand Up @@ -1407,15 +1407,10 @@ namespace Akka.Actor
}
public sealed class Nobody : Akka.Actor.MinimalActorRef
{
public static Akka.Actor.Nobody Instance;
public static readonly Akka.Actor.Nobody Instance;
public override Akka.Actor.ActorPath Path { get; }
public override Akka.Actor.IActorRefProvider Provider { get; }
public override Akka.Util.ISurrogate ToSurrogate(Akka.Actor.ActorSystem system) { }
public class NobodySurrogate : Akka.Util.ISurrogate
{
public NobodySurrogate() { }
public Akka.Util.ISurrogated FromSurrogate(Akka.Actor.ActorSystem system) { }
}
}
public class OneForOneStrategy : Akka.Actor.SupervisorStrategy, System.IEquatable<Akka.Actor.OneForOneStrategy>
{
Expand Down Expand Up @@ -3167,19 +3162,23 @@ namespace Akka.Dispatch.MessageQueues
}
namespace Akka.Dispatch.SysMsg
{
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class ActorTask : Akka.Dispatch.SysMsg.SystemMessage
{
public ActorTask(System.Threading.Tasks.Task task) { }
public System.Threading.Tasks.Task Task { get; }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Create : Akka.Dispatch.SysMsg.SystemMessage
{
public Create(Akka.Actor.ActorInitializationException failure = null) { }
[System.Runtime.CompilerServices.NullableAttribute(2)]
public Akka.Actor.ActorInitializationException Failure { get; }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class DeathWatchNotification : Akka.Dispatch.SysMsg.SystemMessage, Akka.Event.IDeadLetterSuppression
{
public DeathWatchNotification(Akka.Actor.IActorRef actor, bool existenceConfirmed, bool addressTerminated) { }
Expand All @@ -3188,13 +3187,15 @@ namespace Akka.Dispatch.SysMsg
public bool ExistenceConfirmed { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Escalate : Akka.Dispatch.SysMsg.SystemMessage
{
public Escalate(System.Exception reason) { }
public System.Exception Reason { get; }
public override string ToString() { }
}
[Akka.Annotations.InternalApiAttribute()]
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Failed : Akka.Dispatch.SysMsg.SystemMessage
{
public Failed(Akka.Actor.IActorRef child, System.Exception cause, long uid) { }
Expand All @@ -3209,17 +3210,20 @@ namespace Akka.Dispatch.SysMsg
public NoMessage() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Recreate : Akka.Dispatch.SysMsg.SystemMessage
{
public Recreate(System.Exception cause) { }
public System.Exception Cause { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class RegisterTerminationHook
{
public static Akka.Dispatch.SysMsg.RegisterTerminationHook Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Resume : Akka.Dispatch.SysMsg.SystemMessage
{
public Resume(System.Exception causedByFailure) { }
Expand All @@ -3231,12 +3235,14 @@ namespace Akka.Dispatch.SysMsg
public Stop() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class StopChild
{
public StopChild(Akka.Actor.IActorRef child) { }
public Akka.Actor.IActorRef Child { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Supervise : Akka.Dispatch.SysMsg.SystemMessage
{
public Supervise(Akka.Actor.IActorRef child, bool async) { }
Expand All @@ -3261,16 +3267,19 @@ namespace Akka.Dispatch.SysMsg
public Terminate() { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class TerminationHook
{
public static Akka.Dispatch.SysMsg.TerminationHook Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class TerminationHookDone
{
public static Akka.Dispatch.SysMsg.TerminationHookDone Instance { get; }
public override string ToString() { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Unwatch : Akka.Dispatch.SysMsg.SystemMessage
{
public Unwatch(Akka.Actor.IInternalActorRef watchee, Akka.Actor.IInternalActorRef watcher) { }
Expand All @@ -3280,12 +3289,13 @@ namespace Akka.Dispatch.SysMsg
public override int GetHashCode() { }
public override string ToString() { }
}
public class Watch : Akka.Dispatch.SysMsg.SystemMessage
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class Watch : Akka.Dispatch.SysMsg.SystemMessage
{
public Watch(Akka.Actor.IInternalActorRef watchee, Akka.Actor.IInternalActorRef watcher) { }
public Akka.Actor.IInternalActorRef Watchee { get; }
public Akka.Actor.IInternalActorRef Watcher { get; }
protected bool Equals(Akka.Dispatch.SysMsg.Watch other) { }
public bool Equals(Akka.Dispatch.SysMsg.Watch other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ namespace Akka.Remote.Serialization
public override object FromBinary(byte[] bytes, System.Type type) { }
public override byte[] ToBinary(object obj) { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class SystemMessageSerializer : Akka.Serialization.Serializer
{
public SystemMessageSerializer(Akka.Actor.ExtendedActorSystem system) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ namespace Akka.Remote.Serialization
public override object FromBinary(byte[] bytes, System.Type type) { }
public override byte[] ToBinary(object obj) { }
}
[System.Runtime.CompilerServices.NullableAttribute(0)]
public sealed class SystemMessageSerializer : Akka.Serialization.Serializer
{
public SystemMessageSerializer(Akka.Actor.ExtendedActorSystem system) { }
Expand Down
29 changes: 16 additions & 13 deletions src/core/Akka.Remote/Serialization/ExceptionSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

#nullable enable
using System;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -22,8 +22,8 @@ internal sealed class ExceptionSupport
{
private readonly WrappedPayloadSupport _wrappedPayloadSupport;
private const BindingFlags All = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
private readonly HashSet<string> _defaultProperties = new()
{
private readonly HashSet<string> _defaultProperties =
[
"ClassName",
"Message",
"StackTraceString",
Expand All @@ -39,7 +39,7 @@ internal sealed class ExceptionSupport
"HelpLink",
"StackTrace",
"WatsonBuckets"
};
];

public ExceptionSupport(ExtendedActorSystem system)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ internal Exception ExceptionFromProto(Proto.Msg.ExceptionData proto)

private readonly FormatterConverter _defaultFormatterConverter = new();

public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception exception)
public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception? exception)
{
var message = new Proto.Msg.ExceptionData();

Expand All @@ -82,14 +82,15 @@ public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception exception)
message.Message = exception.Message;
message.StackTrace = exception.StackTrace ?? "";
message.Source = exception.Source ?? "";
message.InnerException = ExceptionToProto(exception.InnerException);
if(exception.InnerException != null)
message.InnerException = ExceptionToProto(exception.InnerException);

var forwardedFrom = exceptionType.GetCustomAttribute<TypeForwardedFromAttribute>();
message.TypeForwardedFrom = forwardedFrom is not null
? forwardedFrom.AssemblyFullName[..forwardedFrom.AssemblyFullName.IndexOf(',')]
: string.Empty;

var serializable = exception as ISerializable;
ISerializable serializable = exception;
var serializationInfo = new SerializationInfo(exceptionType, _defaultFormatterConverter);
serializable.GetObjectData(serializationInfo, new StreamingContext());

Expand All @@ -110,11 +111,13 @@ public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception exception)

return message;
}

private static readonly Exception CouldNotBeDeserialized = new("Could not deserialize exception");

public Exception ExceptionFromProtoNet(Proto.Msg.ExceptionData proto)
{
if (string.IsNullOrEmpty(proto.TypeName))
return null;
return CouldNotBeDeserialized;

var exceptionType = Type.GetType(proto.TypeName);

Expand Down Expand Up @@ -151,11 +154,11 @@ public Exception ExceptionFromProtoNet(Proto.Msg.ExceptionData proto)
serializationInfo.AddValue(field.Key, payload);
}

Exception obj = null;
ConstructorInfo constructorInfo = exceptionType.GetConstructor(
Exception? obj = null;
var constructorInfo = exceptionType.GetConstructor(
All,
null,
new[] { typeof(SerializationInfo), typeof(StreamingContext) },
[typeof(SerializationInfo), typeof(StreamingContext)],
null);

if (constructorInfo != null)
Expand All @@ -164,10 +167,10 @@ public Exception ExceptionFromProtoNet(Proto.Msg.ExceptionData proto)
obj = constructorInfo.Invoke(args).AsInstanceOf<Exception>();
}

return obj;
return obj ?? CouldNotBeDeserialized;
}

private static string ValueOrNull(string value)
private static string? ValueOrNull(string? value)
=> string.IsNullOrEmpty(value) ? null : value;
}
}
Loading
Loading