Skip to content

Commit

Permalink
structs in Akka.Streams with exclusively read-only members were m…
Browse files Browse the repository at this point in the history
…ade `readonly` (#6941)

* `struct`s with exclusively read-only members were made `readonly`

* added API approvals

---------

Co-authored-by: Lehonti Ramos <lehonti@ramos>
Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
Co-authored-by: Aaron Stannard <aaron@petabridge.com>
  • Loading branch information
4 people authored Jan 4, 2024
1 parent fd41a82 commit 0486f97
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ namespace Akka.Streams
public static Akka.Streams.IGraph<Akka.Streams.FlowShape<T, T>, Akka.Streams.UniqueKillSwitch> Single<T>() { }
public static Akka.Streams.IGraph<Akka.Streams.BidiShape<T1, T1, T2, T2>, Akka.Streams.UniqueKillSwitch> SingleBidi<T1, T2>() { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct MaterializationContext
{
public readonly Akka.Streams.Attributes EffectiveAttributes;
Expand Down Expand Up @@ -2361,6 +2362,7 @@ namespace Akka.Streams.Dsl
{
public Tcp() { }
public override Akka.Streams.Dsl.TcpExt CreateExtension(Akka.Actor.ExtendedActorSystem system) { }
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct IncomingConnection
{
public readonly Akka.Streams.Dsl.Flow<Akka.IO.ByteString, Akka.IO.ByteString, Akka.NotUsed> Flow;
Expand All @@ -2369,12 +2371,14 @@ namespace Akka.Streams.Dsl
public IncomingConnection(System.Net.EndPoint localAddress, System.Net.EndPoint remoteAddress, Akka.Streams.Dsl.Flow<Akka.IO.ByteString, Akka.IO.ByteString, Akka.NotUsed> flow) { }
public TMat HandleWith<TMat>(Akka.Streams.Dsl.Flow<Akka.IO.ByteString, Akka.IO.ByteString, TMat> handler, Akka.Streams.IMaterializer materializer) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OutgoingConnection
{
public readonly System.Net.EndPoint LocalAddress;
public readonly System.Net.EndPoint RemoteAddress;
public OutgoingConnection(System.Net.EndPoint remoteAddress, System.Net.EndPoint localAddress) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct ServerBinding
{
public readonly System.Net.EndPoint LocalAddress;
Expand Down Expand Up @@ -2753,6 +2757,7 @@ namespace Akka.Streams.IO
public AbruptIOTerminationException(Akka.Streams.IO.IOResult ioResult, System.Exception cause) { }
public Akka.Streams.IO.IOResult IoResult { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct IOResult
{
public readonly long Count;
Expand Down Expand Up @@ -3034,23 +3039,27 @@ namespace Akka.Streams.Implementation
public const byte Depleted = 4;
public const byte Marked = 1;
public const byte Pending = 2;
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnComplete : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly int Id;
public OnComplete(int id) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnError : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly System.Exception Cause;
public readonly int Id;
public OnError(int id, System.Exception cause) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnNext : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly object Element;
public readonly int Id;
public OnNext(int id, object element) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnSubscribe : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly int Id;
Expand Down Expand Up @@ -3080,6 +3089,7 @@ namespace Akka.Streams.Implementation
public void PumpFinished() { }
protected override bool Receive(object message) { }
public void WaitForUpstream(int waitForUpstream) { }
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct SubInput<T> : Reactive.Streams.ISubscriber<T>
{
public SubInput(Akka.Actor.IActorRef impl, int id) { }
Expand All @@ -3092,22 +3102,26 @@ namespace Akka.Streams.Implementation
[Akka.Annotations.InternalApiAttribute()]
public class static FanOut
{
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct ExposedPublishers<T> : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly System.Collections.Immutable.ImmutableList<Akka.Streams.Implementation.ActorPublisher<T>> Publishers;
public ExposedPublishers(System.Collections.Immutable.ImmutableList<Akka.Streams.Implementation.ActorPublisher<T>> publishers) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct SubstreamCancel : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly int Id;
public SubstreamCancel(int id) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct SubstreamRequestMore : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly long Demand;
public readonly int Id;
public SubstreamRequestMore(int id, long demand) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct SubstreamSubscribePending : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
public readonly int Id;
Expand Down Expand Up @@ -3820,6 +3834,7 @@ namespace Akka.Streams.Implementation
public const string GraphStageLogicTimer = "GraphStageLogicTimer";
public static System.TimeSpan IdleTimeoutCheckInterval(System.TimeSpan timeout) { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct TransferPhase
{
public readonly System.Action Action;
Expand Down Expand Up @@ -3910,19 +3925,19 @@ namespace Akka.Streams.Implementation.Fusing
public static Akka.Actor.Props Props(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell) { }
protected override bool Receive(object message) { }
public Akka.Actor.IActorRef RegisterShell(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell) { }
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct Abort : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public Abort(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct AsyncInput : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly object Event;
public readonly System.Action<object> Handler;
public readonly Akka.Streams.Stage.GraphStageLogic Logic;
public AsyncInput(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, Akka.Streams.Stage.GraphStageLogic logic, object @event, System.Action<object> handler) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
public class BatchingActorInputBoundary : Akka.Streams.Implementation.Fusing.GraphInterpreter.UpstreamBoundaryStageLogic
Expand Down Expand Up @@ -3958,77 +3973,76 @@ namespace Akka.Streams.Implementation.Fusing
public void Request(long elements) { }
public override string ToString() { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct Cancel : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly int Id;
public Cancel(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, System.Exception cause) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public System.Exception Cause { get; }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct ExposedPublisher : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly int Id;
public readonly Akka.Streams.Implementation.IActorPublisher Publisher;
public ExposedPublisher(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, Akka.Streams.Implementation.IActorPublisher publisher) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
public interface IBoundaryEvent : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression
{
Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnComplete : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly int Id;
public OnComplete(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnError : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly System.Exception Cause;
public readonly int Id;
public OnError(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, System.Exception cause) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnNext : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly object Event;
public readonly int Id;
public OnNext(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, object @event) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct OnSubscribe : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly int Id;
public readonly Reactive.Streams.ISubscription Subscription;
public OnSubscribe(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, Reactive.Streams.ISubscription subscription) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct RequestMore : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly long Demand;
public readonly int Id;
public RequestMore(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id, long demand) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct Resume : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public Resume(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct SubscribePending : Akka.Actor.INoSerializationVerificationNeeded, Akka.Event.IDeadLetterSuppression, Akka.Streams.Implementation.Fusing.ActorGraphInterpreter.IBoundaryEvent
{
public readonly int Id;
public SubscribePending(Akka.Streams.Implementation.Fusing.GraphInterpreterShell shell, int id) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Implementation.Fusing.GraphInterpreterShell Shell { get; }
}
}
Expand Down Expand Up @@ -5074,12 +5088,11 @@ namespace Akka.Streams.Stage
public virtual void OnUpstreamFailure(System.Exception e) { }
public virtual void OnUpstreamFinish() { }
}
[System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public struct LogicAndMaterializedValue<TMaterialized> : Akka.Streams.Stage.ILogicAndMaterializedValue<TMaterialized>
{
public LogicAndMaterializedValue(Akka.Streams.Stage.GraphStageLogic logic, TMaterialized materializedValue) { }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public Akka.Streams.Stage.GraphStageLogic Logic { get; }
[get: System.Runtime.CompilerServices.IsReadOnlyAttribute()]
public TMaterialized MaterializedValue { get; }
}
public abstract class OutGraphStageLogic : Akka.Streams.Stage.GraphStageLogic, Akka.Streams.Stage.IOutHandler
Expand Down
6 changes: 3 additions & 3 deletions src/core/Akka.Streams/Dsl/Tcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Tcp : ExtensionIdProvider<TcpExt>
/// <summary>
/// Represents a successful TCP server binding.
/// </summary>
public struct ServerBinding
public readonly struct ServerBinding
{
private readonly Func<Task> _unbindAction;

Expand Down Expand Up @@ -63,7 +63,7 @@ public ServerBinding(EndPoint localAddress, Func<Task> unbindAction)
/// <summary>
/// Represents an accepted incoming TCP connection.
/// </summary>
public struct IncomingConnection
public readonly struct IncomingConnection
{
/// <summary>
/// Initializes a new instance of the <see cref="IncomingConnection"/> class.
Expand Down Expand Up @@ -110,7 +110,7 @@ public TMat HandleWith<TMat>(Flow<ByteString, ByteString, TMat> handler, IMateri
/// <summary>
/// Represents a prospective outgoing TCP connection.
/// </summary>
public struct OutgoingConnection
public readonly struct OutgoingConnection
{
/// <summary>
/// Initializes a new instance of the <see cref="OutgoingConnection"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/IMaterializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public MessageDispatcher ExecutionContext
/// <summary>
/// Context parameter to the create methods of sources and sinks.
/// </summary>
public struct MaterializationContext
public readonly struct MaterializationContext
{
/// <summary>
/// TBD
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/IO/IOResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Akka.Streams.IO
/// Holds a result of an IO operation.
/// </summary>
// ReSharper disable once InconsistentNaming
public struct IOResult
public readonly struct IOResult
{
private readonly Result<NotUsed> _status;

Expand Down
10 changes: 5 additions & 5 deletions src/core/Akka.Streams/Implementation/FanIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public static class FanIn
/// TBD
/// </summary>
[Serializable]
public struct OnError : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct OnError : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand All @@ -452,7 +452,7 @@ public OnError(int id, Exception cause)
/// TBD
/// </summary>
[Serializable]
public struct OnComplete : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct OnComplete : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand All @@ -473,7 +473,7 @@ public OnComplete(int id)
/// TBD
/// </summary>
[Serializable]
public struct OnNext : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct OnNext : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand All @@ -500,7 +500,7 @@ public OnNext(int id, object element)
/// TBD
/// </summary>
[Serializable]
public struct OnSubscribe : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct OnSubscribe : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -557,7 +557,7 @@ public abstract class FanIn<T> : ActorBase, IPump
/// <summary>
/// TBD
/// </summary>
public struct SubInput : ISubscriber<T>
public readonly struct SubInput : ISubscriber<T>
{
private readonly IActorRef _impl;
private readonly int _id;
Expand Down
8 changes: 4 additions & 4 deletions src/core/Akka.Streams/Implementation/FanOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public static class FanOut
/// TBD
/// </summary>
[Serializable]
public struct SubstreamRequestMore : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct SubstreamRequestMore : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand All @@ -442,7 +442,7 @@ public SubstreamRequestMore(int id, long demand)
/// TBD
/// </summary>
[Serializable]
public struct SubstreamCancel : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct SubstreamCancel : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand All @@ -463,7 +463,7 @@ public SubstreamCancel(int id)
/// TBD
/// </summary>
[Serializable]
public struct SubstreamSubscribePending : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct SubstreamSubscribePending : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -519,7 +519,7 @@ public SubstreamSubscription(IActorRef parent, int id)
/// </summary>
/// <typeparam name="T">TBD</typeparam>
[Serializable]
public struct ExposedPublishers<T> : INoSerializationVerificationNeeded, IDeadLetterSuppression
public readonly struct ExposedPublishers<T> : INoSerializationVerificationNeeded, IDeadLetterSuppression
{
/// <summary>
/// TBD
Expand Down
Loading

0 comments on commit 0486f97

Please sign in to comment.