Skip to content

Commit b5ac7ef

Browse files
authored
use some compound statements (#6814)
1 parent abae81c commit b5ac7ef

31 files changed

+41
-45
lines changed

src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/MultiNodeClusterShardingSpec.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public PingPongActor()
8484
}
8585

8686
private ILoggingAdapter _log;
87-
private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
87+
private ILoggingAdapter Log => _log ??= Context.GetLogger();
8888

8989
protected override bool Receive(object message)
9090
{

src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/RollingUpdateShardAllocationSpec.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public Home(Address address)
9191
};
9292

9393
private ILoggingAdapter _log;
94-
private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
94+
private ILoggingAdapter Log => _log ??= Context.GetLogger();
9595

9696
private Address SelfAddress => Cluster.Get(Context.System).SelfAddress;
9797

src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ public static Props Props(
14881488
private readonly bool _isRebalance;
14891489
private ILoggingAdapter _log;
14901490

1491-
private ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
1491+
private ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }
14921492

14931493
public ITimerScheduler Timers { get; set; }
14941494

src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static Props Props(DistributedPubSubSettings settings)
126126
/// <summary>
127127
/// TBD
128128
/// </summary>
129-
public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
129+
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }
130130

131131
/// <summary>
132132
/// TBD

src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public ValueHolder(long version, IActorRef @ref)
159159
/// <summary>
160160
/// TBD
161161
/// </summary>
162-
public Routee Routee { get { return _routee ?? (_routee = Ref != null ? new ActorRefRoutee(Ref) : null); } }
162+
public Routee Routee { get { return _routee ??= Ref != null ? new ActorRefRoutee(Ref) : null; } }
163163

164164
/// <inheritdoc/>
165165
public bool Equals(ValueHolder other)

src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ private void SetupCoordinatedShutdown()
707707
});
708708
}
709709

710-
private ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
710+
private ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }
711711

712712
/// <inheritdoc cref="ActorBase.PreStart"/>
713713
protected override void PreStart()

src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public ClusterSingletonProxy(string singletonManagerPath, ClusterSingletonProxyS
162162
});
163163
}
164164

165-
private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
165+
private ILoggingAdapter Log => _log ??= Context.GetLogger();
166166

167167
/// <summary>
168168
/// TBD

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private SendToSecondary() { }
3636

3737
private ILoggingAdapter _log;
3838

39-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
39+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
4040

4141
protected abstract int DoneWhenRemainingSize { get; }
4242

src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected AbstractAllEventsPublisher(int fromOffset, int maxBufferSize, string w
4444
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
4545
}
4646

47-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
47+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
4848
protected IActorRef JournalRef { get; }
4949
protected DeliveryBuffer<EventEnvelope> Buffer { get; }
5050
protected int FromOffset { get; }

src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected AbstractEventsByPersistenceIdPublisher(string persistenceId, long from
5252
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
5353
}
5454

55-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
55+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
5656
protected string PersistenceId { get; }
5757
protected long FromSequenceNr { get; }
5858
protected long ToSequenceNr { get; set; }

src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected AbstractEventsByTagPublisher(string tag, int fromOffset, int maxBuffer
5151
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
5252
}
5353

54-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
54+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
5555
protected string Tag { get; }
5656
protected int FromOffset { get; }
5757
protected abstract int ToOffset { get; }

src/core/Akka.Cluster/SBR/SplitBrainResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected SplitBrainResolverBase(TimeSpan stableAfter, DowningStrategy strategy)
9999

100100
public DowningStrategy Strategy { get; }
101101

102-
public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
102+
public ILoggingAdapter Log => _log ??= Context.GetLogger();
103103

104104
public abstract UniqueAddress SelfUniqueAddress { get; }
105105

src/core/Akka.Cluster/SplitBrainResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public SplitBrainDecider(TimeSpan stableAfter, ISplitBrainStrategy strategy, Clu
264264
_cluster = cluster;
265265
}
266266

267-
public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
267+
public ILoggingAdapter Log => _log ??= Context.GetLogger();
268268

269269
protected override void PreStart()
270270
{

src/core/Akka.Coordination/LeaseProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static LeaseProvider Get(ActorSystem system)
8787

8888
private ILoggingAdapter _log;
8989

90-
private ILoggingAdapter Log { get { return _log ?? (_log = Logging.GetLogger(_system, "LeaseProvider")); } }
90+
private ILoggingAdapter Log { get { return _log ??= Logging.GetLogger(_system, "LeaseProvider"); } }
9191

9292
/// <summary>
9393
/// Initializes a new instance of the <see cref="LeaseProvider"/> class.

src/core/Akka.Persistence.Query/PersistenceQuery.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static PersistenceQuery Get(ActorSystem system)
2525
return system.WithExtension<PersistenceQuery, PersistenceQueryProvider>();
2626
}
2727

28-
public ILoggingAdapter Log => _log ?? (_log = _system.Log);
28+
public ILoggingAdapter Log => _log ??= _system.Log;
2929

3030
public PersistenceQuery(ExtendedActorSystem system)
3131
{

src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal class CrashingActor : AtLeastOnceDeliveryActor
7474
private readonly IActorRef _testProbe;
7575
private ILoggingAdapter _adapter;
7676

77-
ILoggingAdapter Log { get { return _adapter ?? (_adapter = Context.GetLogger()); } }
77+
ILoggingAdapter Log { get { return _adapter ??= Context.GetLogger(); } }
7878

7979
public CrashingActor(IActorRef testProbe)
8080
{

src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ internal class ChaosSender : AtLeastOnceDeliveryActor
134134
private readonly double _replayProcessingFailureRate;
135135
private ILoggingAdapter _log;
136136

137-
public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); }}
137+
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); }}
138138

139139
public ChaosSender(IActorRef destination, IActorRef probe)
140140
: base(x => x.WithRedeliverInterval(TimeSpan.FromMilliseconds(500)))
@@ -242,7 +242,7 @@ internal class ChaosDestination : ReceiveActor, IChaosSupport
242242
private readonly double _confirmFailureRate;
243243
private ILoggingAdapter _log;
244244

245-
public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
245+
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }
246246

247247
public ChaosDestination(IActorRef probe)
248248
{

src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private StateFunction HandleEventDefault
398398

399399
private StateFunction HandleEvent
400400
{
401-
get { return _handleEvent ?? (_handleEvent = HandleEventDefault); }
401+
get { return _handleEvent ??= HandleEventDefault; }
402402
set { _handleEvent = value; }
403403
}
404404

src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ protected override Props ManagerProps
140140
{
141141
get
142142
{
143-
return _managerProps ??
144-
(_managerProps =
145-
Props.Create(() => new AkkaProtocolManager(WrappedTransport, Settings))
146-
.WithDeploy(Deploy.Local));
143+
return _managerProps ??= Props.Create(() => new AkkaProtocolManager(WrappedTransport, Settings))
144+
.WithDeploy(Deploy.Local);
147145
}
148146
}
149147

src/core/Akka.Streams/Implementation/ActorProcessor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ protected ActorProcessorImpl(ActorMaterializerSettings settings)
619619
/// <summary>
620620
/// TBD
621621
/// </summary>
622-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
622+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
623623

624624
/// <summary>
625625
/// TBD

src/core/Akka.Streams/Implementation/ActorRefSourceActor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ActorRefSourceActor(int bufferSize, OverflowStrategy overflowStrategy, in
6868
/// <summary>
6969
/// TBD
7070
/// </summary>
71-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
71+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
7272

7373
/// <summary>
7474
/// TBD

src/core/Akka.Streams/Implementation/FanIn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ protected FanIn(ActorMaterializerSettings settings, int inputCount)
666666
/// <summary>
667667
/// TBD
668668
/// </summary>
669-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
669+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
670670
private ILoggingAdapter _log;
671671

672672
/// <summary>

src/core/Akka.Streams/Implementation/FanOut.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ protected FanOut(ActorMaterializerSettings settings, int outputCount)
590590
/// <summary>
591591
/// TBD
592592
/// </summary>
593-
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
593+
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
594594
private ILoggingAdapter _log;
595595

596596
/// <summary>

src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ public GraphInterpreterShell(GraphAssembly assembly, Connection[] connections, G
185185
/// <summary>
186186
/// TBD
187187
/// </summary>
188-
public ILoggingAdapter Log => _log ?? (_log = GetLogger());
188+
public ILoggingAdapter Log => _log ??= GetLogger();
189189
/// <summary>
190190
/// TBD
191191
/// </summary>
192-
public GraphInterpreter Interpreter => _interpreter ?? (_interpreter = GetInterpreter());
192+
public GraphInterpreter Interpreter => _interpreter ??= GetInterpreter();
193193

194194
/// <summary>
195195
/// TBD
@@ -1358,7 +1358,7 @@ public ActorGraphInterpreter(GraphInterpreterShell shell)
13581358
/// <summary>
13591359
/// TBD
13601360
/// </summary>
1361-
public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
1361+
public ILoggingAdapter Log => _log ??= Context.GetLogger();
13621362

13631363
private void EnqueueToShortCircuit(object input)
13641364
{

src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ private string QueueStatus()
505505
/// <summary>
506506
/// TBD
507507
/// </summary>
508-
internal string Name => _name ?? (_name = GetHashCode().ToString("x"));
508+
internal string Name => _name ??= GetHashCode().ToString("x");
509509

510510
/// <summary>
511511
/// Assign the boundary logic to a given connection. This will serve as the interface to the external world

src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ private sealed class Logic : TimerGraphStageLogic, IInHandler
7878
private StreamRefAttributes.SubscriptionTimeout _subscriptionTimeout;
7979
private string _stageActorName;
8080

81-
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ?? (_streamRefsMaster = StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System));
82-
private StreamRefSettings Settings => _settings ?? (_settings = ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings);
83-
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ?? (_subscriptionTimeout =
84-
_inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout)));
85-
protected override string StageActorName => _stageActorName ?? (_stageActorName = StreamRefsMaster.NextSinkRefName());
81+
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ??= StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System);
82+
private StreamRefSettings Settings => _settings ??= ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings;
83+
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ??= _inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout));
84+
protected override string StageActorName => _stageActorName ??= StreamRefsMaster.NextSinkRefName();
8685

8786
private StageActor _stageActor;
8887

src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ private sealed class Logic : TimerGraphStageLogic, IOutHandler
8888
private StageActor _stageActor;
8989
private IActorRef _partnerRef = null;
9090

91-
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ?? (_streamRefsMaster = StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System));
92-
private StreamRefSettings Settings => _settings ?? (_settings = ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings);
93-
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ?? (_subscriptionTimeout =
94-
_inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout)));
95-
protected override string StageActorName => _stageActorName ?? (_stageActorName = StreamRefsMaster.NextSourceRefName());
91+
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ??= StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System);
92+
private StreamRefSettings Settings => _settings ??= ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings;
93+
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ??= _inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout));
94+
protected override string StageActorName => _stageActorName ??= StreamRefsMaster.NextSourceRefName();
9695

9796
public IActorRef Self => _stageActor.Ref;
9897
public IActorRef PartnerRef

src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract partial class ActorBase
1818
/// </summary>
1919
internal SupervisorStrategy SupervisorStrategyInternal
2020
{
21-
get { return _supervisorStrategy ?? (_supervisorStrategy = SupervisorStrategy()); }
21+
get { return _supervisorStrategy ??= SupervisorStrategy(); }
2222
set { _supervisorStrategy = value; }
2323
}
2424

src/core/Akka/Actor/FSM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ private StateFunction HandleEventDefault
10641064

10651065
private StateFunction HandleEvent
10661066
{
1067-
get { return _handleEvent ?? (_handleEvent = HandleEventDefault); }
1067+
get { return _handleEvent ??= HandleEventDefault; }
10681068
set { _handleEvent = value; }
10691069
}
10701070

src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AkkaConfigurationSection : ConfigurationSection
3636
/// </summary>
3737
public Config AkkaConfig
3838
{
39-
get { return _akkaConfig ?? (_akkaConfig = ConfigurationFactory.ParseString(Hocon.Content)); }
39+
get { return _akkaConfig ??= ConfigurationFactory.ParseString(Hocon.Content); }
4040
}
4141

4242
/// <summary>

src/core/Akka/Routing/ConsistentHash.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ConsistentHash(SortedDictionary<int, T> nodes, int virtualNodesFactor)
5050
private (int[], T[])? _ring = null;
5151
private (int[], T[])? RingTuple
5252
{
53-
get { return _ring ?? (_ring = (_nodes.Keys.ToArray(), _nodes.Values.ToArray())); }
53+
get { return _ring ??= (_nodes.Keys.ToArray(), _nodes.Values.ToArray()); }
5454
}
5555

5656
private int[] NodeHashRing

0 commit comments

Comments
 (0)