From 44a1748e595752fee19772410a33c181c96b5825 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Fri, 16 Jun 2023 13:23:02 +1000 Subject: [PATCH] use target typed new when type is obvious --- .../ActorMessagingMemoryPressureBenchmark.cs | 2 +- .../Actor/ActorPathBenchmarks.cs | 4 +- .../Actor/GetChildBenchmark.cs | 10 +-- .../Actor/PingPongBenchmarks.cs | 4 +- .../Actor/SpawnActorBenchmarks.cs | 4 +- .../Cluster/ReachabilityBenchmarks.cs | 4 +- .../IO/TcpOperationsBenchmarks.cs | 2 +- .../Remoting/AkkaPduCodecBenchmark.cs | 2 +- .../Persistence/JournalWriteBenchmarks.cs | 2 +- .../Persistence/PersistenceInfrastructure.cs | 12 ++-- .../HashCodeMessageExtractorBenchmarks.cs | 4 +- .../Sharding/ShardingInfrastructure.cs | 4 +- .../Akka.Cluster.Cpu.Benchmark/Program.cs | 4 +- src/benchmark/RemotePingPong/Program.cs | 2 +- .../SerializationBenchmarks/Program.cs | 5 +- .../ClustetMetricsRoutingSpec.cs | 2 +- .../ClusterMetricsCollector.cs | 4 +- .../ClusterMetricsSupervisor.cs | 4 +- .../DateTimeExtensions.cs | 2 +- .../Routing/MetricSelectors.cs | 8 +-- .../Serialization/MetricsGossip.cs | 2 +- .../AsyncWriteProxyEx.cs | 2 +- .../ClusterShardCoordinatorDowning2Spec.cs | 2 +- .../ClusterShardCoordinatorDowningSpec.cs | 2 +- ...lusterShardingCustomShardAllocationSpec.cs | 8 +-- ...usterShardingGracefulShutdownOldestSpec.cs | 8 +-- .../ClusterShardingLeavingSpec.cs | 2 +- .../ClusterShardingSpec.cs | 6 +- .../MultiNodeClusterShardingSpec.cs | 6 +- .../ShardedDaemonProcessSpec.cs | 2 +- .../SnapshotStoreProxy.cs | 2 +- .../ClusterShardingInternalsSpec.cs | 2 +- .../InactiveEntityPassivationSpec.cs | 2 +- .../LeastShardAllocationStrategySpec.cs | 2 +- .../ProxyShardingSpec.cs | 2 +- .../ShardWithLeaseSpec.cs | 2 +- .../ShardedDaemonProcessSpec.cs | 2 +- .../SupervisionSpec.cs | 2 +- .../Akka.Cluster.Sharding/ClusterSharding.cs | 4 +- .../ClusterShardingGuardian.cs | 2 +- .../ClusterShardingSettings.cs | 2 +- .../DDataShardCoordinator.cs | 4 +- .../External/ExternalShardAllocation.cs | 2 +- .../ExternalShardAllocationStrategy.cs | 2 +- .../AbstractLeastShardAllocationStrategy.cs | 2 +- ...SourcedRememberEntitiesCoordinatorStore.cs | 4 +- .../EventSourcedRememberEntitiesShardStore.cs | 4 +- .../Internal/RememberEntitiesStore.cs | 4 +- .../Internal/RememberEntityStarter.cs | 2 +- .../cluster/Akka.Cluster.Sharding/Shard.cs | 28 ++++---- .../Akka.Cluster.Sharding/ShardCoordinator.cs | 10 +-- .../Akka.Cluster.Sharding/ShardRegion.cs | 12 ++-- .../ShardedDaemonProcess.cs | 4 +- .../Akka.Cluster.Sharding/ShardingMessages.cs | 12 ++-- .../ClusterClient/ClusterClientSpec.cs | 4 +- .../DistributedPubSubMediatorSpec.cs | 2 +- .../ClusterSingletonManagerChaosSpec.cs | 2 +- .../ClusterSingletonManagerDownedSpec.cs | 4 +- .../ClusterSingletonManagerLeave2Spec.cs | 2 +- .../Singleton/ClusterSingletonManagerSpec.cs | 24 +++---- .../DistributedPubSubMediatorSpec.cs | 4 +- .../DistributedPubSubMessageSerializerSpec.cs | 6 +- .../Singleton/ClusterSingletonApiSpec.cs | 4 +- .../Singleton/ClusterSingletonLeaseSpec.cs | 2 +- .../Client/ClusterClient.cs | 12 ++-- .../Client/ClusterReceptionist.cs | 20 +++--- .../PublishSubscribe/DistributedMessages.cs | 2 +- .../Internal/TopicMessages.cs | 14 ++-- .../PublishSubscribe/Internal/Topics.cs | 3 +- .../PublishSubscribe/PerGroupingBuffer.cs | 2 +- .../Singleton/ClusterSingleton.cs | 9 ++- .../Singleton/ClusterSingletonManager.cs | 22 +++--- .../Singleton/ClusterSingletonProxy.cs | 4 +- .../Singleton/ClusterSingletonSettings.cs | 4 +- .../Singleton/MemberAgeOrdering.cs | 8 +-- .../Singleton/OldestChangedBuffer.cs | 2 +- .../LmdbDurableStore.cs | 4 +- .../DurableDataPocoSpec.cs | 6 +- .../DurableDataSpec.cs | 6 +- .../DurablePruningSpec.cs | 6 +- .../JepsenInspiredInsertSpec.cs | 12 ++-- .../ReplicatorChaosSpec.cs | 24 +++---- .../ReplicatorPruningSpec.cs | 6 +- .../ReplicatorSpec.cs | 30 ++++---- .../DataEnvelopeSpecs.cs | 8 +-- .../DeltaPropagationSelectorSpec.cs | 2 +- .../GCounterSpec.cs | 6 +- .../LocalConcurrencySpec.cs | 2 +- .../PruningStateSpec.cs | 8 +-- .../ReplicatorSpecs.cs | 10 +-- .../VersionVectorSpec.cs | 8 +-- .../WriteAggregatorSpec.cs | 16 ++--- .../Akka.DistributedData/DistributedData.cs | 2 +- .../cluster/Akka.DistributedData/Dsl.cs | 16 ++--- .../Akka.DistributedData/Durable/Messages.cs | 4 +- .../cluster/Akka.DistributedData/Flag.cs | 4 +- .../cluster/Akka.DistributedData/GCounter.cs | 4 +- .../cluster/Akka.DistributedData/GSet.cs | 6 +- .../Akka.DistributedData/Internal/Internal.cs | 33 ++++----- .../Akka.DistributedData/LWWDictionary.cs | 14 ++-- .../Akka.DistributedData/ORDictionary.cs | 2 +- .../ORMultiValueDictionary.cs | 11 ++- .../cluster/Akka.DistributedData/ORSet.cs | 2 +- .../cluster/Akka.DistributedData/PNCounter.cs | 11 ++- .../PNCounterDictionary.cs | 21 +++--- .../Akka.DistributedData/ReadAggregator.cs | 2 +- .../ReadWriteAggregator.cs | 2 +- .../Replicator.Messages.cs | 8 +-- .../Akka.DistributedData/Replicator.cs | 6 +- .../Serialization/OtherMessageComparer.cs | 2 +- .../ReplicatorMessageSerializer.cs | 2 +- .../Akka.DistributedData/VersionVector.cs | 2 +- .../Akka.DistributedData/WriteAggregator.cs | 2 +- .../RouterIntegrationSpec.cs | 4 +- .../AllEventsPublisher.cs | 2 +- .../CurrentPersistenceIdsPublisher.cs | 2 +- .../EventsByPersistenceIdPublisher.cs | 2 +- .../EventsByTagPublisher.cs | 2 +- .../AllPersistenceIdsPublisher.cs | 2 +- .../EventsByPersistenceIdPublisher.cs | 2 +- .../QueryThrottler.cs | 6 +- .../SqlJournalConnectionFailureSpec.cs | 2 +- .../SqlSnapshotConnectionFailureSpec.cs | 6 +- .../BatchingSqliteCurrentAllEventsSpec.cs | 2 +- ...gSqliteCurrentEventsByPersistenceIdSpec.cs | 2 +- .../BatchingSqliteCurrentEventsByTagSpec.cs | 2 +- ...BatchingSqliteCurrentPersistenceIdsSpec.cs | 2 +- ...BatchingSqliteEventsByPersistenceIdSpec.cs | 2 +- .../Batching/BatchingSqliteEventsByTagSpec.cs | 2 +- .../Batching/BatchingSqliteJournalSpec.cs | 2 +- .../Bugfix4360Spec.cs | 4 +- .../Legacy/PersistedLegacyActor.cs | 6 +- .../Legacy/SqliteLegacyJournalSpec.cs | 2 +- .../Query/SqliteCurrentAllEventsSpec.cs | 2 +- .../SqliteCurrentEventsByPersistenceIdSpec.cs | 2 +- .../Query/SqliteCurrentEventsByTagSpec.cs | 2 +- .../Query/SqliteCurrentPersistenceIdsSpec.cs | 2 +- .../Query/SqliteEventsByPersistenceIdSpec.cs | 2 +- .../Query/SqliteEventsByTagSpec.cs | 2 +- .../SqliteJournalSerializationSpec.cs | 2 +- .../SqliteSnapshotStoreSerializationSpec.cs | 2 +- .../SqliteJournalSpec.cs | 2 +- .../SqliteSnapshotStoreSpec.cs | 2 +- .../ConnectionContext.cs | 2 +- .../Journal/BatchingSqliteJournal.cs | 2 +- .../HyperionConfigTests.cs | 2 +- .../HyperionSerializer.cs | 14 ++-- .../HyperionSerializerSetup.cs | 15 ++-- .../testkits/Akka.TestKit.Xunit/TestKit.cs | 2 +- .../testkits/Akka.TestKit.Xunit2/TestKit.cs | 2 +- .../FailureDetectorPuppet.cs | 2 +- .../MultiNodeClusterSpec.cs | 9 ++- .../ClusterConsistentHashingGroupSpec.cs | 2 +- .../StressSpec.cs | 14 ++-- .../SurviveNetworkInstabilitySpec.cs | 2 +- .../ClusterMessageSerializerSpec.cs | 6 +- .../Startup/ClusterStartupSpec.cs | 2 +- .../ClusterDomainEventPublisherSpec.cs | 20 +++--- .../ClusterDomainEventSpec.cs | 2 +- .../ClusterHeartBeatSenderStateSpec.cs | 10 +-- .../Akka.Cluster.Tests/DowningProviderSpec.cs | 2 +- .../HeartbeatNodeRingSpec.cs | 12 ++-- .../Akka.Cluster.Tests/ReachabilitySpec.cs | 10 +-- .../SplitBrainStrategySpec.cs | 14 ++-- src/core/Akka.Cluster/Cluster.cs | 2 +- .../Akka.Cluster/ClusterActorRefProvider.cs | 2 +- src/core/Akka.Cluster/ClusterDaemon.cs | 20 +++--- src/core/Akka.Cluster/ClusterHeartbeat.cs | 2 +- .../Akka.Cluster/CoordinatedShutdownLeave.cs | 2 +- src/core/Akka.Cluster/Gossip.cs | 2 +- src/core/Akka.Cluster/Member.cs | 4 +- src/core/Akka.Cluster/Reachability.cs | 3 +- .../Routing/ClusterRoutingConfig.cs | 2 +- src/core/Akka.Cluster/SBR/DowningStrategy.cs | 10 +-- .../Akka.Cluster/SBR/SplitBrainResolver.cs | 9 ++- .../Serialization/ClusterMessageSerializer.cs | 14 ++-- src/core/Akka.Cluster/SplitBrainResolver.cs | 2 +- src/core/Akka.Coordination.Tests/TestLease.cs | 8 +-- .../Akka.Coordination.Tests/TestLeaseActor.cs | 6 +- src/core/Akka.Coordination/LeaseProvider.cs | 2 +- .../AggregateServiceDiscoverySpec.cs | 8 +-- src/core/Akka.Discovery.Tests/LookupSpec.cs | 2 +- src/core/Akka.Discovery/Discovery.cs | 5 +- src/core/Akka.Discovery/ServiceDiscovery.cs | 7 +- .../FiniteStateMachine.Messages.cs | 2 +- .../Serialization/ExternalAddressProvider.cs | 3 +- .../PersistentActor/PersistentActor.cs | 2 +- .../Persistence/PersistentActor/Snapshots.cs | 2 +- .../Persistence/WebStoreCustomerFSMActor.cs | 20 +++--- .../Testkit/TestKitSampleTest.cs | 2 +- .../Tutorial2/DeviceInProgress.cs | 2 +- .../Tutorial3/DeviceGroup.cs | 4 +- .../Tutorial3/DeviceGroupInProgress.cs | 6 +- .../Tutorial3/DeviceManager.cs | 6 +- .../Tutorial4/DeviceGroup.cs | 10 +-- .../Tutorial4/DeviceGroupQuery.cs | 2 +- .../Tutorial4/DeviceGroupQueryInProgress.cs | 6 +- .../Tutorial4/DeviceManager.cs | 6 +- .../Utils/TimeUuid.cs | 6 +- src/core/Akka.Persistence.Query/Offset.cs | 2 +- .../PersistenceQuery.cs | 2 +- .../Performance/JournalPerfSpec.cs | 4 +- src/core/Akka.Persistence.TCK/PluginSpec.cs | 2 +- .../Serialization/JournalSerializationSpec.cs | 8 +-- .../SnapshotStoreSerializationSpec.cs | 6 +- .../Journal/TestJournal.cs | 6 +- .../SnapshotStore/TestSnapshotStore.cs | 11 ++- .../AtLeastOnceDeliveryCrashSpec.cs | 4 +- .../AtLeastOnceDeliveryFailureSpec.cs | 4 +- .../AtLeastOnceDeliveryReceiveActorSpec.cs | 8 +-- .../AtLeastOnceDeliverySpec.cs | 8 +-- .../Delivery/EventSourcedProducerQueueSpec.cs | 2 +- .../Fsm/PersistentFSMSpec.cs | 18 ++--- .../Journal/ChaosJournal.cs | 4 +- .../Journal/ReplayFilterSpec.cs | 20 ++---- .../Journal/SteppingMemoryJournal.cs | 10 +-- .../Akka.Persistence.Tests/LoadPluginSpec.cs | 2 +- .../MemoryEventAdapterSpec.cs | 2 +- .../OptimizedRecoverySpec.cs | 2 +- .../OptionalSnapshotStoreSpec.cs | 2 +- .../PersistenceConfigAutoStartSpec.cs | 2 +- .../PersistenceConfigSpec.cs | 2 +- .../Akka.Persistence.Tests/PersistenceSpec.cs | 6 +- .../PersistentActorJournalProtocolSpec.cs | 2 +- .../PersistentActorRecoveryTimeoutSpec.cs | 2 +- .../PersistentActorSpec.Actors.cs | 6 +- .../PersistentActorSpec.cs | 2 +- .../PersistentActorSpecAsyncAwait.Actors.cs | 6 +- .../PersistentActorSpecAsyncAwait.cs | 2 +- .../ReceivePersistentActorTests.cs | 4 +- .../SnapshotDirectoryFailureSpec.cs | 2 +- .../SnapshotRecoveryLocalStoreSpec.cs | 4 +- .../Akka.Persistence.Tests/SnapshotSpec.cs | 2 +- .../AtLeastOnceDeliverySemantic.cs | 2 +- .../Delivery/EventSourcedProducerQueue.cs | 2 +- src/core/Akka.Persistence/Eventsourced.cs | 2 +- .../Akka.Persistence/Fsm/PersistentFSMBase.cs | 10 +-- .../Journal/AsyncWriteProxy.cs | 2 +- .../Akka.Persistence/Journal/EventAdapters.cs | 2 +- .../Journal/EventSequences.cs | 2 +- .../Akka.Persistence/Journal/MemoryJournal.cs | 2 +- .../Journal/PersistencePluginProxy.cs | 2 +- .../Akka.Persistence/Journal/ReplayFilter.cs | 4 +- src/core/Akka.Persistence/JournalProtocol.cs | 2 +- src/core/Akka.Persistence/Persistence.cs | 4 +- src/core/Akka.Persistence/PersistentActor.cs | 14 ++-- .../Akka.Persistence/RecoveryPermitter.cs | 8 +-- .../Snapshot/LocalSnapshotStore.cs | 2 +- .../Snapshot/MemorySnapshotStore.cs | 2 +- src/core/Akka.Persistence/SnapshotProtocol.cs | 4 +- .../Akka.Remote.TestKit.Tests/BarrierSpec.cs | 6 +- .../ControllerSpec.cs | 4 +- src/core/Akka.Remote.TestKit/CommandLine.cs | 2 +- src/core/Akka.Remote.TestKit/Conductor.cs | 2 +- src/core/Akka.Remote.TestKit/Controller.cs | 4 +- src/core/Akka.Remote.TestKit/DataTypes.cs | 2 +- src/core/Akka.Remote.TestKit/Player.cs | 2 +- .../RemoteNodeDeathWatchSpec.cs | 2 +- .../TransportFailSpec.cs | 2 +- .../InboundMessageDispatcherSpec.cs | 2 +- .../Transports/AssociationStressSpecBase.cs | 2 +- .../RemoteMessagingThroughputSpecBase.cs | 8 +-- .../Akka.Remote.Tests/EndpointRegistrySpec.cs | 4 +- .../Akka.Remote.Tests/ExceptionSupportSpec.cs | 4 +- .../RemoteActorTelemetrySpecs.cs | 2 +- .../Akka.Remote.Tests/RemoteConfigSpec.cs | 4 +- .../Serialization/Bugfix3903Spec.cs | 2 +- .../MiscMessageSerializerSpec.cs | 2 +- .../TransientSerializationErrorSpec.cs | 12 ++-- .../Transport/AkkaProtocolSpec.cs | 11 ++- .../Transport/AkkaProtocolStressTest.cs | 2 +- .../Transport/DotNettyBatchWriterSpecs.cs | 2 +- .../Transport/GenericTransportSpec.cs | 4 +- .../Transport/TestTransportSpec.cs | 6 +- .../ThrottlerTransportAdapterSpec.cs | 3 +- src/core/Akka.Remote/AckedDelivery.cs | 4 +- .../DefaultFailureDetectorRegistry.cs | 4 +- src/core/Akka.Remote/Endpoint.cs | 22 +++--- src/core/Akka.Remote/EndpointManager.cs | 13 ++-- src/core/Akka.Remote/EndpointRegistry.cs | 11 ++- .../Akka.Remote/RemoteActorRefProvider.cs | 2 +- .../Akka.Remote/RemoteMetricsExtension.cs | 2 +- src/core/Akka.Remote/RemoteSystemDaemon.cs | 4 +- src/core/Akka.Remote/RemoteWatcher.cs | 16 ++--- .../Akka.Remote/Routing/RemoteRouterConfig.cs | 2 +- .../Serialization/ActorPathCache.cs | 2 +- .../Serialization/ExceptionSupport.cs | 4 +- .../Serialization/LruBoundedCache.cs | 2 +- .../Serialization/ProtobufSerializer.cs | 2 +- .../Transport/AkkaProtocolTransport.cs | 4 +- .../Transport/DotNetty/DotNettyTransport.cs | 2 +- .../DotNetty/DotNettyTransportSettings.cs | 2 +- .../Transport/DotNetty/TcpTransport.cs | 2 +- .../FailureInjectorTransportAdapter.cs | 6 +- .../Akka.Remote/Transport/TestTransport.cs | 16 ++--- .../Transport/ThrottleTransportAdapter.cs | 23 +++---- .../Transport/TransportAdapters.cs | 2 +- .../PublisherFluentBuilder.cs | 2 +- .../SubscriberFluentBuilder.cs | 2 +- .../Akka.Streams.TestKit/TestGraphStage.cs | 15 ++-- .../Akka.Streams.TestKit/TestPublisher.cs | 6 +- .../TestPublisher_Fluent.cs | 3 +- .../Akka.Streams.TestKit/TestSubscriber.cs | 2 +- .../TestSubscriber_Fluent.cs | 3 +- .../FusedGraphsBenchmark.cs | 8 +-- .../InterpreterBenchmark.cs | 2 +- .../ActorPublisherTest.cs | 6 +- .../FilePublisherTest.cs | 2 +- .../SinkholeSubscriberTest.cs | 2 +- .../Actor/ActorPublisherSpec.cs | 8 +-- .../Actor/ActorSubscriberSpec.cs | 2 +- .../Dsl/ActorRefBackpressureSinkSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/AttributesSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/FlowCollectSpec.cs | 2 +- .../Dsl/FlowConcatAllSpec.cs | 2 +- .../Dsl/FlowFlattenMergeSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/FlowGroupBySpec.cs | 3 +- .../Akka.Streams.Tests/Dsl/FlowGroupedSpec.cs | 2 +- .../Dsl/FlowPrefixAndTailSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/FlowRecoverSpec.cs | 2 +- .../Dsl/FlowRecoverWithSpec.cs | 2 +- .../Dsl/FlowSelectErrorSpec.cs | 4 +- .../Dsl/FlowSupervisionSpec.cs | 2 +- .../Dsl/FlowWithContextSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/FramingSpec.cs | 8 +-- .../Dsl/FutureFlattenSourceSpec.cs | 6 +- .../Dsl/GraphStageTimersSpec.cs | 10 +-- .../Dsl/GraphUnzipWithSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/LazySourceSpec.cs | 2 +- .../Akka.Streams.Tests/Dsl/QueueSourceSpec.cs | 2 +- .../Dsl/StageActorRefSpec.cs | 10 +-- .../Akka.Streams.Tests/Dsl/UnfoldFlowSpec.cs | 2 +- .../Dsl/UnfoldResourceAsyncSourceSpec.cs | 6 +- .../Dsl/WithContextUsageSpec.cs | 2 +- .../Akka.Streams.Tests/IO/FileSourceSpec.cs | 2 +- src/core/Akka.Streams.Tests/IO/TcpHelper.cs | 6 +- .../Fusing/ChasingEventsSpec.cs | 14 ++-- .../Fusing/GraphInterpreterSpecKit.cs | 8 +-- .../Implementation/Fusing/InterpreterSpec.cs | 4 +- .../Fusing/InterpreterStressSpec.cs | 8 +-- .../Fusing/InterpreterSupervisionSpec.cs | 7 +- .../Fusing/KeepGoingStageSpec.cs | 20 +++--- .../Implementation/GraphStageLogicSpec.cs | 29 ++++---- .../Implementation/StreamLayoutSpec.cs | 6 +- src/core/Akka.Streams.Tests/ScriptedTest.cs | 2 +- .../Akka.Streams/Actors/ActorPublisher.cs | 10 +-- .../Akka.Streams/Actors/ActorSubscriber.cs | 8 +-- .../Akka.Streams/Actors/RequestStrategies.cs | 4 +- src/core/Akka.Streams/Attributes.cs | 40 +++++------ .../Dsl/AccumulateWhileUnchanged.cs | 2 +- src/core/Akka.Streams/Dsl/DelayFlow.cs | 2 +- src/core/Akka.Streams/Dsl/FileIO.cs | 4 +- src/core/Akka.Streams/Dsl/Flow.cs | 8 +-- src/core/Akka.Streams/Dsl/FlowWithContext.cs | 2 +- src/core/Akka.Streams/Dsl/Graph.cs | 34 +++++----- src/core/Akka.Streams/Dsl/Hub.cs | 51 +++++++------- src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs | 8 +-- src/core/Akka.Streams/Dsl/RestartFlow.cs | 8 +-- src/core/Akka.Streams/Dsl/RestartSink.cs | 2 +- src/core/Akka.Streams/Dsl/RestartSource.cs | 2 +- src/core/Akka.Streams/Dsl/Retry.cs | 2 +- src/core/Akka.Streams/Dsl/ReuseLatest.cs | 6 +- src/core/Akka.Streams/Dsl/Sink.cs | 20 +++--- src/core/Akka.Streams/Dsl/Source.cs | 8 +-- src/core/Akka.Streams/Dsl/SourceOperations.cs | 2 +- .../Akka.Streams/Dsl/SourceWithContext.cs | 8 +-- src/core/Akka.Streams/Dsl/StreamRefs.cs | 2 +- src/core/Akka.Streams/Dsl/Tcp.cs | 2 +- src/core/Akka.Streams/Extra/Timed.cs | 2 +- src/core/Akka.Streams/FlowMonitor.cs | 4 +- src/core/Akka.Streams/IO/IOResult.cs | 4 +- .../Implementation/ActorMaterializerImpl.cs | 14 ++-- .../Implementation/ActorPublisher.cs | 6 +- .../ActorRefBackpressureSinkStage.cs | 2 +- .../Implementation/ActorRefSinkStage.cs | 2 +- .../Implementation/CompletedPublishers.cs | 2 +- .../Implementation/ExposedPublisherReceive.cs | 2 +- .../Fusing/ActorGraphInterpreter.cs | 4 +- .../Implementation/Fusing/Fusing.cs | 4 +- .../Implementation/Fusing/GraphInterpreter.cs | 4 +- .../Implementation/Fusing/GraphStages.cs | 31 ++++----- .../Akka.Streams/Implementation/Fusing/Ops.cs | 68 +++++++++---------- .../Implementation/Fusing/StreamOfStreams.cs | 38 +++++------ .../Implementation/IO/FilePublisher.cs | 2 +- .../Implementation/IO/FileSubscriber.cs | 2 +- .../Implementation/IO/InputStreamPublisher.cs | 2 +- .../Implementation/IO/InputStreamSinkStage.cs | 10 +-- .../IO/OutputStreamSourceStage.cs | 12 ++-- .../Implementation/IO/TcpStages.cs | 18 ++--- .../ResizableMultiReaderRingBuffer.cs | 2 +- .../Akka.Streams/Implementation/SetupStage.cs | 6 +- src/core/Akka.Streams/Implementation/Sinks.cs | 14 ++-- .../Akka.Streams/Implementation/Sources.cs | 17 +++-- .../Implementation/Stages/Stages.cs | 12 ++-- .../Implementation/StreamLayout.cs | 16 ++--- .../Implementation/StreamRef/SinkRefImpl.cs | 2 +- .../Implementation/StreamRef/SourceRefImpl.cs | 2 +- .../Implementation/StreamRef/StreamRefs.cs | 3 +- .../StreamSubscriptionTimeout.cs | 4 +- .../Implementation/SubscriberManagement.cs | 4 +- .../Akka.Streams/Implementation/Timers.cs | 14 ++-- .../Akka.Streams/Implementation/Transfer.cs | 8 +-- .../Akka.Streams/Implementation/Unfold.cs | 6 +- src/core/Akka.Streams/KillSwitch.cs | 28 ++++---- src/core/Akka.Streams/QueueOfferResult.cs | 6 +- src/core/Akka.Streams/RestartSettings.cs | 4 +- .../Serialization/SerializationTools.cs | 2 +- src/core/Akka.Streams/Shape.cs | 4 +- src/core/Akka.Streams/Stage/GraphStage.cs | 19 +++--- src/core/Akka.Streams/Stage/Stage.cs | 4 +- src/core/Akka.Streams/StreamRefs.cs | 2 +- src/core/Akka.Streams/StreamTcpException.cs | 4 +- .../SubscriptionWithCancelException.cs | 4 +- .../TestActorRefTests/TestActorRefSpec.cs | 4 +- src/core/Akka.TestKit/AutoPilots.cs | 4 +- .../DelegatingSupervisorStrategy.cs | 2 +- .../EventFilter/TestEventListener.cs | 2 +- src/core/Akka.TestKit/Internal/AsyncQueue.cs | 14 ++-- .../Akka.TestKit/Internal/BlockingQueue.cs | 6 +- .../Internal/InternalTestActor.cs | 2 +- .../Internal/InternalTestActorRef.cs | 7 +- src/core/Akka.TestKit/NullMessageEnvelope.cs | 2 +- src/core/Akka.TestKit/TestKitBase.cs | 2 +- .../Actor/ActorMemoryFootprintSpec.cs | 2 +- .../Actor/ActorPathEqualitySpec.cs | 2 +- .../Actor/ActorPathSpec.cs | 2 +- .../Actor/ActorSelectionSpecs.cs | 4 +- .../Actor/ActorThroughputSpec.cs | 6 +- .../Actor/Pattern/AskSpec.cs | 2 +- .../Dispatch/DispatcherThroughputSpecBase.cs | 2 +- .../Dispatch/GetMailboxTypeSpec.cs | 2 +- .../Dispatch/ReceiveOnlyBenchmark.cs | 2 +- .../Event/EventStreamThroughputSpec.cs | 2 +- .../IO/TcpHorizontalScaleSpec.cs | 2 +- .../IO/TcpInboundOnlySpec.cs | 6 +- .../IO/TcpSingleConnectionSpec.cs | 4 +- .../Akka.Tests.Shared.Internals/AkkaSpec.cs | 2 +- .../Helpers/XAssert.cs | 2 +- .../Actor/ActorProducerPipelineTests.cs | 2 +- src/core/Akka.Tests/Actor/ActorSystemSpec.cs | 2 +- .../Akka.Tests/Actor/ActorTelemetrySpecs.cs | 4 +- src/core/Akka.Tests/Actor/BugFix4376Spec.cs | 6 +- .../Akka.Tests/Actor/ContextWatchWithSpec.cs | 2 +- .../Actor/CoordinatedShutdownSpec.cs | 2 +- .../Actor/Dispatch/ActorModelSpec.cs | 28 ++++---- .../Akka.Tests/Actor/Dispatch/Bug2640Spec.cs | 2 +- src/core/Akka.Tests/Actor/FSMActorSpec.cs | 4 +- src/core/Akka.Tests/Actor/FSMTimingSpec.cs | 8 +-- .../Actor/RootGuardianActorRef_Tests.cs | 6 +- .../Actor/Scheduler/SchedulerShutdownSpec.cs | 2 +- src/core/Akka.Tests/Actor/TimerSpec.cs | 12 ++-- src/core/Akka.Tests/IO/TcpIntegrationSpec.cs | 8 +-- .../Akka.Tests/Loggers/ShutdownLoggerSpec.cs | 2 +- .../MatchHandler/CachedMatchCompilerTests.cs | 8 +-- .../Pattern/BackoffSupervisorSpec.cs | 2 +- .../Akka.Tests/Pattern/CircuitBreakerSpec.cs | 12 ++-- .../Pattern/CircuitBreakerStressSpec.cs | 6 +- src/core/Akka.Tests/Routing/RandomSpec.cs | 2 +- src/core/Akka.Tests/Routing/RoundRobinSpec.cs | 2 +- .../Serialization/SerializationSetupSpec.cs | 6 +- src/core/Akka.Tests/Util/IndexSpec.cs | 2 +- src/core/Akka/Actor/ActorBase.cs | 2 +- src/core/Akka/Actor/ActorProducerPipeline.cs | 4 +- src/core/Akka/Actor/ActorRef.cs | 8 +-- src/core/Akka/Actor/ActorRefProvider.cs | 4 +- src/core/Akka/Actor/ActorSelection.cs | 4 +- src/core/Akka/Actor/ActorSystem.cs | 6 +- src/core/Akka/Actor/Address.cs | 2 +- .../Cancellation/AlreadyCanceledCancelable.cs | 4 +- .../ChildrenContainer/Internal/ChildStats.cs | 2 +- .../Internal/SuspendReason.cs | 4 +- src/core/Akka/Actor/CoordinatedShutdown.cs | 12 ++-- src/core/Akka/Actor/Deploy.cs | 4 +- src/core/Akka/Actor/Deployer.cs | 3 +- src/core/Akka/Actor/FSM.cs | 16 ++--- src/core/Akka/Actor/Futures.cs | 10 +-- src/core/Akka/Actor/IAutoReceivedMessage.cs | 4 +- src/core/Akka/Actor/Inbox.Actor.cs | 4 +- src/core/Akka/Actor/Inbox.cs | 4 +- .../Akka/Actor/Internal/ActorSystemImpl.cs | 2 +- .../Internal/InternalSupportsTestFSMRef.cs | 2 +- src/core/Akka/Actor/LocalScope.cs | 2 +- src/core/Akka/Actor/Props.cs | 2 +- src/core/Akka/Actor/ReceiveActor.cs | 2 +- src/core/Akka/Actor/ReceiveTimeout.cs | 2 +- src/core/Akka/Actor/RepointableActorRef.cs | 4 +- src/core/Akka/Actor/RootGuardianSupervisor.cs | 2 +- .../Scheduler/DateTimeNowTimeProvider.cs | 2 +- .../Scheduler/HashedWheelTimerScheduler.cs | 10 +-- .../Akka/Actor/Scheduler/TimerScheduler.cs | 4 +- src/core/Akka/Actor/Scope.cs | 2 +- src/core/Akka/Actor/Setup/ActorSystemSetup.cs | 2 +- src/core/Akka/Actor/SupervisorStrategy.cs | 2 +- src/core/Akka/ActorState.cs | 8 +-- .../Akka/Configuration/Hocon/HoconObject.cs | 2 +- .../Akka/Configuration/Hocon/HoconParser.cs | 2 +- .../Configuration/Hocon/HoconTokenizer.cs | 2 +- .../Akka/Configuration/Hocon/HoconValue.cs | 30 ++++---- src/core/Akka/Dispatch/AbstractDispatcher.cs | 3 +- .../Dispatch/ChannelSchedulerExtension.cs | 2 +- src/core/Akka/Dispatch/Dispatchers.cs | 5 +- src/core/Akka/Dispatch/Mailboxes.cs | 2 +- .../MessageQueues/BlockingMessageQueue.cs | 2 +- .../MessageQueues/DequeWrapperMessageQueue.cs | 2 +- .../MessageQueues/UnboundedMessageQueue.cs | 2 +- .../UnboundedPriorityMessageQueue.cs | 2 +- .../UnboundedStablePriorityMessageQueue.cs | 2 +- .../Akka/Dispatch/SysMsg/ISystemMessage.cs | 18 ++--- src/core/Akka/Dispatch/ThreadPoolBuilder.cs | 2 +- src/core/Akka/Done.cs | 2 +- src/core/Akka/Event/AddressTerminatedTopic.cs | 2 +- src/core/Akka/Event/DeadLetterListener.cs | 2 +- .../Akka/Event/DefaultLogMessageFormatter.cs | 2 +- src/core/Akka/Event/EventStream.cs | 6 +- src/core/Akka/Event/LoggingBus.cs | 4 +- .../Helios.Concurrency.DedicatedThreadPool.cs | 6 +- src/core/Akka/IO/Buffers/DirectBufferPool.cs | 6 +- .../Akka/IO/Buffers/DisabledBufferPool.cs | 3 +- src/core/Akka/IO/Dns.cs | 2 +- src/core/Akka/IO/SimpleDnsCache.cs | 4 +- src/core/Akka/IO/SimpleDnsManager.cs | 2 +- src/core/Akka/IO/Tcp.cs | 40 +++++------ src/core/Akka/IO/TcpConnection.cs | 12 ++-- src/core/Akka/IO/TcpOutgoingConnection.cs | 2 +- src/core/Akka/IO/Udp.cs | 18 ++--- src/core/Akka/IO/UdpConnected.cs | 16 ++--- src/core/Akka/NotUsed.cs | 2 +- src/core/Akka/Pattern/BackoffOptions.cs | 4 +- src/core/Akka/Pattern/BackoffSupervisor.cs | 8 +-- src/core/Akka/Pattern/CircuitBreaker.cs | 4 +- src/core/Akka/Routing/ConsistentHashRouter.cs | 3 +- src/core/Akka/Routing/Listeners.cs | 2 +- src/core/Akka/Routing/RouterConfig.cs | 4 +- src/core/Akka/Routing/RouterMsg.cs | 2 +- .../Serialization/NewtonSoftJsonSerializer.cs | 2 +- .../NewtonSoftJsonSerializerSetup.cs | 3 +- src/core/Akka/Serialization/Serialization.cs | 6 +- .../Akka/Serialization/SerializerErrorCode.cs | 40 +++++------ src/core/Akka/Util/AppVersion.cs | 2 +- src/core/Akka/Util/Index.cs | 2 +- .../Internal/SynchronizationContextManager.cs | 2 +- .../Util/MatchHandler/CachedMatchCompiler.cs | 4 +- .../Akka/Util/MatchHandler/MatchBuilder.cs | 6 +- .../Akka/Util/MatchHandler/TypeHandler.cs | 2 +- src/core/Akka/Util/MessageBuffer.cs | 6 +- src/core/Akka/Util/Option.cs | 2 +- .../Util/Reflection/ExpressionExtensions.cs | 7 +- src/core/Akka/Util/Reflection/TypeCache.cs | 2 +- src/core/Akka/Util/StandardOutWriter.cs | 2 +- src/core/Akka/Util/Switch.cs | 2 +- src/core/Akka/Util/ThreadLocalRandom.cs | 2 +- src/core/Akka/Util/TypeExtensions.cs | 4 +- src/core/Akka/Util/WildcardTree.cs | 2 +- src/examples/Chat/ChatServer/Program.cs | 2 +- .../ClusterSharding/ShoppingCart/Customers.cs | 2 +- .../ClusterSharding/ShoppingCart/Producer.cs | 2 +- .../TransformationFrontend.cs | 2 +- 557 files changed, 1569 insertions(+), 1634 deletions(-) diff --git a/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs b/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs index 71e988185de..c98487a8021 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/ActorMessagingMemoryPressureBenchmark.cs @@ -21,7 +21,7 @@ public class ActorMessagingMemoryPressureBenchmark public sealed class StopActor { private StopActor(){} - public static readonly StopActor Instance = new StopActor(); + public static readonly StopActor Instance = new(); } public sealed class MyActor : ReceiveActor diff --git a/src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs b/src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs index 0b116bfa646..6507904f673 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs @@ -18,8 +18,8 @@ public class ActorPathBenchmarks private ActorPath x; private ActorPath y; private ActorPath _childPath; - private Address _sysAdr = new Address("akka.tcp", "system", "127.0.0.1", 1337); - private Address _otherAdr = new Address("akka.tcp", "system", "127.0.0.1", 1338); + private Address _sysAdr = new("akka.tcp", "system", "127.0.0.1", 1337); + private Address _otherAdr = new("akka.tcp", "system", "127.0.0.1", 1338); private string _actorPathStr; diff --git a/src/benchmark/Akka.Benchmarks/Actor/GetChildBenchmark.cs b/src/benchmark/Akka.Benchmarks/Actor/GetChildBenchmark.cs index 55814914e79..eefbef1923b 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/GetChildBenchmark.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/GetChildBenchmark.cs @@ -93,17 +93,17 @@ protected override void OnReceive(object message) private ActorSystem _system; private IActorRef _parentActor; - private ActorWithChild.Get _getMessage = new ActorWithChild.Get("food"); - private ActorWithChild.Create _createMessage = new ActorWithChild.Create("food"); + private ActorWithChild.Get _getMessage = new("food"); + private ActorWithChild.Create _createMessage = new("food"); private IActorContext _cell; private RepointableActorRef _repointableActorRef; private LocalActorRef _localActorRef; private VirtualPathContainer _virtualPathContainer; - private List _rpChildQueryPath = new List() { "food", "ood", "od" }; - private List _lclChildQueryPath = new List() { "ood", "od", "d" }; - private List _virtualPathContainerQueryPath = new List() { "foo" }; + private List _rpChildQueryPath = new() { "food", "ood", "od" }; + private List _lclChildQueryPath = new() { "ood", "od", "d" }; + private List _virtualPathContainerQueryPath = new() { "foo" }; [GlobalSetup] public async Task Setup() diff --git a/src/benchmark/Akka.Benchmarks/Actor/PingPongBenchmarks.cs b/src/benchmark/Akka.Benchmarks/Actor/PingPongBenchmarks.cs index 4eb3ef8524f..e41f82cc8fe 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/PingPongBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/PingPongBenchmarks.cs @@ -49,7 +49,7 @@ public async Task Actor_ping_pong_single_pair_in_memory() sealed class StartTest { - public static readonly StartTest Instance = new StartTest(); + public static readonly StartTest Instance = new(); private StartTest() { } } @@ -65,7 +65,7 @@ public Signal(int remaining) sealed class TestDone { - public static readonly TestDone Instance = new TestDone(); + public static readonly TestDone Instance = new(); private TestDone() { } } diff --git a/src/benchmark/Akka.Benchmarks/Actor/SpawnActorBenchmarks.cs b/src/benchmark/Akka.Benchmarks/Actor/SpawnActorBenchmarks.cs index 1c288d7fd95..4c74794dbc0 100644 --- a/src/benchmark/Akka.Benchmarks/Actor/SpawnActorBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/Actor/SpawnActorBenchmarks.cs @@ -66,13 +66,13 @@ public StartTest(int actorCount) { sealed class ChildReady { - public static readonly ChildReady Instance = new ChildReady(); + public static readonly ChildReady Instance = new(); private ChildReady() { } } sealed class TestDone { - public static readonly TestDone Instance = new TestDone(); + public static readonly TestDone Instance = new(); private TestDone() { } } diff --git a/src/benchmark/Akka.Benchmarks/Cluster/ReachabilityBenchmarks.cs b/src/benchmark/Akka.Benchmarks/Cluster/ReachabilityBenchmarks.cs index 7bf4eb78f66..564886ba8d2 100644 --- a/src/benchmark/Akka.Benchmarks/Cluster/ReachabilityBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/Cluster/ReachabilityBenchmarks.cs @@ -27,8 +27,8 @@ public class ReachabilityBenchmarks [Params(100)] public int Iterations; - public Address Address = new Address("akka", "sys", "a", 2552); - public Address Node = new Address("akka", "sys", "a", 2552); + public Address Address = new("akka", "sys", "a", 2552); + public Address Node = new("akka", "sys", "a", 2552); private Reachability CreateReachabilityOfSize(Reachability baseReachability, int size) { diff --git a/src/benchmark/Akka.Benchmarks/IO/TcpOperationsBenchmarks.cs b/src/benchmark/Akka.Benchmarks/IO/TcpOperationsBenchmarks.cs index 162b6b217e7..8cf649c0582 100644 --- a/src/benchmark/Akka.Benchmarks/IO/TcpOperationsBenchmarks.cs +++ b/src/benchmark/Akka.Benchmarks/IO/TcpOperationsBenchmarks.cs @@ -104,7 +104,7 @@ public EchoConnection(IActorRef connection) private class ClientCoordinator : ReceiveActor { - private readonly HashSet _waitingChildren = new HashSet(); + private readonly HashSet _waitingChildren = new(); private IActorRef _requester; public ClientCoordinator(string host, int port, int clientsCount) diff --git a/src/benchmark/Akka.Benchmarks/Remoting/AkkaPduCodecBenchmark.cs b/src/benchmark/Akka.Benchmarks/Remoting/AkkaPduCodecBenchmark.cs index 7074e8568ec..30d4495b2ca 100644 --- a/src/benchmark/Akka.Benchmarks/Remoting/AkkaPduCodecBenchmark.cs +++ b/src/benchmark/Akka.Benchmarks/Remoting/AkkaPduCodecBenchmark.cs @@ -48,7 +48,7 @@ public class AkkaPduCodecBenchmark /// private readonly object _message = "foobar"; - private readonly Ack _lastAck = new Ack(-1); + private readonly Ack _lastAck = new(-1); private ByteString _fullDecode; private ByteString _pduDecoded; diff --git a/src/benchmark/Akka.Cluster.Benchmarks/Persistence/JournalWriteBenchmarks.cs b/src/benchmark/Akka.Cluster.Benchmarks/Persistence/JournalWriteBenchmarks.cs index 8cc94d90291..4b1bfd12f81 100644 --- a/src/benchmark/Akka.Cluster.Benchmarks/Persistence/JournalWriteBenchmarks.cs +++ b/src/benchmark/Akka.Cluster.Benchmarks/Persistence/JournalWriteBenchmarks.cs @@ -20,7 +20,7 @@ namespace Akka.Cluster.Benchmarks.Persistence [Config(typeof(MicroBenchmarkConfig))] public class JournalWriteBenchmarks { - private static readonly Store Message = new Store(1); + private static readonly Store Message = new(1); [Params(1, 10, 100)] public int PersistentActors; diff --git a/src/benchmark/Akka.Cluster.Benchmarks/Persistence/PersistenceInfrastructure.cs b/src/benchmark/Akka.Cluster.Benchmarks/Persistence/PersistenceInfrastructure.cs index bd419a03945..bd68f3a2f2d 100644 --- a/src/benchmark/Akka.Cluster.Benchmarks/Persistence/PersistenceInfrastructure.cs +++ b/src/benchmark/Akka.Cluster.Benchmarks/Persistence/PersistenceInfrastructure.cs @@ -17,19 +17,19 @@ namespace Akka.Cluster.Benchmarks.Persistence { public sealed class Init { - public static readonly Init Instance = new Init(); + public static readonly Init Instance = new(); private Init() { } } public sealed class Finish { - public static readonly Finish Instance = new Finish(); + public static readonly Finish Instance = new(); private Finish() { } } public sealed class Done { - public static readonly Done Instance = new Done(); + public static readonly Done Instance = new(); private Done() { } } @@ -45,7 +45,7 @@ public Finished(long state) public sealed class RecoveryFinished { - public static readonly RecoveryFinished Instance = new RecoveryFinished(); + public static readonly RecoveryFinished Instance = new(); private RecoveryFinished() { } } @@ -75,7 +75,7 @@ public Stored(int value) /// public sealed class IsFinished { - public static readonly IsFinished Instance = new IsFinished(); + public static readonly IsFinished Instance = new(); private IsFinished(){} } @@ -170,7 +170,7 @@ protected override bool ReceiveCommand(object message){ public static class PersistenceInfrastructure{ - public static readonly AtomicCounter DbCounter = new AtomicCounter(0); + public static readonly AtomicCounter DbCounter = new(0); public static Config GenerateJournalConfig(){ var config = ConfigurationFactory.ParseString(@" diff --git a/src/benchmark/Akka.Cluster.Benchmarks/Sharding/HashCodeMessageExtractorBenchmarks.cs b/src/benchmark/Akka.Cluster.Benchmarks/Sharding/HashCodeMessageExtractorBenchmarks.cs index 83c47eaac13..f3ab2238a15 100644 --- a/src/benchmark/Akka.Cluster.Benchmarks/Sharding/HashCodeMessageExtractorBenchmarks.cs +++ b/src/benchmark/Akka.Cluster.Benchmarks/Sharding/HashCodeMessageExtractorBenchmarks.cs @@ -14,8 +14,8 @@ namespace Akka.Cluster.Benchmarks.Sharding [Config(typeof(MicroBenchmarkConfig))] public class HashCodeMessageExtractorBenchmarks { - private ShardingEnvelope _m1 = new ShardingEnvelope("foo", 1); - private ShardedMessage _m2 = new ShardedMessage("foo", 1); + private ShardingEnvelope _m1 = new("foo", 1); + private ShardedMessage _m2 = new("foo", 1); private IMessageExtractor _extractor = new ShardMessageExtractor(); [Benchmark] diff --git a/src/benchmark/Akka.Cluster.Benchmarks/Sharding/ShardingInfrastructure.cs b/src/benchmark/Akka.Cluster.Benchmarks/Sharding/ShardingInfrastructure.cs index 65dcd14a257..e3a2b89a907 100644 --- a/src/benchmark/Akka.Cluster.Benchmarks/Sharding/ShardingInfrastructure.cs +++ b/src/benchmark/Akka.Cluster.Benchmarks/Sharding/ShardingInfrastructure.cs @@ -17,7 +17,7 @@ public sealed class ShardedEntityActor : ReceiveActor { public sealed class Resolve { - public static readonly Resolve Instance = new Resolve(); + public static readonly Resolve Instance = new(); private Resolve(){} } @@ -211,7 +211,7 @@ public override string EntityId(object message) public static class ShardingHelper { - public static AtomicCounter DbId = new AtomicCounter(0); + public static AtomicCounter DbId = new(0); internal static string BoolToToggle(bool val) { diff --git a/src/benchmark/Akka.Cluster.Cpu.Benchmark/Program.cs b/src/benchmark/Akka.Cluster.Cpu.Benchmark/Program.cs index 01a93c582be..d05294cc41b 100644 --- a/src/benchmark/Akka.Cluster.Cpu.Benchmark/Program.cs +++ b/src/benchmark/Akka.Cluster.Cpu.Benchmark/Program.cs @@ -27,8 +27,8 @@ public static class Program private const int DefaultWarmUpRepeat = 5; - private static readonly List Usages = new List(); - private static readonly List Processes = new List(); + private static readonly List Usages = new(); + private static readonly List Processes = new(); public static async Task Main(string[] args) { diff --git a/src/benchmark/RemotePingPong/Program.cs b/src/benchmark/RemotePingPong/Program.cs index e0fa5ef072a..72959bb2f1a 100644 --- a/src/benchmark/RemotePingPong/Program.cs +++ b/src/benchmark/RemotePingPong/Program.cs @@ -228,7 +228,7 @@ private class AllStartedActor : UntypedActor { public class AllStarted { } - private readonly HashSet _actors = new HashSet(); + private readonly HashSet _actors = new(); private int _correlationId = 0; protected override void OnReceive(object message) diff --git a/src/benchmark/SerializationBenchmarks/Program.cs b/src/benchmark/SerializationBenchmarks/Program.cs index 57d0c302a53..945f9478612 100644 --- a/src/benchmark/SerializationBenchmarks/Program.cs +++ b/src/benchmark/SerializationBenchmarks/Program.cs @@ -55,7 +55,7 @@ public JsonSerializerTests() _poolSer = _sys_pool.Serialization.FindSerializerForType(typeof(object)); } - private static TestSer testObj = new TestSer() + private static TestSer testObj = new() { Id = 124, someStr = @@ -123,8 +123,7 @@ public SerializationTests() _ser = _sys.Serialization.FindSerializerForType(typeof(MyType)); } - public static MyType payload => - new MyType() { SomeInt = 1, SomeStr = "lol" }; + public static MyType payload => new() { SomeInt = 1, SomeStr = "lol" }; [Benchmark] public void Serialization_WithTransport_NoState() { diff --git a/src/contrib/cluster/Akka.Cluster.Metrics.Tests.MultiNode/ClustetMetricsRoutingSpec.cs b/src/contrib/cluster/Akka.Cluster.Metrics.Tests.MultiNode/ClustetMetricsRoutingSpec.cs index 37bbbaf8418..4608a4eb6fe 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics.Tests.MultiNode/ClustetMetricsRoutingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics.Tests.MultiNode/ClustetMetricsRoutingSpec.cs @@ -33,7 +33,7 @@ public class AdaptiveLoadBalancingRouterConfig : MultiNodeConfig public sealed class AllocateMemory { private AllocateMemory() { } - public static readonly AllocateMemory Instance = new AllocateMemory(); + public static readonly AllocateMemory Instance = new(); } [Serializable] diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsCollector.cs b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsCollector.cs index 5e943e3acdf..641e1cfa02b 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsCollector.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsCollector.cs @@ -39,7 +39,7 @@ public class ClusterMetricsCollector : ActorBase sealed class MetricsTick { private MetricsTick() { } - public static readonly MetricsTick Instance = new MetricsTick(); + public static readonly MetricsTick Instance = new(); } /// @@ -48,7 +48,7 @@ private MetricsTick() { } sealed class GossipTick { private GossipTick() { } - public static readonly GossipTick Instance = new GossipTick(); + public static readonly GossipTick Instance = new(); } /// diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsSupervisor.cs b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsSupervisor.cs index 199fa18a12a..1c78365c05a 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsSupervisor.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/ClusterMetricsSupervisor.cs @@ -95,7 +95,7 @@ private CollectionStartMessage(){ } /// /// Singleton instance for /// - public static readonly CollectionStartMessage Instance = new CollectionStartMessage(); + public static readonly CollectionStartMessage Instance = new(); } /// @@ -107,7 +107,7 @@ private CollectionStopMessage(){ } /// /// Singleton instance for /// - public static readonly CollectionStopMessage Instance = new CollectionStopMessage(); + public static readonly CollectionStopMessage Instance = new(); } } } diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/DateTimeExtensions.cs b/src/contrib/cluster/Akka.Cluster.Metrics/DateTimeExtensions.cs index 64a6e6511e0..1710c985f23 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/DateTimeExtensions.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/DateTimeExtensions.cs @@ -14,7 +14,7 @@ namespace Akka.Cluster.Metrics /// internal static class DateTimeExtensions { - private static readonly DateTime UnixOffset = new DateTime(1970, 1, 1); + private static readonly DateTime UnixOffset = new(1970, 1, 1); /// /// Converts given date and time to UNIX Timestamp - number of milliseconds elapsed since 1 Jan 1970 diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/Routing/MetricSelectors.cs b/src/contrib/cluster/Akka.Cluster.Metrics/Routing/MetricSelectors.cs index c75b15d4495..80525eba199 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/Routing/MetricSelectors.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/Routing/MetricSelectors.cs @@ -100,8 +100,8 @@ public class MemoryMetricsSelector : CapacityMetricsSelector /// /// Singleton instance /// - public static readonly MemoryMetricsSelector Instance = new MemoryMetricsSelector(); - + public static readonly MemoryMetricsSelector Instance = new(); + /// public override IImmutableDictionary Capacity(IImmutableSet nodeMetrics) { @@ -130,7 +130,7 @@ public class CpuMetricsSelector : CapacityMetricsSelector /// /// Singleton instance /// - public static readonly CpuMetricsSelector Instance = new CpuMetricsSelector(); + public static readonly CpuMetricsSelector Instance = new(); public CpuMetricsSelector() { @@ -198,7 +198,7 @@ public MixMetricsSelector(ImmutableArray selectors) : b /// Singleton instance of the default MixMetricsSelector, which uses and /// /// - public static readonly MixMetricsSelector Instance = new MixMetricsSelector( + public static readonly MixMetricsSelector Instance = new( ImmutableArray.Create( MemoryMetricsSelector.Instance, CpuMetricsSelector.Instance) diff --git a/src/contrib/cluster/Akka.Cluster.Metrics/Serialization/MetricsGossip.cs b/src/contrib/cluster/Akka.Cluster.Metrics/Serialization/MetricsGossip.cs index 62503a56b14..05d77f94290 100644 --- a/src/contrib/cluster/Akka.Cluster.Metrics/Serialization/MetricsGossip.cs +++ b/src/contrib/cluster/Akka.Cluster.Metrics/Serialization/MetricsGossip.cs @@ -28,7 +28,7 @@ public sealed partial class MetricsGossip /// /// Empty metrics gossip /// - public static readonly MetricsGossip Empty = new MetricsGossip(ImmutableHashSet.Empty); + public static readonly MetricsGossip Empty = new(ImmutableHashSet.Empty); public MetricsGossip(IImmutableSet nodes) { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/AsyncWriteProxyEx.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/AsyncWriteProxyEx.cs index f5b9a9d43bd..ad116da7d1d 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/AsyncWriteProxyEx.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/AsyncWriteProxyEx.cs @@ -86,7 +86,7 @@ public abstract class AsyncWriteProxyEx : AsyncWriteJournal, IWithUnboundedStash { private class InitTimeout { - public static readonly InitTimeout Instance = new InitTimeout(); + public static readonly InitTimeout Instance = new(); private InitTimeout() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs index 23ec914f828..b4f292ffede 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowning2Spec.cs @@ -101,7 +101,7 @@ protected override bool Receive(object message) internal class GetLocations { - public static readonly GetLocations Instance = new GetLocations(); + public static readonly GetLocations Instance = new(); private GetLocations() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs index 435f79035f6..613a48276e6 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardCoordinatorDowningSpec.cs @@ -103,7 +103,7 @@ protected override bool Receive(object message) internal class GetLocations { - public static readonly GetLocations Instance = new GetLocations(); + public static readonly GetLocations Instance = new(); private GetLocations() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingCustomShardAllocationSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingCustomShardAllocationSpec.cs index 28df4633a93..9f6b858bbd2 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingCustomShardAllocationSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingCustomShardAllocationSpec.cs @@ -70,7 +70,7 @@ public abstract class ClusterShardingCustomShardAllocationSpec : MultiNodeCluste internal class AllocateReq { - public static readonly AllocateReq Instance = new AllocateReq(); + public static readonly AllocateReq Instance = new(); private AllocateReq() { @@ -89,7 +89,7 @@ public UseRegion(IActorRef region) internal class UseRegionAck { - public static readonly UseRegionAck Instance = new UseRegionAck(); + public static readonly UseRegionAck Instance = new(); private UseRegionAck() { @@ -98,7 +98,7 @@ private UseRegionAck() internal class RebalanceReq { - public static readonly RebalanceReq Instance = new RebalanceReq(); + public static readonly RebalanceReq Instance = new(); private RebalanceReq() { @@ -117,7 +117,7 @@ public RebalanceShards(IImmutableSet shards) internal class RebalanceShardsAck { - public static readonly RebalanceShardsAck Instance = new RebalanceShardsAck(); + public static readonly RebalanceShardsAck Instance = new(); private RebalanceShardsAck() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGracefulShutdownOldestSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGracefulShutdownOldestSpec.cs index 6290884ab7c..071ce064390 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGracefulShutdownOldestSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingGracefulShutdownOldestSpec.cs @@ -71,7 +71,7 @@ public class TerminationOrderActor : ActorBase { public class RegionTerminated { - public static RegionTerminated Instance = new RegionTerminated(); + public static RegionTerminated Instance = new(); private RegionTerminated() { @@ -80,7 +80,7 @@ private RegionTerminated() public class CoordinatorTerminated { - public static CoordinatorTerminated Instance = new CoordinatorTerminated(); + public static CoordinatorTerminated Instance = new(); private CoordinatorTerminated() { @@ -127,7 +127,7 @@ public class SlowStopShardedEntity : ActorBase, IWithTimers { public class Stop { - public static Stop Instance = new Stop(); + public static Stop Instance = new(); private Stop() { @@ -136,7 +136,7 @@ private Stop() public class ActualStop { - public static ActualStop Instance = new ActualStop(); + public static ActualStop Instance = new(); private ActualStop() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs index 220993ae5bb..e770a9abb75 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingLeavingSpec.cs @@ -93,7 +93,7 @@ public Ping(string id) [Serializable] internal sealed class GetLocations { - public static readonly GetLocations Instance = new GetLocations(); + public static readonly GetLocations Instance = new(); private GetLocations() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs index 1e47d8d0569..6a0a004faff 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs @@ -160,7 +160,7 @@ public abstract class ClusterShardingSpec : MultiNodeClusterShardingSpec internal sealed class ImmutableDictionaryKeepOrder : IImmutableDictionary { - public static readonly ImmutableDictionaryKeepOrder Empty = new ImmutableDictionaryKeepOrder(ImmutableDictionary.Empty, ImmutableList>.Empty); + public static readonly ImmutableDictionaryKeepOrder Empty = new(ImmutableDictionary.Empty, ImmutableList>.Empty); private readonly ImmutableDictionary _dictionary = ImmutableDictionary.Empty; private readonly ImmutableList> _items = ImmutableList>.Empty; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ProxyShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ProxyShardingSpec.cs index 9435cd8b37f..26bf1e5a05f 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ProxyShardingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ProxyShardingSpec.cs @@ -21,7 +21,7 @@ public class ProxyShardingSpec : Akka.TestKit.Xunit2.TestKit { ClusterSharding clusterSharding; ClusterShardingSettings shardingSettings; - private MessageExtractor messageExtractor = new MessageExtractor(10); + private MessageExtractor messageExtractor = new(10); private class MessageExtractor : HashCodeMessageExtractor { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardWithLeaseSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardWithLeaseSpec.cs index d7b8407a4a7..27790a86ab9 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardWithLeaseSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardWithLeaseSpec.cs @@ -138,7 +138,7 @@ public TestLease LeaseFor(string shardId) private TimeSpan shortDuration = TimeSpan.FromMilliseconds(100); private TestLeaseExt testLeaseExt; - private static AtomicCounter typeIdx = new AtomicCounter(0); + private static AtomicCounter typeIdx = new(0); public ShardWithLeaseSpec(ITestOutputHelper helper) : base(SpecConfig, helper) { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs index 8432c0a2869..9aea9fb27ac 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardedDaemonProcessSpec.cs @@ -20,7 +20,7 @@ public class ShardedDaemonProcessSpec : AkkaSpec { private sealed class Stop { - public static Stop Instance { get; } = new Stop(); + public static Stop Instance { get; } = new(); private Stop() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/SupervisionSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/SupervisionSpec.cs index 9a5d59a39aa..a6df7a77953 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/SupervisionSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/SupervisionSpec.cs @@ -47,7 +47,7 @@ public Response(IActorRef self) internal class StopMessage { - public static readonly StopMessage Instance = new StopMessage(); + public static readonly StopMessage Instance = new(); private StopMessage() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs index 1dda5eed1bb..c6b8e35ec77 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs @@ -269,8 +269,8 @@ public class ClusterSharding : IExtension #pragma warning restore CS0419 // Ambiguous reference in cref attribute { private readonly Lazy _guardian; - private readonly ConcurrentDictionary _regions = new ConcurrentDictionary(); - private readonly ConcurrentDictionary _proxies = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _regions = new(); + private readonly ConcurrentDictionary _proxies = new(); private readonly ExtendedActorSystem _system; private readonly Cluster _cluster; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs index 40b25cce83a..1f76a1818c6 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs @@ -173,7 +173,7 @@ public StartProxy( private readonly ConcurrentDictionary _regions; private readonly ConcurrentDictionary _proxies; - private readonly ConcurrentDictionary _typeLookup = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _typeLookup = new(); /// /// TBD diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs index 0df6bd78470..51827975e09 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs @@ -230,7 +230,7 @@ private TuningParameters Copy( int? coordinatorStateReadMajorityPlus = null, int? leastShardAllocationAbsoluteLimit = null, double? leastShardAllocationRelativeLimit = null) - => new TuningParameters( + => new( coordinatorFailureBackoff: coordinatorFailureBackoff ?? CoordinatorFailureBackoff, retryInterval: retryInterval ?? RetryInterval, bufferSize: bufferSize ?? BufferSize, diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/DDataShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/DDataShardCoordinator.cs index 1393196e109..25cba4b05ff 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/DDataShardCoordinator.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/DDataShardCoordinator.cs @@ -28,7 +28,7 @@ internal sealed class DDataShardCoordinator : ActorBase, IWithTimers, IWithUnbou private sealed class RememberEntitiesStoreStopped { - public static RememberEntitiesStoreStopped Instance = new RememberEntitiesStoreStopped(); + public static RememberEntitiesStoreStopped Instance = new(); private RememberEntitiesStoreStopped() { @@ -47,7 +47,7 @@ public RememberEntitiesTimeout(ShardId shardId) private sealed class RememberEntitiesLoadTimeout { - public static readonly RememberEntitiesLoadTimeout Instance = new RememberEntitiesLoadTimeout(); + public static readonly RememberEntitiesLoadTimeout Instance = new(); private RememberEntitiesLoadTimeout() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocation.cs b/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocation.cs index 1ede3674a6a..5fdb60dca56 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocation.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocation.cs @@ -24,7 +24,7 @@ public static ExternalShardAllocation Get(ActorSystem system) } private readonly ExtendedActorSystem _system; - private readonly ConcurrentDictionary _clients = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _clients = new(); public ExternalShardAllocation(ExtendedActorSystem system) { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocationStrategy.cs b/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocationStrategy.cs index 4bdd42bdd8e..ccd85e1b10a 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocationStrategy.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/External/ExternalShardAllocationStrategy.cs @@ -58,7 +58,7 @@ public override int GetHashCode() public sealed class GetShardLocations : INoSerializationVerificationNeeded { - public static readonly GetShardLocations Instance = new GetShardLocations(); + public static readonly GetShardLocations Instance = new(); private GetShardLocations() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/AbstractLeastShardAllocationStrategy.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/AbstractLeastShardAllocationStrategy.cs index 668f611ac23..432fca72093 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/AbstractLeastShardAllocationStrategy.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/AbstractLeastShardAllocationStrategy.cs @@ -41,7 +41,7 @@ public RegionEntry(IActorRef region, Member member, IImmutableList shar internal sealed class ShardSuitabilityOrdering : IComparer { - public static readonly ShardSuitabilityOrdering Instance = new ShardSuitabilityOrdering(); + public static readonly ShardSuitabilityOrdering Instance = new(); private ShardSuitabilityOrdering() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs index 6b0a6f3d20d..b8edd25380c 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesCoordinatorStore.cs @@ -74,7 +74,7 @@ public override int GetHashCode() public sealed class MigrationMarker : IClusterShardingSerializable { - public static readonly MigrationMarker Instance = new MigrationMarker(); + public static readonly MigrationMarker Instance = new(); private MigrationMarker() { @@ -107,7 +107,7 @@ public EventSourcedRememberEntitiesCoordinatorStore( /// public override string PersistenceId { get; } - private readonly HashSet _shards = new HashSet(); + private readonly HashSet _shards = new(); private bool _writtenMarker = false; protected override bool ReceiveRecover(object message) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs index c61541bb32b..3f2b01e0402 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/EventSourcedRememberEntitiesShardStore.cs @@ -120,7 +120,7 @@ public override int GetHashCode() public sealed class StartedAck { - public static readonly StartedAck Instance = new StartedAck(); + public static readonly StartedAck Instance = new(); private StartedAck() { @@ -179,7 +179,7 @@ public static Props Props(string typeName, ShardId shardId, ClusterShardingSetti } private readonly int _maxUpdatesPerWrite; - private State _state = new State(); + private State _state = new(); /// /// Persistent actor keeping the state for Akka Persistence backed remember entities (enabled through `state-store-mode=persistence`). diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntitiesStore.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntitiesStore.cs index ad3ddaafdcc..3d4861c7d30 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntitiesStore.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntitiesStore.cs @@ -154,7 +154,7 @@ public override int GetHashCode() public sealed class GetEntities : ICommand { - public static readonly GetEntities Instance = new GetEntities(); + public static readonly GetEntities Instance = new(); private GetEntities() { @@ -342,7 +342,7 @@ public override int GetHashCode() /// public sealed class GetShards : ICommand { - public static readonly GetShards Instance = new GetShards(); + public static readonly GetShards Instance = new(); private GetShards() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntityStarter.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntityStarter.cs index 329cf46eaa8..485ec915c97 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntityStarter.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Internal/RememberEntityStarter.cs @@ -42,7 +42,7 @@ public StartBatch(int batchSize) // private case object ResendUnAcked extends NoSerializationVerificationNeeded private sealed class ResendUnAcked { - public static readonly ResendUnAcked Instance = new ResendUnAcked(); + public static readonly ResendUnAcked Instance = new(); private ResendUnAcked() { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs index 3418551cf34..44611eb2a3a 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs @@ -134,7 +134,7 @@ public sealed class GetCurrentShardState : IShardQuery, IClusterShardingSerializ /// /// TBD /// - public static readonly GetCurrentShardState Instance = new GetCurrentShardState(); + public static readonly GetCurrentShardState Instance = new(); private GetCurrentShardState() { @@ -211,7 +211,7 @@ public sealed class GetShardStats : IShardQuery, IClusterShardingSerializable /// /// TBD /// - public static readonly GetShardStats Instance = new GetShardStats(); + public static readonly GetShardStats Instance = new(); private GetShardStats() { @@ -309,7 +309,7 @@ public LeaseLost(Exception reason) [Serializable] public sealed class LeaseRetry : IDeadLetterSuppression, INoSerializationVerificationNeeded { - public static readonly LeaseRetry Instance = new LeaseRetry(); + public static readonly LeaseRetry Instance = new(); private LeaseRetry() { } } @@ -340,7 +340,7 @@ public static Props Props( [Serializable] public sealed class PassivateIdleTick : INoSerializationVerificationNeeded { - public static readonly PassivateIdleTick Instance = new PassivateIdleTick(); + public static readonly PassivateIdleTick Instance = new(); private PassivateIdleTick() { } } @@ -456,7 +456,7 @@ public override string ToString() /// internal sealed class NoState : EntityState { - public static readonly NoState Instance = new NoState(); + public static readonly NoState Instance = new(); private NoState() { @@ -488,7 +488,7 @@ public override EntityState Transition(EntityState newState, Entities entities) /// internal sealed class RememberedButNotCreated : EntityState { - public static readonly RememberedButNotCreated Instance = new RememberedButNotCreated(); + public static readonly RememberedButNotCreated Instance = new(); private RememberedButNotCreated() { @@ -518,7 +518,7 @@ public override EntityState Transition(EntityState newState, Entities entities) /// internal sealed class RememberingStart : EntityState, IEquatable { - private static readonly RememberingStart Empty = new RememberingStart(ImmutableHashSet.Empty); + private static readonly RememberingStart Empty = new(ImmutableHashSet.Empty); public static RememberingStart Create(IActorRef ackTo) { @@ -601,7 +601,7 @@ public override int GetHashCode() /// internal sealed class RememberingStop : EntityState { - public static readonly RememberingStop Instance = new RememberingStop(); + public static readonly RememberingStop Instance = new(); private RememberingStop() { @@ -705,7 +705,7 @@ public override EntityState Transition(EntityState newState, Entities entities) internal sealed class WaitingForRestart : EntityState { - public static readonly WaitingForRestart Instance = new WaitingForRestart(); + public static readonly WaitingForRestart Instance = new(); private WaitingForRestart() { @@ -730,11 +730,11 @@ public override EntityState Transition(EntityState newState, Entities entities) internal sealed class Entities { - private readonly Dictionary _entities = new Dictionary(); + private readonly Dictionary _entities = new(); // needed to look up entity by ref when a Passivating is received - private readonly Dictionary _byRef = new Dictionary(); + private readonly Dictionary _byRef = new(); // optimization to not have to go through all entities to find batched writes - private readonly HashSet _remembering = new HashSet(); + private readonly HashSet _remembering = new(); public Entities( @@ -928,8 +928,8 @@ public override string ToString() private readonly IActorRef _rememberEntitiesStore; private readonly bool _rememberEntities; private readonly Entities _entities; - private readonly Dictionary _lastMessageTimestamp = new Dictionary(); - private readonly MessageBufferMap _messageBuffers = new MessageBufferMap(); + private readonly Dictionary _lastMessageTimestamp = new(); + private readonly MessageBufferMap _messageBuffers = new(); private IActorRef _handOffStopper; private readonly ICancelable _passivateIdleTask; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs index ad078938b3b..dc8f043d64e 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs @@ -29,7 +29,7 @@ internal class ShardCoordinator /// internal sealed class Terminate : IDeadLetterSuppression { - public static readonly Terminate Instance = new Terminate(); + public static readonly Terminate Instance = new(); private Terminate() { @@ -1005,7 +1005,7 @@ public override int GetHashCode() [Serializable] public sealed class ShardCoordinatorInitialized : IDomainEvent, IEquatable { - public static readonly ShardCoordinatorInitialized Instance = new ShardCoordinatorInitialized(); + public static readonly ShardCoordinatorInitialized Instance = new(); private ShardCoordinatorInitialized() { @@ -1047,7 +1047,7 @@ internal sealed class StateInitialized /// /// TBD /// - public static readonly StateInitialized Instance = new StateInitialized(); + public static readonly StateInitialized Instance = new(); private StateInitialized() { } } @@ -1062,7 +1062,7 @@ internal sealed class CoordinatorState : IClusterShardingSerializable, IEquatabl /// /// TBD /// - public static readonly CoordinatorState Empty = new CoordinatorState(); + public static readonly CoordinatorState Empty = new(); /// /// Region for each shard. @@ -1301,7 +1301,7 @@ private sealed class RebalanceTick /// /// TBD /// - public static readonly RebalanceTick Instance = new RebalanceTick(); + public static readonly RebalanceTick Instance = new(); private RebalanceTick() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs index 98011c610ea..9540cf03e45 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardRegion.cs @@ -44,7 +44,7 @@ internal sealed class Retry : IShardRegionCommand, INoSerializationVerificationN /// /// TBD /// - public static readonly Retry Instance = new Retry(); + public static readonly Retry Instance = new(); private Retry() { } } @@ -65,7 +65,7 @@ internal sealed class RegisterRetry : IShardRegionCommand /// /// TBD /// - public static readonly RegisterRetry Instance = new RegisterRetry(); + public static readonly RegisterRetry Instance = new(); private RegisterRetry() { } } @@ -214,7 +214,7 @@ internal class HandOffStopper : ReceiveActor, IWithTimers { private sealed class StopTimeout { - public static readonly StopTimeout Instance = new StopTimeout(); + public static readonly StopTimeout Instance = new(); private StopTimeout() { @@ -223,7 +223,7 @@ private StopTimeout() private sealed class StopTimeoutWarning { - public static readonly StopTimeoutWarning Instance = new StopTimeoutWarning(); + public static readonly StopTimeoutWarning Instance = new(); private StopTimeoutWarning() { @@ -408,7 +408,7 @@ internal static Props ProxyProps( private IImmutableDictionary> _regions = ImmutableDictionary>.Empty; private IImmutableDictionary _regionByShard = ImmutableDictionary.Empty; - private readonly MessageBufferMap _shardBuffers = new MessageBufferMap(); + private readonly MessageBufferMap _shardBuffers = new(); private IImmutableDictionary _shards = ImmutableDictionary.Empty; private IImmutableDictionary _shardsByRef = ImmutableDictionary.Empty; private IImmutableSet _startingShards = ImmutableHashSet.Empty; @@ -424,7 +424,7 @@ internal static Props ProxyProps( private bool _gracefulShutdownInProgress; private readonly CoordinatedShutdown _coordShutdown = CoordinatedShutdown.Get(Context.System); - private readonly TaskCompletionSource _gracefulShutdownProgress = new TaskCompletionSource(); + private readonly TaskCompletionSource _gracefulShutdownProgress = new(); /// /// TBD diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs index fc3fcfc5549..0de178d708c 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs @@ -18,7 +18,7 @@ internal class KeepAlivePinger : UntypedActor, IWithTimers { private sealed class Tick { - public static Tick Instance { get; } = new Tick(); + public static Tick Instance { get; } = new(); private Tick() { } } @@ -170,6 +170,6 @@ public void Init(string name, int numberOfInstances, Func propsFacto public class ShardedDaemonProcessExtensionProvider : ExtensionIdProvider { - public override ShardedDaemonProcess CreateExtension(ExtendedActorSystem system) => new ShardedDaemonProcess(system); + public override ShardedDaemonProcess CreateExtension(ExtendedActorSystem system) => new(system); } } diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardingMessages.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardingMessages.cs index 0cf2bd2b857..a95d8094758 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardingMessages.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardingMessages.cs @@ -72,7 +72,7 @@ public sealed class GracefulShutdown : IShardRegionCommand /// /// TBD /// - public static readonly GracefulShutdown Instance = new GracefulShutdown(); + public static readonly GracefulShutdown Instance = new(); private GracefulShutdown() { @@ -85,7 +85,7 @@ internal sealed class GracefulShutdownTimeout : IShardRegionCommand /// /// TBD /// - public static readonly GracefulShutdownTimeout Instance = new GracefulShutdownTimeout(); + public static readonly GracefulShutdownTimeout Instance = new(); private GracefulShutdownTimeout() { @@ -151,7 +151,7 @@ public sealed class GetCurrentRegions : IShardRegionQuery, IClusterShardingSeria /// /// TBD /// - public static readonly GetCurrentRegions Instance = new GetCurrentRegions(); + public static readonly GetCurrentRegions Instance = new(); private GetCurrentRegions() { @@ -399,7 +399,7 @@ public sealed class GetShardRegionStats : IShardRegionQuery, IClusterShardingSer /// /// TBD /// - public static readonly GetShardRegionStats Instance = new GetShardRegionStats(); + public static readonly GetShardRegionStats Instance = new(); private GetShardRegionStats() { @@ -493,7 +493,7 @@ public sealed class GetShardRegionState : IShardRegionQuery, IClusterShardingSer /// /// TBD /// - public static readonly GetShardRegionState Instance = new GetShardRegionState(); + public static readonly GetShardRegionState Instance = new(); private GetShardRegionState() { @@ -644,7 +644,7 @@ public override string ToString() /// internal sealed class GetShardRegionStatus : IShardRegionQuery, INoSerializationVerificationNeeded { - public static readonly GetShardRegionStatus Instance = new GetShardRegionStatus(); + public static readonly GetShardRegionStatus Instance = new(); private GetShardRegionStatus() { diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs index 3498962cd05..0599542346b 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientSpec.cs @@ -109,7 +109,7 @@ public class TestClientListener : ReceiveActor #region TestClientListener messages public sealed class GetLatestContactPoints { - public static readonly GetLatestContactPoints Instance = new GetLatestContactPoints(); + public static readonly GetLatestContactPoints Instance = new(); private GetLatestContactPoints() { } } @@ -168,7 +168,7 @@ public class TestReceptionistListener : ReceiveActor #region TestReceptionistListener messages public sealed class GetLatestClusterClients { - public static readonly GetLatestClusterClients Instance = new GetLatestClusterClients(); + public static readonly GetLatestClusterClients Instance = new(); private GetLatestClusterClients() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/PublishSubscribe/DistributedPubSubMediatorSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/PublishSubscribe/DistributedPubSubMediatorSpec.cs index 8d47ebe0eff..95d060501d8 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/PublishSubscribe/DistributedPubSubMediatorSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/PublishSubscribe/DistributedPubSubMediatorSpec.cs @@ -238,7 +238,7 @@ protected override void OnReceive(object message) private readonly RoleName _second; private readonly RoleName _third; - private readonly ConcurrentDictionary _chatUsers = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _chatUsers = new(); public DistributedPubSubMediatorSpec() : this(new DistributedPubSubMediatorSpecConfig()) { diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs index 0d18ed2b323..b95fa792562 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerChaosSpec.cs @@ -57,7 +57,7 @@ public class ClusterSingletonManagerChaosSpec : MultiNodeClusterSpec { private class EchoStarted { - public static readonly EchoStarted Instance = new EchoStarted(); + public static readonly EchoStarted Instance = new(); private EchoStarted() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerDownedSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerDownedSpec.cs index 03e0efd9468..6e562891a43 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerDownedSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerDownedSpec.cs @@ -44,7 +44,7 @@ public ClusterSingletonManagerDownedSpecConfig() internal class EchoStarted { - public static readonly EchoStarted Instance = new EchoStarted(); + public static readonly EchoStarted Instance = new(); private EchoStarted() { } @@ -52,7 +52,7 @@ private EchoStarted() internal class EchoStopped { - public static readonly EchoStopped Instance = new EchoStopped(); + public static readonly EchoStopped Instance = new(); private EchoStopped() { } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerLeave2Spec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerLeave2Spec.cs index 7d1461e7fe0..4dbbaa4de3b 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerLeave2Spec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerLeave2Spec.cs @@ -51,7 +51,7 @@ public ClusterSingletonManagerLeave2SpecConfig() public class EchoStared { - public static EchoStared Instance { get; } = new EchoStared(); + public static EchoStared Instance { get; } = new(); private EchoStared() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerSpec.cs index 0dab4e99e97..5906e7750a8 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/Singleton/ClusterSingletonManagerSpec.cs @@ -69,7 +69,7 @@ internal class PointToPointChannel : UntypedActor public sealed class UnregisterConsumer { - public static readonly UnregisterConsumer Instance = new UnregisterConsumer(); + public static readonly UnregisterConsumer Instance = new(); private UnregisterConsumer() { @@ -78,7 +78,7 @@ private UnregisterConsumer() public sealed class RegisterConsumer { - public static readonly RegisterConsumer Instance = new RegisterConsumer(); + public static readonly RegisterConsumer Instance = new(); private RegisterConsumer() { @@ -87,7 +87,7 @@ private RegisterConsumer() public sealed class RegistrationOk { - public static readonly RegistrationOk Instance = new RegistrationOk(); + public static readonly RegistrationOk Instance = new(); private RegistrationOk() { @@ -96,7 +96,7 @@ private RegistrationOk() public sealed class UnexpectedRegistration { - public static readonly UnexpectedRegistration Instance = new UnexpectedRegistration(); + public static readonly UnexpectedRegistration Instance = new(); private UnexpectedRegistration() { @@ -105,7 +105,7 @@ private UnexpectedRegistration() public sealed class UnregistrationOk { - public static readonly UnregistrationOk Instance = new UnregistrationOk(); + public static readonly UnregistrationOk Instance = new(); private UnregistrationOk() { @@ -114,7 +114,7 @@ private UnregistrationOk() public sealed class UnexpectedUnregistration { - public static readonly UnexpectedUnregistration Instance = new UnexpectedUnregistration(); + public static readonly UnexpectedUnregistration Instance = new(); private UnexpectedUnregistration() { @@ -123,7 +123,7 @@ private UnexpectedUnregistration() public sealed class Reset { - public static readonly Reset Instance = new Reset(); + public static readonly Reset Instance = new(); private Reset() { @@ -132,7 +132,7 @@ private Reset() public sealed class ResetOk { - public static readonly ResetOk Instance = new ResetOk(); + public static readonly ResetOk Instance = new(); private ResetOk() { @@ -223,7 +223,7 @@ internal class Consumer : ReceiveActor public sealed class Ping { - public static readonly Ping Instance = new Ping(); + public static readonly Ping Instance = new(); private Ping() { @@ -232,7 +232,7 @@ private Ping() public sealed class Pong { - public static readonly Pong Instance = new Pong(); + public static readonly Pong Instance = new(); private Pong() { @@ -241,7 +241,7 @@ private Pong() public sealed class End { - public static readonly End Instance = new End(); + public static readonly End Instance = new(); private End() { @@ -250,7 +250,7 @@ private End() public sealed class GetCurrent { - public static readonly GetCurrent Instance = new GetCurrent(); + public static readonly GetCurrent Instance = new(); private GetCurrent() { diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMediatorSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMediatorSpec.cs index 36f6a693f55..03a3c239dac 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMediatorSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMediatorSpec.cs @@ -86,11 +86,11 @@ await EventFilter.DeadLetter().ExpectAsync(1, public sealed class QueryTopics { - public static QueryTopics Instance = new QueryTopics(); + public static QueryTopics Instance = new(); } public sealed class PublishTopic { - public static PublishTopic Instance = new PublishTopic(); + public static PublishTopic Instance = new(); } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMessageSerializerSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMessageSerializerSpec.cs index 69211553812..972156b5473 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMessageSerializerSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/PublishSubscribe/DistributedPubSubMessageSerializerSpec.cs @@ -57,16 +57,16 @@ public void Can_serialize_Delta() // TODO: Bucket should accepts IDictionary instead of ImmutableDictionary var message = new Delta(new List { - new Bucket(address1, 3, new Dictionary + new(address1, 3, new Dictionary { {"/user/u1", new ValueHolder(2, u1)}, {"/user/u2", new ValueHolder(3, u2)}, }.ToImmutableDictionary()), - new Bucket(address2, 17, new Dictionary + new(address2, 17, new Dictionary { {"/user/u3", new ValueHolder(17, u3)} }.ToImmutableDictionary()), - new Bucket(address3, 5, new Dictionary + new(address3, 5, new Dictionary { {"/user/u4", new ValueHolder(4, u4)}, {"/user/u5", new ValueHolder(5, null)}, diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonApiSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonApiSpec.cs index 43fe91c252b..c7068afb0a1 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonApiSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonApiSpec.cs @@ -24,7 +24,7 @@ public class ClusterSingletonApiSpec : AkkaSpec public sealed class Pong { - public static Pong Instance => new Pong(); + public static Pong Instance => new(); private Pong() { } } @@ -36,7 +36,7 @@ public sealed class Ping public sealed class Perish { - public static Perish Instance => new Perish(); + public static Perish Instance => new(); private Perish() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeaseSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeaseSpec.cs index 1cbf24b7918..a2ef81c5bb5 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeaseSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeaseSpec.cs @@ -80,7 +80,7 @@ protected TestException(SerializationInfo info, StreamingContext context) private Cluster cluster; private TestLeaseExt testLeaseExt; - private AtomicCounter counter = new AtomicCounter(0); + private AtomicCounter counter = new(0); private TimeSpan shortDuration = TimeSpan.FromMilliseconds(50); private string leaseOwner; diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterClient.cs b/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterClient.cs index 8da70cc5293..8d19f0415f5 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterClient.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterClient.cs @@ -132,7 +132,7 @@ internal sealed class RefreshContactsTick /// /// TBD /// - public static RefreshContactsTick Instance { get; } = new RefreshContactsTick(); + public static RefreshContactsTick Instance { get; } = new(); private RefreshContactsTick() { } } @@ -145,7 +145,7 @@ internal sealed class HeartbeatTick /// /// TBD /// - public static HeartbeatTick Instance { get; } = new HeartbeatTick(); + public static HeartbeatTick Instance { get; } = new(); private HeartbeatTick() { } } @@ -158,7 +158,7 @@ internal sealed class ReconnectTimeout /// /// TBD /// - public static ReconnectTimeout Instance { get; } = new ReconnectTimeout(); + public static ReconnectTimeout Instance { get; } = new(); private ReconnectTimeout() { } } @@ -598,7 +598,7 @@ public sealed class SubscribeContactPoints : ISubscribeContactPoints /// /// TBD /// - public static readonly SubscribeContactPoints Instance = new SubscribeContactPoints(); + public static readonly SubscribeContactPoints Instance = new(); private SubscribeContactPoints() { } } @@ -617,7 +617,7 @@ public sealed class UnsubscribeContactPoints : IUnsubscribeContactPoints /// /// TBD /// - public static readonly UnsubscribeContactPoints Instance = new UnsubscribeContactPoints(); + public static readonly UnsubscribeContactPoints Instance = new(); private UnsubscribeContactPoints() { } } @@ -637,7 +637,7 @@ public sealed class GetContactPoints : IGetContactPoints /// /// The singleton instance of this message. /// - public static readonly GetContactPoints Instance = new GetContactPoints(); + public static readonly GetContactPoints Instance = new(); private GetContactPoints() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterReceptionist.cs b/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterReceptionist.cs index 676a6c3b7aa..f2ae074c917 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterReceptionist.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Client/ClusterReceptionist.cs @@ -92,7 +92,7 @@ public sealed class SubscribeClusterClients /// /// TBD /// - public static SubscribeClusterClients Instance { get; } = new SubscribeClusterClients(); + public static SubscribeClusterClients Instance { get; } = new(); private SubscribeClusterClients() { } } @@ -104,7 +104,7 @@ public sealed class UnsubscribeClusterClients /// /// TBD /// - public static UnsubscribeClusterClients Instance { get; } = new UnsubscribeClusterClients(); + public static UnsubscribeClusterClients Instance { get; } = new(); private UnsubscribeClusterClients() { } } @@ -117,7 +117,7 @@ public sealed class GetClusterClients /// /// TBD /// - public static GetClusterClients Instance { get; } = new GetClusterClients(); + public static GetClusterClients Instance { get; } = new(); private GetClusterClients() { } } @@ -176,7 +176,7 @@ internal sealed class GetContacts : IClusterClientMessage, IDeadLetterSuppressio /// /// TBD /// - public static GetContacts Instance { get; } = new GetContacts(); + public static GetContacts Instance { get; } = new(); private GetContacts() { } } @@ -236,7 +236,7 @@ internal sealed class Heartbeat : IClusterClientMessage, IDeadLetterSuppression /// /// TBD /// - public static Heartbeat Instance { get; } = new Heartbeat(); + public static Heartbeat Instance { get; } = new(); private Heartbeat() { } } @@ -249,7 +249,7 @@ internal sealed class HeartbeatRsp : IClusterClientMessage, IDeadLetterSuppressi /// /// TBD /// - public static HeartbeatRsp Instance { get; } = new HeartbeatRsp(); + public static HeartbeatRsp Instance { get; } = new(); private HeartbeatRsp() { } } @@ -262,7 +262,7 @@ internal sealed class Ping : IDeadLetterSuppression /// /// TBD /// - public static Ping Instance { get; } = new Ping(); + public static Ping Instance { get; } = new(); private Ping() { } } @@ -274,7 +274,7 @@ internal sealed class CheckDeadlines /// /// TBD /// - public static CheckDeadlines Instance { get; } = new CheckDeadlines(); + public static CheckDeadlines Instance { get; } = new(); private CheckDeadlines() { } } @@ -286,7 +286,7 @@ private CheckDeadlines() { } /// internal sealed class ReceptionistShutdown : IClusterClientMessage { - public static readonly ReceptionistShutdown Instance = new ReceptionistShutdown(); + public static readonly ReceptionistShutdown Instance = new(); private ReceptionistShutdown() { } } #endregion @@ -314,7 +314,7 @@ internal class RingOrdering : IComparer
/// /// The singleton instance of this comparer /// - public static RingOrdering Instance { get; } = new RingOrdering(); + public static RingOrdering Instance { get; } = new(); private RingOrdering() { } /// diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedMessages.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedMessages.cs index 465f971d1df..d839d3bf9e6 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedMessages.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedMessages.cs @@ -561,7 +561,7 @@ public sealed class GetTopics /// /// TBD /// - public static GetTopics Instance { get; } = new GetTopics(); + public static GetTopics Instance { get; } = new(); private GetTopics() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs index cbcb0782e02..819c9cdd961 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs @@ -24,7 +24,7 @@ internal sealed class Prune /// /// TBD /// - public static Prune Instance { get; } = new Prune(); + public static Prune Instance { get; } = new(); private Prune() { } } @@ -37,7 +37,7 @@ internal sealed class Count /// /// TBD /// - public static Count Instance { get; } = new Count(); + public static Count Instance { get; } = new(); private Count() { } } @@ -299,7 +299,7 @@ internal sealed class DeltaCount /// /// TBD /// - public static readonly DeltaCount Instance = new DeltaCount(); + public static readonly DeltaCount Instance = new(); private DeltaCount() { } } @@ -313,7 +313,7 @@ internal sealed class GossipTick /// /// TBD /// - public static GossipTick Instance { get; } = new GossipTick(); + public static GossipTick Instance { get; } = new(); private GossipTick() { } } @@ -458,7 +458,7 @@ internal sealed class NoMoreSubscribers : IChildActorTerminationProtocol /// /// TBD /// - public static NoMoreSubscribers Instance { get; } = new NoMoreSubscribers(); + public static NoMoreSubscribers Instance { get; } = new(); private NoMoreSubscribers() {} } @@ -471,7 +471,7 @@ internal sealed class TerminateRequest : IChildActorTerminationProtocol /// /// TBD /// - public static TerminateRequest Instance { get; } = new TerminateRequest(); + public static TerminateRequest Instance { get; } = new(); private TerminateRequest() {} } @@ -485,7 +485,7 @@ internal sealed class NewSubscriberArrived : IChildActorTerminationProtocol /// /// TBD /// - public static NewSubscriberArrived Instance { get; } = new NewSubscriberArrived(); + public static NewSubscriberArrived Instance { get; } = new(); private NewSubscriberArrived() { } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/Topics.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/Topics.cs index af7b1545c35..b1be7fffd6c 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/Topics.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/Topics.cs @@ -324,8 +324,7 @@ protected override bool Business(object message) /// internal static class Utils { - private static System.Text.RegularExpressions.Regex _pathRegex = - new System.Text.RegularExpressions.Regex("^/remote/.+(/user/.+)"); + private static System.Text.RegularExpressions.Regex _pathRegex = new("^/remote/.+(/user/.+)"); /// /// diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/PerGroupingBuffer.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/PerGroupingBuffer.cs index 22c88092b03..728c3237b92 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/PerGroupingBuffer.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/PerGroupingBuffer.cs @@ -17,7 +17,7 @@ namespace Akka.Cluster.Tools.PublishSubscribe /// internal class PerGroupingBuffer { - private readonly Dictionary _buffers = new Dictionary(); + private readonly Dictionary _buffers = new(); private int _totalBufferSize = 0; /// diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingleton.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingleton.cs index 0c73b15e96f..d86d402b74c 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingleton.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingleton.cs @@ -22,7 +22,7 @@ public class ClusterSingleton : IExtension { private readonly ActorSystem _system; private readonly Lazy _cluster; - private readonly ConcurrentDictionary _proxies = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _proxies = new(); public static ClusterSingleton Get(ActorSystem system) => system.WithExtension(); @@ -83,7 +83,7 @@ IActorRef ProxyCreator() public class ClusterSingletonProvider : ExtensionIdProvider { - public override ClusterSingleton CreateExtension(ExtendedActorSystem system) => new ClusterSingleton(system); + public override ClusterSingleton CreateExtension(ExtendedActorSystem system) => new(system); } public class SingletonActor @@ -96,8 +96,7 @@ public class SingletonActor public Option Settings { get; } - public static SingletonActor Create(Props props, string name) => - new SingletonActor(name, props, Option.None, Option.None); + public static SingletonActor Create(Props props, string name) => new(name, props, Option.None, Option.None); private SingletonActor(string name, Props props, Option stopMessage, Option settings) { @@ -126,6 +125,6 @@ private SingletonActor(string name, Props props, Option stopMessage, Opt public SingletonActor WithSettings(ClusterSingletonSettings settings) => Copy(settings: settings); private SingletonActor Copy(string name = null, Props props = null, Option stopMessage = default, Option settings = default) => - new SingletonActor(name ?? Name, props ?? Props, stopMessage.HasValue ? stopMessage : StopMessage, settings.HasValue ? settings : Settings); + new(name ?? Name, props ?? Props, stopMessage.HasValue ? stopMessage : StopMessage, settings.HasValue ? settings : Settings); } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs index b2d7326c043..848a1caffd9 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs @@ -39,7 +39,7 @@ internal sealed class HandOverToMe : IClusterSingletonMessage, IDeadLetterSuppre /// /// TBD /// - public static HandOverToMe Instance { get; } = new HandOverToMe(); + public static HandOverToMe Instance { get; } = new(); private HandOverToMe() { } } @@ -54,7 +54,7 @@ internal sealed class HandOverInProgress : IClusterSingletonMessage /// /// TBD /// - public static HandOverInProgress Instance { get; } = new HandOverInProgress(); + public static HandOverInProgress Instance { get; } = new(); private HandOverInProgress() { } } @@ -69,7 +69,7 @@ internal sealed class HandOverDone : IClusterSingletonMessage /// /// TBD /// - public static HandOverDone Instance { get; } = new HandOverDone(); + public static HandOverDone Instance { get; } = new(); private HandOverDone() { } } @@ -87,7 +87,7 @@ internal sealed class TakeOverFromMe : IClusterSingletonMessage, IDeadLetterSupp /// /// TBD /// - public static TakeOverFromMe Instance { get; } = new TakeOverFromMe(); + public static TakeOverFromMe Instance { get; } = new(); private TakeOverFromMe() { } } @@ -100,7 +100,7 @@ internal sealed class Cleanup /// /// TBD /// - public static Cleanup Instance { get; } = new Cleanup(); + public static Cleanup Instance { get; } = new(); private Cleanup() { } } @@ -113,7 +113,7 @@ internal sealed class StartOldestChangedBuffer /// /// TBD /// - public static StartOldestChangedBuffer Instance { get; } = new StartOldestChangedBuffer(); + public static StartOldestChangedBuffer Instance { get; } = new(); private StartOldestChangedBuffer() { } } @@ -168,7 +168,7 @@ internal sealed class LeaseRetry: INoSerializationVerificationNeeded /// /// TBD /// - public static LeaseRetry Instance { get; } = new LeaseRetry(); + public static LeaseRetry Instance { get; } = new(); private LeaseRetry() { } } @@ -186,7 +186,7 @@ internal sealed class Uninitialized : IClusterSingletonData /// /// TBD /// - public static Uninitialized Instance { get; } = new Uninitialized(); + public static Uninitialized Instance { get; } = new(); private Uninitialized() { } } @@ -340,7 +340,7 @@ internal sealed class EndData : IClusterSingletonData /// /// TBD /// - public static EndData Instance { get; } = new EndData(); + public static EndData Instance { get; } = new(); private EndData() { } } @@ -461,7 +461,7 @@ private SelfExiting() { } /// /// Singleton instance /// - public static SelfExiting Instance { get; } = new SelfExiting(); + public static SelfExiting Instance { get; } = new(); } /// @@ -633,7 +633,7 @@ public static Props Props(Props singletonProps, object terminationMessage, Clust private ILoggingAdapter _log; private readonly CoordinatedShutdown _coordShutdown = CoordinatedShutdown.Get(Context.System); - private readonly TaskCompletionSource _memberExitingProgress = new TaskCompletionSource(); + private readonly TaskCompletionSource _memberExitingProgress = new(); private readonly string singletonLeaseName; private readonly Lease lease; diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs index 882eb3dcc6d..178123b3b3c 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs @@ -47,7 +47,7 @@ internal sealed class TryToIdentifySingleton : INoSerializationVerificationNeede /// /// TBD /// - public static TryToIdentifySingleton Instance { get; } = new TryToIdentifySingleton(); + public static TryToIdentifySingleton Instance { get; } = new(); private TryToIdentifySingleton() { } } @@ -79,7 +79,7 @@ public static Props Props(string singletonManagerPath, ClusterSingletonProxySett private readonly MemberAgeOrdering _memberAgeComparer; private readonly ClusterSingletonProxySettings _settings; private readonly Cluster _cluster = Cluster.Get(Context.System); - private readonly Queue> _buffer = new Queue>(); // queue seems to fit better + private readonly Queue> _buffer = new(); // queue seems to fit better private readonly string[] _singletonPath; private int _identityCounter = 0; private string _identityId; diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonSettings.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonSettings.cs index 8d023766be8..f70d9c061a2 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonSettings.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonSettings.cs @@ -150,11 +150,11 @@ private ClusterSingletonSettings Copy( [InternalApi] internal ClusterSingletonManagerSettings ToManagerSettings(string singletonName) => - new ClusterSingletonManagerSettings(singletonName, Role, RemovalMargin, HandOverRetryInterval, LeaseSettings, ConsiderAppVersion); + new(singletonName, Role, RemovalMargin, HandOverRetryInterval, LeaseSettings, ConsiderAppVersion); [InternalApi] internal ClusterSingletonProxySettings ToProxySettings(string singletonName) => - new ClusterSingletonProxySettings(singletonName, Role, SingletonIdentificationInterval, BufferSize, ConsiderAppVersion); + new(singletonName, Role, SingletonIdentificationInterval, BufferSize, ConsiderAppVersion); [InternalApi] internal bool ShouldRunManager(Cluster cluster) => string.IsNullOrEmpty(Role) || cluster.SelfMember.Roles.Contains(Role); diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/MemberAgeOrdering.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/MemberAgeOrdering.cs index fac15deaf04..420ca1b68c3 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/MemberAgeOrdering.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/MemberAgeOrdering.cs @@ -43,15 +43,15 @@ public int Compare(Member x, Member y) /// /// TBD /// - public static readonly MemberAgeOrdering Ascending = new MemberAgeOrdering(true, false); + public static readonly MemberAgeOrdering Ascending = new(true, false); - public static readonly MemberAgeOrdering AscendingWithAppVersion = new MemberAgeOrdering(true, true); + public static readonly MemberAgeOrdering AscendingWithAppVersion = new(true, true); /// /// TBD /// - public static readonly MemberAgeOrdering Descending = new MemberAgeOrdering(false, false); + public static readonly MemberAgeOrdering Descending = new(false, false); - public static readonly MemberAgeOrdering DescendingWithAppVersion = new MemberAgeOrdering(false, true); + public static readonly MemberAgeOrdering DescendingWithAppVersion = new(false, true); } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/OldestChangedBuffer.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/OldestChangedBuffer.cs index 3ba87332439..7af3a3aeca4 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/OldestChangedBuffer.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/OldestChangedBuffer.cs @@ -37,7 +37,7 @@ public sealed class GetNext /// /// TBD /// - public static GetNext Instance { get; } = new GetNext(); + public static GetNext Instance { get; } = new(); private GetNext() { } } diff --git a/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs b/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs index b6fb2afa32d..56d2b6447ea 100644 --- a/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs +++ b/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs @@ -45,7 +45,7 @@ public sealed class LmdbDurableStore : ReceiveActor private sealed class WriteBehind : IDeadLetterSuppression { - public static readonly WriteBehind Instance = new WriteBehind(); + public static readonly WriteBehind Instance = new(); private WriteBehind() { } } @@ -58,7 +58,7 @@ private WriteBehind() { } private readonly TimeSpan _writeBehindInterval; private readonly string _dir; - private readonly Dictionary _pending = new Dictionary(); + private readonly Dictionary _pending = new(); private readonly ILoggingAdapter _log; public LmdbDurableStore(Config config) diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs index d753e4b3546..be9ff4d20b1 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataPocoSpec.cs @@ -97,9 +97,9 @@ public abstract class DurableDataPocoSpecBase : MultiNodeClusterSpec private readonly IWriteConsistency _writeThree; private readonly IReadConsistency _readThree; - private readonly ORDictionaryKey _keyA = new ORDictionaryKey("durable-A"); - private readonly ORDictionaryKey _keyB = new ORDictionaryKey("durable-B"); - private readonly ORSetKey _keyC = new ORSetKey("durable-C"); + private readonly ORDictionaryKey _keyA = new("durable-A"); + private readonly ORDictionaryKey _keyB = new("durable-B"); + private readonly ORSetKey _keyC = new("durable-C"); private int _testStepCounter = 0; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs index c060f6ec616..aba0e5f1d5a 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurableDataSpec.cs @@ -85,9 +85,9 @@ public static Props TestDurableStoreProps(bool failLoad = false, bool failStore private readonly IWriteConsistency writeTwo; private readonly IReadConsistency readTwo; - private readonly GCounterKey keyA = new GCounterKey("durable-A"); - private readonly GCounterKey keyB = new GCounterKey("durable-B"); - private readonly ORSetKey keyC = new ORSetKey("durable-C"); + private readonly GCounterKey keyA = new("durable-A"); + private readonly GCounterKey keyB = new("durable-B"); + private readonly ORSetKey keyC = new("durable-C"); private int testStepCounter = 0; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurablePruningSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurablePruningSpec.cs index a76d8c04b01..b1c161ab127 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurablePruningSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurablePruningSpec.cs @@ -44,11 +44,11 @@ public DurablePruningSpecConfig() public class DurablePruningSpec : MultiNodeClusterSpec { private readonly Cluster.Cluster cluster; - private readonly RoleName first = new RoleName("first"); - private readonly RoleName second = new RoleName("second"); + private readonly RoleName first = new("first"); + private readonly RoleName second = new("second"); private readonly TimeSpan maxPruningDissemination = TimeSpan.FromSeconds(3); private readonly TimeSpan timeout; - private readonly GCounterKey keyA = new GCounterKey("A"); + private readonly GCounterKey keyA = new("A"); private readonly IActorRef replicator; public DurablePruningSpec() : this(new DurablePruningSpecConfig()) diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/JepsenInspiredInsertSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/JepsenInspiredInsertSpec.cs index ce3ecc5ebf3..14f46647dd8 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/JepsenInspiredInsertSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/JepsenInspiredInsertSpec.cs @@ -54,12 +54,12 @@ public JepsenInspiredInsertSpecConfig() public class JepsenInspiredInsertSpec : MultiNodeClusterSpec { - public static readonly RoleName Controller = new RoleName("controller"); - public static readonly RoleName N1 = new RoleName("n1"); - public static readonly RoleName N2 = new RoleName("n2"); - public static readonly RoleName N3 = new RoleName("n3"); - public static readonly RoleName N4 = new RoleName("n4"); - public static readonly RoleName N5 = new RoleName("n5"); + public static readonly RoleName Controller = new("controller"); + public static readonly RoleName N1 = new("n1"); + public static readonly RoleName N2 = new("n2"); + public static readonly RoleName N3 = new("n3"); + public static readonly RoleName N4 = new("n4"); + public static readonly RoleName N5 = new("n5"); private readonly Cluster.Cluster _cluster; private readonly IActorRef _replicator; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorChaosSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorChaosSpec.cs index eec55e7a2b7..b1f8f80c92a 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorChaosSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorChaosSpec.cs @@ -50,23 +50,23 @@ public ReplicatorChaosSpecConfig() public class ReplicatorChaosSpec : MultiNodeClusterSpec { - public static readonly RoleName First = new RoleName("first"); - public static readonly RoleName Second = new RoleName("second"); - public static readonly RoleName Third = new RoleName("third"); - public static readonly RoleName Fourth = new RoleName("fourth"); - public static readonly RoleName Fifth = new RoleName("fifth"); + public static readonly RoleName First = new("first"); + public static readonly RoleName Second = new("second"); + public static readonly RoleName Third = new("third"); + public static readonly RoleName Fourth = new("fourth"); + public static readonly RoleName Fifth = new("fifth"); private readonly Cluster.Cluster _cluster; private readonly IActorRef _replicator; private readonly TimeSpan _timeout; - public readonly GCounterKey KeyA = new GCounterKey("A"); - public readonly PNCounterKey KeyB = new PNCounterKey("B"); - public readonly GCounterKey KeyC = new GCounterKey("C"); - public readonly GCounterKey KeyD = new GCounterKey("D"); - public readonly GSetKey KeyE = new GSetKey("E"); - public readonly ORSetKey KeyF = new ORSetKey("F"); - public readonly GCounterKey KeyX = new GCounterKey("X"); + public readonly GCounterKey KeyA = new("A"); + public readonly PNCounterKey KeyB = new("B"); + public readonly GCounterKey KeyC = new("C"); + public readonly GCounterKey KeyD = new("D"); + public readonly GSetKey KeyE = new("E"); + public readonly ORSetKey KeyF = new("F"); + public readonly GCounterKey KeyX = new("X"); public ReplicatorChaosSpec() : this(new ReplicatorChaosSpecConfig()) { } protected ReplicatorChaosSpec(ReplicatorChaosSpecConfig config) : base(config, typeof(ReplicatorChaosSpec)) diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorPruningSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorPruningSpec.cs index 7ffddaafa6e..78c21e433e4 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorPruningSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorPruningSpec.cs @@ -51,9 +51,9 @@ public class ReplicatorPruningSpec : MultiNodeClusterSpec private readonly IActorRef _replicator; private readonly TimeSpan _timeout; - private readonly GCounterKey _keyA = new GCounterKey("A"); - private readonly ORSetKey _keyB = new ORSetKey("B"); - private readonly PNCounterDictionaryKey _keyC = new PNCounterDictionaryKey("C"); + private readonly GCounterKey _keyA = new("A"); + private readonly ORSetKey _keyB = new("B"); + private readonly PNCounterDictionaryKey _keyC = new("C"); public ReplicatorPruningSpec() : this(new ReplicatorPruningSpecConfig()) { diff --git a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs index 31089fb4b0d..bf72db01330 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/ReplicatorSpec.cs @@ -51,21 +51,21 @@ public class ReplicatorSpec : MultiNodeClusterSpec private readonly IActorRef _replicator; - private readonly GCounterKey KeyA = new GCounterKey("A"); - private readonly GCounterKey KeyB = new GCounterKey("B"); - private readonly GCounterKey KeyC = new GCounterKey("C"); - private readonly GCounterKey KeyD = new GCounterKey("D"); - private readonly GCounterKey KeyE = new GCounterKey("E"); - private readonly GCounterKey KeyE2 = new GCounterKey("E2"); - private readonly GCounterKey KeyF = new GCounterKey("F"); - private readonly ORSetKey KeyG = new ORSetKey("G"); - private readonly ORDictionaryKey KeyH = new ORDictionaryKey("H"); - private readonly GSetKey KeyI = new GSetKey("I"); - private readonly GSetKey KeyJ = new GSetKey("J"); - private readonly LWWRegisterKey KeyK = new LWWRegisterKey("K"); - private readonly GCounterKey KeyX = new GCounterKey("X"); - private readonly GCounterKey KeyY = new GCounterKey("Y"); - private readonly GCounterKey KeyZ = new GCounterKey("Z"); + private readonly GCounterKey KeyA = new("A"); + private readonly GCounterKey KeyB = new("B"); + private readonly GCounterKey KeyC = new("C"); + private readonly GCounterKey KeyD = new("D"); + private readonly GCounterKey KeyE = new("E"); + private readonly GCounterKey KeyE2 = new("E2"); + private readonly GCounterKey KeyF = new("F"); + private readonly ORSetKey KeyG = new("G"); + private readonly ORDictionaryKey KeyH = new("H"); + private readonly GSetKey KeyI = new("I"); + private readonly GSetKey KeyJ = new("J"); + private readonly LWWRegisterKey KeyK = new("K"); + private readonly GCounterKey KeyX = new("X"); + private readonly GCounterKey KeyY = new("Y"); + private readonly GCounterKey KeyZ = new("Z"); private readonly TimeSpan _timeOut; private readonly WriteTo _writeTwo; diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/DataEnvelopeSpecs.cs b/src/contrib/cluster/Akka.DistributedData.Tests/DataEnvelopeSpecs.cs index 05f3f3ff512..fc22cf72f89 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/DataEnvelopeSpecs.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/DataEnvelopeSpecs.cs @@ -17,10 +17,10 @@ namespace Akka.DistributedData.Tests { public class DataEnvelopeSpec { - private readonly UniqueAddress node1 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2551), 1); - private readonly UniqueAddress node2 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2552), 1); - private readonly UniqueAddress node3 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2553), 1); - private readonly UniqueAddress node4 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2554), 1); + private readonly UniqueAddress node1 = new(new Address("akka.tcp", "Sys", "localhost", 2551), 1); + private readonly UniqueAddress node2 = new(new Address("akka.tcp", "Sys", "localhost", 2552), 1); + private readonly UniqueAddress node3 = new(new Address("akka.tcp", "Sys", "localhost", 2553), 1); + private readonly UniqueAddress node4 = new(new Address("akka.tcp", "Sys", "localhost", 2554), 1); private readonly DateTime obsoleteTimeInFuture = DateTime.UtcNow.AddHours(1); private readonly DateTime obsoleteTime = DateTime.UtcNow.AddHours(-1); diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/DeltaPropagationSelectorSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/DeltaPropagationSelectorSpec.cs index aadfdac34a6..290f011c6ae 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/DeltaPropagationSelectorSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/DeltaPropagationSelectorSpec.cs @@ -36,7 +36,7 @@ public TestSelector(UniqueAddress selfUniqueAddress, ImmutableArray
all protected override int MaxDeltaSize => 10; protected override DeltaPropagation CreateDeltaPropagation(ImmutableDictionary deltas) => - new DeltaPropagation(selfUniqueAddress, false, deltas + new(selfUniqueAddress, false, deltas .Select(kv => new KeyValuePair(kv.Key, new Delta(new DataEnvelope(kv.Value.Item1), kv.Value.Item2, kv.Value.Item3))) .ToImmutableDictionary()); } diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/GCounterSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/GCounterSpec.cs index 8af5688cfcf..52eaf306c37 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/GCounterSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/GCounterSpec.cs @@ -17,9 +17,9 @@ namespace Akka.DistributedData.Tests [Collection("DistributedDataSpec")] public class GCounterSpec { - private readonly UniqueAddress _node1 = new UniqueAddress(new Actor.Address("akka.tcp", "Sys", "localhost", 2551), 1); - private readonly UniqueAddress _node2 = new UniqueAddress(new Actor.Address("akka.tcp", "Sys", "localhost", 2552), 2); - private readonly UniqueAddress _node3 = new UniqueAddress(new Actor.Address("akka.tcp", "Sys", "localhost", 2553), 3); + private readonly UniqueAddress _node1 = new(new Actor.Address("akka.tcp", "Sys", "localhost", 2551), 1); + private readonly UniqueAddress _node2 = new(new Actor.Address("akka.tcp", "Sys", "localhost", 2552), 2); + private readonly UniqueAddress _node3 = new(new Actor.Address("akka.tcp", "Sys", "localhost", 2553), 3); public GCounterSpec(ITestOutputHelper output) { diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs index fb1ba20f7e6..d55ef5d1116 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs @@ -18,7 +18,7 @@ public class LocalConcurrencySpec : Akka.TestKit.Xunit2.TestKit { public sealed class Updater : ReceiveActor, IWithUnboundedStash { - public static readonly ORSetKey Key = new ORSetKey("key"); + public static readonly ORSetKey Key = new("key"); public Updater() { var cluster = Cluster.Cluster.Get(Context.System); diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/PruningStateSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/PruningStateSpec.cs index 5fe46049fec..547ce79bceb 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/PruningStateSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/PruningStateSpec.cs @@ -18,10 +18,10 @@ namespace Akka.DistributedData.Tests [Collection("DistributedDataSpec")] public class PruningStateSpec { - private readonly UniqueAddress _node1 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2551), 1); - private readonly UniqueAddress _node2 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2552), 2); - private readonly UniqueAddress _node3 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2553), 3); - private readonly UniqueAddress _node4 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2554), 4); + private readonly UniqueAddress _node1 = new(new Address("akka.tcp", "Sys", "localhost", 2551), 1); + private readonly UniqueAddress _node2 = new(new Address("akka.tcp", "Sys", "localhost", 2552), 2); + private readonly UniqueAddress _node3 = new(new Address("akka.tcp", "Sys", "localhost", 2553), 3); + private readonly UniqueAddress _node4 = new(new Address("akka.tcp", "Sys", "localhost", 2554), 4); public PruningStateSpec(ITestOutputHelper output) { diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs index 438d0ef3e48..8cb60f43848 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/ReplicatorSpecs.cs @@ -59,11 +59,11 @@ static ReplicatorSpecs() private readonly ReadMajority _readMajority; private readonly ReadAll _readAll; - private readonly PNCounterDictionaryKey _keyC = new PNCounterDictionaryKey("C"); - private readonly ORDictionaryKey _keyH = new ORDictionaryKey("H"); - private readonly GSetKey _keyI = new GSetKey("I"); - private readonly ORMultiValueDictionaryKey _keyJ = new ORMultiValueDictionaryKey("J"); - private readonly LWWDictionaryKey _keyK = new LWWDictionaryKey("K"); + private readonly PNCounterDictionaryKey _keyC = new("C"); + private readonly ORDictionaryKey _keyH = new("H"); + private readonly GSetKey _keyI = new("I"); + private readonly ORMultiValueDictionaryKey _keyJ = new("J"); + private readonly LWWDictionaryKey _keyK = new("K"); public ReplicatorSpecs(ITestOutputHelper helper) : base(SpecConfig, helper) { diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/VersionVectorSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/VersionVectorSpec.cs index c86c8ba577a..5a82fda3baf 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/VersionVectorSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/VersionVectorSpec.cs @@ -15,10 +15,10 @@ namespace Akka.DistributedData.Tests [Collection("DistributedDataSpec")] public class VersionVectorSpec { - private readonly UniqueAddress _node1 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2551), 1); - private readonly UniqueAddress _node2 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2552), 2); - private readonly UniqueAddress _node3 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2553), 3); - private readonly UniqueAddress _node4 = new UniqueAddress(new Address("akka.tcp", "Sys", "localhost", 2554), 4); + private readonly UniqueAddress _node1 = new(new Address("akka.tcp", "Sys", "localhost", 2551), 1); + private readonly UniqueAddress _node2 = new(new Address("akka.tcp", "Sys", "localhost", 2552), 2); + private readonly UniqueAddress _node3 = new(new Address("akka.tcp", "Sys", "localhost", 2553), 3); + private readonly UniqueAddress _node4 = new(new Address("akka.tcp", "Sys", "localhost", 2554), 4); public VersionVectorSpec(ITestOutputHelper output) { diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/WriteAggregatorSpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/WriteAggregatorSpec.cs index 05a8850ac9b..fcf190b8be0 100644 --- a/src/contrib/cluster/Akka.DistributedData.Tests/WriteAggregatorSpec.cs +++ b/src/contrib/cluster/Akka.DistributedData.Tests/WriteAggregatorSpec.cs @@ -78,18 +78,18 @@ private static Props TestWriteAggregatorPropsWithDelta(ORSet data, IActorRef replyTo, bool durable) => Actor.Props.Create(() => new TestWriteAggregator>(KeyB, data, delta, consistency, probes, nodes, unreachable, replyTo, durable)); - private static readonly GSetKey KeyA = new GSetKey("a"); - private static readonly ORSetKey KeyB = new ORSetKey("b"); + private static readonly GSetKey KeyA = new("a"); + private static readonly ORSetKey KeyB = new("b"); - private readonly Address _nodeA = new Address("akka.tcp", "Sys", "a", 2552); - private readonly Address _nodeB = new Address("akka.tcp", "Sys", "b", 2552); - private readonly Address _nodeC = new Address("akka.tcp", "Sys", "c", 2552); - private readonly Address _nodeD = new Address("akka.tcp", "Sys", "d", 2552); + private readonly Address _nodeA = new("akka.tcp", "Sys", "a", 2552); + private readonly Address _nodeB = new("akka.tcp", "Sys", "b", 2552); + private readonly Address _nodeC = new("akka.tcp", "Sys", "c", 2552); + private readonly Address _nodeD = new("akka.tcp", "Sys", "d", 2552); private readonly IImmutableList
_nodes; private readonly GSet _data = GSet.Create("A", "B"); - private readonly WriteTo _writeThree = new WriteTo(3, TimeSpan.FromSeconds(3)); - private readonly WriteMajority _writeMajority = new WriteMajority(TimeSpan.FromSeconds(3)); + private readonly WriteTo _writeThree = new(3, TimeSpan.FromSeconds(3)); + private readonly WriteMajority _writeMajority = new(TimeSpan.FromSeconds(3)); private readonly WriteAll _writeAll; private readonly ORSet _fullState1; diff --git a/src/contrib/cluster/Akka.DistributedData/DistributedData.cs b/src/contrib/cluster/Akka.DistributedData/DistributedData.cs index 20f38f7557b..0f19f371b6c 100644 --- a/src/contrib/cluster/Akka.DistributedData/DistributedData.cs +++ b/src/contrib/cluster/Akka.DistributedData/DistributedData.cs @@ -249,7 +249,7 @@ public class DistributedDataProvider : ExtensionIdProvider ///
/// TBD /// TBD - public override DistributedData CreateExtension(ExtendedActorSystem system) => new DistributedData(system); + public override DistributedData CreateExtension(ExtendedActorSystem system) => new(system); } public static class DistributedDataExtensions diff --git a/src/contrib/cluster/Akka.DistributedData/Dsl.cs b/src/contrib/cluster/Akka.DistributedData/Dsl.cs index bfd60bce475..185c6852d39 100644 --- a/src/contrib/cluster/Akka.DistributedData/Dsl.cs +++ b/src/contrib/cluster/Akka.DistributedData/Dsl.cs @@ -62,7 +62,7 @@ public static class Dsl /// public static Update Update(IKey key, T value, IWriteConsistency consistency = null) where T : IReplicatedData => - new Update(key, value, consistency ?? WriteLocal, old => old.Merge(value)); + new(key, value, consistency ?? WriteLocal, old => old.Merge(value)); /// /// Constructs a message that, when send to , @@ -79,7 +79,7 @@ public static Update Update(IKey key, T value, IWriteConsistency consisten /// An updating function. /// TBD public static Update Update(IKey key, IWriteConsistency consistency, Func modify) where T : IReplicatedData => - new Update(key, consistency, data => modify((T)data)); + new(key, consistency, data => modify((T)data)); /// /// Constructs a message that, when send to , @@ -98,7 +98,7 @@ public static Update Update(IKey key, IWriteConsistency consistency, Func< /// An updating function. /// TBD public static Update Update(IKey key, T initial, IWriteConsistency consistency, Func modify) where T : IReplicatedData => - new Update(key, initial, consistency, data => modify((T)data)); + new(key, initial, consistency, data => modify((T)data)); /// /// Constructs a message that, when send to , @@ -121,7 +121,7 @@ public static Update Update(IKey key, T initial, IWriteConsistency consist /// An updating function. /// TBD public static Update Update(IKey key, T initial, IWriteConsistency consistency, object request, Func modify) where T : IReplicatedData => - new Update(key, initial, consistency, data => modify((T)data), request); + new(key, initial, consistency, data => modify((T)data), request); /// /// Constructs a message that, when send to , @@ -140,7 +140,7 @@ public static Update Update(IKey key, T initial, IWriteConsistency consist /// /// TBD public static Get Get(IKey key, IReadConsistency consistency = null, object request = null) where T : IReplicatedData => - new Get(key, consistency ?? ReadLocal, request); + new(key, consistency ?? ReadLocal, request); /// /// Constructs a message that, when send to , @@ -162,7 +162,7 @@ public static Get Get(IKey key, IReadConsistency consistency = null, objec /// /// TBD public static Delete Delete(IKey key, IWriteConsistency consistency, object request = null) where T: IReplicatedData => - new Delete(key, consistency, request); + new(key, consistency, request); /// /// Constructs a message that, when send to , @@ -177,7 +177,7 @@ public static Delete Delete(IKey key, IWriteConsistency consistency, objec /// Actor subscribing to changes under provided . /// TBD public static Subscribe Subscribe(IKey key, IActorRef subscriber) where T : IReplicatedData => - new Subscribe(key, subscriber); + new(key, subscriber); /// /// Constructs a message that, when send to , @@ -189,6 +189,6 @@ public static Subscribe Subscribe(IKey key, IActorRef subscriber) where T /// A subscriber for the ed value changes. /// TBD public static Unsubscribe Unsubscribe(IKey key, IActorRef subscriber) where T : IReplicatedData => - new Unsubscribe(key, subscriber); + new(key, subscriber); } } diff --git a/src/contrib/cluster/Akka.DistributedData/Durable/Messages.cs b/src/contrib/cluster/Akka.DistributedData/Durable/Messages.cs index ecd06a959dd..e3df2425945 100644 --- a/src/contrib/cluster/Akka.DistributedData/Durable/Messages.cs +++ b/src/contrib/cluster/Akka.DistributedData/Durable/Messages.cs @@ -57,7 +57,7 @@ public StoreReply(object successMessage, object failureMessage, IActorRef replyT /// public sealed class LoadAll : IEquatable { - public static readonly LoadAll Instance = new LoadAll(); + public static readonly LoadAll Instance = new(); private LoadAll() { } public bool Equals(LoadAll other) => true; public override bool Equals(object obj) => obj is LoadAll; @@ -75,7 +75,7 @@ public LoadData(ImmutableDictionary data) public sealed class LoadAllCompleted : IEquatable { - public static readonly LoadAllCompleted Instance = new LoadAllCompleted(); + public static readonly LoadAllCompleted Instance = new(); private LoadAllCompleted() { } public bool Equals(LoadAllCompleted other) => true; public override bool Equals(object obj) => obj is LoadAllCompleted; diff --git a/src/contrib/cluster/Akka.DistributedData/Flag.cs b/src/contrib/cluster/Akka.DistributedData/Flag.cs index eeb8a918b6b..8cb8fe75376 100644 --- a/src/contrib/cluster/Akka.DistributedData/Flag.cs +++ b/src/contrib/cluster/Akka.DistributedData/Flag.cs @@ -26,11 +26,11 @@ public sealed class Flag : /// /// Flag with a false value set. /// - public static readonly Flag False = new Flag(false); + public static readonly Flag False = new(false); /// /// Flag with a true value set. /// - public static readonly Flag True = new Flag(true); + public static readonly Flag True = new(true); /// /// Checks if current flag value is set. diff --git a/src/contrib/cluster/Akka.DistributedData/GCounter.cs b/src/contrib/cluster/Akka.DistributedData/GCounter.cs index d2ffb7d5236..c8eadccbeef 100644 --- a/src/contrib/cluster/Akka.DistributedData/GCounter.cs +++ b/src/contrib/cluster/Akka.DistributedData/GCounter.cs @@ -61,7 +61,7 @@ public sealed class GCounter : /// /// TBD /// - public static GCounter Empty => new GCounter(); + public static GCounter Empty => new(); /// /// Current total value of the counter. @@ -181,7 +181,7 @@ public GCounter Prune(UniqueAddress removedNode, UniqueAddress collapseInto) /// /// TBD /// TBD - public GCounter PruningCleanup(UniqueAddress removedNode) => new GCounter(State.Remove(removedNode)); + public GCounter PruningCleanup(UniqueAddress removedNode) => new(State.Remove(removedNode)); public override int GetHashCode() => State.GetHashCode(); diff --git a/src/contrib/cluster/Akka.DistributedData/GSet.cs b/src/contrib/cluster/Akka.DistributedData/GSet.cs index a8067c87875..00928f4e976 100644 --- a/src/contrib/cluster/Akka.DistributedData/GSet.cs +++ b/src/contrib/cluster/Akka.DistributedData/GSet.cs @@ -34,7 +34,7 @@ public static class GSet /// TBD /// TBD /// TBD - public static GSet Create(params T[] elements) => new GSet(ImmutableHashSet.Create(elements)); + public static GSet Create(params T[] elements) => new(ImmutableHashSet.Create(elements)); /// /// TBD @@ -42,7 +42,7 @@ public static class GSet /// TBD /// TBD /// TBD - public static GSet Create(IImmutableSet elements) => new GSet(elements); + public static GSet Create(IImmutableSet elements) => new(elements); } /// @@ -70,7 +70,7 @@ public sealed class GSet : /// /// TBD /// - public static readonly GSet Empty = new GSet(); + public static readonly GSet Empty = new(); /// /// TBD diff --git a/src/contrib/cluster/Akka.DistributedData/Internal/Internal.cs b/src/contrib/cluster/Akka.DistributedData/Internal/Internal.cs index 13c76a0940a..6fb358dc21a 100644 --- a/src/contrib/cluster/Akka.DistributedData/Internal/Internal.cs +++ b/src/contrib/cluster/Akka.DistributedData/Internal/Internal.cs @@ -26,7 +26,7 @@ internal sealed class GossipTick /// /// TBD /// - internal static readonly GossipTick Instance = new GossipTick(); + internal static readonly GossipTick Instance = new(); private GossipTick() { } /// /// TBD @@ -44,7 +44,7 @@ internal sealed class DeltaPropagationTick /// /// Singleton instance /// - public static DeltaPropagationTick Instance { get; } = new DeltaPropagationTick(); + public static DeltaPropagationTick Instance { get; } = new(); private DeltaPropagationTick() { } } @@ -58,7 +58,7 @@ internal class RemovedNodePruningTick /// /// TBD /// - internal static readonly RemovedNodePruningTick Instance = new RemovedNodePruningTick(); + internal static readonly RemovedNodePruningTick Instance = new(); private RemovedNodePruningTick() { } /// /// TBD @@ -76,7 +76,7 @@ internal class ClockTick /// /// TBD /// - internal static readonly ClockTick Instance = new ClockTick(); + internal static readonly ClockTick Instance = new(); private ClockTick() { } /// /// TBD @@ -161,7 +161,7 @@ internal sealed class WriteAck : IReplicatorMessage, IEquatable /// /// TBD /// - internal static readonly WriteAck Instance = new WriteAck(); + internal static readonly WriteAck Instance = new(); private WriteAck() { } /// @@ -184,7 +184,7 @@ internal sealed class WriteNack : IReplicatorMessage, IEquatable /// /// TBD /// - internal static readonly WriteNack Instance = new WriteNack(); + internal static readonly WriteNack Instance = new(); private WriteNack() { } /// @@ -353,7 +353,7 @@ internal sealed class ReadRepairAck /// /// TBD /// - public static readonly ReadRepairAck Instance = new ReadRepairAck(); + public static readonly ReadRepairAck Instance = new(); private ReadRepairAck() { } @@ -370,7 +370,7 @@ public sealed class DataEnvelope : IEquatable, IReplicatorMessage /// /// TBD /// - public static DataEnvelope DeletedEnvelope => new DataEnvelope(DeletedData.Instance); + public static DataEnvelope DeletedEnvelope => new(DeletedData.Instance); /// /// TBD @@ -396,14 +396,11 @@ internal DataEnvelope(IReplicatedData data, ImmutableDictionary - new DataEnvelope(data, Pruning, DeltaVersions); + internal DataEnvelope WithData(IReplicatedData data) => new(data, Pruning, DeltaVersions); - internal DataEnvelope WithPruning(ImmutableDictionary pruning) => - new DataEnvelope(Data, pruning, DeltaVersions); + internal DataEnvelope WithPruning(ImmutableDictionary pruning) => new(Data, pruning, DeltaVersions); - internal DataEnvelope WithDeltaVersions(VersionVector deltaVersions) => - new DataEnvelope(Data, Pruning, deltaVersions); + internal DataEnvelope WithDeltaVersions(VersionVector deltaVersions) => new(Data, Pruning, deltaVersions); internal DataEnvelope WithoutDeltaVersions() => DeltaVersions.IsEmpty @@ -435,7 +432,7 @@ internal bool NeedPruningFrom(UniqueAddress removedNode) /// TBD /// TBD internal DataEnvelope InitRemovedNodePruning(UniqueAddress removed, UniqueAddress owner) => - new DataEnvelope(Data, Pruning.SetItem(removed, new PruningInitialized(owner, ImmutableHashSet
.Empty))); + new(Data, Pruning.SetItem(removed, new PruningInitialized(owner, ImmutableHashSet
.Empty))); /// /// TBD @@ -635,7 +632,7 @@ public override string ToString() [Serializable] internal sealed class DeletedData : IReplicatedData, IEquatable, IReplicatedDataSerialization { - public static readonly DeletedData Instance = new DeletedData(); + public static readonly DeletedData Instance = new(); private DeletedData() { } @@ -866,7 +863,7 @@ public sealed class DeltaPropagation : IReplicatorMessage, IEquatable, IRequireCausualDeliveryOfDeltas { - public static readonly NoDelta Instance = new NoDelta(); + public static readonly NoDelta Instance = new(); private NoDelta() { } IReplicatedDelta IDeltaReplicatedData.Delta => Delta; @@ -937,7 +934,7 @@ public override int GetHashCode() public sealed class DeltaNack : IReplicatorMessage, IDeadLetterSuppression, IEquatable { - public static readonly DeltaNack Instance = new DeltaNack(); + public static readonly DeltaNack Instance = new(); private DeltaNack() { } public bool Equals(DeltaNack other) => true; public override bool Equals(object obj) => obj is DeltaNack; diff --git a/src/contrib/cluster/Akka.DistributedData/LWWDictionary.cs b/src/contrib/cluster/Akka.DistributedData/LWWDictionary.cs index 4e21ce022d9..a2f9fc1e8e5 100644 --- a/src/contrib/cluster/Akka.DistributedData/LWWDictionary.cs +++ b/src/contrib/cluster/Akka.DistributedData/LWWDictionary.cs @@ -138,7 +138,7 @@ public sealed class LWWDictionary : /// /// An empty instance of the /// - public static readonly LWWDictionary Empty = new LWWDictionary(ORDictionary>.Empty); + public static readonly LWWDictionary Empty = new(ORDictionary>.Empty); internal readonly ORDictionary> Underlying; @@ -232,8 +232,7 @@ public LWWDictionary SetItem(UniqueAddress node, TKey key, TValue /// Note that if there is a conflicting update on another node the entry will /// not be removed after merge. /// - public LWWDictionary Remove(UniqueAddress node, TKey key) => - new LWWDictionary(Underlying.Remove(node, key)); + public LWWDictionary Remove(UniqueAddress node, TKey key) => new(Underlying.Remove(node, key)); /// /// Tries to return a value under provided is such value exists. @@ -259,7 +258,7 @@ public bool TryGetValue(TKey key, out TValue value) /// TBD /// TBD public LWWDictionary Merge(LWWDictionary other) => - new LWWDictionary(Underlying.Merge(other.Underlying)); + new(Underlying.Merge(other.Underlying)); /// /// TBD @@ -290,7 +289,7 @@ public bool NeedPruningFrom(UniqueAddress removedNode) => /// TBD /// TBD public LWWDictionary Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => - new LWWDictionary(Underlying.Prune(removedNode, collapseInto)); + new(Underlying.Prune(removedNode, collapseInto)); /// /// TBD @@ -298,7 +297,7 @@ public LWWDictionary Prune(UniqueAddress removedNode, UniqueAddres /// TBD /// TBD public LWWDictionary PruningCleanup(UniqueAddress removedNode) => - new LWWDictionary(Underlying.PruningCleanup(removedNode)); + new(Underlying.PruningCleanup(removedNode)); /// /// TBD @@ -421,8 +420,7 @@ public LWWDictionary MergeDelta(ORDictionary(Underlying.MergeDelta(delta)); } - public LWWDictionary ResetDelta() => - new LWWDictionary(Underlying.ResetDelta()); + public LWWDictionary ResetDelta() => new(Underlying.ResetDelta()); #endregion diff --git a/src/contrib/cluster/Akka.DistributedData/ORDictionary.cs b/src/contrib/cluster/Akka.DistributedData/ORDictionary.cs index eec7d314998..1d8b6512986 100644 --- a/src/contrib/cluster/Akka.DistributedData/ORDictionary.cs +++ b/src/contrib/cluster/Akka.DistributedData/ORDictionary.cs @@ -130,7 +130,7 @@ public sealed class ORDictionary : /// /// An empty instance of the /// - public static readonly ORDictionary Empty = new ORDictionary(ORSet.Empty, ImmutableDictionary.Empty); + public static readonly ORDictionary Empty = new(ORSet.Empty, ImmutableDictionary.Empty); internal readonly ORSet KeySet; internal readonly IImmutableDictionary ValueMap; diff --git a/src/contrib/cluster/Akka.DistributedData/ORMultiValueDictionary.cs b/src/contrib/cluster/Akka.DistributedData/ORMultiValueDictionary.cs index 9dcbcf64ffa..e358e4ff0e2 100644 --- a/src/contrib/cluster/Akka.DistributedData/ORMultiValueDictionary.cs +++ b/src/contrib/cluster/Akka.DistributedData/ORMultiValueDictionary.cs @@ -74,8 +74,8 @@ public sealed class ORMultiValueDictionary : IReplicatedDataSerialization, IEquatable>, IEnumerable>>, IORMultiValueDictionary { - public static readonly ORMultiValueDictionary Empty = new ORMultiValueDictionary(ORDictionary>.Empty, withValueDeltas: false); - public static readonly ORMultiValueDictionary EmptyWithValueDeltas = new ORMultiValueDictionary(ORDictionary>.Empty, withValueDeltas: true); + public static readonly ORMultiValueDictionary Empty = new(ORDictionary>.Empty, withValueDeltas: false); + public static readonly ORMultiValueDictionary EmptyWithValueDeltas = new(ORDictionary>.Empty, withValueDeltas: true); internal readonly ORDictionary> Underlying; private readonly bool _withValueDeltas; @@ -263,10 +263,10 @@ public IReplicatedData Merge(IReplicatedData other) => IReplicatedData IRemovedNodePruning.Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => Prune(removedNode, collapseInto); public ORMultiValueDictionary Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => - new ORMultiValueDictionary(Underlying.Prune(removedNode, collapseInto), _withValueDeltas); + new(Underlying.Prune(removedNode, collapseInto), _withValueDeltas); public ORMultiValueDictionary PruningCleanup(UniqueAddress removedNode) => - new ORMultiValueDictionary(Underlying.PruningCleanup(removedNode), _withValueDeltas); + new(Underlying.PruningCleanup(removedNode), _withValueDeltas); public bool Equals(ORMultiValueDictionary other) { @@ -398,8 +398,7 @@ IReplicatedData IDeltaReplicatedData.MergeDelta(IReplicatedDelta delta) IReplicatedData IDeltaReplicatedData.ResetDelta() => ResetDelta(); - public ORMultiValueDictionary ResetDelta() => - new ORMultiValueDictionary(Underlying.ResetDelta(), _withValueDeltas); + public ORMultiValueDictionary ResetDelta() => new(Underlying.ResetDelta(), _withValueDeltas); #endregion diff --git a/src/contrib/cluster/Akka.DistributedData/ORSet.cs b/src/contrib/cluster/Akka.DistributedData/ORSet.cs index 57bf13349a7..2956a83f3f0 100644 --- a/src/contrib/cluster/Akka.DistributedData/ORSet.cs +++ b/src/contrib/cluster/Akka.DistributedData/ORSet.cs @@ -174,7 +174,7 @@ public sealed class ORSet : IEnumerable, IDeltaReplicatedData, ORSet.IDeltaOperation> { - public static readonly ORSet Empty = new ORSet(); + public static readonly ORSet Empty = new(); internal readonly ImmutableDictionary ElementsMap; diff --git a/src/contrib/cluster/Akka.DistributedData/PNCounter.cs b/src/contrib/cluster/Akka.DistributedData/PNCounter.cs index 40c84e6162d..ce6ae465009 100644 --- a/src/contrib/cluster/Akka.DistributedData/PNCounter.cs +++ b/src/contrib/cluster/Akka.DistributedData/PNCounter.cs @@ -34,7 +34,7 @@ public sealed class PNCounter : IEquatable, IReplicatedDelta { - public static readonly PNCounter Empty = new PNCounter(); + public static readonly PNCounter Empty = new(); public BigInteger Value => new BigInteger(Increments.Value) - new BigInteger(Decrements.Value); @@ -82,8 +82,7 @@ private PNCounter Change(UniqueAddress key, long delta) return this; } - public PNCounter Merge(PNCounter other) => - new PNCounter(Increments.Merge(other.Increments), Decrements.Merge(other.Decrements)); + public PNCounter Merge(PNCounter other) => new(Increments.Merge(other.Increments), Decrements.Merge(other.Decrements)); public ImmutableHashSet ModifiedByNodes => Increments.ModifiedByNodes.Union(Decrements.ModifiedByNodes); @@ -95,10 +94,10 @@ public bool NeedPruningFrom(Cluster.UniqueAddress removedNode) => IReplicatedData IRemovedNodePruning.Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => Prune(removedNode, collapseInto); public PNCounter Prune(Cluster.UniqueAddress removedNode, Cluster.UniqueAddress collapseInto) => - new PNCounter(Increments.Prune(removedNode, collapseInto), Decrements.Prune(removedNode, collapseInto)); + new(Increments.Prune(removedNode, collapseInto), Decrements.Prune(removedNode, collapseInto)); public PNCounter PruningCleanup(Cluster.UniqueAddress removedNode) => - new PNCounter(Increments.PruningCleanup(removedNode), Decrements.PruningCleanup(removedNode)); + new(Increments.PruningCleanup(removedNode), Decrements.PruningCleanup(removedNode)); public bool Equals(PNCounter other) @@ -126,7 +125,7 @@ public bool Equals(PNCounter other) #region delta - public PNCounter Delta => new PNCounter(Increments.Delta ?? GCounter.Empty, Decrements.Delta ?? GCounter.Empty); + public PNCounter Delta => new(Increments.Delta ?? GCounter.Empty, Decrements.Delta ?? GCounter.Empty); public PNCounter MergeDelta(PNCounter delta) => Merge(delta); diff --git a/src/contrib/cluster/Akka.DistributedData/PNCounterDictionary.cs b/src/contrib/cluster/Akka.DistributedData/PNCounterDictionary.cs index 6b6be57ce7f..1aaa057f2a4 100644 --- a/src/contrib/cluster/Akka.DistributedData/PNCounterDictionary.cs +++ b/src/contrib/cluster/Akka.DistributedData/PNCounterDictionary.cs @@ -48,7 +48,7 @@ public sealed class PNCounterDictionary : IEquatable>, IEnumerable>, IPNCounterDictionary { - public static readonly PNCounterDictionary Empty = new PNCounterDictionary(ORDictionary.Empty); + public static readonly PNCounterDictionary Empty = new(ORDictionary.Empty); /// /// Needs to be internal for serialization purposes @@ -126,7 +126,7 @@ public PNCounterDictionary Increment(Cluster.Cluster node, TKey key, long /// If the delta is negative then it will decrement instead of increment. /// public PNCounterDictionary Increment(UniqueAddress node, TKey key, long delta = 1L) => - new PNCounterDictionary(Underlying.AddOrUpdate(node, key, PNCounter.Empty, old => old.Increment(node, delta))); + new(Underlying.AddOrUpdate(node, key, PNCounter.Empty, old => old.Increment(node, delta))); /// /// Decrement the counter with the delta specified. @@ -140,7 +140,7 @@ public PNCounterDictionary Decrement(Cluster.Cluster node, TKey key, long /// If the delta is negative then it will increment instead of decrement. /// public PNCounterDictionary Decrement(UniqueAddress node, TKey key, long delta = 1L) => - new PNCounterDictionary(Underlying.AddOrUpdate(node, key, PNCounter.Empty, old => old.Decrement(node, delta))); + new(Underlying.AddOrUpdate(node, key, PNCounter.Empty, old => old.Decrement(node, delta))); /// /// Removes an entry from the map. @@ -155,11 +155,9 @@ public PNCounterDictionary Remove(Cluster.Cluster node, TKey key) => /// Note that if there is a conflicting update on another node the entry will /// not be removed after merge. /// - public PNCounterDictionary Remove(UniqueAddress node, TKey key) => - new PNCounterDictionary(Underlying.Remove(node, key)); + public PNCounterDictionary Remove(UniqueAddress node, TKey key) => new(Underlying.Remove(node, key)); - public PNCounterDictionary Merge(PNCounterDictionary other) => - new PNCounterDictionary(Underlying.Merge(other.Underlying)); + public PNCounterDictionary Merge(PNCounterDictionary other) => new(Underlying.Merge(other.Underlying)); public IReplicatedData Merge(IReplicatedData other) => Merge((PNCounterDictionary)other); @@ -173,11 +171,9 @@ public bool NeedPruningFrom(UniqueAddress removedNode) => IReplicatedData IRemovedNodePruning.Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => Prune(removedNode, collapseInto); - public PNCounterDictionary Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => - new PNCounterDictionary(Underlying.Prune(removedNode, collapseInto)); + public PNCounterDictionary Prune(UniqueAddress removedNode, UniqueAddress collapseInto) => new(Underlying.Prune(removedNode, collapseInto)); - public PNCounterDictionary PruningCleanup(UniqueAddress removedNode) => - new PNCounterDictionary(Underlying.PruningCleanup(removedNode)); + public PNCounterDictionary PruningCleanup(UniqueAddress removedNode) => new(Underlying.PruningCleanup(removedNode)); public bool Equals(PNCounterDictionary other) @@ -306,8 +302,7 @@ IReplicatedData IDeltaReplicatedData.MergeDelta(IReplicatedDelta delta) IReplicatedData IDeltaReplicatedData.ResetDelta() => ResetDelta(); - public PNCounterDictionary ResetDelta() => - new PNCounterDictionary(Underlying.ResetDelta()); + public PNCounterDictionary ResetDelta() => new(Underlying.ResetDelta()); #endregion diff --git a/src/contrib/cluster/Akka.DistributedData/ReadAggregator.cs b/src/contrib/cluster/Akka.DistributedData/ReadAggregator.cs index a2bb7143d16..f9957fab2cb 100644 --- a/src/contrib/cluster/Akka.DistributedData/ReadAggregator.cs +++ b/src/contrib/cluster/Akka.DistributedData/ReadAggregator.cs @@ -164,7 +164,7 @@ public interface IReadConsistency public sealed class ReadLocal : IReadConsistency { - public static readonly ReadLocal Instance = new ReadLocal(); + public static readonly ReadLocal Instance = new(); public TimeSpan Timeout => TimeSpan.Zero; diff --git a/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs b/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs index 8e6c3d6c2b6..9d0ade1a0c3 100644 --- a/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs +++ b/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs @@ -19,7 +19,7 @@ internal abstract class ReadWriteAggregator : ActorBase { protected sealed class SendToSecondary { - public static readonly SendToSecondary Instance = new SendToSecondary(); + public static readonly SendToSecondary Instance = new(); private SendToSecondary() { } } diff --git a/src/contrib/cluster/Akka.DistributedData/Replicator.Messages.cs b/src/contrib/cluster/Akka.DistributedData/Replicator.Messages.cs index 272a9b8b94b..b2047d6598d 100644 --- a/src/contrib/cluster/Akka.DistributedData/Replicator.Messages.cs +++ b/src/contrib/cluster/Akka.DistributedData/Replicator.Messages.cs @@ -17,7 +17,7 @@ namespace Akka.DistributedData [Serializable] public class GetKeyIds { - public static readonly GetKeyIds Instance = new GetKeyIds(); + public static readonly GetKeyIds Instance = new(); private GetKeyIds() { } @@ -720,7 +720,7 @@ public void ThrowOnFailure() throw Cause; } - public Exception Cause => new Exception($"Failed to store value under the key {_key}"); + public Exception Cause => new($"Failed to store value under the key {_key}"); public override string ToString() => $"StoreFailure({_key}{(_request == null ? "" : ", req=" + _request)})"; @@ -945,7 +945,7 @@ public void ThrowOnFailure() [Serializable] public sealed class GetReplicaCount { - public static readonly GetReplicaCount Instance = new GetReplicaCount(); + public static readonly GetReplicaCount Instance = new(); private GetReplicaCount() { } } @@ -983,7 +983,7 @@ public ReplicaCount(int n) [Serializable] public sealed class FlushChanges { - public static readonly FlushChanges Instance = new FlushChanges(); + public static readonly FlushChanges Instance = new(); private FlushChanges() { } diff --git a/src/contrib/cluster/Akka.DistributedData/Replicator.cs b/src/contrib/cluster/Akka.DistributedData/Replicator.cs index e79a7e19ba0..6b629a7f173 100644 --- a/src/contrib/cluster/Akka.DistributedData/Replicator.cs +++ b/src/contrib/cluster/Akka.DistributedData/Replicator.cs @@ -270,7 +270,7 @@ public static Props Props(ReplicatorSettings settings) => private static readonly Digest LazyDigest = ByteString.CopyFrom(new byte[] { 0 }); private static readonly Digest NotFoundDigest = ByteString.CopyFrom(new byte[] { 255 }); - private static readonly DataEnvelope DeletedEnvelope = new DataEnvelope(DeletedData.Instance); + private static readonly DataEnvelope DeletedEnvelope = new(DeletedData.Instance); private readonly ReplicatorSettings _settings; @@ -346,8 +346,8 @@ private bool IsKnownNode(Address node) => _nodes.Contains(node) || _weaklyUpNode private long _statusCount = 0; private int _statusTotChunks = 0; - private readonly Dictionary> _subscribers = new Dictionary>(); - private readonly Dictionary> _newSubscribers = new Dictionary>(); + private readonly Dictionary> _subscribers = new(); + private readonly Dictionary> _newSubscribers = new(); private ImmutableDictionary _subscriptionKeys = ImmutableDictionary.Empty; private readonly ILoggingAdapter _log; diff --git a/src/contrib/cluster/Akka.DistributedData/Serialization/OtherMessageComparer.cs b/src/contrib/cluster/Akka.DistributedData/Serialization/OtherMessageComparer.cs index 9c8e48e8f63..048f71c7229 100644 --- a/src/contrib/cluster/Akka.DistributedData/Serialization/OtherMessageComparer.cs +++ b/src/contrib/cluster/Akka.DistributedData/Serialization/OtherMessageComparer.cs @@ -14,7 +14,7 @@ namespace Akka.DistributedData.Serialization { internal class OtherMessageComparer : IComparer { - public static OtherMessageComparer Instance { get; } = new OtherMessageComparer(); + public static OtherMessageComparer Instance { get; } = new(); private OtherMessageComparer() {} diff --git a/src/contrib/cluster/Akka.DistributedData/Serialization/ReplicatorMessageSerializer.cs b/src/contrib/cluster/Akka.DistributedData/Serialization/ReplicatorMessageSerializer.cs index 2f8fdccbe39..c3453e8fee8 100644 --- a/src/contrib/cluster/Akka.DistributedData/Serialization/ReplicatorMessageSerializer.cs +++ b/src/contrib/cluster/Akka.DistributedData/Serialization/ReplicatorMessageSerializer.cs @@ -35,7 +35,7 @@ private sealed class SmallCache { private readonly TimeSpan _ttl; private readonly Func _getOrAddFactory; - private readonly AtomicCounter _n = new AtomicCounter(0); + private readonly AtomicCounter _n = new(0); private readonly int _mask; private readonly KeyValuePair[] _elements; diff --git a/src/contrib/cluster/Akka.DistributedData/VersionVector.cs b/src/contrib/cluster/Akka.DistributedData/VersionVector.cs index b908b8e594a..97917806df6 100644 --- a/src/contrib/cluster/Akka.DistributedData/VersionVector.cs +++ b/src/contrib/cluster/Akka.DistributedData/VersionVector.cs @@ -47,7 +47,7 @@ public static VersionVector Create(ImmutableDictionary vers return new MultiVersionVector(versions); } - protected static readonly AtomicCounterLong Counter = new AtomicCounterLong(1L); + protected static readonly AtomicCounterLong Counter = new(1L); /// /// Marker to signal that we have reached the end of a version vector. diff --git a/src/contrib/cluster/Akka.DistributedData/WriteAggregator.cs b/src/contrib/cluster/Akka.DistributedData/WriteAggregator.cs index 676a33f16f3..8fcb7e045f5 100644 --- a/src/contrib/cluster/Akka.DistributedData/WriteAggregator.cs +++ b/src/contrib/cluster/Akka.DistributedData/WriteAggregator.cs @@ -183,7 +183,7 @@ public interface IWriteConsistency public sealed class WriteLocal : IWriteConsistency { - public static readonly WriteLocal Instance = new WriteLocal(); + public static readonly WriteLocal Instance = new(); public TimeSpan Timeout => TimeSpan.Zero; diff --git a/src/contrib/dependencyinjection/Akka.DependencyInjection.Tests/RouterIntegrationSpec.cs b/src/contrib/dependencyinjection/Akka.DependencyInjection.Tests/RouterIntegrationSpec.cs index 9f2d176e58a..76448f35339 100644 --- a/src/contrib/dependencyinjection/Akka.DependencyInjection.Tests/RouterIntegrationSpec.cs +++ b/src/contrib/dependencyinjection/Akka.DependencyInjection.Tests/RouterIntegrationSpec.cs @@ -134,7 +134,7 @@ public async Task DisposeAsync() internal class TestDiActor : ReceiveActor { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public TestDiActor(InjectedService injected) { @@ -151,7 +151,7 @@ internal class Message internal class GetMessage { - public static readonly GetMessage Instance = new GetMessage(); + public static readonly GetMessage Instance = new(); private GetMessage() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs index b4c0061b43d..3ceeb5a36da 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs @@ -18,7 +18,7 @@ internal static class AllEventsPublisher [Serializable] public sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/CurrentPersistenceIdsPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/CurrentPersistenceIdsPublisher.cs index f88bf341e06..524e84497d9 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/CurrentPersistenceIdsPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/CurrentPersistenceIdsPublisher.cs @@ -125,7 +125,7 @@ internal sealed class LivePersistenceIdsPublisher : ActorPublisher, IWit { private sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs index db6cd0e9430..0b2c85108ff 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs @@ -17,7 +17,7 @@ internal static class EventsByPersistenceIdPublisher [Serializable] public sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs index 7907cd45c61..9d863a7f344 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs @@ -18,7 +18,7 @@ internal static class EventsByTagPublisher [Serializable] public sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { diff --git a/src/contrib/persistence/Akka.Persistence.Query.Sql/AllPersistenceIdsPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.Sql/AllPersistenceIdsPublisher.cs index ee87c2f859d..9f5b2ca85ce 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.Sql/AllPersistenceIdsPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.Sql/AllPersistenceIdsPublisher.cs @@ -151,7 +151,7 @@ internal sealed class LivePersistenceIdsPublisher : ActorPublisher, IWit { private sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Query.Sql/EventsByPersistenceIdPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.Sql/EventsByPersistenceIdPublisher.cs index 1defa63968f..596b59f17bb 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.Sql/EventsByPersistenceIdPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.Sql/EventsByPersistenceIdPublisher.cs @@ -17,7 +17,7 @@ internal static class EventsByPersistenceIdPublisher [Serializable] public sealed class Continue { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); private Continue() { diff --git a/src/contrib/persistence/Akka.Persistence.Query.Sql/QueryThrottler.cs b/src/contrib/persistence/Akka.Persistence.Query.Sql/QueryThrottler.cs index d0e879c882e..f5485fa9242 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.Sql/QueryThrottler.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.Sql/QueryThrottler.cs @@ -18,7 +18,7 @@ namespace Akka.Persistence.Query.Sql; /// internal sealed class RequestQueryStart { - public static readonly RequestQueryStart Instance = new RequestQueryStart(); + public static readonly RequestQueryStart Instance = new(); private RequestQueryStart() { } } @@ -27,7 +27,7 @@ private RequestQueryStart() { } /// internal sealed class QueryStartGranted { - public static readonly QueryStartGranted Instance = new QueryStartGranted(); + public static readonly QueryStartGranted Instance = new(); private QueryStartGranted() { } } @@ -36,7 +36,7 @@ private QueryStartGranted() { } /// internal sealed class ReturnQueryStart { - public static readonly ReturnQueryStart Instance = new ReturnQueryStart(); + public static readonly ReturnQueryStart Instance = new(); private ReturnQueryStart() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlJournalConnectionFailureSpec.cs b/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlJournalConnectionFailureSpec.cs index 216fc557c1f..046892caa7e 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlJournalConnectionFailureSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlJournalConnectionFailureSpec.cs @@ -52,7 +52,7 @@ public ReceiveAnyPersistentActor(string pid) : base(pid) private abstract class TestReceivePersistentActor : ReceivePersistentActor { - public readonly LinkedList State = new LinkedList(); + public readonly LinkedList State = new(); private readonly string _persistenceId; protected TestReceivePersistentActor(string persistenceId) diff --git a/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlSnapshotConnectionFailureSpec.cs b/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlSnapshotConnectionFailureSpec.cs index 36140850ef3..559667868d8 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlSnapshotConnectionFailureSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.TestKit/SqlSnapshotConnectionFailureSpec.cs @@ -39,7 +39,7 @@ public void Persistent_actor_should_throw_exception_upon_connection_failure_when private class SaveSnapshotTestActor : NamedPersistentActor { private readonly IActorRef _probe; - protected LinkedList _state = new LinkedList(); + protected LinkedList _state = new(); public SaveSnapshotTestActor(string name, IActorRef probe) : base(name) @@ -86,7 +86,7 @@ protected override bool ReceiveCommand(object message) internal class TakeSnapshot { - public static readonly TakeSnapshot Instance = new TakeSnapshot(); + public static readonly TakeSnapshot Instance = new(); private TakeSnapshot() { } @@ -94,7 +94,7 @@ private TakeSnapshot() internal sealed class GetState { - public static readonly GetState Instance = new GetState(); + public static readonly GetState Instance = new(); private GetState() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentAllEventsSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentAllEventsSpec.cs index 3a660472caa..bdc36d56942 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentAllEventsSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentAllEventsSpec.cs @@ -19,7 +19,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingCurrentSqliteAllEventsSpec : CurrentAllEventsSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByPersistenceIdSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByPersistenceIdSpec.cs index e85007d3ed4..572d041936f 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByPersistenceIdSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByPersistenceIdSpec.cs @@ -16,7 +16,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByTagSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByTagSpec.cs index cf494eae150..07eae6d2703 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByTagSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentEventsByTagSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteCurrentEventsByTagSpec : CurrentEventsByTagSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentPersistenceIdsSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentPersistenceIdsSpec.cs index d5a5a6d061f..4abba1c9353 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentPersistenceIdsSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteCurrentPersistenceIdsSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteCurrentPersistenceIdsSpec : CurrentPersistenceIdsSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByPersistenceIdSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByPersistenceIdSpec.cs index 373522c1306..84c7c6620c4 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByPersistenceIdSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByPersistenceIdSpec.cs @@ -16,7 +16,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteEventsByPersistenceIdSpec : EventsByPersistenceIdSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByTagSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByTagSpec.cs index c7b56502cb4..1c50946faad 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByTagSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteEventsByTagSpec.cs @@ -16,7 +16,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteEventsByTagSpec : EventsByTagSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteJournalSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteJournalSpec.cs index 43f04f62d33..02be3b4a1ae 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteJournalSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Batching/BatchingSqliteJournalSpec.cs @@ -14,7 +14,7 @@ namespace Akka.Persistence.Sqlite.Tests.Batching { public class BatchingSqliteJournalSpec : JournalSpec { - private static AtomicCounter counter = new AtomicCounter(0); + private static AtomicCounter counter = new(0); public BatchingSqliteJournalSpec(ITestOutputHelper output) : base(CreateSpecConfig($"Datasource=memdb-journal-batch-{counter.IncrementAndGet()}.db;Mode=Memory;Cache=Shared"), "BatchingSqliteJournalSpec", output) diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Bugfix4360Spec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Bugfix4360Spec.cs index 8ed37c9c453..9e035bcf696 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Bugfix4360Spec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Bugfix4360Spec.cs @@ -49,11 +49,11 @@ class = ""Akka.Persistence.Sqlite.Snapshot.SqliteSnapshotStore, Akka.Persistence private class RecoverActor : UntypedPersistentActor { - private HashSet _values = new HashSet(); + private HashSet _values = new(); public class DoSnapshot { - public static readonly DoSnapshot Instance = new DoSnapshot(); + public static readonly DoSnapshot Instance = new(); private DoSnapshot() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/PersistedLegacyActor.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/PersistedLegacyActor.cs index 9ace8142900..89d6860a52d 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/PersistedLegacyActor.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/PersistedLegacyActor.cs @@ -14,7 +14,7 @@ namespace Akka.Persistence.Sqlite.Tests.Legacy public class PersistedLegacyActor: ReceivePersistentActor { private Persisted _savedState; - private readonly List _events = new List(); + private readonly List _events = new(); private bool _recoveryCompleted; private bool _stateRequested; private int _persistCount; @@ -89,7 +89,7 @@ public Persisted(int payload) public sealed class PersistAck { - public static readonly PersistAck Instance = new PersistAck(); + public static readonly PersistAck Instance = new(); private PersistAck() { } } @@ -107,7 +107,7 @@ public SaveSnapshotAck(Persisted state, List events) public sealed class GetState { - public static readonly GetState Instance = new GetState(); + public static readonly GetState Instance = new(); private GetState() { } } diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/SqliteLegacyJournalSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/SqliteLegacyJournalSpec.cs index f7ad0198cf5..75ab2a5c50c 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/SqliteLegacyJournalSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Legacy/SqliteLegacyJournalSpec.cs @@ -21,7 +21,7 @@ namespace Akka.Persistence.Sqlite.Tests.Legacy { public class SqliteLegacyJournalSpec: Akka.TestKit.Xunit2.TestKit { - private Dictionary _actors = new Dictionary(); + private Dictionary _actors = new(); private readonly TestProbe _probe; public SqliteLegacyJournalSpec(ITestOutputHelper output) diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentAllEventsSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentAllEventsSpec.cs index 1386a72e554..1ab79f78cc6 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentAllEventsSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentAllEventsSpec.cs @@ -19,7 +19,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteCurrentAllEventsSpec:CurrentAllEventsSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByPersistenceIdSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByPersistenceIdSpec.cs index e84f214868e..b22ec3e9bba 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByPersistenceIdSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByPersistenceIdSpec.cs @@ -16,7 +16,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByTagSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByTagSpec.cs index 95f45586c28..2f7585f8668 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByTagSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentEventsByTagSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteCurrentEventsByTagSpec : CurrentEventsByTagSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentPersistenceIdsSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentPersistenceIdsSpec.cs index 95581ac1b3e..51287e012b2 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentPersistenceIdsSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteCurrentPersistenceIdsSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteCurrentPersistenceIdsSpec : CurrentPersistenceIdsSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByPersistenceIdSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByPersistenceIdSpec.cs index 1985b31b258..db3e8aaff72 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByPersistenceIdSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByPersistenceIdSpec.cs @@ -16,7 +16,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteEventsByPersistenceIdSpec : EventsByPersistenceIdSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByTagSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByTagSpec.cs index edf23b5718e..208cd8e5cbf 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByTagSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Query/SqliteEventsByTagSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite.Tests.Query { public class SqliteEventsByTagSpec : EventsByTagSpec { - public static readonly AtomicCounter Counter = new AtomicCounter(0); + public static readonly AtomicCounter Counter = new(0); public static Config Config(int id) => ConfigurationFactory.ParseString($@" akka.loglevel = INFO diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteJournalSerializationSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteJournalSerializationSpec.cs index 029e8913bfc..32e75ed931e 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteJournalSerializationSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteJournalSerializationSpec.cs @@ -15,7 +15,7 @@ namespace Akka.Persistence.Sqlite.Tests.Serialization { public class SqliteJournalSerializationSpec : JournalSerializationSpec { - private static AtomicCounter Counter { get; } = new AtomicCounter(0); + private static AtomicCounter Counter { get; } = new(0); public SqliteJournalSerializationSpec(ITestOutputHelper output) : base(CreateSpecConfig("Filename=file:serialization-journal-" + Counter.IncrementAndGet() + ".db;Mode=Memory;Cache=Shared"), "SqliteJournalSerializationSpec", output) diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteSnapshotStoreSerializationSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteSnapshotStoreSerializationSpec.cs index 99076e2de1c..9041b7ef2b0 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteSnapshotStoreSerializationSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/Serialization/SqliteSnapshotStoreSerializationSpec.cs @@ -15,7 +15,7 @@ namespace Akka.Persistence.Sqlite.Tests.Serialization { public class SqliteSnapshotStoreSerializationSpec : SnapshotStoreSerializationSpec { - private static AtomicCounter Counter { get; } = new AtomicCounter(0); + private static AtomicCounter Counter { get; } = new(0); public SqliteSnapshotStoreSerializationSpec(ITestOutputHelper output) : base(CreateSpecConfig("Filename=file:serialization-snapshot-" + Counter.IncrementAndGet() + ".db;Mode=Memory;Cache=Shared"), "SqliteSnapshotStoreSerializationSpec", output) diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteJournalSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteJournalSpec.cs index 22ae1e63990..85f4ebc12c8 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteJournalSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteJournalSpec.cs @@ -14,7 +14,7 @@ namespace Akka.Persistence.Sqlite.Tests { public class SqliteJournalSpec : JournalSpec { - private static AtomicCounter counter = new AtomicCounter(0); + private static AtomicCounter counter = new(0); public SqliteJournalSpec(ITestOutputHelper output) : base(CreateSpecConfig("Filename=file:memdb-journal-" + counter.IncrementAndGet() + ".db;Mode=Memory;Cache=Shared"), "SqliteJournalSpec", output) diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteSnapshotStoreSpec.cs b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteSnapshotStoreSpec.cs index 2200128b80a..03778e2a6d6 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteSnapshotStoreSpec.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite.Tests/SqliteSnapshotStoreSpec.cs @@ -14,7 +14,7 @@ namespace Akka.Persistence.Sqlite.Tests { public class SqliteSnapshotStoreSpec : SnapshotStoreSpec { - private static AtomicCounter counter = new AtomicCounter(0); + private static AtomicCounter counter = new(0); public SqliteSnapshotStoreSpec(ITestOutputHelper output) : base(CreateSpecConfig("Filename=file:memdb-snapshot-" + counter.IncrementAndGet() + ".db;Mode=Memory;Cache=Shared"), "SqliteSnapshotStoreSpec", output) { diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite/ConnectionContext.cs b/src/contrib/persistence/Akka.Persistence.Sqlite/ConnectionContext.cs index 757ffa1951e..e7befdbddcc 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite/ConnectionContext.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite/ConnectionContext.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Sqlite /// internal static class ConnectionContext { - private static readonly ConcurrentDictionary Remembered = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Remembered = new(); /// /// TBD diff --git a/src/contrib/persistence/Akka.Persistence.Sqlite/Journal/BatchingSqliteJournal.cs b/src/contrib/persistence/Akka.Persistence.Sqlite/Journal/BatchingSqliteJournal.cs index 300b71efe3f..ab0d9b9ea06 100644 --- a/src/contrib/persistence/Akka.Persistence.Sqlite/Journal/BatchingSqliteJournal.cs +++ b/src/contrib/persistence/Akka.Persistence.Sqlite/Journal/BatchingSqliteJournal.cs @@ -223,6 +223,6 @@ protected override void PostStop() /// /// TBD /// TBD - protected override SqliteConnection CreateConnection(string connectionString) => new SqliteConnection(connectionString); + protected override SqliteConnection CreateConnection(string connectionString) => new(connectionString); } } diff --git a/src/contrib/serializers/Akka.Serialization.Hyperion.Tests/HyperionConfigTests.cs b/src/contrib/serializers/Akka.Serialization.Hyperion.Tests/HyperionConfigTests.cs index 9d40ed45251..d1fef409be4 100644 --- a/src/contrib/serializers/Akka.Serialization.Hyperion.Tests/HyperionConfigTests.cs +++ b/src/contrib/serializers/Akka.Serialization.Hyperion.Tests/HyperionConfigTests.cs @@ -366,7 +366,7 @@ public FooSurrogate(string bar) public class FooHyperionSurrogate : Surrogate { - public static readonly List Surrogated = new List(); + public static readonly List Surrogated = new(); public FooHyperionSurrogate() { diff --git a/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializer.cs b/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializer.cs index cac7b920717..4830a4cb450 100644 --- a/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializer.cs +++ b/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializer.cs @@ -405,7 +405,7 @@ public HyperionSerializerSettings( } public HyperionSerializerSettings WithPreserveObjectReference(bool preserveObjectReferences) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: preserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: KnownTypesProvider, @@ -415,7 +415,7 @@ public HyperionSerializerSettings WithPreserveObjectReference(bool preserveObjec typeFilter: TypeFilter); public HyperionSerializerSettings WithVersionTolerance(bool versionTolerance) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: versionTolerance, knownTypesProvider: KnownTypesProvider, @@ -425,7 +425,7 @@ public HyperionSerializerSettings WithVersionTolerance(bool versionTolerance) typeFilter: TypeFilter); public HyperionSerializerSettings WithKnownTypesProvider(Type knownTypesProvider) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: knownTypesProvider, @@ -435,7 +435,7 @@ public HyperionSerializerSettings WithKnownTypesProvider(Type knownTypesProvider typeFilter: TypeFilter); public HyperionSerializerSettings WithPackageNameOverrides(IEnumerable> packageNameOverrides) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: KnownTypesProvider, @@ -445,7 +445,7 @@ public HyperionSerializerSettings WithPackageNameOverrides(IEnumerable surrogates) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: KnownTypesProvider, @@ -455,7 +455,7 @@ public HyperionSerializerSettings WithSurrogates(IEnumerable surrogat typeFilter: TypeFilter); public HyperionSerializerSettings WithDisallowUnsafeType(bool disallowUnsafeType) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: KnownTypesProvider, @@ -465,7 +465,7 @@ public HyperionSerializerSettings WithDisallowUnsafeType(bool disallowUnsafeType typeFilter: TypeFilter); public HyperionSerializerSettings WithTypeFilter(ITypeFilter typeFilter) - => new HyperionSerializerSettings( + => new( preserveObjectReferences: PreserveObjectReferences, versionTolerance: VersionTolerance, knownTypesProvider: KnownTypesProvider, diff --git a/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializerSetup.cs b/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializerSetup.cs index b7a88aef789..2708b82fca0 100644 --- a/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializerSetup.cs +++ b/src/contrib/serializers/Akka.Serialization.Hyperion/HyperionSerializerSetup.cs @@ -16,21 +16,20 @@ namespace Akka.Serialization.Hyperion { public class HyperionSerializerSetup : Setup { - public static readonly HyperionSerializerSetup Empty = - new HyperionSerializerSetup(null, null, null, null, null, null, null); + public static readonly HyperionSerializerSetup Empty = new(null, null, null, null, null, null, null); public static HyperionSerializerSetup Create( bool preserveObjectReferences, bool versionTolerance, Type knownTypesProvider) - => new HyperionSerializerSetup(preserveObjectReferences, versionTolerance, knownTypesProvider, null, null, null, DisabledTypeFilter.Instance); + => new(preserveObjectReferences, versionTolerance, knownTypesProvider, null, null, null, DisabledTypeFilter.Instance); public static HyperionSerializerSetup Create( bool preserveObjectReferences, bool versionTolerance, Type knownTypesProvider, IEnumerable> packageNameOverrides) - => new HyperionSerializerSetup(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, null, null, DisabledTypeFilter.Instance); + => new(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, null, null, DisabledTypeFilter.Instance); public static HyperionSerializerSetup Create( bool preserveObjectReferences, @@ -38,7 +37,7 @@ public static HyperionSerializerSetup Create( Type knownTypesProvider, IEnumerable> packageNameOverrides, IEnumerable surrogates) - => new HyperionSerializerSetup(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, null, DisabledTypeFilter.Instance); + => new(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, null, DisabledTypeFilter.Instance); public static HyperionSerializerSetup Create( bool preserveObjectReferences, @@ -47,7 +46,7 @@ public static HyperionSerializerSetup Create( IEnumerable> packageNameOverrides, IEnumerable surrogates, bool disallowUnsafeType) - => new HyperionSerializerSetup(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, disallowUnsafeType, DisabledTypeFilter.Instance); + => new(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, disallowUnsafeType, DisabledTypeFilter.Instance); public static HyperionSerializerSetup Create( bool preserveObjectReferences, @@ -57,7 +56,7 @@ public static HyperionSerializerSetup Create( IEnumerable surrogates, bool disallowUnsafeType, ITypeFilter typeFilter) - => new HyperionSerializerSetup(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, disallowUnsafeType, typeFilter); + => new(preserveObjectReferences, versionTolerance, knownTypesProvider, packageNameOverrides, surrogates, disallowUnsafeType, typeFilter); private HyperionSerializerSetup( bool? preserveObjectReferences, @@ -179,7 +178,7 @@ private HyperionSerializerSetup Copy( bool? disallowUnsafeType = null, ITypeFilter typeFilter = null ) - => new HyperionSerializerSetup( + => new( preserveObjectReferences ?? PreserveObjectReferences, versionTolerance ?? VersionTolerance, knownTypesProvider ?? KnownTypesProvider, diff --git a/src/contrib/testkits/Akka.TestKit.Xunit/TestKit.cs b/src/contrib/testkits/Akka.TestKit.Xunit/TestKit.cs index 85b34d4dbe9..570fc28454f 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit/TestKit.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit/TestKit.cs @@ -98,7 +98,7 @@ public TestKit(string config, ITestOutputHelper output = null) /// /// Commonly used assertions used throughout the testkit. /// - protected static XunitAssertions Assertions { get; } = new XunitAssertions(); + protected static XunitAssertions Assertions { get; } = new(); /// /// This method is called when a test ends. diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs index 38106599b4c..1c2dfae2bac 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs @@ -123,7 +123,7 @@ public TestKit(string config, ITestOutputHelper output = null) /// /// Commonly used assertions used throughout the testkit. /// - protected static XunitAssertions Assertions { get; } = new XunitAssertions(); + protected static XunitAssertions Assertions { get; } = new(); /// /// This method is called when a test ends. diff --git a/src/core/Akka.Cluster.TestKit/FailureDetectorPuppet.cs b/src/core/Akka.Cluster.TestKit/FailureDetectorPuppet.cs index 37105520fcb..1ea7f959501 100644 --- a/src/core/Akka.Cluster.TestKit/FailureDetectorPuppet.cs +++ b/src/core/Akka.Cluster.TestKit/FailureDetectorPuppet.cs @@ -28,7 +28,7 @@ public enum Status Unknown } - readonly AtomicReference _status = new AtomicReference(Status.Unknown); + readonly AtomicReference _status = new(Status.Unknown); public void MarkNodeAsUnavailable() { diff --git a/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs b/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs index 7a3d9de80b2..23674f198ef 100644 --- a/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs +++ b/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs @@ -82,7 +82,7 @@ public class EndActor : UntypedActor public sealed class SendEnd { private SendEnd() { } - private static readonly SendEnd _instance = new SendEnd(); + private static readonly SendEnd _instance = new(); public static SendEnd Instance { get @@ -95,7 +95,7 @@ public static SendEnd Instance public sealed class End { private End() { } - private static readonly End _instance = new End(); + private static readonly End _instance = new(); public static End Instance { get @@ -108,7 +108,7 @@ public static End Instance public sealed class EndAck { private EndAck() { } - private static readonly EndAck _instance = new EndAck(); + private static readonly EndAck _instance = new(); public static EndAck Instance { get @@ -190,8 +190,7 @@ protected override int InitialParticipantsValueFactory get { return Roles.Count; } } - readonly ConcurrentDictionary _cachedAddresses = - new ConcurrentDictionary(); + readonly ConcurrentDictionary _cachedAddresses = new(); protected override void AtStartup() { diff --git a/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterConsistentHashingGroupSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterConsistentHashingGroupSpec.cs index fa5d7a67e76..8c5dd83d596 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterConsistentHashingGroupSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/Routing/ClusterConsistentHashingGroupSpec.cs @@ -36,7 +36,7 @@ public Collected(HashSet messages) public class Destination : UntypedActor { - private readonly HashSet _receivedMessages = new HashSet(); + private readonly HashSet _receivedMessages = new(); protected override void OnReceive(object message) { diff --git a/src/core/Akka.Cluster.Tests.MultiNode/StressSpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/StressSpec.cs index 3c5fb59ea72..24181bcc95a 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/StressSpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/StressSpec.cs @@ -412,7 +412,7 @@ internal class PhiObserver : ReceiveActor private ImmutableDictionary _phiByNode = ImmutableDictionary.Empty; private Option _reportTo = Option.None; - private HashSet
_nodes = new HashSet
(); + private HashSet
_nodes = new(); private ICancelable _checkPhiTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( TimeSpan.FromSeconds(1), @@ -632,31 +632,31 @@ protected override bool Receive(object message) internal sealed class Begin { - public static readonly Begin Instance = new Begin(); + public static readonly Begin Instance = new(); private Begin() { } } internal sealed class End { - public static readonly End Instance = new End(); + public static readonly End Instance = new(); private End() { } } internal sealed class RetryTick { - public static readonly RetryTick Instance = new RetryTick(); + public static readonly RetryTick Instance = new(); private RetryTick() { } } internal sealed class ReportTick { - public static readonly ReportTick Instance = new ReportTick(); + public static readonly ReportTick Instance = new(); private ReportTick() { } } internal sealed class PhiTick { - public static readonly PhiTick Instance = new PhiTick(); + public static readonly PhiTick Instance = new(); private PhiTick() { } } @@ -685,7 +685,7 @@ public StatsResult(Address address, ClusterEvent.CurrentInternalStats stats) internal sealed class Reset { - public static readonly Reset Instance = new Reset(); + public static readonly Reset Instance = new(); private Reset() { } } diff --git a/src/core/Akka.Cluster.Tests.MultiNode/SurviveNetworkInstabilitySpec.cs b/src/core/Akka.Cluster.Tests.MultiNode/SurviveNetworkInstabilitySpec.cs index 6514d73b6ea..06e07b557cd 100644 --- a/src/core/Akka.Cluster.Tests.MultiNode/SurviveNetworkInstabilitySpec.cs +++ b/src/core/Akka.Cluster.Tests.MultiNode/SurviveNetworkInstabilitySpec.cs @@ -81,7 +81,7 @@ public Targets(ISet refs) public class TargetsRegistered { - public static readonly TargetsRegistered Instance = new TargetsRegistered(); + public static readonly TargetsRegistered Instance = new(); private TargetsRegistered() { } } diff --git a/src/core/Akka.Cluster.Tests.Performance/Serialization/ClusterMessageSerializerSpec.cs b/src/core/Akka.Cluster.Tests.Performance/Serialization/ClusterMessageSerializerSpec.cs index e4138ded43c..2b474e2cf91 100644 --- a/src/core/Akka.Cluster.Tests.Performance/Serialization/ClusterMessageSerializerSpec.cs +++ b/src/core/Akka.Cluster.Tests.Performance/Serialization/ClusterMessageSerializerSpec.cs @@ -20,7 +20,7 @@ namespace Akka.Cluster.Tests.Performance.Serialization public class ClusterMessageSerializerSpec { private const string SerializerCounterName = "SerializerCounter"; - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); private Counter _serializationThroughput; private ActorSystem _system; private ClusterMessageSerializer _serializer; @@ -28,14 +28,14 @@ public class ClusterMessageSerializerSpec // MESSAGES - internal Lazy ClusterRouterPoolMessage { get; } = new Lazy(() => + internal Lazy ClusterRouterPoolMessage { get; } = new(() => { var roundRobinPool = new RoundRobinPool(nrOfInstances: 4); var clusterRouterPoolSettings = new ClusterRouterPoolSettings(2, 5, true, "Richard, Duke"); return new ClusterRouterPool(roundRobinPool, clusterRouterPoolSettings); }); - internal Lazy WelcomeMessage { get; } = new Lazy(() => + internal Lazy WelcomeMessage { get; } = new(() => { var member1 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4718), 34), 1, MemberStatus.Joining, ImmutableHashSet.Empty, AppVersion.Zero); var member2 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4710), 35), 1, MemberStatus.Joining, ImmutableHashSet.Empty, AppVersion.Zero); diff --git a/src/core/Akka.Cluster.Tests.Performance/Startup/ClusterStartupSpec.cs b/src/core/Akka.Cluster.Tests.Performance/Startup/ClusterStartupSpec.cs index f60c8b0a645..a875e8a508f 100644 --- a/src/core/Akka.Cluster.Tests.Performance/Startup/ClusterStartupSpec.cs +++ b/src/core/Akka.Cluster.Tests.Performance/Startup/ClusterStartupSpec.cs @@ -30,7 +30,7 @@ public class ClusterStartup2NodeSpec akka.remote.dot-netty.tcp.public-hostname = localhost akka.cluster.seed-nodes = [""akka.tcp://ClusterSys@localhost:8110""]"; - public TaskCompletionSource _clusterMemberUp = new TaskCompletionSource(); + public TaskCompletionSource _clusterMemberUp = new(); [PerfSetup] public void Setup(BenchmarkContext context) diff --git a/src/core/Akka.Cluster.Tests/ClusterDomainEventPublisherSpec.cs b/src/core/Akka.Cluster.Tests/ClusterDomainEventPublisherSpec.cs index 83514a3f727..bfd66ccfda4 100644 --- a/src/core/Akka.Cluster.Tests/ClusterDomainEventPublisherSpec.cs +++ b/src/core/Akka.Cluster.Tests/ClusterDomainEventPublisherSpec.cs @@ -37,25 +37,25 @@ public class ClusterDomainEventPublisherSpec : AkkaSpec static readonly Member dUp = TestMember.Create(new Address("akka.tcp", "sys", "d", 2552), MemberStatus.Up, ImmutableHashSet.Create("GRP")); static readonly Gossip g0 = new Gossip(ImmutableSortedSet.Create(aUp)).Seen(aUp.UniqueAddress); - static readonly MembershipState state0 = new MembershipState(g0, aUp.UniqueAddress); + static readonly MembershipState state0 = new(g0, aUp.UniqueAddress); static readonly Gossip g1 = new Gossip(ImmutableSortedSet.Create(aUp, cJoining)).Seen(aUp.UniqueAddress).Seen(cJoining.UniqueAddress); - static readonly MembershipState state1 = new MembershipState(g1, aUp.UniqueAddress); + static readonly MembershipState state1 = new(g1, aUp.UniqueAddress); static readonly Gossip g2 = new Gossip(ImmutableSortedSet.Create(aUp, bExiting, cUp)).Seen(aUp.UniqueAddress); - static readonly MembershipState state2 = new MembershipState(g2, aUp.UniqueAddress); + static readonly MembershipState state2 = new(g2, aUp.UniqueAddress); static readonly Gossip g3 = g2.Seen(bExiting.UniqueAddress).Seen(cUp.UniqueAddress); - static readonly MembershipState state3 = new MembershipState(g3, aUp.UniqueAddress); + static readonly MembershipState state3 = new(g3, aUp.UniqueAddress); static readonly Gossip g4 = new Gossip(ImmutableSortedSet.Create(a51Up, aUp, bExiting, cUp)).Seen(aUp.UniqueAddress); - static readonly MembershipState state4 = new MembershipState(g4, aUp.UniqueAddress); + static readonly MembershipState state4 = new(g4, aUp.UniqueAddress); static readonly Gossip g5 = new Gossip(ImmutableSortedSet.Create(a51Up, aUp, bExiting, cUp)).Seen(aUp.UniqueAddress).Seen(bExiting.UniqueAddress).Seen(cUp.UniqueAddress); - static readonly MembershipState state5 = new MembershipState(g5, aUp.UniqueAddress); + static readonly MembershipState state5 = new(g5, aUp.UniqueAddress); static readonly Gossip g6 = new Gossip(ImmutableSortedSet.Create(aLeaving, bExiting, cUp)).Seen(aUp.UniqueAddress); - static readonly MembershipState state6 = new MembershipState(g6, aUp.UniqueAddress); + static readonly MembershipState state6 = new(g6, aUp.UniqueAddress); static readonly Gossip g7 = new Gossip(ImmutableSortedSet.Create(aExiting, bExiting, cUp)).Seen(aUp.UniqueAddress); - static readonly MembershipState state7 = new MembershipState(g7, aUp.UniqueAddress); + static readonly MembershipState state7 = new(g7, aUp.UniqueAddress); static readonly Gossip g8 = new Gossip(ImmutableSortedSet.Create(aUp, bExiting, cUp, dUp), new GossipOverview(Reachability.Empty.Unreachable(aUp.UniqueAddress, dUp.UniqueAddress))).Seen(aUp.UniqueAddress); - static readonly MembershipState state8 = new MembershipState(g8, aUp.UniqueAddress); + static readonly MembershipState state8 = new(g8, aUp.UniqueAddress); - static readonly MembershipState _emptyMembershipState = new MembershipState(Gossip.Empty, aUp.UniqueAddress); + static readonly MembershipState _emptyMembershipState = new(Gossip.Empty, aUp.UniqueAddress); readonly TestProbe _memberSubscriber; public ClusterDomainEventPublisherSpec() : base(Config) diff --git a/src/core/Akka.Cluster.Tests/ClusterDomainEventSpec.cs b/src/core/Akka.Cluster.Tests/ClusterDomainEventSpec.cs index 3a7b003b629..c5cb925be48 100644 --- a/src/core/Akka.Cluster.Tests/ClusterDomainEventSpec.cs +++ b/src/core/Akka.Cluster.Tests/ClusterDomainEventSpec.cs @@ -35,7 +35,7 @@ public class ClusterDomainEventSpec static readonly Member eUp = TestMember.Create(new Address("akka.tcp", "sys", "e", 2552), MemberStatus.Up, eRoles); static readonly Member eDown = TestMember.Create(new Address("akka.tcp", "sys", "e", 2552), MemberStatus.Down, eRoles); - static readonly UniqueAddress selfDummyAddress = new UniqueAddress(new Address("akka.tcp", "sys", "selfDummy", 2552), 17); + static readonly UniqueAddress selfDummyAddress = new(new Address("akka.tcp", "sys", "selfDummy", 2552), 17); private static (Gossip, ImmutableHashSet) Converge(Gossip gossip) { diff --git a/src/core/Akka.Cluster.Tests/ClusterHeartBeatSenderStateSpec.cs b/src/core/Akka.Cluster.Tests/ClusterHeartBeatSenderStateSpec.cs index 7c998b8cc27..00c89562288 100644 --- a/src/core/Akka.Cluster.Tests/ClusterHeartBeatSenderStateSpec.cs +++ b/src/core/Akka.Cluster.Tests/ClusterHeartBeatSenderStateSpec.cs @@ -87,11 +87,11 @@ public override void HeartBeat() #endregion - private UniqueAddress aa = new UniqueAddress(new Address("akka.tcp", "sys", "aa", 2552), 1); - private UniqueAddress bb = new UniqueAddress(new Address("akka.tcp", "sys", "bb", 2552), 2); - private UniqueAddress cc = new UniqueAddress(new Address("akka.tcp", "sys", "cc", 2552), 3); - private UniqueAddress dd = new UniqueAddress(new Address("akka.tcp", "sys", "dd", 2552), 4); - private UniqueAddress ee = new UniqueAddress(new Address("akka.tcp", "sys", "ee", 2552), 5); + private UniqueAddress aa = new(new Address("akka.tcp", "sys", "aa", 2552), 1); + private UniqueAddress bb = new(new Address("akka.tcp", "sys", "bb", 2552), 2); + private UniqueAddress cc = new(new Address("akka.tcp", "sys", "cc", 2552), 3); + private UniqueAddress dd = new(new Address("akka.tcp", "sys", "dd", 2552), 4); + private UniqueAddress ee = new(new Address("akka.tcp", "sys", "ee", 2552), 5); private readonly ClusterHeartbeatSenderState _emptyState; diff --git a/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs b/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs index c9831428734..0e5411af9f6 100644 --- a/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs +++ b/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs @@ -36,7 +36,7 @@ public Props DowningActorProps internal class DummyDowningProvider : IDowningProvider { - public readonly AtomicBoolean ActorPropsAccessed = new AtomicBoolean(false); + public readonly AtomicBoolean ActorPropsAccessed = new(false); public DummyDowningProvider(ActorSystem system, Cluster cluster) { } diff --git a/src/core/Akka.Cluster.Tests/HeartbeatNodeRingSpec.cs b/src/core/Akka.Cluster.Tests/HeartbeatNodeRingSpec.cs index 5b3047f7911..1cfc6eede44 100644 --- a/src/core/Akka.Cluster.Tests/HeartbeatNodeRingSpec.cs +++ b/src/core/Akka.Cluster.Tests/HeartbeatNodeRingSpec.cs @@ -34,12 +34,12 @@ protected HeartbeatNodeRingBase(ITestOutputHelper output, bool useLegacyMessage) _nodes = ImmutableHashSet.Create(aa, bb, cc, dd, ee, ff); } - private UniqueAddress aa = new UniqueAddress(new Address("akka.tcp", "sys", "aa", 2552), 1); - private UniqueAddress bb = new UniqueAddress(new Address("akka.tcp", "sys", "bb", 2552), 2); - private UniqueAddress cc = new UniqueAddress(new Address("akka.tcp", "sys", "cc", 2552), 3); - private UniqueAddress dd = new UniqueAddress(new Address("akka.tcp", "sys", "dd", 2552), 4); - private UniqueAddress ee = new UniqueAddress(new Address("akka.tcp", "sys", "ee", 2552), 5); - private UniqueAddress ff = new UniqueAddress(new Address("akka.tcp", "sys", "ff", 2552), 6); + private UniqueAddress aa = new(new Address("akka.tcp", "sys", "aa", 2552), 1); + private UniqueAddress bb = new(new Address("akka.tcp", "sys", "bb", 2552), 2); + private UniqueAddress cc = new(new Address("akka.tcp", "sys", "cc", 2552), 3); + private UniqueAddress dd = new(new Address("akka.tcp", "sys", "dd", 2552), 4); + private UniqueAddress ee = new(new Address("akka.tcp", "sys", "ee", 2552), 5); + private UniqueAddress ff = new(new Address("akka.tcp", "sys", "ff", 2552), 6); private readonly ImmutableHashSet _nodes; diff --git a/src/core/Akka.Cluster.Tests/ReachabilitySpec.cs b/src/core/Akka.Cluster.Tests/ReachabilitySpec.cs index 6000ae1d4be..76d73cf7a86 100644 --- a/src/core/Akka.Cluster.Tests/ReachabilitySpec.cs +++ b/src/core/Akka.Cluster.Tests/ReachabilitySpec.cs @@ -15,11 +15,11 @@ namespace Akka.Cluster.Tests { public class ReachabilitySpec { - static readonly UniqueAddress nodeA = new UniqueAddress(new Address("akka.tcp", "sys", "a", 2552), 1); - static readonly UniqueAddress nodeB = new UniqueAddress(new Address("akka.tcp", "sys", "b", 2552), 2); - static readonly UniqueAddress nodeC = new UniqueAddress(new Address("akka.tcp", "sys", "c", 2552), 3); - static readonly UniqueAddress nodeD = new UniqueAddress(new Address("akka.tcp", "sys", "d", 2552), 4); - static readonly UniqueAddress nodeE = new UniqueAddress(new Address("akka.tcp", "sys", "e", 2552), 5); + static readonly UniqueAddress nodeA = new(new Address("akka.tcp", "sys", "a", 2552), 1); + static readonly UniqueAddress nodeB = new(new Address("akka.tcp", "sys", "b", 2552), 2); + static readonly UniqueAddress nodeC = new(new Address("akka.tcp", "sys", "c", 2552), 3); + static readonly UniqueAddress nodeD = new(new Address("akka.tcp", "sys", "d", 2552), 4); + static readonly UniqueAddress nodeE = new(new Address("akka.tcp", "sys", "e", 2552), 5); [Fact] public void ReachabilityTable_must_be_reachable_when_empty() diff --git a/src/core/Akka.Cluster.Tests/SplitBrainStrategySpec.cs b/src/core/Akka.Cluster.Tests/SplitBrainStrategySpec.cs index 814593d3535..a69b1656a2e 100644 --- a/src/core/Akka.Cluster.Tests/SplitBrainStrategySpec.cs +++ b/src/core/Akka.Cluster.Tests/SplitBrainStrategySpec.cs @@ -18,16 +18,16 @@ namespace Akka.Cluster.Tests public class SplitBrainStrategySpec { private static Member Member(Address address, int upNumber = 1, MemberStatus status = MemberStatus.Up, string role = null) => - new Member(new UniqueAddress(address, ThreadLocalRandom.Current.Next()), upNumber, status, role == null ? ImmutableHashSet.Empty : ImmutableHashSet.Create(role), AppVersion.Zero); + new(new UniqueAddress(address, ThreadLocalRandom.Current.Next()), upNumber, status, role == null ? ImmutableHashSet.Empty : ImmutableHashSet.Create(role), AppVersion.Zero); private static ImmutableSortedSet Members(params Member[] members) => ImmutableSortedSet.CreateRange(Akka.Cluster.Member.AgeOrdering, members); - private static readonly Address a = new Address("akka.tcp", "system", "localhost", 10000); - private static readonly Address b = new Address("akka.tcp", "system", "localhost", 10001); - private static readonly Address c = new Address("akka.tcp", "system", "localhost", 10002); - private static readonly Address d = new Address("akka.tcp", "system", "localhost", 10003); - private static readonly Address e = new Address("akka.tcp", "system", "localhost", 10004); - private static readonly Address f = new Address("akka.tcp", "system", "localhost", 10005); + private static readonly Address a = new("akka.tcp", "system", "localhost", 10000); + private static readonly Address b = new("akka.tcp", "system", "localhost", 10001); + private static readonly Address c = new("akka.tcp", "system", "localhost", 10002); + private static readonly Address d = new("akka.tcp", "system", "localhost", 10003); + private static readonly Address e = new("akka.tcp", "system", "localhost", 10004); + private static readonly Address f = new("akka.tcp", "system", "localhost", 10005); [Fact] public void StaticQuorum_must_down_unreachable_nodes_if_remaining_size_is_equal_quorum_size() diff --git a/src/core/Akka.Cluster/Cluster.cs b/src/core/Akka.Cluster/Cluster.cs index e331901c0b8..9909c64156f 100644 --- a/src/core/Akka.Cluster/Cluster.cs +++ b/src/core/Akka.Cluster/Cluster.cs @@ -543,7 +543,7 @@ public ImmutableHashSet SelfRoles /// public Member SelfMember => _readView.Self; - private readonly AtomicBoolean _isTerminated = new AtomicBoolean(false); + private readonly AtomicBoolean _isTerminated = new(false); /// /// Determine whether or not this cluster instance has been shutdown. diff --git a/src/core/Akka.Cluster/ClusterActorRefProvider.cs b/src/core/Akka.Cluster/ClusterActorRefProvider.cs index e789fb94cd0..b2206fbc0d7 100644 --- a/src/core/Akka.Cluster/ClusterActorRefProvider.cs +++ b/src/core/Akka.Cluster/ClusterActorRefProvider.cs @@ -94,7 +94,7 @@ private ClusterScope() { } /// /// The singleton instance of this scope. /// - public static readonly ClusterScope Instance = new ClusterScope(); + public static readonly ClusterScope Instance = new(); /// /// Creates a new from this scope using another diff --git a/src/core/Akka.Cluster/ClusterDaemon.cs b/src/core/Akka.Cluster/ClusterDaemon.cs index ca38727ca18..b556b421130 100644 --- a/src/core/Akka.Cluster/ClusterDaemon.cs +++ b/src/core/Akka.Cluster/ClusterDaemon.cs @@ -432,7 +432,7 @@ private ExitingCompleted() { } /// /// Singleton instance /// - public static readonly ExitingCompleted Instance = new ExitingCompleted(); + public static readonly ExitingCompleted Instance = new(); } /// @@ -446,7 +446,7 @@ internal interface ITick { } internal class GossipTick : ITick { private GossipTick() { } - private static readonly GossipTick _instance = new GossipTick(); + private static readonly GossipTick _instance = new(); /// /// TBD /// @@ -465,7 +465,7 @@ public static GossipTick Instance internal class GossipSpeedupTick : ITick { private GossipSpeedupTick() { } - private static readonly GossipSpeedupTick _instance = new GossipSpeedupTick(); + private static readonly GossipSpeedupTick _instance = new(); /// /// TBD /// @@ -484,7 +484,7 @@ public static GossipSpeedupTick Instance internal class ReapUnreachableTick : ITick { private ReapUnreachableTick() { } - private static readonly ReapUnreachableTick _instance = new ReapUnreachableTick(); + private static readonly ReapUnreachableTick _instance = new(); /// /// TBD /// @@ -503,7 +503,7 @@ public static ReapUnreachableTick Instance internal class MetricsTick : ITick { private MetricsTick() { } - private static readonly MetricsTick _instance = new MetricsTick(); + private static readonly MetricsTick _instance = new(); /// /// TBD /// @@ -522,7 +522,7 @@ public static MetricsTick Instance internal class LeaderActionsTick : ITick { private LeaderActionsTick() { } - private static readonly LeaderActionsTick _instance = new LeaderActionsTick(); + private static readonly LeaderActionsTick _instance = new(); /// /// TBD /// @@ -541,7 +541,7 @@ public static LeaderActionsTick Instance internal class PublishStatsTick : ITick { private PublishStatsTick() { } - private static readonly PublishStatsTick _instance = new PublishStatsTick(); + private static readonly PublishStatsTick _instance = new(); /// /// TBD /// @@ -833,7 +833,7 @@ internal sealed class ClusterDaemon : ReceiveActor, IRequiresMessageQueue _clusterPromise = new TaskCompletionSource(); + private readonly TaskCompletionSource _clusterPromise = new(); /// /// Creates a new instance of the ClusterDaemon @@ -1015,7 +1015,7 @@ internal static string VclockName(UniqueAddress node) private Gossip LatestGossip => _membershipState.LatestGossip; private readonly bool _statsEnabled; - private GossipStats _gossipStats = new GossipStats(); + private GossipStats _gossipStats = new(); private ImmutableList
_seedNodes; private IActorRef _seedNodeProcess; private int _seedNodeProcessCounter = 0; //for unique names @@ -1026,7 +1026,7 @@ internal static string VclockName(UniqueAddress node) private int _selfDownCounter = 0; private bool _exitingTasksInProgress = false; - private readonly TaskCompletionSource _selfExiting = new TaskCompletionSource(); + private readonly TaskCompletionSource _selfExiting = new(); private readonly CoordinatedShutdown _coordShutdown = CoordinatedShutdown.Get(Context.System); private ImmutableHashSet _exitingConfirmed = ImmutableHashSet.Empty; diff --git a/src/core/Akka.Cluster/ClusterHeartbeat.cs b/src/core/Akka.Cluster/ClusterHeartbeat.cs index 7cab74982fc..22397baf579 100644 --- a/src/core/Akka.Cluster/ClusterHeartbeat.cs +++ b/src/core/Akka.Cluster/ClusterHeartbeat.cs @@ -754,7 +754,7 @@ internal class RingComparer : IComparer /// /// The singleton instance of this comparer /// - public static readonly RingComparer Instance = new RingComparer(); + public static readonly RingComparer Instance = new(); private RingComparer() { } /// diff --git a/src/core/Akka.Cluster/CoordinatedShutdownLeave.cs b/src/core/Akka.Cluster/CoordinatedShutdownLeave.cs index 4c0467c4199..1b57fcce9b9 100644 --- a/src/core/Akka.Cluster/CoordinatedShutdownLeave.cs +++ b/src/core/Akka.Cluster/CoordinatedShutdownLeave.cs @@ -29,7 +29,7 @@ private LeaveReq() { } /// /// Singleton instance. /// - public static readonly LeaveReq Instance = new LeaveReq(); + public static readonly LeaveReq Instance = new(); } private readonly Cluster _cluster = Cluster.Get(Context.System); diff --git a/src/core/Akka.Cluster/Gossip.cs b/src/core/Akka.Cluster/Gossip.cs index 454f8b14bfd..0d011ea0b91 100644 --- a/src/core/Akka.Cluster/Gossip.cs +++ b/src/core/Akka.Cluster/Gossip.cs @@ -55,7 +55,7 @@ internal sealed class Gossip /// /// An empty object. /// - public static readonly Gossip Empty = new Gossip(EmptyMembers); + public static readonly Gossip Empty = new(EmptyMembers); /// /// Creates a new from the given set of members. diff --git a/src/core/Akka.Cluster/Member.cs b/src/core/Akka.Cluster/Member.cs index 586cc0117b7..3846f15fb1e 100644 --- a/src/core/Akka.Cluster/Member.cs +++ b/src/core/Akka.Cluster/Member.cs @@ -255,7 +255,7 @@ public int Compare(Member a, Member b) /// Orders the members by their address except that members with status /// Joining, Exiting and Down are ordered last (in that order). /// - internal static readonly LeaderStatusMemberComparer LeaderStatusOrdering = new LeaderStatusMemberComparer(); + internal static readonly LeaderStatusMemberComparer LeaderStatusOrdering = new(); /// /// INTERNAL API @@ -283,7 +283,7 @@ public int Compare(Member a, Member b) /// /// ordering type class, sorts members by host and port. /// - internal static readonly MemberComparer Ordering = new MemberComparer(); + internal static readonly MemberComparer Ordering = new(); /// /// INTERNAL API diff --git a/src/core/Akka.Cluster/Reachability.cs b/src/core/Akka.Cluster/Reachability.cs index 37d4b18e1d9..168fb807336 100644 --- a/src/core/Akka.Cluster/Reachability.cs +++ b/src/core/Akka.Cluster/Reachability.cs @@ -52,8 +52,7 @@ public enum ReachabilityStatus /// /// TBD /// - public static readonly Reachability Empty = - new Reachability(ImmutableList.Create(), ImmutableDictionary.Create()); + public static readonly Reachability Empty = new(ImmutableList.Create(), ImmutableDictionary.Create()); private readonly Lazy _cache; diff --git a/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs b/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs index 3e6220b6fc2..762595f1c2b 100644 --- a/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs +++ b/src/core/Akka.Cluster/Routing/ClusterRoutingConfig.cs @@ -227,7 +227,7 @@ internal static int GetMaxTotalNrOfInstances(Config config) /// public sealed class ClusterRouterPool : Pool { - private readonly AtomicCounter _childNameCounter = new AtomicCounter(0); + private readonly AtomicCounter _childNameCounter = new(0); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka.Cluster/SBR/DowningStrategy.cs b/src/core/Akka.Cluster/SBR/DowningStrategy.cs index 0c18cc66da4..6958c603d17 100644 --- a/src/core/Akka.Cluster/SBR/DowningStrategy.cs +++ b/src/core/Akka.Cluster/SBR/DowningStrategy.cs @@ -21,7 +21,7 @@ internal interface IDecision internal class DownReachable : IDecision { - public static readonly DownReachable Instance = new DownReachable(); + public static readonly DownReachable Instance = new(); private DownReachable() { @@ -32,7 +32,7 @@ private DownReachable() internal class DownUnreachable : IDecision { - public static readonly DownUnreachable Instance = new DownUnreachable(); + public static readonly DownUnreachable Instance = new(); private DownUnreachable() { @@ -43,7 +43,7 @@ private DownUnreachable() internal class DownAll : IDecision { - public static readonly DownAll Instance = new DownAll(); + public static readonly DownAll Instance = new(); private DownAll() { @@ -54,7 +54,7 @@ private DownAll() internal class DownIndirectlyConnected : IDecision { - public static readonly DownIndirectlyConnected Instance = new DownIndirectlyConnected(); + public static readonly DownIndirectlyConnected Instance = new(); private DownIndirectlyConnected() { @@ -129,7 +129,7 @@ public override int GetHashCode() internal class ReverseDownIndirectlyConnected : IDecision { - public static readonly ReverseDownIndirectlyConnected Instance = new ReverseDownIndirectlyConnected(); + public static readonly ReverseDownIndirectlyConnected Instance = new(); public bool IsIndirectlyConnected => true; diff --git a/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs b/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs index 763a7bc0bbe..bd4e4575e2c 100644 --- a/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs +++ b/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs @@ -73,8 +73,7 @@ internal abstract class SplitBrainResolverBase : ActorBase, IWithUnboundedStash, private ILoggingAdapter _log; - private ReachabilityChangedStats _reachabilityChangedStats = - new ReachabilityChangedStats(DateTime.UtcNow, DateTime.UtcNow, 0); + private ReachabilityChangedStats _reachabilityChangedStats = new(DateTime.UtcNow, DateTime.UtcNow, 0); private IReleaseLeaseCondition _releaseLeaseCondition = ReleaseLeaseCondition.NoLease.Instance; private bool _selfMemberAdded; @@ -658,7 +657,7 @@ private void ReleaseLease() internal class Tick { - public static readonly Tick Instance = new Tick(); + public static readonly Tick Instance = new(); private Tick() { @@ -696,7 +695,7 @@ public ReleaseLeaseResult(bool released) /// protected class AcquireLease { - public static readonly AcquireLease Instance = new AcquireLease(); + public static readonly AcquireLease Instance = new(); private AcquireLease() { @@ -738,7 +737,7 @@ protected static class ReleaseLeaseCondition { public class NoLease : IReleaseLeaseCondition { - public static readonly NoLease Instance = new NoLease(); + public static readonly NoLease Instance = new(); private NoLease() { diff --git a/src/core/Akka.Cluster/Serialization/ClusterMessageSerializer.cs b/src/core/Akka.Cluster/Serialization/ClusterMessageSerializer.cs index 206e713e6cf..8a057f6018d 100644 --- a/src/core/Akka.Cluster/Serialization/ClusterMessageSerializer.cs +++ b/src/core/Akka.Cluster/Serialization/ClusterMessageSerializer.cs @@ -475,12 +475,12 @@ private static ClusterHeartbeatSender.HeartbeatRsp DeserializeHeartbeatRspAsUniq } private static Proto.Msg.HeartBeatResponse HeartbeatRspToProto(ClusterHeartbeatSender.HeartbeatRsp heartbeatRsp) - => new HeartBeatResponse - { - From = UniqueAddressToProto(heartbeatRsp.From), - CreationTime = heartbeatRsp.CreationTimeNanos, - SequenceNr = heartbeatRsp.SequenceNr - }; + => new() + { + From = UniqueAddressToProto(heartbeatRsp.From), + CreationTime = heartbeatRsp.CreationTimeNanos, + SequenceNr = heartbeatRsp.SequenceNr + }; private static ClusterHeartbeatSender.HeartbeatRsp DeserializeHeartbeatRsp(byte[] bytes) { @@ -494,7 +494,7 @@ private static ClusterHeartbeatSender.Heartbeat DeserializeHeartbeatAsAddress(by } private static Proto.Msg.Heartbeat HeartbeatToProto(ClusterHeartbeatSender.Heartbeat heartbeat) - => new Heartbeat + => new() { From = AddressToProto(heartbeat.From), CreationTime = heartbeat.CreationTimeNanos, diff --git a/src/core/Akka.Cluster/SplitBrainResolver.cs b/src/core/Akka.Cluster/SplitBrainResolver.cs index 146535b2e5b..b5bf8e1712d 100644 --- a/src/core/Akka.Cluster/SplitBrainResolver.cs +++ b/src/core/Akka.Cluster/SplitBrainResolver.cs @@ -237,7 +237,7 @@ internal sealed class SplitBrainDecider : UntypedActor private sealed class StabilityReached { - public static readonly StabilityReached Instance = new StabilityReached(); + public static readonly StabilityReached Instance = new(); private StabilityReached() { } } diff --git a/src/core/Akka.Coordination.Tests/TestLease.cs b/src/core/Akka.Coordination.Tests/TestLease.cs index f417492f576..1992bea1be0 100644 --- a/src/core/Akka.Coordination.Tests/TestLease.cs +++ b/src/core/Akka.Coordination.Tests/TestLease.cs @@ -34,7 +34,7 @@ public static TestLeaseExt Get(ActorSystem system) } private readonly ExtendedActorSystem _system; - private readonly ConcurrentDictionary testLeases = new ConcurrentDictionary(); + private readonly ConcurrentDictionary testLeases = new(); public TestLeaseExt(ExtendedActorSystem system) { @@ -118,10 +118,10 @@ public static Config Configuration public TestProbe Probe { get; } private AtomicReference> nextAcquireResult; - private AtomicBoolean nextCheckLeaseResult = new AtomicBoolean(false); - private AtomicReference> currentCallBack = new AtomicReference>(_ => { }); + private AtomicBoolean nextCheckLeaseResult = new(false); + private AtomicReference> currentCallBack = new(_ => { }); private ILoggingAdapter _log; - public TaskCompletionSource InitialPromise { get; } = new TaskCompletionSource(); + public TaskCompletionSource InitialPromise { get; } = new(); public TestLease(LeaseSettings settings, ExtendedActorSystem system) diff --git a/src/core/Akka.Coordination.Tests/TestLeaseActor.cs b/src/core/Akka.Coordination.Tests/TestLeaseActor.cs index 70438527407..8fb727aebb6 100644 --- a/src/core/Akka.Coordination.Tests/TestLeaseActor.cs +++ b/src/core/Akka.Coordination.Tests/TestLeaseActor.cs @@ -107,7 +107,7 @@ public override int GetHashCode() public sealed class GetRequests { - public static readonly GetRequests Instance = new GetRequests(); + public static readonly GetRequests Instance = new(); private GetRequests() { } @@ -143,7 +143,7 @@ public ActionRequest(ILeaseRequest request, bool result) public static Props Props => Props.Create(() => new TestLeaseActor()); private ILoggingAdapter _log = Context.GetLogger(); - private readonly List<(IActorRef, ILeaseRequest)> _requests = new List<(IActorRef, ILeaseRequest)>(); + private readonly List<(IActorRef, ILeaseRequest)> _requests = new(); public TestLeaseActor() { @@ -201,7 +201,7 @@ public static TestLeaseActorClientExt Get(ActorSystem system) } private readonly ExtendedActorSystem _system; - private AtomicReference leaseActor = new AtomicReference(); + private AtomicReference leaseActor = new(); public TestLeaseActorClientExt(ExtendedActorSystem system) { diff --git a/src/core/Akka.Coordination/LeaseProvider.cs b/src/core/Akka.Coordination/LeaseProvider.cs index fbdd0e3d8cb..bb3452010d3 100644 --- a/src/core/Akka.Coordination/LeaseProvider.cs +++ b/src/core/Akka.Coordination/LeaseProvider.cs @@ -83,7 +83,7 @@ public static LeaseProvider Get(ActorSystem system) } private readonly ExtendedActorSystem _system; - private readonly ConcurrentDictionary _leases = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _leases = new(); private ILoggingAdapter _log; diff --git a/src/core/Akka.Discovery.Tests/Aggregate/AggregateServiceDiscoverySpec.cs b/src/core/Akka.Discovery.Tests/Aggregate/AggregateServiceDiscoverySpec.cs index 793d11849ca..c554938b9f8 100644 --- a/src/core/Akka.Discovery.Tests/Aggregate/AggregateServiceDiscoverySpec.cs +++ b/src/core/Akka.Discovery.Tests/Aggregate/AggregateServiceDiscoverySpec.cs @@ -79,7 +79,7 @@ public void Aggregate_service_discovery_must_only_call_first_one_if_returns_resu "stubbed", new List { - new ServiceDiscovery.ResolvedTarget("stubbed1", 1234) + new("stubbed1", 1234) })); } @@ -91,8 +91,8 @@ public void Aggregate_service_discovery_must_move_onto_the_next_if_no_resolved_t "config1", new List { - new ServiceDiscovery.ResolvedTarget("cat", 1233), - new ServiceDiscovery.ResolvedTarget("dog", 1234) + new("cat", 1233), + new("dog", 1234) })); } @@ -105,7 +105,7 @@ public void Aggregate_service_discovery_must_move_onto_next_if_fails() "fail", new List { - new ServiceDiscovery.ResolvedTarget("from-config") + new("from-config") })); } } diff --git a/src/core/Akka.Discovery.Tests/LookupSpec.cs b/src/core/Akka.Discovery.Tests/LookupSpec.cs index 51192953fb1..ddbf98ee917 100644 --- a/src/core/Akka.Discovery.Tests/LookupSpec.cs +++ b/src/core/Akka.Discovery.Tests/LookupSpec.cs @@ -20,7 +20,7 @@ public class LookupSpec : TestKit.Xunit2.TestKit private readonly List srvWithValidDomainNames; // No SRV that should result in simple A/AAAA lookups - private readonly List noSrvLookups = new List + private readonly List noSrvLookups = new() { "portName.protocol.serviceName.local", "serviceName.local", diff --git a/src/core/Akka.Discovery/Discovery.cs b/src/core/Akka.Discovery/Discovery.cs index a299f1ab54d..fceba8f59d5 100644 --- a/src/core/Akka.Discovery/Discovery.cs +++ b/src/core/Akka.Discovery/Discovery.cs @@ -19,8 +19,7 @@ public class Discovery : IExtension { private readonly ExtendedActorSystem _system; private readonly Lazy _defaultImpl; - private readonly ConcurrentDictionary> _implementations = - new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _implementations = new(); private readonly ILoggingAdapter _log; public Discovery(ExtendedActorSystem system) @@ -100,7 +99,7 @@ Try Create(string typeName) public class DiscoveryProvider : ExtensionIdProvider { - public override Discovery CreateExtension(ExtendedActorSystem system) => new Discovery(system); + public override Discovery CreateExtension(ExtendedActorSystem system) => new(system); /// /// Returns a default configuration for the Akka Discovery module. diff --git a/src/core/Akka.Discovery/ServiceDiscovery.cs b/src/core/Akka.Discovery/ServiceDiscovery.cs index 137e65b79da..a5e70a54f56 100644 --- a/src/core/Akka.Discovery/ServiceDiscovery.cs +++ b/src/core/Akka.Discovery/ServiceDiscovery.cs @@ -146,7 +146,7 @@ public override int GetHashCode() /// public class Lookup : INoSerializationVerificationNeeded, IEquatable { - private static readonly Regex srvQueryRegex = new Regex(@"^_(.+?)\._(.+?)\.(.+?)$", + private static readonly Regex srvQueryRegex = new(@"^_(.+?)\._(.+?)\.(.+?)$", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); // Validates domain name: @@ -170,7 +170,7 @@ public class Lookup : INoSerializationVerificationNeeded, IEquatable // . => separated by a . (dot) // label pattern => (?![0-9-])[A-Za-z0-9-]{1,63}(? match zero or more times - private static readonly Regex domainNameRegex = new Regex(@"^((?![0-9-])[A-Za-z0-9-]{1,63}(? @@ -250,8 +250,7 @@ public static bool IsValid(string srv) public override string ToString() => $"Lookup({ServiceName}, {PortName}, {Protocol})"; - public Lookup Copy(string serviceName = null, string portName = null, string protocol = null) => - new Lookup(serviceName ?? ServiceName, portName ?? PortName, protocol ?? Protocol); + public Lookup Copy(string serviceName = null, string portName = null, string protocol = null) => new(serviceName ?? ServiceName, portName ?? PortName, protocol ?? Protocol); public bool Equals(Lookup other) { diff --git a/src/core/Akka.Docs.Tests/Actors/FiniteStateMachine/FiniteStateMachine.Messages.cs b/src/core/Akka.Docs.Tests/Actors/FiniteStateMachine/FiniteStateMachine.Messages.cs index 0ca42d6c37b..679f4b362ff 100644 --- a/src/core/Akka.Docs.Tests/Actors/FiniteStateMachine/FiniteStateMachine.Messages.cs +++ b/src/core/Akka.Docs.Tests/Actors/FiniteStateMachine/FiniteStateMachine.Messages.cs @@ -64,7 +64,7 @@ public interface IData { } public class Uninitialized : IData { - public static Uninitialized Instance = new Uninitialized(); + public static Uninitialized Instance = new(); private Uninitialized() { } } diff --git a/src/core/Akka.Docs.Tests/Networking/Serialization/ExternalAddressProvider.cs b/src/core/Akka.Docs.Tests/Networking/Serialization/ExternalAddressProvider.cs index 2d8df7a098e..072f97cdc90 100644 --- a/src/core/Akka.Docs.Tests/Networking/Serialization/ExternalAddressProvider.cs +++ b/src/core/Akka.Docs.Tests/Networking/Serialization/ExternalAddressProvider.cs @@ -13,8 +13,7 @@ namespace DocsExamples.Networking.Serialization { public class ExternalAddress : ExtensionIdProvider { - public override ExternalAddressExtension CreateExtension(ExtendedActorSystem system) => - new ExternalAddressExtension(system); + public override ExternalAddressExtension CreateExtension(ExtendedActorSystem system) => new(system); } public class ExternalAddressExtension : IExtension diff --git a/src/core/Akka.Docs.Tests/Persistence/PersistentActor/PersistentActor.cs b/src/core/Akka.Docs.Tests/Persistence/PersistentActor/PersistentActor.cs index f0dd3c6bbec..5168d723d89 100644 --- a/src/core/Akka.Docs.Tests/Persistence/PersistentActor/PersistentActor.cs +++ b/src/core/Akka.Docs.Tests/Persistence/PersistentActor/PersistentActor.cs @@ -62,7 +62,7 @@ public override string ToString() public class PersistentActor : UntypedPersistentActor { - private ExampleState _state = new ExampleState(); + private ExampleState _state = new(); private void UpdateState(Evt evt) { diff --git a/src/core/Akka.Docs.Tests/Persistence/PersistentActor/Snapshots.cs b/src/core/Akka.Docs.Tests/Persistence/PersistentActor/Snapshots.cs index dbf7029758b..1d6795a6ed0 100644 --- a/src/core/Akka.Docs.Tests/Persistence/PersistentActor/Snapshots.cs +++ b/src/core/Akka.Docs.Tests/Persistence/PersistentActor/Snapshots.cs @@ -16,7 +16,7 @@ public class MyPersistentActor : UntypedPersistentActor { public override string PersistenceId => "my-stable-persistence-id"; private const int SnapShotInterval = 1000; - private object state = new object(); + private object state = new(); protected override void OnRecover(object message) { diff --git a/src/core/Akka.Docs.Tests/Persistence/WebStoreCustomerFSMActor.cs b/src/core/Akka.Docs.Tests/Persistence/WebStoreCustomerFSMActor.cs index 97011a0d5d0..c4ea4221abd 100644 --- a/src/core/Akka.Docs.Tests/Persistence/WebStoreCustomerFSMActor.cs +++ b/src/core/Akka.Docs.Tests/Persistence/WebStoreCustomerFSMActor.cs @@ -28,19 +28,19 @@ public AddItem(Item item) public class Buy : ICommand { - public static Buy Instance { get; } = new Buy(); + public static Buy Instance { get; } = new(); private Buy() { } } public class Leave : ICommand { - public static Leave Instance { get; } = new Leave(); + public static Leave Instance { get; } = new(); private Leave() { } } public class GetCurrentCart : ICommand { - public static GetCurrentCart Instance { get; } = new GetCurrentCart(); + public static GetCurrentCart Instance { get; } = new(); private GetCurrentCart() { } } #endregion @@ -50,28 +50,28 @@ public interface IUserState : Akka.Persistence.Fsm.PersistentFSM.IFsmState { } public class LookingAround : IUserState { - public static LookingAround Instance { get; } = new LookingAround(); + public static LookingAround Instance { get; } = new(); private LookingAround() { } public string Identifier => "Looking Around"; } public class Shopping : IUserState { - public static Shopping Instance { get; } = new Shopping(); + public static Shopping Instance { get; } = new(); private Shopping() { } public string Identifier => "Shopping"; } public class Inactive : IUserState { - public static Inactive Instance { get; } = new Inactive(); + public static Inactive Instance { get; } = new(); private Inactive() { } public string Identifier => "Inactive"; } public class Paid : IUserState { - public static Paid Instance { get; } = new Paid(); + public static Paid Instance { get; } = new(); private Paid() { } public string Identifier => "Paid"; } @@ -92,13 +92,13 @@ public ItemAdded(Item item) public class OrderExecuted : IDomainEvent { - public static OrderExecuted Instance { get; } = new OrderExecuted(); + public static OrderExecuted Instance { get; } = new(); private OrderExecuted() { } } public class OrderDiscarded : IDomainEvent { - public static OrderDiscarded Instance { get; } = new OrderDiscarded(); + public static OrderDiscarded Instance { get; } = new(); private OrderDiscarded() { } } #endregion @@ -175,7 +175,7 @@ public PurchaseWasMade(IEnumerable items) public class ShoppingCardDiscarded : IReportEvent { - public static ShoppingCardDiscarded Instance { get; } = new ShoppingCardDiscarded(); + public static ShoppingCardDiscarded Instance { get; } = new(); private ShoppingCardDiscarded() { } } #endregion diff --git a/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs b/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs index c9aaf7630e0..9e85029bcec 100644 --- a/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs +++ b/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs @@ -36,7 +36,7 @@ public SomeActor() public class TestKitSampleTest : TestKit { - private TimeSpan EpsilonValueForWithins => new TimeSpan(0, 0, 1); // https://github.com/akkadotnet/akka.net/issues/2130 + private TimeSpan EpsilonValueForWithins => new(0, 0, 1); // https://github.com/akkadotnet/akka.net/issues/2130 [Fact] public void Test() diff --git a/src/core/Akka.Docs.Tutorials/Tutorial2/DeviceInProgress.cs b/src/core/Akka.Docs.Tutorials/Tutorial2/DeviceInProgress.cs index e19eaa235fa..289652fea70 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial2/DeviceInProgress.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial2/DeviceInProgress.cs @@ -20,7 +20,7 @@ public static class DeviceInProgress1 #region read-protocol-1 public sealed class ReadTemperature { - public static ReadTemperature Instance { get; } = new ReadTemperature(); + public static ReadTemperature Instance { get; } = new(); private ReadTemperature() { } } diff --git a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroup.cs b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroup.cs index 88d7b862b82..8ca252852e6 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroup.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroup.cs @@ -38,8 +38,8 @@ public ReplyDeviceList(long requestId, ISet ids) public class DeviceGroup : UntypedActor { - private Dictionary deviceIdToActor = new Dictionary(); - private Dictionary actorToDeviceId = new Dictionary(); + private Dictionary deviceIdToActor = new(); + private Dictionary actorToDeviceId = new(); public DeviceGroup(string groupId) { diff --git a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupInProgress.cs b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupInProgress.cs index f1393003fe4..52bbc1eebce 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupInProgress.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupInProgress.cs @@ -17,7 +17,7 @@ public static class DeviceGroupInProgress #region device-group-register public class DeviceGroup : UntypedActor { - private Dictionary deviceIdToActor = new Dictionary(); + private Dictionary deviceIdToActor = new(); public DeviceGroup(string groupId) { @@ -63,8 +63,8 @@ public static class DeviceGroupInProgress2 #region device-group-remove public class DeviceGroup : UntypedActor { - private Dictionary deviceIdToActor = new Dictionary(); - private Dictionary actorToDeviceId = new Dictionary(); + private Dictionary deviceIdToActor = new(); + private Dictionary actorToDeviceId = new(); public DeviceGroup(string groupId) { diff --git a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceManager.cs b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceManager.cs index f899a803f7c..87509df5922 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceManager.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceManager.cs @@ -29,15 +29,15 @@ public RequestTrackDevice(string groupId, string deviceId) public sealed class DeviceRegistered { - public static DeviceRegistered Instance { get; } = new DeviceRegistered(); + public static DeviceRegistered Instance { get; } = new(); private DeviceRegistered() { } } #endregion public class DeviceManager : UntypedActor { - private Dictionary groupIdToActor = new Dictionary(); - private Dictionary actorToGroupId = new Dictionary(); + private Dictionary groupIdToActor = new(); + private Dictionary actorToGroupId = new(); protected override void PreStart() => Log.Info("DeviceManager started"); protected override void PostStop() => Log.Info("DeviceManager stopped"); diff --git a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroup.cs b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroup.cs index 879c2fea394..0484e13a940 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroup.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroup.cs @@ -75,27 +75,27 @@ public Temperature(double value) public sealed class TemperatureNotAvailable : ITemperatureReading { - public static TemperatureNotAvailable Instance { get; } = new TemperatureNotAvailable(); + public static TemperatureNotAvailable Instance { get; } = new(); private TemperatureNotAvailable() { } } public sealed class DeviceNotAvailable : ITemperatureReading { - public static DeviceNotAvailable Instance { get; } = new DeviceNotAvailable(); + public static DeviceNotAvailable Instance { get; } = new(); private DeviceNotAvailable() { } } public sealed class DeviceTimedOut : ITemperatureReading { - public static DeviceTimedOut Instance { get; } = new DeviceTimedOut(); + public static DeviceTimedOut Instance { get; } = new(); private DeviceTimedOut() { } } #endregion public class DeviceGroup : UntypedActor { - private Dictionary deviceIdToActor = new Dictionary(); - private Dictionary actorToDeviceId = new Dictionary(); + private Dictionary deviceIdToActor = new(); + private Dictionary actorToDeviceId = new(); private long nextCollectionId = 0L; public DeviceGroup(string groupId) diff --git a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQuery.cs b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQuery.cs index 1a25d6b83ac..b606ead1f60 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQuery.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQuery.cs @@ -17,7 +17,7 @@ public static partial class MainDeviceGroup #region query-full public sealed class CollectionTimeout { - public static CollectionTimeout Instance { get; } = new CollectionTimeout(); + public static CollectionTimeout Instance { get; } = new(); private CollectionTimeout() { } } diff --git a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQueryInProgress.cs b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQueryInProgress.cs index 58e0a7cabef..127c8a7afea 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQueryInProgress.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupQueryInProgress.cs @@ -21,7 +21,7 @@ public static class DeviceGroupQueryInProgress #region query-outline public sealed class CollectionTimeout { - public static CollectionTimeout Instance { get; } = new CollectionTimeout(); + public static CollectionTimeout Instance { get; } = new(); private CollectionTimeout() { } } @@ -75,8 +75,8 @@ public static class DeviceGroupInProgress2 #region query-added public class DeviceGroup : UntypedActor { - private Dictionary deviceIdToActor = new Dictionary(); - private Dictionary actorToDeviceId = new Dictionary(); + private Dictionary deviceIdToActor = new(); + private Dictionary actorToDeviceId = new(); private long nextCollectionId = 0L; public DeviceGroup(string groupId) diff --git a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceManager.cs b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceManager.cs index 84e738f6769..229ef8f477d 100644 --- a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceManager.cs +++ b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceManager.cs @@ -27,14 +27,14 @@ public RequestTrackDevice(string groupId, string deviceId) public sealed class DeviceRegistered { - public static DeviceRegistered Instance { get; } = new DeviceRegistered(); + public static DeviceRegistered Instance { get; } = new(); private DeviceRegistered() { } } public class DeviceManager : UntypedActor { - private Dictionary groupIdToActor = new Dictionary(); - private Dictionary actorToGroupId = new Dictionary(); + private Dictionary groupIdToActor = new(); + private Dictionary actorToGroupId = new(); protected override void PreStart() => Log.Info("DeviceManager started"); protected override void PostStop() => Log.Info("DeviceManager stopped"); diff --git a/src/core/Akka.Persistence.Query.Tests/Utils/TimeUuid.cs b/src/core/Akka.Persistence.Query.Tests/Utils/TimeUuid.cs index 3f46403b0b4..376feb746eb 100644 --- a/src/core/Akka.Persistence.Query.Tests/Utils/TimeUuid.cs +++ b/src/core/Akka.Persistence.Query.Tests/Utils/TimeUuid.cs @@ -30,10 +30,10 @@ namespace Akka.Persistence.Query /// internal struct TimeUuid : IEquatable, IComparable { - private static readonly DateTimeOffset GregorianCalendarTime = new DateTimeOffset(1582, 10, 15, 0, 0, 0, TimeSpan.Zero); + private static readonly DateTimeOffset GregorianCalendarTime = new(1582, 10, 15, 0, 0, 0, TimeSpan.Zero); //Reuse the random generator to avoid collisions - private static readonly Random RandomGenerator = new Random(); - private static readonly object RandomLock = new object(); + private static readonly Random RandomGenerator = new(); + private static readonly object RandomLock = new(); private static readonly byte[] MinNodeId = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; private static readonly byte[] MinClockId = { 0x80, 0x80 }; private static readonly byte[] MaxNodeId = { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f }; diff --git a/src/core/Akka.Persistence.Query/Offset.cs b/src/core/Akka.Persistence.Query/Offset.cs index 8151f3b81cc..9f2a1301308 100644 --- a/src/core/Akka.Persistence.Query/Offset.cs +++ b/src/core/Akka.Persistence.Query/Offset.cs @@ -133,7 +133,7 @@ public sealed class NoOffset : Offset /// /// The singleton instance of . /// - public static NoOffset Instance { get; } = new NoOffset(); + public static NoOffset Instance { get; } = new(); private NoOffset() { } public override int CompareTo(Offset other) diff --git a/src/core/Akka.Persistence.Query/PersistenceQuery.cs b/src/core/Akka.Persistence.Query/PersistenceQuery.cs index d0e5bc1ab39..b1010fde77a 100644 --- a/src/core/Akka.Persistence.Query/PersistenceQuery.cs +++ b/src/core/Akka.Persistence.Query/PersistenceQuery.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Query public sealed class PersistenceQuery : IExtension { private readonly ExtendedActorSystem _system; - private readonly ConcurrentDictionary _readJournalPluginExtensionIds = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _readJournalPluginExtensionIds = new(); private ILoggingAdapter _log; public static PersistenceQuery Get(ActorSystem system) diff --git a/src/core/Akka.Persistence.TCK/Performance/JournalPerfSpec.cs b/src/core/Akka.Persistence.TCK/Performance/JournalPerfSpec.cs index 42572f26387..19e63d3c87e 100644 --- a/src/core/Akka.Persistence.TCK/Performance/JournalPerfSpec.cs +++ b/src/core/Akka.Persistence.TCK/Performance/JournalPerfSpec.cs @@ -342,7 +342,7 @@ public void PersistenceActor_performance_must_measure_RecoveringFour() internal class ResetCounter { - public static ResetCounter Instance { get; } = new ResetCounter(); + public static ResetCounter Instance { get; } = new(); private ResetCounter() { } } @@ -363,7 +363,7 @@ internal class BenchActor : UntypedPersistentActor { private int _counter = 0; private const int BatchSize = 50; - private List _batch = new List(BatchSize); + private List _batch = new(BatchSize); public BenchActor(string persistenceId, IActorRef replyTo, int replyAfter, bool isGroup = false) { diff --git a/src/core/Akka.Persistence.TCK/PluginSpec.cs b/src/core/Akka.Persistence.TCK/PluginSpec.cs index 2cd0a196f0d..341429ffec0 100644 --- a/src/core/Akka.Persistence.TCK/PluginSpec.cs +++ b/src/core/Akka.Persistence.TCK/PluginSpec.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.TCK { public abstract class PluginSpec : Akka.TestKit.Xunit2.TestKit, IDisposable { - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); protected int ActorInstanceId = 1; diff --git a/src/core/Akka.Persistence.TCK/Serialization/JournalSerializationSpec.cs b/src/core/Akka.Persistence.TCK/Serialization/JournalSerializationSpec.cs index fa574a45ec0..9aa0365a95d 100644 --- a/src/core/Akka.Persistence.TCK/Serialization/JournalSerializationSpec.cs +++ b/src/core/Akka.Persistence.TCK/Serialization/JournalSerializationSpec.cs @@ -49,7 +49,7 @@ public virtual void Journal_should_serialize_Persistent() var messages = new List { - new AtomicWrite(persistentEvent) + new(persistentEvent) }; Journal.Tell(new WriteMessages(messages, probe.Ref, ActorInstanceId)); @@ -71,7 +71,7 @@ public virtual void Journal_should_serialize_Persistent_with_string_manifest() var messages = new List { - new AtomicWrite(persistentEvent) + new(persistentEvent) }; Journal.Tell(new WriteMessages(messages, probe.Ref, ActorInstanceId)); @@ -93,7 +93,7 @@ public virtual void Journal_should_serialize_Persistent_with_EventAdapter_manife var messages = new List { - new AtomicWrite(persistentEvent) + new(persistentEvent) }; Journal.Tell(new WriteMessages(messages, probe.Ref, ActorInstanceId)); @@ -117,7 +117,7 @@ public virtual void Journal_should_serialize_StateChangeEvent() var messages = new List { - new AtomicWrite(new Persistent(stateChangeEvent, 1, Pid)) + new(new Persistent(stateChangeEvent, 1, Pid)) }; Journal.Tell(new WriteMessages(messages, probe.Ref, ActorInstanceId)); diff --git a/src/core/Akka.Persistence.TCK/Serialization/SnapshotStoreSerializationSpec.cs b/src/core/Akka.Persistence.TCK/Serialization/SnapshotStoreSerializationSpec.cs index 0b14677fd28..7aaee62bcee 100644 --- a/src/core/Akka.Persistence.TCK/Serialization/SnapshotStoreSerializationSpec.cs +++ b/src/core/Akka.Persistence.TCK/Serialization/SnapshotStoreSerializationSpec.cs @@ -76,9 +76,9 @@ public virtual void SnapshotStore_should_serialize_AtLeastOnceDeliverySnapshot() var unconfirmed = new UnconfirmedDelivery[] { - new UnconfirmedDelivery(1, TestActor.Path, "a"), - new UnconfirmedDelivery(2, TestActor.Path, "b"), - new UnconfirmedDelivery(3, TestActor.Path, 42) + new(1, TestActor.Path, "a"), + new(2, TestActor.Path, "b"), + new(3, TestActor.Path, 42) }; var atLeastOnceDeliverySnapshot = new AtLeastOnceDeliverySnapshot(17, unconfirmed); diff --git a/src/core/Akka.Persistence.TestKit/Journal/TestJournal.cs b/src/core/Akka.Persistence.TestKit/Journal/TestJournal.cs index 445dbc192be..56aa3f6b528 100644 --- a/src/core/Akka.Persistence.TestKit/Journal/TestJournal.cs +++ b/src/core/Akka.Persistence.TestKit/Journal/TestJournal.cs @@ -130,7 +130,7 @@ public UseRecoveryInterceptor(IJournalInterceptor interceptor) public sealed class Ack { - public static readonly Ack Instance = new Ack(); + public static readonly Ack Instance = new(); } internal class TestJournalWrapper : ITestJournal @@ -142,9 +142,9 @@ public TestJournalWrapper(IActorRef actor) private readonly IActorRef _actor; - public JournalWriteBehavior OnWrite => new JournalWriteBehavior(new JournalWriteBehaviorSetter(_actor)); + public JournalWriteBehavior OnWrite => new(new JournalWriteBehaviorSetter(_actor)); - public JournalRecoveryBehavior OnRecovery => new JournalRecoveryBehavior(new JournalRecoveryBehaviorSetter(_actor)); + public JournalRecoveryBehavior OnRecovery => new(new JournalRecoveryBehaviorSetter(_actor)); } } } diff --git a/src/core/Akka.Persistence.TestKit/SnapshotStore/TestSnapshotStore.cs b/src/core/Akka.Persistence.TestKit/SnapshotStore/TestSnapshotStore.cs index cf1440a2b49..838f06ce40e 100644 --- a/src/core/Akka.Persistence.TestKit/SnapshotStore/TestSnapshotStore.cs +++ b/src/core/Akka.Persistence.TestKit/SnapshotStore/TestSnapshotStore.cs @@ -69,8 +69,7 @@ protected override async Task DeleteAsync(string persistenceId, SnapshotSelectio } static SnapshotSelectionCriteria ToSelectionCriteria(SnapshotMetadata metadata) - => new SnapshotSelectionCriteria(metadata.SequenceNr, metadata.Timestamp, metadata.SequenceNr, - metadata.Timestamp); + => new(metadata.SequenceNr, metadata.Timestamp, metadata.SequenceNr, metadata.Timestamp); /// /// Create proxy object from snapshot store actor reference which can alter behavior of snapshot store. @@ -117,7 +116,7 @@ public UseDeleteInterceptor(ISnapshotStoreInterceptor interceptor) public sealed class Ack { - public static readonly Ack Instance = new Ack(); + public static readonly Ack Instance = new(); } internal class TestSnapshotStoreWrapper : ITestSnapshotStore @@ -129,9 +128,9 @@ public TestSnapshotStoreWrapper(IActorRef actor) private readonly IActorRef _actor; - public SnapshotStoreSaveBehavior OnSave => new SnapshotStoreSaveBehavior(new SnapshotStoreSaveBehaviorSetter(_actor)); - public SnapshotStoreLoadBehavior OnLoad => new SnapshotStoreLoadBehavior(new SnapshotStoreLoadBehaviorSetter(_actor)); - public SnapshotStoreDeleteBehavior OnDelete => new SnapshotStoreDeleteBehavior(new SnapshotStoreDeleteBehaviorSetter(_actor)); + public SnapshotStoreSaveBehavior OnSave => new(new SnapshotStoreSaveBehaviorSetter(_actor)); + public SnapshotStoreLoadBehavior OnLoad => new(new SnapshotStoreLoadBehaviorSetter(_actor)); + public SnapshotStoreDeleteBehavior OnDelete => new(new SnapshotStoreDeleteBehaviorSetter(_actor)); } } } diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs index 684282aca7f..b5bd9bea650 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs @@ -47,13 +47,13 @@ protected override SupervisorStrategy SupervisorStrategy() internal class Message { - public static readonly Message Instance = new Message(); + public static readonly Message Instance = new(); private Message() { } } internal class CrashMessage { - public static readonly CrashMessage Instance = new CrashMessage(); + public static readonly CrashMessage Instance = new(); private CrashMessage() { } } diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs index dce7c471cfe..9a0d43b59bb 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs @@ -19,7 +19,7 @@ namespace Akka.Persistence.Tests { static class ChaosSupportExtensions { - private static readonly Random random = new Random(); + private static readonly Random random = new(); internal static void Add(this AtLeastOnceDeliveryFailureSpec.IChaosSupport chaos, int i) { @@ -42,7 +42,7 @@ public class AtLeastOnceDeliveryFailureSpec : AkkaSpec internal sealed class Start { - public static readonly Start Instance = new Start(); + public static readonly Start Instance = new(); private Start() { } } diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryReceiveActorSpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryReceiveActorSpec.cs index fee280bb2c6..b42b3bbbc63 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryReceiveActorSpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryReceiveActorSpec.cs @@ -87,7 +87,7 @@ public bool Equals(ActionAck other) [Serializable] private sealed class Boom { - public static readonly Boom Instance = new Boom(); + public static readonly Boom Instance = new(); } private class Destination : ReceiveActor @@ -117,7 +117,7 @@ private interface IEvt [Serializable] private sealed class InvalidReq { - public static readonly InvalidReq Instance = new InvalidReq(); + public static readonly InvalidReq Instance = new(); private InvalidReq() { @@ -261,7 +261,7 @@ public Req(string payload) [Serializable] private sealed class ReqAck { - public static readonly ReqAck Instance = new ReqAck(); + public static readonly ReqAck Instance = new(); private ReqAck() { @@ -292,7 +292,7 @@ public bool Equals(ReqDone other) [Serializable] private sealed class SaveSnap { - public static readonly SaveSnap Instance = new SaveSnap(); + public static readonly SaveSnap Instance = new(); } [Serializable] diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliverySpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliverySpec.cs index 03d2208eabd..af78af772d1 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliverySpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliverySpec.cs @@ -218,7 +218,7 @@ public ReqSelection(string message) [Serializable] sealed class ReqAck { - public static readonly ReqAck Instance = new ReqAck(); + public static readonly ReqAck Instance = new(); private ReqAck() { } public override bool Equals(object obj) { @@ -229,7 +229,7 @@ public override bool Equals(object obj) [Serializable] sealed class InvalidReq { - public static readonly InvalidReq Instance = new InvalidReq(); + public static readonly InvalidReq Instance = new(); private InvalidReq() { } public override bool Equals(object obj) { @@ -332,10 +332,10 @@ public bool Equals(ActionAck other) } [Serializable] - sealed class Boom { public static readonly Boom Instance = new Boom(); } + sealed class Boom { public static readonly Boom Instance = new(); } [Serializable] - sealed class SaveSnap { public static readonly SaveSnap Instance = new SaveSnap(); } + sealed class SaveSnap { public static readonly SaveSnap Instance = new(); } [Serializable] sealed class Snap diff --git a/src/core/Akka.Persistence.Tests/Delivery/EventSourcedProducerQueueSpec.cs b/src/core/Akka.Persistence.Tests/Delivery/EventSourcedProducerQueueSpec.cs index e835e8628ce..f91d57801b2 100644 --- a/src/core/Akka.Persistence.Tests/Delivery/EventSourcedProducerQueueSpec.cs +++ b/src/core/Akka.Persistence.Tests/Delivery/EventSourcedProducerQueueSpec.cs @@ -40,7 +40,7 @@ public EventSourcedProducerQueueSpec(ITestOutputHelper output) : base(Config, ou StateProbe = CreateTestProbe(); } - private static readonly AtomicCounter _pidCounter = new AtomicCounter(0); + private static readonly AtomicCounter _pidCounter = new(0); private string NextPersistenceId() => $"p-{_pidCounter.IncrementAndGet()}"; public TestProbe JournalOperationsProbe { get; private set; } public TestProbe StateProbe { get; private set; } diff --git a/src/core/Akka.Persistence.Tests/Fsm/PersistentFSMSpec.cs b/src/core/Akka.Persistence.Tests/Fsm/PersistentFSMSpec.cs index 0cdd40b976c..7f8130e8c50 100644 --- a/src/core/Akka.Persistence.Tests/Fsm/PersistentFSMSpec.cs +++ b/src/core/Akka.Persistence.Tests/Fsm/PersistentFSMSpec.cs @@ -604,7 +604,7 @@ public interface ITimeoutState: PersistentFSM.IFsmState public class Init : ITimeoutState { - public static Init Instance { get; } = new Init(); + public static Init Instance { get; } = new(); private Init() { } public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is Init; @@ -615,7 +615,7 @@ private Init() { } public class OverrideTimeoutToInf { - public static readonly OverrideTimeoutToInf Instance = new OverrideTimeoutToInf(); + public static readonly OverrideTimeoutToInf Instance = new(); private OverrideTimeoutToInf() { } } @@ -728,7 +728,7 @@ public interface IUserState : PersistentFSM.IFsmState { } public class Shopping : IUserState { - public static Shopping Instance { get; } = new Shopping(); + public static Shopping Instance { get; } = new(); private Shopping() { } public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is Shopping; @@ -740,7 +740,7 @@ private Shopping() { } public class Inactive : IUserState { - public static Inactive Instance { get; } = new Inactive(); + public static Inactive Instance { get; } = new(); private Inactive() { } public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is Inactive; @@ -752,7 +752,7 @@ private Inactive() { } public class Paid : IUserState { - public static Paid Instance { get; } = new Paid(); + public static Paid Instance { get; } = new(); private Paid() { } public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is Paid; @@ -764,7 +764,7 @@ private Paid() { } public class LookingAround : IUserState { - public static LookingAround Instance { get; } = new LookingAround(); + public static LookingAround Instance { get; } = new(); private LookingAround() { } public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is LookingAround; @@ -946,14 +946,14 @@ public interface ISnapshotFSMState : PersistentFSM.IFsmState { } public class PersistSingleAtOnce : ISnapshotFSMState { - public static PersistSingleAtOnce Instance { get; } = new PersistSingleAtOnce(); + public static PersistSingleAtOnce Instance { get; } = new(); private PersistSingleAtOnce() { } public string Identifier => "PersistSingleAtOnce"; } public class Persist4xAtOnce : ISnapshotFSMState { - public static Persist4xAtOnce Instance { get; } = new Persist4xAtOnce(); + public static Persist4xAtOnce Instance { get; } = new(); private Persist4xAtOnce() { } public string Identifier => "Persist4xAtOnce"; } @@ -1074,7 +1074,7 @@ public interface IState : PersistentFSM.IFsmState public class Init : IState { - public static readonly Init Instance = new Init(); + public static readonly Init Instance = new(); public string Identifier => "Init"; } diff --git a/src/core/Akka.Persistence.Tests/Journal/ChaosJournal.cs b/src/core/Akka.Persistence.Tests/Journal/ChaosJournal.cs index 348638483fc..05a9b8da728 100644 --- a/src/core/Akka.Persistence.Tests/Journal/ChaosJournal.cs +++ b/src/core/Akka.Persistence.Tests/Journal/ChaosJournal.cs @@ -38,9 +38,9 @@ public ReadHighestFailedException() : base("recovery failed when reading the hig public class ChaosJournal : AsyncWriteJournal, IMemoryMessages { - private readonly ConcurrentDictionary> _messages = new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _messages = new(); - private readonly Random _random = new Random(); + private readonly Random _random = new(); private readonly double _writeFailureRate; private readonly double _deleteFailureRate; diff --git a/src/core/Akka.Persistence.Tests/Journal/ReplayFilterSpec.cs b/src/core/Akka.Persistence.Tests/Journal/ReplayFilterSpec.cs index 2373c44f30e..83cc9a53992 100644 --- a/src/core/Akka.Persistence.Tests/Journal/ReplayFilterSpec.cs +++ b/src/core/Akka.Persistence.Tests/Journal/ReplayFilterSpec.cs @@ -19,25 +19,19 @@ public class ReplayFilterSpec : AkkaSpec private const string WriterB = "writer-B"; private const string WriterC = "writer-C"; - private readonly ReplayedMessage _n1 = - new ReplayedMessage(new Persistent("a", 13, "p1", "", writerGuid: Persistent.Undefined)); + private readonly ReplayedMessage _n1 = new(new Persistent("a", 13, "p1", "", writerGuid: Persistent.Undefined)); - private readonly ReplayedMessage _n2 = - new ReplayedMessage(new Persistent("b", 14, "p1", "", writerGuid: Persistent.Undefined)); + private readonly ReplayedMessage _n2 = new(new Persistent("b", 14, "p1", "", writerGuid: Persistent.Undefined)); - private readonly ReplayedMessage _m1 = - new ReplayedMessage(new Persistent("a", 13, "p1", "", writerGuid: WriterA)); + private readonly ReplayedMessage _m1 = new(new Persistent("a", 13, "p1", "", writerGuid: WriterA)); - private readonly ReplayedMessage _m2 = - new ReplayedMessage(new Persistent("b", 14, "p1", "", writerGuid: WriterA)); + private readonly ReplayedMessage _m2 = new(new Persistent("b", 14, "p1", "", writerGuid: WriterA)); - private readonly ReplayedMessage _m3 = - new ReplayedMessage(new Persistent("c", 15, "p1", "", writerGuid: WriterA)); + private readonly ReplayedMessage _m3 = new(new Persistent("c", 15, "p1", "", writerGuid: WriterA)); - private readonly ReplayedMessage _m4 = - new ReplayedMessage(new Persistent("d", 16, "p1", "", writerGuid: WriterA)); + private readonly ReplayedMessage _m4 = new(new Persistent("d", 16, "p1", "", writerGuid: WriterA)); - private readonly RecoverySuccess _successMsg = new RecoverySuccess(15); + private readonly RecoverySuccess _successMsg = new(15); private static IPersistentRepresentation WithWriter(IPersistentRepresentation p, string writer) { diff --git a/src/core/Akka.Persistence.Tests/Journal/SteppingMemoryJournal.cs b/src/core/Akka.Persistence.Tests/Journal/SteppingMemoryJournal.cs index af5467af439..f6c861e0538 100644 --- a/src/core/Akka.Persistence.Tests/Journal/SteppingMemoryJournal.cs +++ b/src/core/Akka.Persistence.Tests/Journal/SteppingMemoryJournal.cs @@ -33,22 +33,22 @@ public sealed class SteppingMemoryJournal : MemoryJournal /// internal class Token { - public static readonly Token Instance = new Token(); + public static readonly Token Instance = new(); private Token() { } } internal class TokenConsumed { - public static readonly TokenConsumed Instance = new TokenConsumed(); + public static readonly TokenConsumed Instance = new(); private TokenConsumed() { } } private static readonly TaskContinuationOptions _continuationOptions = TaskContinuationOptions.ExecuteSynchronously; // keep it in a thread safe global so that tests can get their hand on the actor ref and send Steps to it - private static readonly ConcurrentDictionary _current = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary _current = new(); private readonly string _instanceId; - private readonly Queue> _queuedOps = new Queue>(); - private readonly Queue _queuedTokenRecipients = new Queue(); + private readonly Queue> _queuedOps = new(); + private readonly Queue _queuedTokenRecipients = new(); public SteppingMemoryJournal() diff --git a/src/core/Akka.Persistence.Tests/LoadPluginSpec.cs b/src/core/Akka.Persistence.Tests/LoadPluginSpec.cs index 0c8b6392a76..e114701fcbd 100644 --- a/src/core/Akka.Persistence.Tests/LoadPluginSpec.cs +++ b/src/core/Akka.Persistence.Tests/LoadPluginSpec.cs @@ -17,7 +17,7 @@ public class LoadPluginSpec : PersistenceSpec { public sealed class GetConfig { - public static readonly GetConfig Instance = new GetConfig(); + public static readonly GetConfig Instance = new(); private GetConfig() { } } diff --git a/src/core/Akka.Persistence.Tests/MemoryEventAdapterSpec.cs b/src/core/Akka.Persistence.Tests/MemoryEventAdapterSpec.cs index de2c901ecc3..5ed94476268 100644 --- a/src/core/Akka.Persistence.Tests/MemoryEventAdapterSpec.cs +++ b/src/core/Akka.Persistence.Tests/MemoryEventAdapterSpec.cs @@ -180,7 +180,7 @@ public IEventSequence FromJournal(object evt, string manifest) public class PersistAllIncomingActor : NamedPersistentActor { - public readonly LinkedList State = new LinkedList(); + public readonly LinkedList State = new(); public PersistAllIncomingActor(string name, string journalPluginId) : base(name) { diff --git a/src/core/Akka.Persistence.Tests/OptimizedRecoverySpec.cs b/src/core/Akka.Persistence.Tests/OptimizedRecoverySpec.cs index f70846a938e..0cff6093a38 100644 --- a/src/core/Akka.Persistence.Tests/OptimizedRecoverySpec.cs +++ b/src/core/Akka.Persistence.Tests/OptimizedRecoverySpec.cs @@ -48,7 +48,7 @@ public bool Equals(Saved other) internal sealed class PersistFromRecoveryCompleted { - public static PersistFromRecoveryCompleted Instance { get; } = new PersistFromRecoveryCompleted(); + public static PersistFromRecoveryCompleted Instance { get; } = new(); private PersistFromRecoveryCompleted() { } } diff --git a/src/core/Akka.Persistence.Tests/OptionalSnapshotStoreSpec.cs b/src/core/Akka.Persistence.Tests/OptionalSnapshotStoreSpec.cs index 14cc01d7814..70bc72a921c 100644 --- a/src/core/Akka.Persistence.Tests/OptionalSnapshotStoreSpec.cs +++ b/src/core/Akka.Persistence.Tests/OptionalSnapshotStoreSpec.cs @@ -17,7 +17,7 @@ public class OptionalSnapshotStoreSpec : PersistenceSpec { public sealed class GetConfig { - public static readonly GetConfig Instance = new GetConfig(); + public static readonly GetConfig Instance = new(); private GetConfig() { } } diff --git a/src/core/Akka.Persistence.Tests/PersistenceConfigAutoStartSpec.cs b/src/core/Akka.Persistence.Tests/PersistenceConfigAutoStartSpec.cs index 61787685de0..91f49dcd05e 100644 --- a/src/core/Akka.Persistence.Tests/PersistenceConfigAutoStartSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistenceConfigAutoStartSpec.cs @@ -21,7 +21,7 @@ public class PersistenceConfigAutoStartSpec : AkkaSpec private sealed class TestRequest { - public static readonly TestRequest Instance = new TestRequest(); + public static readonly TestRequest Instance = new(); private TestRequest() { diff --git a/src/core/Akka.Persistence.Tests/PersistenceConfigSpec.cs b/src/core/Akka.Persistence.Tests/PersistenceConfigSpec.cs index be00057d0bf..945845a92cb 100644 --- a/src/core/Akka.Persistence.Tests/PersistenceConfigSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistenceConfigSpec.cs @@ -21,7 +21,7 @@ public class PersistenceConfigSpec : AkkaSpec private sealed class TestRequest { - public static readonly TestRequest Instance = new TestRequest(); + public static readonly TestRequest Instance = new(); private TestRequest() { diff --git a/src/core/Akka.Persistence.Tests/PersistenceSpec.cs b/src/core/Akka.Persistence.Tests/PersistenceSpec.cs index 1daa6bff605..bdd3c831966 100644 --- a/src/core/Akka.Persistence.Tests/PersistenceSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistenceSpec.cs @@ -37,7 +37,7 @@ public static Config Configuration(string test, string serialization = null, internal readonly Cleanup Clean; - private readonly AtomicCounter _counter = new AtomicCounter(0); + private readonly AtomicCounter _counter = new(0); private readonly string _name; @@ -93,7 +93,7 @@ protected void ExpectAnyMsgInOrder(params IEnumerable[] expected) internal class Cleanup : IDisposable { internal List StorageLocations; - private static readonly object _syncRoot = new object(); + private static readonly object _syncRoot = new(); public Cleanup(AkkaSpec spec) { @@ -146,7 +146,7 @@ public override string PersistenceId internal sealed class GetState { - public static readonly GetState Instance = new GetState(); + public static readonly GetState Instance = new(); private GetState() { } } diff --git a/src/core/Akka.Persistence.Tests/PersistentActorJournalProtocolSpec.cs b/src/core/Akka.Persistence.Tests/PersistentActorJournalProtocolSpec.cs index 613f85ba9e6..c9eb0db5a06 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorJournalProtocolSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorJournalProtocolSpec.cs @@ -274,7 +274,7 @@ private void PA(PersistAsync p) public class JournalProbeExtension : ExtensionIdProvider { - public static readonly JournalProbeExtension Instance = new JournalProbeExtension(); + public static readonly JournalProbeExtension Instance = new(); private JournalProbeExtension() { diff --git a/src/core/Akka.Persistence.Tests/PersistentActorRecoveryTimeoutSpec.cs b/src/core/Akka.Persistence.Tests/PersistentActorRecoveryTimeoutSpec.cs index 82f4ab0aeb4..3d06152ce94 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorRecoveryTimeoutSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorRecoveryTimeoutSpec.cs @@ -19,7 +19,7 @@ namespace Akka.Persistence.Tests [Collection("PersistentActorRecoveryTimeout")] // force tests to run sequentially public class PersistentActorRecoveryTimeoutSpec : PersistenceSpec { - private static readonly AtomicCounter JournalIdNumber = new AtomicCounter(0); + private static readonly AtomicCounter JournalIdNumber = new(0); private static readonly string JournalId = "persistent-actor-recovery-timeout-spec" + JournalIdNumber.GetAndIncrement(); private readonly IActorRef _journal; diff --git a/src/core/Akka.Persistence.Tests/PersistentActorSpec.Actors.cs b/src/core/Akka.Persistence.Tests/PersistentActorSpec.Actors.cs index 5ed6544122e..f71b8ded9d4 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorSpec.Actors.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorSpec.Actors.cs @@ -498,7 +498,7 @@ protected override bool ReceiveCommand(object message) internal class AsyncPersistSameEventTwiceActor : ExamplePersistentActor { - private AtomicCounter _sendMessageCounter = new AtomicCounter(0); + private AtomicCounter _sendMessageCounter = new(0); public AsyncPersistSameEventTwiceActor(string name) : base(name) { @@ -1025,7 +1025,7 @@ internal class DeeplyNestedPersists : ExamplePersistentActor { private readonly int _maxDepth; private readonly IActorRef _probe; - private readonly Dictionary _currentDepths = new Dictionary(); + private readonly Dictionary _currentDepths = new(); public DeeplyNestedPersists(string name, int maxDepth, IActorRef probe) : base(name) @@ -1068,7 +1068,7 @@ internal class DeeplyNestedPersistAsyncs : ExamplePersistentActor { private readonly int _maxDepth; private readonly IActorRef _probe; - private readonly Dictionary _currentDepths = new Dictionary(); + private readonly Dictionary _currentDepths = new(); public DeeplyNestedPersistAsyncs(string name, int maxDepth, IActorRef probe) : base(name) diff --git a/src/core/Akka.Persistence.Tests/PersistentActorSpec.cs b/src/core/Akka.Persistence.Tests/PersistentActorSpec.cs index af3d1eacc33..aadf3284827 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorSpec.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorSpec.cs @@ -18,7 +18,7 @@ namespace Akka.Persistence.Tests { public partial class PersistentActorSpec : PersistenceSpec { - private readonly Random _random = new Random(); + private readonly Random _random = new(); public PersistentActorSpec() : base(Configuration("PersistentActorSpec")) { diff --git a/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.Actors.cs b/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.Actors.cs index 6673c47522d..47bd4ce156d 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.Actors.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.Actors.cs @@ -579,7 +579,7 @@ protected override bool ReceiveCommand(object message) internal class AsyncPersistSameEventTwiceActor : ExamplePersistentActor { - private AtomicCounter _sendMessageCounter = new AtomicCounter(0); + private AtomicCounter _sendMessageCounter = new(0); public AsyncPersistSameEventTwiceActor(string name) : base(name) { @@ -1202,7 +1202,7 @@ internal class DeeplyNestedPersists : ExamplePersistentActor { private readonly int _maxDepth; private readonly IActorRef _probe; - private readonly Dictionary _currentDepths = new Dictionary(); + private readonly Dictionary _currentDepths = new(); public DeeplyNestedPersists(string name, int maxDepth, IActorRef probe) : base(name) @@ -1250,7 +1250,7 @@ internal class DeeplyNestedPersistAsyncs : ExamplePersistentActor { private readonly int _maxDepth; private readonly IActorRef _probe; - private readonly Dictionary _currentDepths = new Dictionary(); + private readonly Dictionary _currentDepths = new(); public DeeplyNestedPersistAsyncs(string name, int maxDepth, IActorRef probe) : base(name) diff --git a/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.cs b/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.cs index bbf61ddc521..fb4cd05e263 100644 --- a/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.cs +++ b/src/core/Akka.Persistence.Tests/PersistentActorSpecAsyncAwait.cs @@ -17,7 +17,7 @@ namespace Akka.Persistence.Tests { public partial class PersistentActorSpecAsyncAwait : PersistenceSpec { - private readonly Random _random = new Random(); + private readonly Random _random = new(); public PersistentActorSpecAsyncAwait() : base(Configuration("PersistentActorSpecAsyncAwait")) { diff --git a/src/core/Akka.Persistence.Tests/ReceivePersistentActorTests.cs b/src/core/Akka.Persistence.Tests/ReceivePersistentActorTests.cs index 14e8326852b..15cc3763aab 100644 --- a/src/core/Akka.Persistence.Tests/ReceivePersistentActorTests.cs +++ b/src/core/Akka.Persistence.Tests/ReceivePersistentActorTests.cs @@ -136,7 +136,7 @@ public void Given_a_persistent_actor_with_ReceiveAnyCommand_When_sending_differe ExpectMsg((object)"any:hello"); } - private readonly AtomicCounterLong _seqNrCounter = new AtomicCounterLong(1L); + private readonly AtomicCounterLong _seqNrCounter = new(1L); /// /// Initialize test journal using provided events. /// @@ -155,7 +155,7 @@ private void WriteEvents(string pid, params object[] events) private abstract class TestReceivePersistentActor : ReceivePersistentActor { - public readonly LinkedList State = new LinkedList(); + public readonly LinkedList State = new(); private readonly string _persistenceId; protected TestReceivePersistentActor(string persistenceId) diff --git a/src/core/Akka.Persistence.Tests/SnapshotDirectoryFailureSpec.cs b/src/core/Akka.Persistence.Tests/SnapshotDirectoryFailureSpec.cs index ec97f2d3c3b..cadb52abbfa 100644 --- a/src/core/Akka.Persistence.Tests/SnapshotDirectoryFailureSpec.cs +++ b/src/core/Akka.Persistence.Tests/SnapshotDirectoryFailureSpec.cs @@ -49,7 +49,7 @@ protected override bool ReceiveCommand(object message) } } - private readonly FileInfo _file = new FileInfo(InUseSnapshotPath); + private readonly FileInfo _file = new(InUseSnapshotPath); public SnapshotDirectoryFailureSpec() : base(Configuration("SnapshotDirectoryFailureSpec", extraConfig: "akka.persistence.snapshot-store.local.dir = \"" + InUseSnapshotPath + "\"")) diff --git a/src/core/Akka.Persistence.Tests/SnapshotRecoveryLocalStoreSpec.cs b/src/core/Akka.Persistence.Tests/SnapshotRecoveryLocalStoreSpec.cs index d7d0451f0f4..f94e5b02fd6 100644 --- a/src/core/Akka.Persistence.Tests/SnapshotRecoveryLocalStoreSpec.cs +++ b/src/core/Akka.Persistence.Tests/SnapshotRecoveryLocalStoreSpec.cs @@ -18,7 +18,7 @@ public class SnapshotRecoveryLocalStoreSpec : PersistenceSpec public sealed class TakeSnapshot { private TakeSnapshot() {} - public static readonly TakeSnapshot Instance = new TakeSnapshot(); + public static readonly TakeSnapshot Instance = new(); } internal class SaveSnapshotTestPersistentActor : NamedPersistentActor @@ -60,7 +60,7 @@ public LoadSnapshotTestPersistentActor(string name, IActorRef probe) : base(name _probe = probe; } - public override Recovery Recovery => new Recovery(SnapshotSelectionCriteria.Latest, 0); + public override Recovery Recovery => new(SnapshotSelectionCriteria.Latest, 0); protected override bool ReceiveRecover(object message) { diff --git a/src/core/Akka.Persistence.Tests/SnapshotSpec.cs b/src/core/Akka.Persistence.Tests/SnapshotSpec.cs index e034af12993..fca49477ca1 100644 --- a/src/core/Akka.Persistence.Tests/SnapshotSpec.cs +++ b/src/core/Akka.Persistence.Tests/SnapshotSpec.cs @@ -23,7 +23,7 @@ public class SnapshotSpec : PersistenceSpec internal class TakeSnapshot { - public static readonly TakeSnapshot Instance = new TakeSnapshot(); + public static readonly TakeSnapshot Instance = new(); private TakeSnapshot() { } diff --git a/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs b/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs index dbdb6abcbb3..9a2580d794b 100644 --- a/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs +++ b/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs @@ -300,7 +300,7 @@ public sealed class RedeliveryTick : INotInfluenceReceiveTimeout, IDeadLetterSup /// /// The singleton instance of the redelivery tick /// - public static RedeliveryTick Instance { get; } = new RedeliveryTick(); + public static RedeliveryTick Instance { get; } = new(); private RedeliveryTick() { } diff --git a/src/core/Akka.Persistence/Delivery/EventSourcedProducerQueue.cs b/src/core/Akka.Persistence/Delivery/EventSourcedProducerQueue.cs index de94aafaab3..ac769c75362 100644 --- a/src/core/Akka.Persistence/Delivery/EventSourcedProducerQueue.cs +++ b/src/core/Akka.Persistence/Delivery/EventSourcedProducerQueue.cs @@ -88,7 +88,7 @@ private Settings(TimeSpan restartMaxBackoff, int snapshotEvery, int keepNSnapsho /// internal sealed class CleanupTick { - public static readonly CleanupTick Instance = new CleanupTick(); + public static readonly CleanupTick Instance = new(); private CleanupTick() { diff --git a/src/core/Akka.Persistence/Eventsourced.cs b/src/core/Akka.Persistence/Eventsourced.cs index 6f8d7b76d5e..a0befa7741b 100644 --- a/src/core/Akka.Persistence/Eventsourced.cs +++ b/src/core/Akka.Persistence/Eventsourced.cs @@ -74,7 +74,7 @@ public RecoveryTick(bool snapshot) /// public abstract partial class Eventsourced : ActorBase, IPersistentIdentity, IPersistenceStash, IPersistenceRecovery { - private static readonly AtomicCounter InstanceCounter = new AtomicCounter(1); + private static readonly AtomicCounter InstanceCounter = new(1); private readonly int _instanceId; private readonly string _writerGuid; diff --git a/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs b/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs index 8892e210dc1..6fba220839d 100644 --- a/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs +++ b/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs @@ -167,7 +167,7 @@ public StateFunction Using(Func, State /// TBD /// TBD - public TransformHelper Transform(StateFunction func) => new TransformHelper(func); + public TransformHelper Transform(StateFunction func) => new(func); /// /// Schedule named timer to deliver message after given delay, possibly repeating. @@ -361,11 +361,11 @@ private string GetSourceString(object source) // Timer handling private readonly IDictionary _timers = new Dictionary(); - private readonly AtomicCounter _timerGen = new AtomicCounter(0); + private readonly AtomicCounter _timerGen = new(0); // State definitions - private readonly Dictionary _stateFunctions = new Dictionary(); - private readonly Dictionary _stateTimeouts = new Dictionary(); + private readonly Dictionary _stateFunctions = new(); + private readonly Dictionary _stateTimeouts = new(); private void Register(TState name, StateFunction function, TimeSpan? timeout) { @@ -419,7 +419,7 @@ private void HandleTransition(TState previous, TState next) /// /// Listener support /// - public ListenerSupport Listeners { get; } = new ListenerSupport(); + public ListenerSupport Listeners { get; } = new(); // ** // Main actor Receive method diff --git a/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs b/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs index 1d20eb81b95..b8ac9166881 100644 --- a/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs +++ b/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs @@ -416,7 +416,7 @@ private Task StoreNotInitialized() public class InitTimeout { private InitTimeout() { } - private static readonly InitTimeout _instance = new InitTimeout(); + private static readonly InitTimeout _instance = new(); /// /// TBD diff --git a/src/core/Akka.Persistence/Journal/EventAdapters.cs b/src/core/Akka.Persistence/Journal/EventAdapters.cs index fccab386d5c..a4d37b77a7b 100644 --- a/src/core/Akka.Persistence/Journal/EventAdapters.cs +++ b/src/core/Akka.Persistence/Journal/EventAdapters.cs @@ -98,7 +98,7 @@ public sealed class IdentityEventAdapter : IEventAdapter /// /// The singleton instance of . /// - public static IdentityEventAdapter Instance { get; } = new IdentityEventAdapter(); + public static IdentityEventAdapter Instance { get; } = new(); private IdentityEventAdapter() { } diff --git a/src/core/Akka.Persistence/Journal/EventSequences.cs b/src/core/Akka.Persistence/Journal/EventSequences.cs index ddcc36836a2..10882a7a6f7 100644 --- a/src/core/Akka.Persistence/Journal/EventSequences.cs +++ b/src/core/Akka.Persistence/Journal/EventSequences.cs @@ -36,7 +36,7 @@ public sealed class EmptyEventSequence : IEmptyEventSequence, IEquatable /// TBD /// - public static readonly EmptyEventSequence Instance = new EmptyEventSequence(); + public static readonly EmptyEventSequence Instance = new(); private EmptyEventSequence() { } diff --git a/src/core/Akka.Persistence/Journal/MemoryJournal.cs b/src/core/Akka.Persistence/Journal/MemoryJournal.cs index 392b18058e3..25a861db3ac 100644 --- a/src/core/Akka.Persistence/Journal/MemoryJournal.cs +++ b/src/core/Akka.Persistence/Journal/MemoryJournal.cs @@ -639,7 +639,7 @@ public long HighestSequenceNr(string pid) /// public class SharedMemoryJournal : MemoryJournal { - private static readonly ConcurrentDictionary> SharedMessages = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> SharedMessages = new(); /// /// TBD diff --git a/src/core/Akka.Persistence/Journal/PersistencePluginProxy.cs b/src/core/Akka.Persistence/Journal/PersistencePluginProxy.cs index 9585f803a41..4b18dc545cc 100644 --- a/src/core/Akka.Persistence/Journal/PersistencePluginProxy.cs +++ b/src/core/Akka.Persistence/Journal/PersistencePluginProxy.cs @@ -42,7 +42,7 @@ public TargetLocation(Address address) private sealed class InitTimeout { - public static readonly InitTimeout Instance = new InitTimeout(); + public static readonly InitTimeout Instance = new(); private InitTimeout() { } } diff --git a/src/core/Akka.Persistence/Journal/ReplayFilter.cs b/src/core/Akka.Persistence/Journal/ReplayFilter.cs index 3d36ef4e97e..e6fda67e051 100644 --- a/src/core/Akka.Persistence/Journal/ReplayFilter.cs +++ b/src/core/Akka.Persistence/Journal/ReplayFilter.cs @@ -42,8 +42,8 @@ public enum ReplayFilterMode /// public class ReplayFilter : ActorBase { - private readonly LinkedList _buffer = new LinkedList(); - private readonly LinkedList _oldWriters = new LinkedList(); + private readonly LinkedList _buffer = new(); + private readonly LinkedList _oldWriters = new(); private string _writerUuid = string.Empty; private long _sequenceNr = -1; private readonly ILoggingAdapter _log = Context.GetLogger(); diff --git a/src/core/Akka.Persistence/JournalProtocol.cs b/src/core/Akka.Persistence/JournalProtocol.cs index 74b4e73360d..756a0192a26 100644 --- a/src/core/Akka.Persistence/JournalProtocol.cs +++ b/src/core/Akka.Persistence/JournalProtocol.cs @@ -253,7 +253,7 @@ public sealed class WriteMessagesSuccessful : IJournalResponse /// /// The singleton instance of . /// - public static WriteMessagesSuccessful Instance { get; } = new WriteMessagesSuccessful(); + public static WriteMessagesSuccessful Instance { get; } = new(); private WriteMessagesSuccessful() { } } diff --git a/src/core/Akka.Persistence/Persistence.cs b/src/core/Akka.Persistence/Persistence.cs index a0c7b3ceb12..204fd982365 100644 --- a/src/core/Akka.Persistence/Persistence.cs +++ b/src/core/Akka.Persistence/Persistence.cs @@ -51,7 +51,7 @@ public class PersistenceExtension : IExtension private readonly Lazy _defaultInternalStashOverflowStrategy; private readonly Lazy _recoveryPermitter; - private readonly ConcurrentDictionary> _pluginExtensionIds = new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _pluginExtensionIds = new(); private const string JournalFallbackConfigPath = "akka.persistence.journal-plugin-fallback"; private const string SnapshotStoreFallbackConfigPath = "akka.persistence.snapshot-store-plugin-fallback"; @@ -313,7 +313,7 @@ public class Persistence : ExtensionIdProvider /// /// TBD /// - public static Persistence Instance { get; } = new Persistence(); + public static Persistence Instance { get; } = new(); /// /// TBD diff --git a/src/core/Akka.Persistence/PersistentActor.cs b/src/core/Akka.Persistence/PersistentActor.cs index 52538102169..2ef88c66864 100644 --- a/src/core/Akka.Persistence/PersistentActor.cs +++ b/src/core/Akka.Persistence/PersistentActor.cs @@ -25,7 +25,7 @@ public sealed class RecoveryCompleted /// /// The singleton instance of . /// - public static readonly RecoveryCompleted Instance = new RecoveryCompleted(); + public static readonly RecoveryCompleted Instance = new(); private RecoveryCompleted(){} public override bool Equals(object obj) => obj is RecoveryCompleted; @@ -51,7 +51,7 @@ public sealed class Recovery /// /// TBD /// - public static Recovery Default { get; } = new Recovery(SnapshotSelectionCriteria.Latest); + public static Recovery Default { get; } = new(SnapshotSelectionCriteria.Latest); /// /// Convenience method for skipping recovery in . @@ -60,7 +60,7 @@ public sealed class Recovery /// higher sequence numbers rather than starting from 1 and assuming that there are no /// previous event with that sequence number. /// - public static Recovery None { get; } = new Recovery(SnapshotSelectionCriteria.None, 0); + public static Recovery None { get; } = new(SnapshotSelectionCriteria.None, 0); /// /// Initializes a new instance of the class. @@ -160,7 +160,7 @@ public class DiscardToDeadLetterStrategy : IStashOverflowStrategy /// /// The singleton instance of . /// - public static DiscardToDeadLetterStrategy Instance { get; } = new DiscardToDeadLetterStrategy(); + public static DiscardToDeadLetterStrategy Instance { get; } = new(); private DiscardToDeadLetterStrategy() { } } @@ -177,7 +177,7 @@ public class ThrowOverflowExceptionStrategy : IStashOverflowStrategy /// /// The singleton instance of . /// - public static ThrowOverflowExceptionStrategy Instance { get; } = new ThrowOverflowExceptionStrategy(); + public static ThrowOverflowExceptionStrategy Instance { get; } = new(); private ThrowOverflowExceptionStrategy() { } } @@ -331,8 +331,8 @@ protected void BecomeStacked(UntypedReceive receive) public abstract class ReceivePersistentActor : UntypedPersistentActor, IInitializableActor { private bool _shouldUnhandle = true; - private readonly Stack _matchCommandBuilders = new Stack(); - private readonly Stack _matchRecoverBuilders = new Stack(); + private readonly Stack _matchCommandBuilders = new(); + private readonly Stack _matchRecoverBuilders = new(); private PartialAction _partialReceiveCommand = _ => false; private PartialAction _partialReceiveRecover = _ => false; private bool _hasBeenInitialized; diff --git a/src/core/Akka.Persistence/RecoveryPermitter.cs b/src/core/Akka.Persistence/RecoveryPermitter.cs index 463b98202ab..cc29f40913c 100644 --- a/src/core/Akka.Persistence/RecoveryPermitter.cs +++ b/src/core/Akka.Persistence/RecoveryPermitter.cs @@ -16,19 +16,19 @@ namespace Akka.Persistence { internal sealed class RequestRecoveryPermit { - public static RequestRecoveryPermit Instance { get; } = new RequestRecoveryPermit(); + public static RequestRecoveryPermit Instance { get; } = new(); private RequestRecoveryPermit() { } } internal sealed class RecoveryPermitGranted { - public static RecoveryPermitGranted Instance { get; } = new RecoveryPermitGranted(); + public static RecoveryPermitGranted Instance { get; } = new(); private RecoveryPermitGranted() { } } internal sealed class ReturnRecoveryPermit { - public static ReturnRecoveryPermit Instance { get; } = new ReturnRecoveryPermit(); + public static ReturnRecoveryPermit Instance { get; } = new(); private ReturnRecoveryPermit() { } } @@ -38,7 +38,7 @@ private ReturnRecoveryPermit() { } /// internal class RecoveryPermitter : UntypedActor { - private readonly LinkedList pending = new LinkedList(); + private readonly LinkedList pending = new(); private readonly ILoggingAdapter Log = Context.GetLogger(); private int _usedPermits; private int _maxPendingStats; diff --git a/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs b/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs index 0b05f36baf7..f4fa5e34a2d 100644 --- a/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs +++ b/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs @@ -27,7 +27,7 @@ namespace Akka.Persistence.Snapshot /// public class LocalSnapshotStore : SnapshotStore { - private static readonly Regex FilenameRegex = new Regex(@"^snapshot-(.+)-(\d+)-(\d+)", RegexOptions.Compiled); + private static readonly Regex FilenameRegex = new(@"^snapshot-(.+)-(\d+)-(\d+)", RegexOptions.Compiled); private readonly int _maxLoadAttempts; private readonly MessageDispatcher _streamDispatcher; diff --git a/src/core/Akka.Persistence/Snapshot/MemorySnapshotStore.cs b/src/core/Akka.Persistence/Snapshot/MemorySnapshotStore.cs index 0304e2dd35a..5a3454f29de 100644 --- a/src/core/Akka.Persistence/Snapshot/MemorySnapshotStore.cs +++ b/src/core/Akka.Persistence/Snapshot/MemorySnapshotStore.cs @@ -23,7 +23,7 @@ public class MemorySnapshotStore : SnapshotStore /// /// This is available to expose/override the snapshots in derived snapshot stores /// - protected virtual List Snapshots { get; } = new List(); + protected virtual List Snapshots { get; } = new(); protected override Task DeleteAsync(SnapshotMetadata metadata) { diff --git a/src/core/Akka.Persistence/SnapshotProtocol.cs b/src/core/Akka.Persistence/SnapshotProtocol.cs index 88ba802d139..df39b38de3c 100644 --- a/src/core/Akka.Persistence/SnapshotProtocol.cs +++ b/src/core/Akka.Persistence/SnapshotProtocol.cs @@ -478,12 +478,12 @@ public sealed class SnapshotSelectionCriteria : IEquatable /// The latest saved snapshot. /// - public static SnapshotSelectionCriteria Latest { get; } = new SnapshotSelectionCriteria(long.MaxValue, DateTime.MaxValue); + public static SnapshotSelectionCriteria Latest { get; } = new(long.MaxValue, DateTime.MaxValue); /// /// No saved snapshot matches. /// - public static SnapshotSelectionCriteria None { get; } = new SnapshotSelectionCriteria(0L, DateTime.MinValue); + public static SnapshotSelectionCriteria None { get; } = new(0L, DateTime.MinValue); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka.Remote.TestKit.Tests/BarrierSpec.cs b/src/core/Akka.Remote.TestKit.Tests/BarrierSpec.cs index 67ea5977a83..8ea7830f1d9 100644 --- a/src/core/Akka.Remote.TestKit.Tests/BarrierSpec.cs +++ b/src/core/Akka.Remote.TestKit.Tests/BarrierSpec.cs @@ -79,9 +79,9 @@ public BarrierSpec() : base(Config) { } - private readonly RoleName A = new RoleName("a"); - private readonly RoleName B = new RoleName("b"); - private readonly RoleName C = new RoleName("c"); + private readonly RoleName A = new("a"); + private readonly RoleName B = new("b"); + private readonly RoleName C = new("c"); [Fact] public void A_BarrierCoordinator_must_register_clients_and_remove_them() diff --git a/src/core/Akka.Remote.TestKit.Tests/ControllerSpec.cs b/src/core/Akka.Remote.TestKit.Tests/ControllerSpec.cs index c983219e1f7..c277df662ea 100644 --- a/src/core/Akka.Remote.TestKit.Tests/ControllerSpec.cs +++ b/src/core/Akka.Remote.TestKit.Tests/ControllerSpec.cs @@ -28,8 +28,8 @@ public ControllerSpec() { } - private readonly RoleName A = new RoleName("a"); - private readonly RoleName B = new RoleName("b"); + private readonly RoleName A = new("a"); + private readonly RoleName B = new("b"); [Fact] public void Controller_must_publish_its_nodes() diff --git a/src/core/Akka.Remote.TestKit/CommandLine.cs b/src/core/Akka.Remote.TestKit/CommandLine.cs index cdf91dc3ba6..fcea06815ea 100644 --- a/src/core/Akka.Remote.TestKit/CommandLine.cs +++ b/src/core/Akka.Remote.TestKit/CommandLine.cs @@ -28,7 +28,7 @@ namespace Akka.Remote.TestKit /// public static class CommandLine { - private static readonly Dictionary Values = new Dictionary(); + private static readonly Dictionary Values = new(); static CommandLine() { diff --git a/src/core/Akka.Remote.TestKit/Conductor.cs b/src/core/Akka.Remote.TestKit/Conductor.cs index a618d4b4ff5..502412dc5dd 100644 --- a/src/core/Akka.Remote.TestKit/Conductor.cs +++ b/src/core/Akka.Remote.TestKit/Conductor.cs @@ -242,7 +242,7 @@ internal class ConductorHandler : ChannelHandlerAdapter { private readonly ILoggingAdapter _log; private readonly IActorRef _controller; - private readonly ConcurrentDictionary _clients = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _clients = new(); /// /// A single gets shared across all of the connections between diff --git a/src/core/Akka.Remote.TestKit/Controller.cs b/src/core/Akka.Remote.TestKit/Controller.cs index 579fa216d7d..31c26ebf2ff 100644 --- a/src/core/Akka.Remote.TestKit/Controller.cs +++ b/src/core/Akka.Remote.TestKit/Controller.cs @@ -111,7 +111,7 @@ protected ClientDisconnectedException(SerializationInfo info, StreamingContext c public class GetNodes { private GetNodes() { } - private static readonly GetNodes _instance = new GetNodes(); + private static readonly GetNodes _instance = new(); public static GetNodes Instance { @@ -125,7 +125,7 @@ public static GetNodes Instance public class GetSockAddr { private GetSockAddr() { } - private static readonly GetSockAddr _instance = new GetSockAddr(); + private static readonly GetSockAddr _instance = new(); public static GetSockAddr Instance { diff --git a/src/core/Akka.Remote.TestKit/DataTypes.cs b/src/core/Akka.Remote.TestKit/DataTypes.cs index 3b5b51bb7c5..c45ca4ec4e1 100644 --- a/src/core/Akka.Remote.TestKit/DataTypes.cs +++ b/src/core/Akka.Remote.TestKit/DataTypes.cs @@ -1029,7 +1029,7 @@ public override int GetHashCode() public class Done : IServerOp, IUnconfirmedClientOp, INetworkOp { private Done() { } - private static readonly Done _instance = new Done(); + private static readonly Done _instance = new(); public static Done Instance { diff --git a/src/core/Akka.Remote.TestKit/Player.cs b/src/core/Akka.Remote.TestKit/Player.cs index f4d96e06c93..1528edc51cd 100644 --- a/src/core/Akka.Remote.TestKit/Player.cs +++ b/src/core/Akka.Remote.TestKit/Player.cs @@ -320,7 +320,7 @@ public ConnectionFailure(string message) : base(message) internal class Disconnected { private Disconnected() { } - private static readonly Disconnected _instance = new Disconnected(); + private static readonly Disconnected _instance = new(); public static Disconnected Instance { diff --git a/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs b/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs index 9c0147b107a..317e37e12b0 100644 --- a/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs +++ b/src/core/Akka.Remote.Tests.MultiNode/RemoteNodeDeathWatchSpec.cs @@ -63,7 +63,7 @@ public UnwatchIt(IActorRef watchee) public sealed class Ack { - public static Ack Instance { get; } = new Ack(); + public static Ack Instance { get; } = new(); private Ack() { diff --git a/src/core/Akka.Remote.Tests.MultiNode/TransportFailSpec.cs b/src/core/Akka.Remote.Tests.MultiNode/TransportFailSpec.cs index 66bdd8a99b7..ee9895bac9c 100644 --- a/src/core/Akka.Remote.Tests.MultiNode/TransportFailSpec.cs +++ b/src/core/Akka.Remote.Tests.MultiNode/TransportFailSpec.cs @@ -42,7 +42,7 @@ public TransportFailSpecConfig() ")); } - internal static AtomicBoolean FdAvailable = new AtomicBoolean(true); + internal static AtomicBoolean FdAvailable = new(true); /// /// Failure detector implementation that will fail when is false. diff --git a/src/core/Akka.Remote.Tests.Performance/InboundMessageDispatcherSpec.cs b/src/core/Akka.Remote.Tests.Performance/InboundMessageDispatcherSpec.cs index 7b67ac45b76..a3374f7a962 100644 --- a/src/core/Akka.Remote.Tests.Performance/InboundMessageDispatcherSpec.cs +++ b/src/core/Akka.Remote.Tests.Performance/InboundMessageDispatcherSpec.cs @@ -25,7 +25,7 @@ public class InboundMessageDispatcherSpec private SerializedMessage _message; private Counter _inboundMessageDispatcherCounter; - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); private ActorSystem _actorSystem; private Address _systemAddress; diff --git a/src/core/Akka.Remote.Tests.Performance/Transports/AssociationStressSpecBase.cs b/src/core/Akka.Remote.Tests.Performance/Transports/AssociationStressSpecBase.cs index 715bd481ec0..3b38551293e 100644 --- a/src/core/Akka.Remote.Tests.Performance/Transports/AssociationStressSpecBase.cs +++ b/src/core/Akka.Remote.Tests.Performance/Transports/AssociationStressSpecBase.cs @@ -22,7 +22,7 @@ namespace Akka.Remote.Tests.Performance.Transports public abstract class AssociationStressSpecBase { private const string AssociationCounterName = "AssociationConfirmed"; - private static readonly AtomicCounter ActorSystemNameCounter = new AtomicCounter(0); + private static readonly AtomicCounter ActorSystemNameCounter = new(0); protected readonly TimeSpan AssociationTimeout = TimeSpan.FromSeconds(2); protected Counter AssociationCounter; diff --git a/src/core/Akka.Remote.Tests.Performance/Transports/RemoteMessagingThroughputSpecBase.cs b/src/core/Akka.Remote.Tests.Performance/Transports/RemoteMessagingThroughputSpecBase.cs index e9945f08a9b..b685b60b2e8 100644 --- a/src/core/Akka.Remote.Tests.Performance/Transports/RemoteMessagingThroughputSpecBase.cs +++ b/src/core/Akka.Remote.Tests.Performance/Transports/RemoteMessagingThroughputSpecBase.cs @@ -26,13 +26,13 @@ public abstract class RemoteMessagingThroughputSpecBase private const int RemoteMessageCount = 10000; private const int NumClients = 10; private Counter _remoteMessageThroughput; - private List _tasks = new List(); - private readonly List _receivers = new List(); + private List _tasks = new(); + private readonly List _receivers = new(); private IActorRef _echo; private IActorRef _remoteEcho; private IActorRef _remoteReceiver; - private static readonly AtomicCounter ActorSystemNameCounter = new AtomicCounter(0); + private static readonly AtomicCounter ActorSystemNameCounter = new(0); protected ActorSystem System1; protected ActorSystem System2; @@ -42,7 +42,7 @@ private class AllStartedActor : UntypedActor { public class AllStarted { } - private readonly HashSet _actors = new HashSet(); + private readonly HashSet _actors = new(); private int _correlationId = 0; protected override void OnReceive(object message) diff --git a/src/core/Akka.Remote.Tests/EndpointRegistrySpec.cs b/src/core/Akka.Remote.Tests/EndpointRegistrySpec.cs index 4be5d03d352..b71c320612d 100644 --- a/src/core/Akka.Remote.Tests/EndpointRegistrySpec.cs +++ b/src/core/Akka.Remote.Tests/EndpointRegistrySpec.cs @@ -20,8 +20,8 @@ public class EndpointRegistrySpec : AkkaSpec private IActorRef actorA; private IActorRef actorB; - Address address1 = new Address("test", "testsys1", "testhost1", 1234); - Address address2 = new Address("test", "testsy2", "testhost2", 1234); + Address address1 = new("test", "testsys1", "testhost1", 1234); + Address address2 = new("test", "testsy2", "testhost2", 1234); public EndpointRegistrySpec() { diff --git a/src/core/Akka.Remote.Tests/ExceptionSupportSpec.cs b/src/core/Akka.Remote.Tests/ExceptionSupportSpec.cs index cf84044aee9..f27005f5424 100644 --- a/src/core/Akka.Remote.Tests/ExceptionSupportSpec.cs +++ b/src/core/Akka.Remote.Tests/ExceptionSupportSpec.cs @@ -28,8 +28,8 @@ namespace Akka.Remote.Tests public class ExceptionSupportSpec : AkkaSpec { private readonly ExceptionSupport _serializer; - private readonly Exception _innerException = new Exception("inner message"); - private readonly Exception _innerException2 = new Exception("inner message 2"); + private readonly Exception _innerException = new("inner message"); + private readonly Exception _innerException2 = new("inner message 2"); public ExceptionSupportSpec(ITestOutputHelper output) : base(output) { diff --git a/src/core/Akka.Remote.Tests/RemoteActorTelemetrySpecs.cs b/src/core/Akka.Remote.Tests/RemoteActorTelemetrySpecs.cs index 5cc7b5f1a32..f292d1ce896 100644 --- a/src/core/Akka.Remote.Tests/RemoteActorTelemetrySpecs.cs +++ b/src/core/Akka.Remote.Tests/RemoteActorTelemetrySpecs.cs @@ -64,7 +64,7 @@ public GetTelemetry(int actorCreated, int actorStopped, int actorRestarted) public class GetTelemetryRequest { // make singleton - public static readonly GetTelemetryRequest Instance = new GetTelemetryRequest(); + public static readonly GetTelemetryRequest Instance = new(); private GetTelemetryRequest() { diff --git a/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs b/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs index 0dafefa0361..bd59e864f7e 100644 --- a/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs +++ b/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs @@ -64,8 +64,8 @@ public void Remoting_should_contain_correct_configuration_values_in_ReferenceCon var remoteSettingsAdaptersStandart = new List>() { - new KeyValuePair("gremlin", typeof(FailureInjectorProvider)), - new KeyValuePair("trttl", typeof(ThrottlerProvider)) + new("gremlin", typeof(FailureInjectorProvider)), + new("trttl", typeof(ThrottlerProvider)) }; var remoteSettingsAdapters = diff --git a/src/core/Akka.Remote.Tests/Serialization/Bugfix3903Spec.cs b/src/core/Akka.Remote.Tests/Serialization/Bugfix3903Spec.cs index 788d8c25a8b..d14a094e398 100644 --- a/src/core/Akka.Remote.Tests/Serialization/Bugfix3903Spec.cs +++ b/src/core/Akka.Remote.Tests/Serialization/Bugfix3903Spec.cs @@ -60,7 +60,7 @@ internal class EchoActor : ReceiveActor { public class Fail { - public static readonly Fail Instance = new Fail(); + public static readonly Fail Instance = new(); private Fail(){} } diff --git a/src/core/Akka.Remote.Tests/Serialization/MiscMessageSerializerSpec.cs b/src/core/Akka.Remote.Tests/Serialization/MiscMessageSerializerSpec.cs index 9d7581ae98a..c6fb4764f90 100644 --- a/src/core/Akka.Remote.Tests/Serialization/MiscMessageSerializerSpec.cs +++ b/src/core/Akka.Remote.Tests/Serialization/MiscMessageSerializerSpec.cs @@ -334,7 +334,7 @@ public void Can_serialize_RemoteRouterConfig() { var message = new RemoteRouterConfig( local: new RandomPool(25), - nodes: new List
{ new Address("akka.tcp", "TestSys", "localhost", 23423) }); + nodes: new List
{ new("akka.tcp", "TestSys", "localhost", 23423) }); AssertEqual(message); } diff --git a/src/core/Akka.Remote.Tests/TransientSerializationErrorSpec.cs b/src/core/Akka.Remote.Tests/TransientSerializationErrorSpec.cs index 71d39f7a8cd..3c4cc73ccc4 100644 --- a/src/core/Akka.Remote.Tests/TransientSerializationErrorSpec.cs +++ b/src/core/Akka.Remote.Tests/TransientSerializationErrorSpec.cs @@ -21,42 +21,42 @@ public abstract class AbstractTransientSerializationErrorSpec : AkkaSpec { internal class ManifestNotSerializable { - public static readonly ManifestNotSerializable Instance = new ManifestNotSerializable(); + public static readonly ManifestNotSerializable Instance = new(); private ManifestNotSerializable() { } } internal class ManifestIllegal { - public static readonly ManifestIllegal Instance = new ManifestIllegal(); + public static readonly ManifestIllegal Instance = new(); private ManifestIllegal() { } } internal class ToBinaryNotSerializable { - public static readonly ToBinaryNotSerializable Instance = new ToBinaryNotSerializable(); + public static readonly ToBinaryNotSerializable Instance = new(); private ToBinaryNotSerializable() { } } internal class ToBinaryIllegal { - public static readonly ToBinaryIllegal Instance = new ToBinaryIllegal(); + public static readonly ToBinaryIllegal Instance = new(); private ToBinaryIllegal() { } } internal class NotDeserializable { - public static readonly NotDeserializable Instance = new NotDeserializable(); + public static readonly NotDeserializable Instance = new(); private NotDeserializable() { } } internal class IllegalOnDeserialize { - public static readonly IllegalOnDeserialize Instance = new IllegalOnDeserialize(); + public static readonly IllegalOnDeserialize Instance = new(); private IllegalOnDeserialize() { } } diff --git a/src/core/Akka.Remote.Tests/Transport/AkkaProtocolSpec.cs b/src/core/Akka.Remote.Tests/Transport/AkkaProtocolSpec.cs index ff19132244d..97ca7e66ec2 100644 --- a/src/core/Akka.Remote.Tests/Transport/AkkaProtocolSpec.cs +++ b/src/core/Akka.Remote.Tests/Transport/AkkaProtocolSpec.cs @@ -29,16 +29,15 @@ public class AkkaProtocolSpec : AkkaSpec { #region Setup / Config - private readonly Address _localAddress = new Address("test", "testsystem", "testhost", 1234); - private readonly Address _localAkkaAddress = new Address("akka.test", "testsystem", "testhost", 1234); + private readonly Address _localAddress = new("test", "testsystem", "testhost", 1234); + private readonly Address _localAkkaAddress = new("akka.test", "testsystem", "testhost", 1234); - private readonly Address _remoteAddress = new Address("test", "testsystem2", "testhost2", 1234); - private readonly Address _remoteAkkaAddress = new Address("akka.test", "testsystem2", "testhost2", 1234); + private readonly Address _remoteAddress = new("test", "testsystem2", "testhost2", 1234); + private readonly Address _remoteAkkaAddress = new("akka.test", "testsystem2", "testhost2", 1234); private readonly AkkaPduCodec _codec; - private readonly SerializedMessage _testMsg = - new SerializedMessage { SerializerId = 0, Message = ByteString.CopyFromUtf8("foo") }; + private readonly SerializedMessage _testMsg = new() { SerializerId = 0, Message = ByteString.CopyFromUtf8("foo") }; private readonly ByteString _testEnvelope; private readonly ByteString _testMsgPdu; diff --git a/src/core/Akka.Remote.Tests/Transport/AkkaProtocolStressTest.cs b/src/core/Akka.Remote.Tests/Transport/AkkaProtocolStressTest.cs index 0a85bf2e53e..d9a303dc017 100644 --- a/src/core/Akka.Remote.Tests/Transport/AkkaProtocolStressTest.cs +++ b/src/core/Akka.Remote.Tests/Transport/AkkaProtocolStressTest.cs @@ -61,7 +61,7 @@ private sealed class ResendFinal { private ResendFinal() { } - public static ResendFinal Instance { get; } = new ResendFinal(); + public static ResendFinal Instance { get; } = new(); } private class SequenceVerifier : UntypedActor diff --git a/src/core/Akka.Remote.Tests/Transport/DotNettyBatchWriterSpecs.cs b/src/core/Akka.Remote.Tests/Transport/DotNettyBatchWriterSpecs.cs index 17d58be7457..a74e85044cb 100644 --- a/src/core/Akka.Remote.Tests/Transport/DotNettyBatchWriterSpecs.cs +++ b/src/core/Akka.Remote.Tests/Transport/DotNettyBatchWriterSpecs.cs @@ -29,7 +29,7 @@ public class FlushLogger : ChannelHandlerAdapter { public ITestOutputHelper Helper; - private TaskCompletionSource _tcs = new TaskCompletionSource(); + private TaskCompletionSource _tcs = new(); public Task Activated => _tcs.Task; diff --git a/src/core/Akka.Remote.Tests/Transport/GenericTransportSpec.cs b/src/core/Akka.Remote.Tests/Transport/GenericTransportSpec.cs index 1d5418fb1fc..525525ea658 100644 --- a/src/core/Akka.Remote.Tests/Transport/GenericTransportSpec.cs +++ b/src/core/Akka.Remote.Tests/Transport/GenericTransportSpec.cs @@ -19,8 +19,8 @@ namespace Akka.Remote.Tests.Transport { public abstract class GenericTransportSpec : AkkaSpec { - private readonly Address _addressATest = new Address("test", "testsytemA", "testhostA", 4321); - private readonly Address _addressBTest = new Address("test", "testsytemB", "testhostB", 5432); + private readonly Address _addressATest = new("test", "testsytemA", "testhostA", 4321); + private readonly Address _addressBTest = new("test", "testsytemB", "testhostB", 5432); private Address _addressA; private Address _addressB; diff --git a/src/core/Akka.Remote.Tests/Transport/TestTransportSpec.cs b/src/core/Akka.Remote.Tests/Transport/TestTransportSpec.cs index 1a436880dce..2505dce8721 100644 --- a/src/core/Akka.Remote.Tests/Transport/TestTransportSpec.cs +++ b/src/core/Akka.Remote.Tests/Transport/TestTransportSpec.cs @@ -22,9 +22,9 @@ public class TestTransportSpec : AkkaSpec { #region Setup / Teardown - private readonly Address _addressA = new Address("test", "testsystemA", "testhostA", 4321); - private readonly Address _addressB = new Address("test", "testsystemB", "testhostB", 5432); - private readonly Address _nonExistantAddress = new Address("test", "nosystem", "nohost", 0); + private readonly Address _addressA = new("test", "testsystemA", "testhostA", 4321); + private readonly Address _addressB = new("test", "testsystemB", "testhostB", 5432); + private readonly Address _nonExistantAddress = new("test", "nosystem", "nohost", 0); private TimeSpan DefaultTimeout => Dilated(TestKitSettings.DefaultTimeout); #endregion diff --git a/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs b/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs index 8694256c414..748ffdf937c 100644 --- a/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs +++ b/src/core/Akka.Remote.Tests/Transport/ThrottlerTransportAdapterSpec.cs @@ -143,8 +143,7 @@ protected override void OnReceive(object message) private TimeSpan DefaultTimeout => Dilated(TestKitSettings.DefaultTimeout); - private RootActorPath RootB - => new RootActorPath(_systemB.AsInstanceOf().Provider.DefaultAddress); + private RootActorPath RootB => new(_systemB.AsInstanceOf().Provider.DefaultAddress); private async Task Here() { diff --git a/src/core/Akka.Remote/AckedDelivery.cs b/src/core/Akka.Remote/AckedDelivery.cs index f884e80f94c..a86377cee9f 100644 --- a/src/core/Akka.Remote/AckedDelivery.cs +++ b/src/core/Akka.Remote/AckedDelivery.cs @@ -235,7 +235,7 @@ public int GetHashCode(SeqNo obj) /// /// TBD /// - public static readonly SeqNoComparer Comparer = new SeqNoComparer(); + public static readonly SeqNoComparer Comparer = new(); /// /// TBD /// @@ -523,7 +523,7 @@ internal sealed class AckedReceiveBuffer : IEquatable> /// /// TBD /// - public static readonly SeqNo.HasSeqNoComparer Comparer = new SeqNo.HasSeqNoComparer(); + public static readonly SeqNo.HasSeqNoComparer Comparer = new(); /// /// Constructor diff --git a/src/core/Akka.Remote/DefaultFailureDetectorRegistry.cs b/src/core/Akka.Remote/DefaultFailureDetectorRegistry.cs index 0ad8a19238d..8a8b945e90e 100644 --- a/src/core/Akka.Remote/DefaultFailureDetectorRegistry.cs +++ b/src/core/Akka.Remote/DefaultFailureDetectorRegistry.cs @@ -31,9 +31,9 @@ public DefaultFailureDetectorRegistry(Func factory) private readonly Func _factory; - private readonly AtomicReference> _resourceToFailureDetector = new AtomicReference>(ImmutableDictionary.Empty); + private readonly AtomicReference> _resourceToFailureDetector = new(ImmutableDictionary.Empty); - private readonly object _failureDetectorCreationLock = new object(); + private readonly object _failureDetectorCreationLock = new(); private ImmutableDictionary ResourceToFailureDetector { diff --git a/src/core/Akka.Remote/Endpoint.cs b/src/core/Akka.Remote/Endpoint.cs index 2a093539243..28701087ac2 100644 --- a/src/core/Akka.Remote/Endpoint.cs +++ b/src/core/Akka.Remote/Endpoint.cs @@ -409,7 +409,7 @@ public class IsIdle /// /// TBD /// - public static readonly IsIdle Instance = new IsIdle(); + public static readonly IsIdle Instance = new(); private IsIdle() { } } @@ -421,7 +421,7 @@ public class Idle /// /// TBD /// - public static readonly Idle Instance = new Idle(); + public static readonly Idle Instance = new(); private Idle() { } } @@ -433,7 +433,7 @@ public class TooLongIdle /// /// TBD /// - public static readonly TooLongIdle Instance = new TooLongIdle(); + public static readonly TooLongIdle Instance = new(); private TooLongIdle() { } } @@ -1072,7 +1072,7 @@ public EndpointWriter( private DisassociateInfo _stopReason = DisassociateInfo.Unknown; private IActorRef _reader; - private readonly AtomicCounter _readerId = new AtomicCounter(0); + private readonly AtomicCounter _readerId = new(0); private readonly IInboundMessageDispatcher _msgDispatcher; private Ack _lastAck = null; @@ -1084,10 +1084,10 @@ public EndpointWriter( // Use an internal buffer instead of Stash for efficiency // stash/unstashAll is slow when many messages are stashed // IMPORTANT: sender is not stored, so .Sender and forward must not be used in EndpointWriter - private readonly LinkedList _buffer = new LinkedList(); + private readonly LinkedList _buffer = new(); //buffer for IPriorityMessages - ensures that heartbeats get delivered before user-defined messages - private readonly LinkedList _prioBuffer = new LinkedList(); + private readonly LinkedList _prioBuffer = new(); private long _largeBufferLogTimestamp = MonotonicClock.GetNanos(); private readonly IRemoteMetrics _remoteMetrics; @@ -1717,7 +1717,7 @@ public TookOver(IActorRef writer, AkkaProtocolHandle protocolHandle) public sealed class BackoffTimer { private BackoffTimer() { } - private static readonly BackoffTimer _instance = new BackoffTimer(); + private static readonly BackoffTimer _instance = new(); /// /// TBD /// @@ -1730,7 +1730,7 @@ private BackoffTimer() { } public sealed class FlushAndStop { private FlushAndStop() { } - private static readonly FlushAndStop _instance = new FlushAndStop(); + private static readonly FlushAndStop _instance = new(); /// /// TBD /// @@ -1743,7 +1743,7 @@ private FlushAndStop() { } public sealed class AckIdleCheckTimer { private AckIdleCheckTimer() { } - private static readonly AckIdleCheckTimer _instance = new AckIdleCheckTimer(); + private static readonly AckIdleCheckTimer _instance = new(); /// /// TBD /// @@ -1753,7 +1753,7 @@ private AckIdleCheckTimer() { } private sealed class FlushAndStopTimeout { private FlushAndStopTimeout() { } - private static readonly FlushAndStopTimeout _instance = new FlushAndStopTimeout(); + private static readonly FlushAndStopTimeout _instance = new(); public static FlushAndStopTimeout Instance { get { return _instance; } } } @@ -1899,7 +1899,7 @@ public EndpointReader( private readonly IInboundMessageDispatcher _msgDispatch; private readonly IRemoteActorRefProvider _provider; - private AckedReceiveBuffer _ackedReceiveBuffer = new AckedReceiveBuffer(); + private AckedReceiveBuffer _ackedReceiveBuffer = new(); #region ActorBase overrides diff --git a/src/core/Akka.Remote/EndpointManager.cs b/src/core/Akka.Remote/EndpointManager.cs index ecd35a8a6c3..24959efaa5f 100644 --- a/src/core/Akka.Remote/EndpointManager.cs +++ b/src/core/Akka.Remote/EndpointManager.cs @@ -462,10 +462,10 @@ public EndpointManager(Config config, ILoggingAdapter log) /// Mapping between addresses and endpoint actors. If passive connections are turned off, incoming connections /// will not be part of this map! /// - private readonly EndpointRegistry _endpoints = new EndpointRegistry(); + private readonly EndpointRegistry _endpoints = new(); private readonly RemoteSettings _settings; private readonly Config _conf; - private readonly AtomicCounterLong _endpointId = new AtomicCounterLong(0L); + private readonly AtomicCounterLong _endpointId = new(0L); private readonly ILoggingAdapter _log; private readonly EventPublisher _eventPublisher; @@ -477,10 +477,9 @@ public EndpointManager(Config config, ILoggingAdapter log) /// /// Mapping between transports and the local addresses they listen to /// - private Dictionary _transportMapping = - new Dictionary(); + private Dictionary _transportMapping = new(); - private readonly ConcurrentDictionary _receiveBuffers = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _receiveBuffers = new(); private bool RetryGateEnabled => _settings.RetryGateClosedFor > TimeSpan.Zero; @@ -511,8 +510,8 @@ private ICancelable PruneTimerCancelleable } } - private Dictionary _pendingReadHandoffs = new Dictionary(); - private Dictionary> _stashedInbound = new Dictionary>(); + private Dictionary _pendingReadHandoffs = new(); + private Dictionary> _stashedInbound = new(); private void HandleStashedInbound(IActorRef endpoint, bool writerIsIdle) diff --git a/src/core/Akka.Remote/EndpointRegistry.cs b/src/core/Akka.Remote/EndpointRegistry.cs index 65233601ae4..a9bc731174d 100644 --- a/src/core/Akka.Remote/EndpointRegistry.cs +++ b/src/core/Akka.Remote/EndpointRegistry.cs @@ -18,14 +18,13 @@ namespace Akka.Remote /// internal class EndpointRegistry { - private Dictionary _addressToRefuseUid = new Dictionary(); - private readonly Dictionary _addressToReadonly = new Dictionary(); + private Dictionary _addressToRefuseUid = new(); + private readonly Dictionary _addressToReadonly = new(); - private Dictionary _addressToWritable = - new Dictionary(); + private Dictionary _addressToWritable = new(); - private readonly Dictionary _readonlyToAddress = new Dictionary(); - private readonly Dictionary _writableToAddress = new Dictionary(); + private readonly Dictionary _readonlyToAddress = new(); + private readonly Dictionary _writableToAddress = new(); /// /// Registers a new writable endpoint with the system. diff --git a/src/core/Akka.Remote/RemoteActorRefProvider.cs b/src/core/Akka.Remote/RemoteActorRefProvider.cs index 1dc5ed1e52c..5cb9553b5de 100644 --- a/src/core/Akka.Remote/RemoteActorRefProvider.cs +++ b/src/core/Akka.Remote/RemoteActorRefProvider.cs @@ -778,7 +778,7 @@ private void InitFSM() public sealed class TransportShutdown { private TransportShutdown() { } - public static TransportShutdown Instance { get; } = new TransportShutdown(); + public static TransportShutdown Instance { get; } = new(); public override string ToString() { diff --git a/src/core/Akka.Remote/RemoteMetricsExtension.cs b/src/core/Akka.Remote/RemoteMetricsExtension.cs index c7cbe8da895..9afbb64c939 100644 --- a/src/core/Akka.Remote/RemoteMetricsExtension.cs +++ b/src/core/Akka.Remote/RemoteMetricsExtension.cs @@ -58,7 +58,7 @@ internal class RemoteMetricsOn : IRemoteMetrics { private readonly ILoggingAdapter _log; private readonly long? _logFrameSizeExceeding; - private readonly ConcurrentDictionary _maxPayloadBytes = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _maxPayloadBytes = new(); /// /// TBD diff --git a/src/core/Akka.Remote/RemoteSystemDaemon.cs b/src/core/Akka.Remote/RemoteSystemDaemon.cs index fad1ab7a78c..1076ad98327 100644 --- a/src/core/Akka.Remote/RemoteSystemDaemon.cs +++ b/src/core/Akka.Remote/RemoteSystemDaemon.cs @@ -80,8 +80,8 @@ public DaemonMsgCreate(Props props, Deploy deploy, string path, IActorRef superv internal sealed class RemoteSystemDaemon : VirtualPathContainer { private readonly ActorSystemImpl _system; - private readonly Switch _terminating = new Switch(false); - private readonly ConcurrentDictionary> _parent2Children = new ConcurrentDictionary>(); + private readonly Switch _terminating = new(false); + private readonly ConcurrentDictionary> _parent2Children = new(); private readonly IActorRef _terminator; /// diff --git a/src/core/Akka.Remote/RemoteWatcher.cs b/src/core/Akka.Remote/RemoteWatcher.cs index e55c0229319..951d941af4a 100644 --- a/src/core/Akka.Remote/RemoteWatcher.cs +++ b/src/core/Akka.Remote/RemoteWatcher.cs @@ -132,7 +132,7 @@ private Heartbeat() /// /// TBD /// - public static Heartbeat Instance { get; } = new Heartbeat(); + public static Heartbeat Instance { get; } = new(); } /// @@ -171,7 +171,7 @@ private HeartbeatTick() { } /// /// TBD /// - public static HeartbeatTick Instance { get; } = new HeartbeatTick(); + public static HeartbeatTick Instance { get; } = new(); } /// @@ -184,7 +184,7 @@ private ReapUnreachableTick() { } /// /// TBD /// - public static ReapUnreachableTick Instance { get; } = new ReapUnreachableTick(); + public static ReapUnreachableTick Instance { get; } = new(); } /// @@ -366,17 +366,17 @@ TimeSpan heartbeatExpectedResponseAfter private readonly TimeSpan _heartbeatExpectedResponseAfter; private readonly IScheduler _scheduler = Context.System.Scheduler; private readonly IRemoteActorRefProvider _remoteProvider; - private readonly HeartbeatRsp _selfHeartbeatRspMsg = new HeartbeatRsp(AddressUidExtension.Uid(Context.System)); + private readonly HeartbeatRsp _selfHeartbeatRspMsg = new(AddressUidExtension.Uid(Context.System)); /// /// Actors that this node is watching, map of watchee --> Set(watchers) /// - protected readonly Dictionary> Watching = new Dictionary>(); + protected readonly Dictionary> Watching = new(); /// /// Nodes that this node is watching, i.e. expecting heartbeats from these nodes. Map of address --> Set(watchee) on this address. /// - protected readonly Dictionary> WatcheeByNodes = new Dictionary>(); + protected readonly Dictionary> WatcheeByNodes = new(); /// /// TBD @@ -385,9 +385,9 @@ TimeSpan heartbeatExpectedResponseAfter /// /// TBD /// - protected HashSet
Unreachable { get; } = new HashSet
(); + protected HashSet
Unreachable { get; } = new(); - private readonly Dictionary _addressUids = new Dictionary(); + private readonly Dictionary _addressUids = new(); private readonly ICancelable _heartbeatCancelable; private readonly ICancelable _failureDetectorReaperCancelable; diff --git a/src/core/Akka.Remote/Routing/RemoteRouterConfig.cs b/src/core/Akka.Remote/Routing/RemoteRouterConfig.cs index 1c1a51137f0..18f842c95c2 100644 --- a/src/core/Akka.Remote/Routing/RemoteRouterConfig.cs +++ b/src/core/Akka.Remote/Routing/RemoteRouterConfig.cs @@ -24,7 +24,7 @@ namespace Akka.Remote.Routing public sealed class RemoteRouterConfig : Pool, IEquatable { private readonly IEnumerator
_nodeAddrEnumerator; - private readonly AtomicCounter _childNameCounter = new AtomicCounter(); + private readonly AtomicCounter _childNameCounter = new(); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka.Remote/Serialization/ActorPathCache.cs b/src/core/Akka.Remote/Serialization/ActorPathCache.cs index f4c48139f2c..c39300619c8 100644 --- a/src/core/Akka.Remote/Serialization/ActorPathCache.cs +++ b/src/core/Akka.Remote/Serialization/ActorPathCache.cs @@ -17,7 +17,7 @@ namespace Akka.Remote.Serialization /// internal sealed class ActorPathThreadLocalCache : ExtensionIdProvider, IExtension { - private readonly ThreadLocal _current = new ThreadLocal(() => new ActorPathCache()); + private readonly ThreadLocal _current = new(() => new ActorPathCache()); public ActorPathCache Cache => _current.Value; diff --git a/src/core/Akka.Remote/Serialization/ExceptionSupport.cs b/src/core/Akka.Remote/Serialization/ExceptionSupport.cs index 2ca4a2e4a8d..c2b3d638e64 100644 --- a/src/core/Akka.Remote/Serialization/ExceptionSupport.cs +++ b/src/core/Akka.Remote/Serialization/ExceptionSupport.cs @@ -22,7 +22,7 @@ internal class ExceptionSupport { private readonly WrappedPayloadSupport _wrappedPayloadSupport; private const BindingFlags All = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; - private readonly HashSet _defaultProperties = new HashSet + private readonly HashSet _defaultProperties = new() { "ClassName", "Message", @@ -67,7 +67,7 @@ internal Exception ExceptionFromProto(Proto.Msg.ExceptionData proto) return ExceptionFromProtoNet(proto); } - private readonly FormatterConverter _defaultFormatterConverter = new FormatterConverter(); + private readonly FormatterConverter _defaultFormatterConverter = new(); public Proto.Msg.ExceptionData ExceptionToProtoNet(Exception exception) { diff --git a/src/core/Akka.Remote/Serialization/LruBoundedCache.cs b/src/core/Akka.Remote/Serialization/LruBoundedCache.cs index a5ba42f8c88..708fa4e6025 100644 --- a/src/core/Akka.Remote/Serialization/LruBoundedCache.cs +++ b/src/core/Akka.Remote/Serialization/LruBoundedCache.cs @@ -102,7 +102,7 @@ public static int OfStringFast(string s) ///
internal sealed class FastHashComparer : IEqualityComparer { - public readonly static FastHashComparer Default = new FastHashComparer(); + public readonly static FastHashComparer Default = new(); public bool Equals(string x, string y) { diff --git a/src/core/Akka.Remote/Serialization/ProtobufSerializer.cs b/src/core/Akka.Remote/Serialization/ProtobufSerializer.cs index d69698157db..4ddde9e16a6 100644 --- a/src/core/Akka.Remote/Serialization/ProtobufSerializer.cs +++ b/src/core/Akka.Remote/Serialization/ProtobufSerializer.cs @@ -19,7 +19,7 @@ namespace Akka.Remote.Serialization ///
public class ProtobufSerializer : Serializer { - private static readonly ConcurrentDictionary TypeLookup = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary TypeLookup = new(); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs b/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs index 66533f2247b..4b8f7e1eb3f 100644 --- a/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs +++ b/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs @@ -107,7 +107,7 @@ public AkkaProtocolTransport(Transport wrappedTransport, ActorSystem system, Akk /// protected AkkaPduCodec Codec { get; private set; } - private readonly SchemeAugmenter _schemeAugmenter = new SchemeAugmenter(RemoteSettings.AkkaScheme); + private readonly SchemeAugmenter _schemeAugmenter = new(RemoteSettings.AkkaScheme); /// /// TBD @@ -178,7 +178,7 @@ public async Task Associate(Address remoteAddress, int? refu /// /// TBD /// - public static AtomicCounter UniqueId = new AtomicCounter(0); + public static AtomicCounter UniqueId = new(0); #endregion } diff --git a/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs b/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs index 0c3d9da66b2..9dc1ade8453 100644 --- a/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs +++ b/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs @@ -479,7 +479,7 @@ public static EndPoint AddressToSocketAddress(Address address) internal class HeliosBackwardsCompatabilityLengthFramePrepender : LengthFieldPrepender { - private readonly List _temporaryOutput = new List(2); + private readonly List _temporaryOutput = new(2); public HeliosBackwardsCompatabilityLengthFramePrepender(int lengthFieldLength, bool lengthFieldIncludesLengthFieldLength) : base(ByteOrder.LittleEndian, lengthFieldLength, 0, lengthFieldIncludesLengthFieldLength) diff --git a/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransportSettings.cs b/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransportSettings.cs index bec3fccd1b7..820dfa3a230 100644 --- a/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransportSettings.cs +++ b/src/core/Akka.Remote/Transport/DotNetty/DotNettyTransportSettings.cs @@ -290,7 +290,7 @@ internal enum TransportMode internal sealed class SslSettings { - public static readonly SslSettings Empty = new SslSettings(); + public static readonly SslSettings Empty = new(); public static SslSettings Create(Config config) { if (config.IsNullOrEmpty()) diff --git a/src/core/Akka.Remote/Transport/DotNetty/TcpTransport.cs b/src/core/Akka.Remote/Transport/DotNetty/TcpTransport.cs index 091301b362f..e6ebd3a35ef 100644 --- a/src/core/Akka.Remote/Transport/DotNetty/TcpTransport.cs +++ b/src/core/Akka.Remote/Transport/DotNetty/TcpTransport.cs @@ -132,7 +132,7 @@ void InitInbound(IChannel channel, IPEndPoint socketAddress, object msg) internal sealed class TcpClientHandler : TcpHandlers { - private readonly TaskCompletionSource _statusPromise = new TaskCompletionSource(); + private readonly TaskCompletionSource _statusPromise = new(); private readonly Address _remoteAddress; public Task StatusFuture => _statusPromise.Task; diff --git a/src/core/Akka.Remote/Transport/FailureInjectorTransportAdapter.cs b/src/core/Akka.Remote/Transport/FailureInjectorTransportAdapter.cs index 13a390f69bf..e927ff9e77d 100644 --- a/src/core/Akka.Remote/Transport/FailureInjectorTransportAdapter.cs +++ b/src/core/Akka.Remote/Transport/FailureInjectorTransportAdapter.cs @@ -140,7 +140,7 @@ public sealed class PassThru : IGremlinMode { private PassThru() { } // ReSharper disable once InconsistentNaming - private static readonly PassThru _instance = new PassThru(); + private static readonly PassThru _instance = new(); /// /// TBD @@ -205,7 +205,7 @@ private Random Rng private bool _shouldDebugLog; private volatile IAssociationEventListener _upstreamListener = null; - private readonly ConcurrentDictionary addressChaosTable = new ConcurrentDictionary(); + private readonly ConcurrentDictionary addressChaosTable = new(); private volatile IGremlinMode _allMode = PassThru.Instance; /// @@ -216,7 +216,7 @@ private Random Rng #region AbstractTransportAdapter members // ReSharper disable once InconsistentNaming - private static readonly SchemeAugmenter _augmenter = new SchemeAugmenter(FailureInjectorSchemeIdentifier); + private static readonly SchemeAugmenter _augmenter = new(FailureInjectorSchemeIdentifier); /// /// TBD /// diff --git a/src/core/Akka.Remote/Transport/TestTransport.cs b/src/core/Akka.Remote/Transport/TestTransport.cs index 51048ffcdac..d229a86fc24 100644 --- a/src/core/Akka.Remote/Transport/TestTransport.cs +++ b/src/core/Akka.Remote/Transport/TestTransport.cs @@ -25,8 +25,7 @@ namespace Akka.Remote.Transport /// public class TestTransport : Transport { - private readonly TaskCompletionSource _associationListenerPromise = - new TaskCompletionSource(); + private readonly TaskCompletionSource _associationListenerPromise = new(); private readonly AssociationRegistry _registry; /// @@ -434,8 +433,7 @@ public DisassociateAttempt(Address requestor, Address remote) /// TBD public class SwitchableLoggedBehavior { - private readonly ConcurrentStack>> _behaviorStack = - new ConcurrentStack>>(); + private readonly ConcurrentStack>> _behaviorStack = new(); /// /// TBD @@ -564,18 +562,16 @@ public Task Apply(TIn param) /// public class AssociationRegistry { - private static readonly ConcurrentDictionary registries = - new ConcurrentDictionary(); + private static readonly ConcurrentDictionary registries = new(); - private readonly ConcurrentStack _activityLog = new ConcurrentStack(); + private readonly ConcurrentStack _activityLog = new(); private readonly ConcurrentDictionary<(Address, Address), (IHandleEventListener, IHandleEventListener)> - _listenersTable = - new ConcurrentDictionary<(Address, Address), (IHandleEventListener, IHandleEventListener)>(); + _listenersTable = new(); private readonly ConcurrentDictionary)> - _transportTable = new ConcurrentDictionary)>(); + _transportTable = new(); /// /// Retrieves the specified associated with the . diff --git a/src/core/Akka.Remote/Transport/ThrottleTransportAdapter.cs b/src/core/Akka.Remote/Transport/ThrottleTransportAdapter.cs index 90e449cee8e..0e9b9db72b8 100644 --- a/src/core/Akka.Remote/Transport/ThrottleTransportAdapter.cs +++ b/src/core/Akka.Remote/Transport/ThrottleTransportAdapter.cs @@ -46,7 +46,7 @@ public class ThrottleTransportAdapter : ActorTransportAdapter /// /// TBD /// - public static readonly AtomicCounter UniqueId = new AtomicCounter(0); + public static readonly AtomicCounter UniqueId = new(0); /// /// TBD @@ -79,7 +79,7 @@ public ThrottleTransportAdapter(Transport wrappedTransport, ActorSystem system) } // ReSharper disable once InconsistentNaming - private static readonly SchemeAugmenter _schemeAugmenter = new SchemeAugmenter(Scheme); + private static readonly SchemeAugmenter _schemeAugmenter = new(Scheme); /// /// TBD /// @@ -190,7 +190,7 @@ public sealed class ForceDisassociateAck { private ForceDisassociateAck() { } // ReSharper disable once InconsistentNaming - private static readonly ForceDisassociateAck _instance = new ForceDisassociateAck(); + private static readonly ForceDisassociateAck _instance = new(); /// /// TBD @@ -338,10 +338,9 @@ public Listener(IHandleEventListener handleEventListener) /// TBD /// protected readonly Transport WrappedTransport; - private Dictionary _throttlingModes - = new Dictionary(); + private Dictionary _throttlingModes = new(); - private List<(Address, ThrottlerHandle)> _handleTable = new List<(Address, ThrottlerHandle)>(); + private List<(Address, ThrottlerHandle)> _handleTable = new(); /// /// TBD @@ -604,7 +603,7 @@ public class Blackhole : ThrottleMode { private Blackhole() { } // ReSharper disable once InconsistentNaming - private static readonly Blackhole _instance = new Blackhole(); + private static readonly Blackhole _instance = new(); /// /// The singleton instance @@ -636,7 +635,7 @@ public override TimeSpan TimeToAvailable(long currentNanoTime, int tokens) public class Unthrottled : ThrottleMode { private Unthrottled() { } - private static readonly Unthrottled _instance = new Unthrottled(); + private static readonly Unthrottled _instance = new(); /// /// TBD @@ -870,7 +869,7 @@ public sealed class SetThrottleAck { private SetThrottleAck() { } // ReSharper disable once InconsistentNaming - private static readonly SetThrottleAck _instance = new SetThrottleAck(); + private static readonly SetThrottleAck _instance = new(); /// /// TBD @@ -888,7 +887,7 @@ internal sealed class ThrottlerHandle : AbstractTransportAdapterHandle internal readonly IActorRef ThrottlerActor; - internal AtomicReference OutboundThrottleMode = new AtomicReference(Unthrottled.Instance); + internal AtomicReference OutboundThrottleMode = new(Unthrottled.Instance); /// /// TBD @@ -1010,7 +1009,7 @@ internal class Uninitialized : IThrottlerData { private Uninitialized() { } // ReSharper disable once InconsistentNaming - private static readonly Uninitialized _instance = new Uninitialized(); + private static readonly Uninitialized _instance = new(); /// /// TBD /// @@ -1083,7 +1082,7 @@ public FailWith(DisassociateInfo failReason) /// /// TBD /// - protected Queue ThrottledMessages = new Queue(); + protected Queue ThrottledMessages = new(); /// /// TBD /// diff --git a/src/core/Akka.Remote/Transport/TransportAdapters.cs b/src/core/Akka.Remote/Transport/TransportAdapters.cs index e309b96805b..ebf4565397a 100644 --- a/src/core/Akka.Remote/Transport/TransportAdapters.cs +++ b/src/core/Akka.Remote/Transport/TransportAdapters.cs @@ -561,7 +561,7 @@ internal abstract class ActorTransportAdapterManager : UntypedActor /// /// Lightweight Stash implementation /// - protected Queue DelayedEvents = new Queue(); + protected Queue DelayedEvents = new(); /// /// TBD diff --git a/src/core/Akka.Streams.TestKit/PublisherFluentBuilder.cs b/src/core/Akka.Streams.TestKit/PublisherFluentBuilder.cs index ca473b97ae9..59d228a3dae 100644 --- a/src/core/Akka.Streams.TestKit/PublisherFluentBuilder.cs +++ b/src/core/Akka.Streams.TestKit/PublisherFluentBuilder.cs @@ -19,7 +19,7 @@ namespace Akka.Streams.TestKit { public class PublisherFluentBuilder { - private readonly List> _tasks = new List>(); + private readonly List> _tasks = new(); private bool _executed; internal PublisherFluentBuilder(ManualProbe probe) diff --git a/src/core/Akka.Streams.TestKit/SubscriberFluentBuilder.cs b/src/core/Akka.Streams.TestKit/SubscriberFluentBuilder.cs index 7c8a1bc9090..e2674e6771d 100644 --- a/src/core/Akka.Streams.TestKit/SubscriberFluentBuilder.cs +++ b/src/core/Akka.Streams.TestKit/SubscriberFluentBuilder.cs @@ -307,7 +307,7 @@ await ExecuteAsync(cancellationToken: cancellationToken) #endregion - private readonly List> _tasks = new List>(); + private readonly List> _tasks = new(); private bool _executed; internal SubscriberFluentBuilder(ManualProbe probe) diff --git a/src/core/Akka.Streams.TestKit/TestGraphStage.cs b/src/core/Akka.Streams.TestKit/TestGraphStage.cs index 9d5badbe4fe..e2725552dcc 100644 --- a/src/core/Akka.Streams.TestKit/TestGraphStage.cs +++ b/src/core/Akka.Streams.TestKit/TestGraphStage.cs @@ -17,14 +17,14 @@ public static class GraphStageMessages { public class Push : INoSerializationVerificationNeeded { - public static Push Instance { get; } = new Push(); + public static Push Instance { get; } = new(); private Push() { } } public class UpstreamFinish : INoSerializationVerificationNeeded { - public static UpstreamFinish Instance { get; } = new UpstreamFinish(); + public static UpstreamFinish Instance { get; } = new(); private UpstreamFinish() { } } @@ -41,14 +41,14 @@ public Failure(Exception ex) public class Pull : INoSerializationVerificationNeeded { - public static Pull Instance { get; } = new Pull(); + public static Pull Instance { get; } = new(); private Pull() { } } public class DownstreamFinish : INoSerializationVerificationNeeded { - public static DownstreamFinish Instance { get; } = new DownstreamFinish(); + public static DownstreamFinish Instance { get; } = new(); private DownstreamFinish() { } } @@ -56,10 +56,9 @@ private DownstreamFinish() { } public sealed class TestSinkStage : GraphStageWithMaterializedValue, TMat> { - public static TestSinkStage Create(GraphStageWithMaterializedValue, TMat> stageUnderTest, - TestProbe probe) => new TestSinkStage(stageUnderTest, probe); + public static TestSinkStage Create(GraphStageWithMaterializedValue, TMat> stageUnderTest, TestProbe probe) => new(stageUnderTest, probe); - private readonly Inlet _in = new Inlet("testSinkStage.in"); + private readonly Inlet _in = new("testSinkStage.in"); private readonly GraphStageWithMaterializedValue, TMat> _stageUnderTest; private readonly TestProbe _probe; @@ -102,7 +101,7 @@ public sealed class TestSourceStage : GraphStageWithMaterializedValue Create(GraphStageWithMaterializedValue, TMat> stageUnderTest, TestProbe probe) => Source.FromGraph(new TestSourceStage(stageUnderTest, probe)); - private readonly Outlet _out = new Outlet("testSourceStage.out"); + private readonly Outlet _out = new("testSourceStage.out"); private readonly GraphStageWithMaterializedValue, TMat> _stageUnderTest; private readonly TestProbe _probe; diff --git a/src/core/Akka.Streams.TestKit/TestPublisher.cs b/src/core/Akka.Streams.TestKit/TestPublisher.cs index a77e26d93f6..e20492ef11a 100644 --- a/src/core/Akka.Streams.TestKit/TestPublisher.cs +++ b/src/core/Akka.Streams.TestKit/TestPublisher.cs @@ -364,10 +364,8 @@ public void Subscribe(ISubscriber subscriber) /// /// Probe that implements Reactive.Streams.IPublisher{T} interface. /// - public static ManualProbe CreateManualPublisherProbe(this TestKitBase testKit, bool autoOnSubscribe = true) - => new ManualProbe(testKit, autoOnSubscribe); + public static ManualProbe CreateManualPublisherProbe(this TestKitBase testKit, bool autoOnSubscribe = true) => new(testKit, autoOnSubscribe); - public static Probe CreatePublisherProbe(this TestKitBase testKit, long initialPendingRequests = 0L) - => new Probe(testKit, initialPendingRequests); + public static Probe CreatePublisherProbe(this TestKitBase testKit, long initialPendingRequests = 0L) => new(testKit, initialPendingRequests); } } diff --git a/src/core/Akka.Streams.TestKit/TestPublisher_Fluent.cs b/src/core/Akka.Streams.TestKit/TestPublisher_Fluent.cs index 1d919528591..a5d91de9678 100644 --- a/src/core/Akka.Streams.TestKit/TestPublisher_Fluent.cs +++ b/src/core/Akka.Streams.TestKit/TestPublisher_Fluent.cs @@ -29,8 +29,7 @@ public partial class ManualProbe /// after another before executing its own code. /// /// - public PublisherFluentBuilder AsyncBuilder() - => new PublisherFluentBuilder(this); + public PublisherFluentBuilder AsyncBuilder() => new(this); /// /// Fluent DSL diff --git a/src/core/Akka.Streams.TestKit/TestSubscriber.cs b/src/core/Akka.Streams.TestKit/TestSubscriber.cs index 53dd87a5f6c..87840deeb15 100644 --- a/src/core/Akka.Streams.TestKit/TestSubscriber.cs +++ b/src/core/Akka.Streams.TestKit/TestSubscriber.cs @@ -65,7 +65,7 @@ public override int GetHashCode() public sealed class OnComplete: ISubscriberEvent { - public static readonly OnComplete Instance = new OnComplete(); + public static readonly OnComplete Instance = new(); private OnComplete() { } public override string ToString() => "TestSubscriber.OnComplete"; diff --git a/src/core/Akka.Streams.TestKit/TestSubscriber_Fluent.cs b/src/core/Akka.Streams.TestKit/TestSubscriber_Fluent.cs index 4b94e145800..6ab2e1b582c 100644 --- a/src/core/Akka.Streams.TestKit/TestSubscriber_Fluent.cs +++ b/src/core/Akka.Streams.TestKit/TestSubscriber_Fluent.cs @@ -28,8 +28,7 @@ public partial class ManualProbe /// after another before executing its own code. /// /// - public SubscriberFluentBuilder AsyncBuilder() - => new SubscriberFluentBuilder(this); + public SubscriberFluentBuilder AsyncBuilder() => new(this); /// /// Fluent DSL. Expect and return (any of: , , or ). diff --git a/src/core/Akka.Streams.Tests.Performance/FusedGraphsBenchmark.cs b/src/core/Akka.Streams.Tests.Performance/FusedGraphsBenchmark.cs index 3faab2c542f..e0709127670 100644 --- a/src/core/Akka.Streams.Tests.Performance/FusedGraphsBenchmark.cs +++ b/src/core/Akka.Streams.Tests.Performance/FusedGraphsBenchmark.cs @@ -60,7 +60,7 @@ public TestSource(MutableElement[] elements) Shape = new SourceShape(Out); } - private Outlet Out { get; } = new Outlet("TestSource.out"); + private Outlet Out { get; } = new("TestSource.out"); public override SourceShape Shape { get; } @@ -104,7 +104,7 @@ public CompletionLatch() Shape = new SinkShape(In); } - private Inlet In { get; } = new Inlet("CompletionLatch.in"); + private Inlet In { get; } = new("CompletionLatch.in"); public override SinkShape Shape { get; } public override ILogicAndMaterializedValue CreateLogicAndMaterializedValue(Attributes inheritedAttributes) @@ -131,9 +131,9 @@ public IdentityStage() Shape = new FlowShape(In, Out); } - private Outlet Out { get; } = new Outlet("IdentityStage.out"); + private Outlet Out { get; } = new("IdentityStage.out"); - private Inlet In { get; } = new Inlet("IdentityStage.in"); + private Inlet In { get; } = new("IdentityStage.in"); public override FlowShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests.Performance/InterpreterBenchmark.cs b/src/core/Akka.Streams.Tests.Performance/InterpreterBenchmark.cs index d36a60f7c67..ad4e3a5cfeb 100644 --- a/src/core/Akka.Streams.Tests.Performance/InterpreterBenchmark.cs +++ b/src/core/Akka.Streams.Tests.Performance/InterpreterBenchmark.cs @@ -105,7 +105,7 @@ public GraphDataSource(string toString, T[] data) private sealed class GraphDataSink : GraphInterpreter.DownstreamBoundaryStageLogic { - private readonly Inlet _inlet = new Inlet("in"); + private readonly Inlet _inlet = new("in"); private readonly string _toString; public GraphDataSink(string toString, int expected) diff --git a/src/core/Akka.Streams.Tests.TCK/ActorPublisherTest.cs b/src/core/Akka.Streams.Tests.TCK/ActorPublisherTest.cs index 680b846adc9..2c670da76e0 100644 --- a/src/core/Akka.Streams.Tests.TCK/ActorPublisherTest.cs +++ b/src/core/Akka.Streams.Tests.TCK/ActorPublisherTest.cs @@ -27,7 +27,7 @@ private sealed class TestPublisher : ActorPublisher { private sealed class Produce { - public static Produce Instance { get; } = new Produce(); + public static Produce Instance { get; } = new(); private Produce() { @@ -37,7 +37,7 @@ private Produce() private sealed class Loop { - public static Loop Instance { get; } = new Loop(); + public static Loop Instance { get; } = new(); private Loop() { @@ -47,7 +47,7 @@ private Loop() private sealed class Complete { - public static Complete Instance { get; } = new Complete(); + public static Complete Instance { get; } = new(); private Complete() { diff --git a/src/core/Akka.Streams.Tests.TCK/FilePublisherTest.cs b/src/core/Akka.Streams.Tests.TCK/FilePublisherTest.cs index 3664c5ebd3b..792666dba5c 100644 --- a/src/core/Akka.Streams.Tests.TCK/FilePublisherTest.cs +++ b/src/core/Akka.Streams.Tests.TCK/FilePublisherTest.cs @@ -22,7 +22,7 @@ class FilePublisherTest : AkkaPublisherVerification private const int Elements = 1000; private static int _counter; - private readonly List _files = new List(); + private readonly List _files = new(); public FilePublisherTest() : base(Utils.UnboundedMailboxConfig.WithFallback(AkkaSpec.AkkaSpecConfig)) { diff --git a/src/core/Akka.Streams.Tests.TCK/SinkholeSubscriberTest.cs b/src/core/Akka.Streams.Tests.TCK/SinkholeSubscriberTest.cs index 5088b819218..f6f3c226100 100644 --- a/src/core/Akka.Streams.Tests.TCK/SinkholeSubscriberTest.cs +++ b/src/core/Akka.Streams.Tests.TCK/SinkholeSubscriberTest.cs @@ -26,7 +26,7 @@ public SinkholeSubscriberTest() : base(new TestEnvironment()) private sealed class Subscriber : ISubscriber { - private readonly SinkholeSubscriber _hole = new SinkholeSubscriber(new TaskCompletionSource()); + private readonly SinkholeSubscriber _hole = new(new TaskCompletionSource()); private readonly WhiteboxSubscriberProbe _probe; public Subscriber(WhiteboxSubscriberProbe probe) diff --git a/src/core/Akka.Streams.Tests/Actor/ActorPublisherSpec.cs b/src/core/Akka.Streams.Tests/Actor/ActorPublisherSpec.cs index 38b5f75fa41..d7159b6723e 100644 --- a/src/core/Akka.Streams.Tests/Actor/ActorPublisherSpec.cs +++ b/src/core/Akka.Streams.Tests/Actor/ActorPublisherSpec.cs @@ -771,28 +771,28 @@ public ErrThenStop(string reason) internal class Boom { - public static Boom Instance { get; } = new Boom(); + public static Boom Instance { get; } = new(); private Boom() { } } internal class Complete { - public static Complete Instance { get; } = new Complete(); + public static Complete Instance { get; } = new(); private Complete() { } } internal class CompleteThenStop { - public static CompleteThenStop Instance { get; } = new CompleteThenStop(); + public static CompleteThenStop Instance { get; } = new(); private CompleteThenStop() { } } internal class ThreadName { - public static ThreadName Instance { get; } = new ThreadName(); + public static ThreadName Instance { get; } = new(); private ThreadName() { } } diff --git a/src/core/Akka.Streams.Tests/Actor/ActorSubscriberSpec.cs b/src/core/Akka.Streams.Tests/Actor/ActorSubscriberSpec.cs index 70c82d81b0c..e203714ac48 100644 --- a/src/core/Akka.Streams.Tests/Actor/ActorSubscriberSpec.cs +++ b/src/core/Akka.Streams.Tests/Actor/ActorSubscriberSpec.cs @@ -362,7 +362,7 @@ public InFlightStrategy(Streamer streamer) : base(10) public override int InFlight => _streamer._queue.Count; } - private readonly Dictionary _queue = new Dictionary(); + private readonly Dictionary _queue = new(); private readonly Router _router; public Streamer() diff --git a/src/core/Akka.Streams.Tests/Dsl/ActorRefBackpressureSinkSpec.cs b/src/core/Akka.Streams.Tests/Dsl/ActorRefBackpressureSinkSpec.cs index a5f56964234..a3fe45c4fc5 100644 --- a/src/core/Akka.Streams.Tests/Dsl/ActorRefBackpressureSinkSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/ActorRefBackpressureSinkSpec.cs @@ -26,7 +26,7 @@ public class ActorRefBackpressureSinkSpec : AkkaSpec private sealed class TriggerAckMessage { - public static readonly TriggerAckMessage Instance = new TriggerAckMessage(); + public static readonly TriggerAckMessage Instance = new(); private TriggerAckMessage() { } } diff --git a/src/core/Akka.Streams.Tests/Dsl/AttributesSpec.cs b/src/core/Akka.Streams.Tests/Dsl/AttributesSpec.cs index f4955110adc..e45143a254a 100644 --- a/src/core/Akka.Streams.Tests/Dsl/AttributesSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/AttributesSpec.cs @@ -68,7 +68,7 @@ public void Attributes_must_give_access_to_attribute_by_type() private sealed class AttributesSink : SinkModule> { public static Sink> Create() => - new Sink>(new AttributesSink( + new(new AttributesSink( Attributes.CreateName("attributesSink"), new SinkShape(new Inlet("attributesSink")))); diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowCollectSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowCollectSpec.cs index 0e22998d5ac..46f36ef70cc 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowCollectSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowCollectSpec.cs @@ -20,7 +20,7 @@ namespace Akka.Streams.Tests.Dsl { public class FlowCollectSpec : ScriptedTest { - private Random Random { get; } = new Random(12345); + private Random Random { get; } = new(12345); private ActorMaterializer Materializer { get; } public FlowCollectSpec(ITestOutputHelper helper) : base(helper) diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowConcatAllSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowConcatAllSpec.cs index 86583c6db30..ff5f4817374 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowConcatAllSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowConcatAllSpec.cs @@ -30,7 +30,7 @@ public FlowConcatAllSpec(ITestOutputHelper helper) : base(helper) Materializer = ActorMaterializer.Create(Sys, settings); } - private static readonly TestException TestException = new TestException("test"); + private static readonly TestException TestException = new("test"); [Fact] public async Task ConcatAll_must_work_in_the_happy_case() diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowFlattenMergeSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowFlattenMergeSpec.cs index 8cbcf9fd414..df832849efb 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowFlattenMergeSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowFlattenMergeSpec.cs @@ -315,7 +315,7 @@ public AttributesSourceStage() Shape = new SourceShape(Out); } - private Outlet Out { get; } = new Outlet("AttributesSource.out"); + private Outlet Out { get; } = new("AttributesSource.out"); public override SourceShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowGroupBySpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowGroupBySpec.cs index 1422d3f8dff..8cc3bf43a1e 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowGroupBySpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowGroupBySpec.cs @@ -818,8 +818,7 @@ private sealed class RandomDemandProperties public int ProbesReaderTop { get; set; } - public List>> Probes { get; } = - new List>>(100); + public List>> Probes { get; } = new(100); public ByteString BlockingNextElement { get; set; } } diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowGroupedSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowGroupedSpec.cs index 00815855257..5edd2113f0b 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowGroupedSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowGroupedSpec.cs @@ -28,7 +28,7 @@ public FlowGroupedSpec(ITestOutputHelper output = null) : base(output) Settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16); } - private readonly Random _random = new Random(12345); + private readonly Random _random = new(12345); private ICollection RandomSeq(int n) => Enumerable.Range(1, n).Select(_ => _random.Next()).ToList(); private (ICollection, ICollection>) RandomTest(int n) diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowPrefixAndTailSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowPrefixAndTailSpec.cs index 2158f266b87..2086be24e7d 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowPrefixAndTailSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowPrefixAndTailSpec.cs @@ -31,7 +31,7 @@ public FlowPrefixAndTailSpec(ITestOutputHelper helper) : base(helper) Materializer = ActorMaterializer.Create(Sys, settings); } - private static readonly TestException TestException = new TestException("test"); + private static readonly TestException TestException = new("test"); private static Sink<(IImmutableList, Source), Task<(IImmutableList, Source)>> diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowRecoverSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowRecoverSpec.cs index 7025a8d49c7..d7da80c4333 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowRecoverSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowRecoverSpec.cs @@ -29,7 +29,7 @@ public FlowRecoverSpec(ITestOutputHelper helper) : base(helper) Materializer = ActorMaterializer.Create(Sys, settings); } - private static readonly TestException Ex = new TestException("test"); + private static readonly TestException Ex = new("test"); [Fact] public async Task A_Recover_must_recover_when_there_is_a_handler() diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowRecoverWithSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowRecoverWithSpec.cs index f8afdc2483b..7a20207d1ed 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowRecoverWithSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowRecoverWithSpec.cs @@ -29,7 +29,7 @@ public FlowRecoverWithSpec(ITestOutputHelper helper) : base(helper) Materializer = ActorMaterializer.Create(Sys, settings); } - private static readonly TestException Ex = new TestException("test"); + private static readonly TestException Ex = new("test"); [Fact] public async Task A_RecoverWith_must_recover_when_there_is_a_handler() diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowSelectErrorSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowSelectErrorSpec.cs index a7fae790ec7..0a8934f16d7 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowSelectErrorSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowSelectErrorSpec.cs @@ -19,8 +19,8 @@ namespace Akka.Streams.Tests.Dsl // JVM - FlowMapErrorSpec public class FlowSelectErrorSpec : AkkaSpec { - private static readonly Exception Exception = new Exception("ex"); - private static readonly Exception Boom = new Exception("BOOM!"); + private static readonly Exception Exception = new("ex"); + private static readonly Exception Boom = new("BOOM!"); public FlowSelectErrorSpec() { diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowSupervisionSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowSupervisionSpec.cs index e5755c1f425..1c121a99e64 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowSupervisionSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowSupervisionSpec.cs @@ -20,7 +20,7 @@ namespace Akka.Streams.Tests.Dsl { public class FlowSupervisionSpec : AkkaSpec { - private static readonly Exception Exception = new Exception("simulated exception"); + private static readonly Exception Exception = new("simulated exception"); private static Flow FailingMap => Flow.Create().Select(n => { if (n == 3) diff --git a/src/core/Akka.Streams.Tests/Dsl/FlowWithContextSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FlowWithContextSpec.cs index d00dc41e1c8..2e58dc86b61 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FlowWithContextSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FlowWithContextSpec.cs @@ -70,7 +70,7 @@ public Message(string data, long offset) Offset = offset; } - public Message Copy(string data = null, long? offset = null) => new Message(data ?? Data, offset ?? Offset); + public Message Copy(string data = null, long? offset = null) => new(data ?? Data, offset ?? Offset); public bool Equals(Message other) { diff --git a/src/core/Akka.Streams.Tests/Dsl/FramingSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FramingSpec.cs index 3de65bd6535..0162713889e 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FramingSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FramingSpec.cs @@ -218,13 +218,13 @@ private static string RandomString(int length) private static readonly ByteString ReferenceChunk = ByteString.FromString(RandomString(0x100001)); - private static readonly List ByteOrders = new List + private static readonly List ByteOrders = new() { ByteOrder.BigEndian, ByteOrder.LittleEndian }; - private static readonly List FrameLengths = new List + private static readonly List FrameLengths = new() { 0, 1, @@ -241,9 +241,9 @@ private static string RandomString(int length) 0x10001 }; - private static readonly List FieldLengths = new List {1, 2, 3, 4}; + private static readonly List FieldLengths = new() {1, 2, 3, 4}; - private static readonly List FieldOffsets = new List {0, 1, 2, 3, 15, 16, 31, 32, 44, 107}; + private static readonly List FieldOffsets = new() {0, 1, 2, 3, 15, 16, 31, 32, 44, 107}; private static ByteString Encode(ByteString payload, int fieldOffset, int fieldLength, ByteOrder byteOrder) => EncodeComplexFrame(payload, fieldLength, byteOrder, ByteString.FromBytes(new byte[fieldOffset]), ByteString.Empty); diff --git a/src/core/Akka.Streams.Tests/Dsl/FutureFlattenSourceSpec.cs b/src/core/Akka.Streams.Tests/Dsl/FutureFlattenSourceSpec.cs index a38bd8826dc..5fedd9085db 100644 --- a/src/core/Akka.Streams.Tests/Dsl/FutureFlattenSourceSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/FutureFlattenSourceSpec.cs @@ -272,11 +272,11 @@ await this.AssertAllStagesStoppedAsync(async () => private class FailingMatGraphStage : GraphStageWithMaterializedValue, string> { - public static readonly TestException Exception = new TestException("INNER_FAILED"); + public static readonly TestException Exception = new("INNER_FAILED"); - private readonly Outlet _out = new Outlet("whatever"); + private readonly Outlet _out = new("whatever"); - public override SourceShape Shape => new SourceShape(_out); + public override SourceShape Shape => new(_out); public override ILogicAndMaterializedValue CreateLogicAndMaterializedValue(Attributes inheritedAttributes) => throw Exception; diff --git a/src/core/Akka.Streams.Tests/Dsl/GraphStageTimersSpec.cs b/src/core/Akka.Streams.Tests/Dsl/GraphStageTimersSpec.cs index 04396efdf17..94921f412e4 100644 --- a/src/core/Akka.Streams.Tests/Dsl/GraphStageTimersSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/GraphStageTimersSpec.cs @@ -142,7 +142,7 @@ await this.AssertAllStagesStoppedAsync(() => { private sealed class TestSingleTimer { - public static readonly TestSingleTimer Instance = new TestSingleTimer(); + public static readonly TestSingleTimer Instance = new(); private TestSingleTimer() { @@ -152,7 +152,7 @@ private TestSingleTimer() private sealed class TestSingleTimerResubmit { - public static readonly TestSingleTimerResubmit Instance = new TestSingleTimerResubmit(); + public static readonly TestSingleTimerResubmit Instance = new(); private TestSingleTimerResubmit() { @@ -162,7 +162,7 @@ private TestSingleTimerResubmit() private sealed class TestCancelTimer { - public static readonly TestCancelTimer Instance = new TestCancelTimer(); + public static readonly TestCancelTimer Instance = new(); private TestCancelTimer() { @@ -172,7 +172,7 @@ private TestCancelTimer() private sealed class TestCancelTimerAck { - public static readonly TestCancelTimerAck Instance = new TestCancelTimerAck(); + public static readonly TestCancelTimerAck Instance = new(); private TestCancelTimerAck() { @@ -182,7 +182,7 @@ private TestCancelTimerAck() private sealed class TestRepeatedTimer { - public static readonly TestRepeatedTimer Instance = new TestRepeatedTimer(); + public static readonly TestRepeatedTimer Instance = new(); private TestRepeatedTimer() { diff --git a/src/core/Akka.Streams.Tests/Dsl/GraphUnzipWithSpec.cs b/src/core/Akka.Streams.Tests/Dsl/GraphUnzipWithSpec.cs index 75a3c899e12..026a24a67fa 100644 --- a/src/core/Akka.Streams.Tests/Dsl/GraphUnzipWithSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/GraphUnzipWithSpec.cs @@ -324,7 +324,7 @@ await this.AssertAllStagesStoppedAsync(async() => { #region Test classes and helper - private static readonly TestException TestException = new TestException("test"); + private static readonly TestException TestException = new("test"); private static readonly Func Zipper = i => (i + i, i + "+" + i); diff --git a/src/core/Akka.Streams.Tests/Dsl/LazySourceSpec.cs b/src/core/Akka.Streams.Tests/Dsl/LazySourceSpec.cs index 0ec39f63b75..3bfba2123dc 100644 --- a/src/core/Akka.Streams.Tests/Dsl/LazySourceSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/LazySourceSpec.cs @@ -276,7 +276,7 @@ public AttibutesSourceStage() Shape = new SourceShape(Out); } - private Outlet Out { get; } = new Outlet("AttributesSource.out"); + private Outlet Out { get; } = new("AttributesSource.out"); public override SourceShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests/Dsl/QueueSourceSpec.cs b/src/core/Akka.Streams.Tests/Dsl/QueueSourceSpec.cs index 9cd8d92ae1d..665894a77e6 100644 --- a/src/core/Akka.Streams.Tests/Dsl/QueueSourceSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/QueueSourceSpec.cs @@ -473,7 +473,7 @@ public async Task QueueSource_should_complete_the_stream_when_no_buffer_is_used_ task.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue(); } - private static readonly Exception Ex = new Exception("BUH"); + private static readonly Exception Ex = new("BUH"); [Fact] public void QueueSource_should_fail_the_stream_when_buffer_is_empty() diff --git a/src/core/Akka.Streams.Tests/Dsl/StageActorRefSpec.cs b/src/core/Akka.Streams.Tests/Dsl/StageActorRefSpec.cs index 12e24e1f6b0..9f5385e5090 100644 --- a/src/core/Akka.Streams.Tests/Dsl/StageActorRefSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/StageActorRefSpec.cs @@ -213,22 +213,22 @@ public AddAndTell(int n) } private sealed class CallInitStageActorRef { - public static readonly CallInitStageActorRef Instance = new CallInitStageActorRef(); + public static readonly CallInitStageActorRef Instance = new(); private CallInitStageActorRef() { } } private sealed class BecomeStringEcho { - public static readonly BecomeStringEcho Instance = new BecomeStringEcho(); + public static readonly BecomeStringEcho Instance = new(); private BecomeStringEcho() { } } private sealed class PullNow { - public static readonly PullNow Instance = new PullNow(); + public static readonly PullNow Instance = new(); private PullNow() { } } private sealed class StopNow { - public static readonly StopNow Instance = new StopNow(); + public static readonly StopNow Instance = new(); private StopNow() { } } @@ -303,7 +303,7 @@ private void Behaviour((IActorRef, object) args) } #endregion - private readonly Inlet _inlet = new Inlet("IntSum.in"); + private readonly Inlet _inlet = new("IntSum.in"); public SumTestStage(IActorRef probe) { diff --git a/src/core/Akka.Streams.Tests/Dsl/UnfoldFlowSpec.cs b/src/core/Akka.Streams.Tests/Dsl/UnfoldFlowSpec.cs index bd870b26163..8df96044680 100644 --- a/src/core/Akka.Streams.Tests/Dsl/UnfoldFlowSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/UnfoldFlowSpec.cs @@ -31,7 +31,7 @@ public class UnfoldFlowSpec public class WithSimpleFlow : Akka.TestKit.Xunit2.TestKit { - private readonly Exception _done = new Exception("done"); + private readonly Exception _done = new("done"); private readonly Source, TestPublisher.Probe<(int, int)>)> _source; public WithSimpleFlow() diff --git a/src/core/Akka.Streams.Tests/Dsl/UnfoldResourceAsyncSourceSpec.cs b/src/core/Akka.Streams.Tests/Dsl/UnfoldResourceAsyncSourceSpec.cs index 897d8864dde..c2f4ad27aaa 100644 --- a/src/core/Akka.Streams.Tests/Dsl/UnfoldResourceAsyncSourceSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/UnfoldResourceAsyncSourceSpec.cs @@ -36,9 +36,9 @@ private class ResourceDummy private readonly Task _firstReadFuture; private readonly Task _closeFuture; - private readonly TaskCompletionSource _createdPromise = new TaskCompletionSource(); - private readonly TaskCompletionSource _closedPromise = new TaskCompletionSource(); - private readonly TaskCompletionSource _firstReadPromise = new TaskCompletionSource(); + private readonly TaskCompletionSource _createdPromise = new(); + private readonly TaskCompletionSource _closedPromise = new(); + private readonly TaskCompletionSource _firstReadPromise = new(); // these can be used to observe when the resource calls has happened public Task Created => _createdPromise.Task; diff --git a/src/core/Akka.Streams.Tests/Dsl/WithContextUsageSpec.cs b/src/core/Akka.Streams.Tests/Dsl/WithContextUsageSpec.cs index 0f79912ca55..044a6507411 100644 --- a/src/core/Akka.Streams.Tests/Dsl/WithContextUsageSpec.cs +++ b/src/core/Akka.Streams.Tests/Dsl/WithContextUsageSpec.cs @@ -243,7 +243,7 @@ private static SourceWithContext CreateSourceWithContex sealed class Offset : IEquatable { - public static readonly Offset Uninitialized = new Offset(-1); + public static readonly Offset Uninitialized = new(-1); public int Value { get; } public Offset(int value) diff --git a/src/core/Akka.Streams.Tests/IO/FileSourceSpec.cs b/src/core/Akka.Streams.Tests/IO/FileSourceSpec.cs index 7e228ea8a6e..7ddf04f59dd 100644 --- a/src/core/Akka.Streams.Tests/IO/FileSourceSpec.cs +++ b/src/core/Akka.Streams.Tests/IO/FileSourceSpec.cs @@ -31,7 +31,7 @@ public class FileSourceSpec : AkkaSpec { private readonly string _testText; private readonly ActorMaterializer _materializer; - private readonly FileInfo _testFilePath = new FileInfo(Path.Combine(Path.GetTempPath(), "file-source-spec.tmp")); + private readonly FileInfo _testFilePath = new(Path.Combine(Path.GetTempPath(), "file-source-spec.tmp")); private FileInfo _manyLinesPath; public FileSourceSpec(ITestOutputHelper helper) : base(Utils.UnboundedMailboxConfig, helper) diff --git a/src/core/Akka.Streams.Tests/IO/TcpHelper.cs b/src/core/Akka.Streams.Tests/IO/TcpHelper.cs index 590b6eade44..a43ecaf34c6 100644 --- a/src/core/Akka.Streams.Tests/IO/TcpHelper.cs +++ b/src/core/Akka.Streams.Tests/IO/TcpHelper.cs @@ -93,7 +93,7 @@ public PingClose(IActorRef requester) protected sealed class WriteAck : Tcp.Event { - public static WriteAck Instance { get; } = new WriteAck(); + public static WriteAck Instance { get; } = new(); private WriteAck() { } } @@ -108,7 +108,7 @@ protected static Props TestServerProps(EndPoint address, IActorRef probe) protected class TestClient : UntypedActor { private readonly IActorRef _connection; - private readonly Queue _queuedWrites = new Queue(); + private readonly Queue _queuedWrites = new(); private bool _writePending; private int _toRead; private ByteString _readBuffer = ByteString.Empty; @@ -191,7 +191,7 @@ protected override void OnReceive(object message) protected sealed class ServerClose { - public static ServerClose Instance { get; } = new ServerClose(); + public static ServerClose Instance { get; } = new(); private ServerClose() { } } diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/ChasingEventsSpec.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/ChasingEventsSpec.cs index 5464b48ccdb..743c84d71a7 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/ChasingEventsSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/ChasingEventsSpec.cs @@ -88,9 +88,9 @@ public CancelInChasePull() Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("Propagate.in"); + public Inlet In { get; } = new("Propagate.in"); - public Outlet Out { get; } = new Outlet("Propagate.out"); + public Outlet Out { get; } = new("Propagate.out"); public override FlowShape Shape { get; } @@ -117,9 +117,9 @@ public CompleteInChasePush() Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("Propagate.in"); + public Inlet In { get; } = new("Propagate.in"); - public Outlet Out { get; } = new Outlet("Propagate.out"); + public Outlet Out { get; } = new("Propagate.out"); public override FlowShape Shape { get; } @@ -146,9 +146,9 @@ public FailureInChasedPush() Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("Propagate.in"); + public Inlet In { get; } = new("Propagate.in"); - public Outlet Out { get; } = new Outlet("Propagate.out"); + public Outlet Out { get; } = new("Propagate.out"); public override FlowShape Shape { get; } @@ -175,7 +175,7 @@ public ChasableSink() Shape = new SinkShape(In); } - public Inlet In { get; } = new Inlet("Chaseable.in"); + public Inlet In { get; } = new("Chaseable.in"); public override SinkShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/GraphInterpreterSpecKit.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/GraphInterpreterSpecKit.cs index 9b197f817fb..2c9ba4975df 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/GraphInterpreterSpecKit.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/GraphInterpreterSpecKit.cs @@ -381,9 +381,9 @@ public ISet LastEvents() public void ClearEvents() => LastEvent = new HashSet(); - public UpstreamProbe NewUpstreamProbe(string name) => new UpstreamProbe(this, name); + public UpstreamProbe NewUpstreamProbe(string name) => new(this, name); - public DownstreamProbe NewDownstreamProbe(string name) => new DownstreamProbe(this, name); + public DownstreamProbe NewDownstreamProbe(string name) => new(this, name); public class UpstreamProbe : GraphInterpreter.UpstreamBoundaryStageLogic { @@ -526,9 +526,9 @@ public Logic(EventPropagateStage stage) :base(stage.Shape) public EventPropagateStage() => Shape = new FlowShape(In, Out); - public Inlet In { get; } = new Inlet("Propagate.in"); + public Inlet In { get; } = new("Propagate.in"); - public Outlet Out { get; } = new Outlet("Propagate.out"); + public Outlet Out { get; } = new("Propagate.out"); public override FlowShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSpec.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSpec.cs index effae9ceb4b..1874b95496d 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSpec.cs @@ -35,8 +35,8 @@ public InterpreterSpec(ITestOutputHelper output = null) : base(output) { } - private static readonly Take TakeOne = new Take(1); - private static readonly Take TakeTwo = new Take(2); + private static readonly Take TakeOne = new(1); + private static readonly Take TakeTwo = new(2); [Fact] public void Interpreter_should_implement_map_correctly() diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterStressSpec.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterStressSpec.cs index 9e60d28955f..d59fe182e57 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterStressSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterStressSpec.cs @@ -30,10 +30,10 @@ public class InterpreterStressSpec : GraphInterpreterSpecKit private readonly ITestOutputHelper _helper; // GraphStages can be reused - private static readonly Select Select = new Select(x => x + 1); - private static readonly Skip SkipOne = new Skip(1); - private static readonly Take TakeOne = new Take(1); - private static readonly Take TakeHalfOfRepetition = new Take(Repetition/2); + private static readonly Select Select = new(x => x + 1); + private static readonly Skip SkipOne = new(1); + private static readonly Take TakeOne = new(1); + private static readonly Take TakeHalfOfRepetition = new(Repetition/2); public InterpreterStressSpec(ITestOutputHelper helper = null) : base(helper) { diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSupervisionSpec.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSupervisionSpec.cs index cad69a1b8bd..77f1eb107b6 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSupervisionSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/InterpreterSupervisionSpec.cs @@ -33,8 +33,7 @@ public InterpreterSupervisionSpec(ITestOutputHelper output = null) : base(output { } - private ResumeSelect ResumingSelect(Func func) - => new ResumeSelect(func); + private ResumeSelect ResumingSelect(Func func) => new(func); private sealed class ResumeSelect : GraphStage> { @@ -79,9 +78,9 @@ public ResumeSelect(Func func) protected override Attributes InitialAttributes { get; } = DefaultAttributes.Select; - public Inlet In { get; } = new Inlet("Select.in"); + public Inlet In { get; } = new("Select.in"); - public Outlet Out { get; } = new Outlet("Select.out"); + public Outlet Out { get; } = new("Select.out"); public override FlowShape Shape { get; } diff --git a/src/core/Akka.Streams.Tests/Implementation/Fusing/KeepGoingStageSpec.cs b/src/core/Akka.Streams.Tests/Implementation/Fusing/KeepGoingStageSpec.cs index eb48673d9cf..5e987277377 100644 --- a/src/core/Akka.Streams.Tests/Implementation/Fusing/KeepGoingStageSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/Fusing/KeepGoingStageSpec.cs @@ -35,28 +35,28 @@ public Register(IActorRef probe) private sealed class Ping : IPingCmd { - public static Ping Instance { get; } = new Ping(); + public static Ping Instance { get; } = new(); private Ping() { } } private sealed class CompleteStage : IPingCmd { - public static CompleteStage Instance { get; } = new CompleteStage(); + public static CompleteStage Instance { get; } = new(); private CompleteStage() { } } private sealed class FailStage : IPingCmd { - public static FailStage Instance { get; } = new FailStage(); + public static FailStage Instance { get; } = new(); private FailStage() { } } private sealed class Throw : IPingCmd { - public static Throw Instance { get; } = new Throw(); + public static Throw Instance { get; } = new(); private Throw() { } } @@ -65,28 +65,28 @@ private interface IPingEvt { } private sealed class Pong : IPingEvt { - public static Pong Instance { get; } = new Pong(); + public static Pong Instance { get; } = new(); private Pong() { } } private sealed class PostStop : IPingEvt { - public static PostStop Instance { get; } = new PostStop(); + public static PostStop Instance { get; } = new(); private PostStop() { } } private sealed class UpstreamCompleted : IPingEvt { - public static UpstreamCompleted Instance { get; } = new UpstreamCompleted(); + public static UpstreamCompleted Instance { get; } = new(); private UpstreamCompleted() { } } private sealed class EndOfEventHandler : IPingEvt { - public static EndOfEventHandler Instance { get; } = new EndOfEventHandler(); + public static EndOfEventHandler Instance { get; } = new(); private EndOfEventHandler() { } } @@ -177,14 +177,14 @@ private void OnCommand(IPingCmd cmd) #endregion - private readonly TaskCompletionSource _promise = new TaskCompletionSource(); + private readonly TaskCompletionSource _promise = new(); public PingableSink(bool keepAlive) { _keepAlive = keepAlive; } - public override SinkShape Shape { get; } = new SinkShape(new Inlet("ping.in")); + public override SinkShape Shape { get; } = new(new Inlet("ping.in")); public override ILogicAndMaterializedValue> CreateLogicAndMaterializedValue(Attributes inheritedAttributes) { diff --git a/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs b/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs index b41137f7248..ed23ca7efad 100644 --- a/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/GraphStageLogicSpec.cs @@ -50,8 +50,8 @@ public override void PreStart() #endregion - private readonly Inlet _in = new Inlet("in"); - private readonly Outlet _out = new Outlet("out"); + private readonly Inlet _in = new("in"); + private readonly Outlet _out = new("out"); public Emit1234() { @@ -83,8 +83,8 @@ public Emit5678Logic(Emit5678 emit) : base(emit.Shape) #endregion - private readonly Inlet _in = new Inlet("in"); - private readonly Outlet _out = new Outlet("out"); + private readonly Inlet _in = new("in"); + private readonly Outlet _out = new("out"); public Emit5678() { @@ -112,9 +112,9 @@ public PassThroughLogic(PassThrough emit) : base(emit.Shape) #endregion - public Inlet In { get; } = new Inlet("in"); + public Inlet In { get; } = new("in"); - public Outlet Out { get; } = new Outlet("out"); + public Outlet Out { get; } = new("out"); public PassThrough() { @@ -140,7 +140,7 @@ public EmitEmptyIterableLogic(EmitEmptyIterable emit) : base(emit.Shape) #endregion - private readonly Outlet _out = new Outlet("out"); + private readonly Outlet _out = new("out"); public EmitEmptyIterable() { @@ -184,8 +184,7 @@ public ReadNEmitN(int n) _n = n; } - public override FlowShape Shape { get; } = new FlowShape(new Inlet("readN.in"), - new Outlet("readN.out")); + public override FlowShape Shape { get; } = new(new Inlet("readN.in"), new Outlet("readN.out")); protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) => new ReadNEmitNLogic(this); } @@ -222,7 +221,7 @@ public ReadNEmitRestOnComplete(int n) _n = n; } - public override FlowShape Shape { get; } = new FlowShape(new Inlet("readN.in"), + public override FlowShape Shape { get; } = new(new Inlet("readN.in"), new Outlet("readN.out")); protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) @@ -257,7 +256,7 @@ public RandomLettersSource() Shape = new SourceShape(Out); } - private Outlet Out { get; } = new Outlet("RandomLettersSource.out"); + private Outlet Out { get; } = new("RandomLettersSource.out"); public override SourceShape Shape { get; } @@ -464,8 +463,8 @@ public override void PostStop() #endregion - private readonly Inlet _in = new Inlet("in"); - private readonly Outlet _out = new Outlet("out"); + private readonly Inlet _in = new("in"); + private readonly Outlet _out = new("out"); private readonly IActorRef _testActor; public LifecycleStage(IActorRef testActor) @@ -533,8 +532,8 @@ public DoubleTerminateStage(IActorRef testActor) } public override FlowShape Shape { get; } - public Inlet In { get; } = new Inlet("in"); - public Outlet Out { get; } = new Outlet("out"); + public Inlet In { get; } = new("in"); + public Outlet Out { get; } = new("out"); protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) => new DoubleTerminateLogic(this, _testActor); diff --git a/src/core/Akka.Streams.Tests/Implementation/StreamLayoutSpec.cs b/src/core/Akka.Streams.Tests/Implementation/StreamLayoutSpec.cs index 42dd9c602a7..3097fed8f99 100644 --- a/src/core/Akka.Streams.Tests/Implementation/StreamLayoutSpec.cs +++ b/src/core/Akka.Streams.Tests/Implementation/StreamLayoutSpec.cs @@ -144,9 +144,9 @@ protected override object MaterializeAtomic(AtomicModule atomic, Attributes effe private static readonly TimeSpan VeryPatient = TimeSpan.FromSeconds(20); private readonly IMaterializer _materializer; - private static TestAtomicModule TestStage() => new TestAtomicModule(1, 1); - private static TestAtomicModule TestSource() => new TestAtomicModule(0, 1); - private static TestAtomicModule TestSink() => new TestAtomicModule(1, 0); + private static TestAtomicModule TestStage() => new(1, 1); + private static TestAtomicModule TestSource() => new(0, 1); + private static TestAtomicModule TestSink() => new(1, 0); public StreamLayoutSpec(ITestOutputHelper output) : base(output: output) { diff --git a/src/core/Akka.Streams.Tests/ScriptedTest.cs b/src/core/Akka.Streams.Tests/ScriptedTest.cs index aa0a700e30b..414e26f7e36 100644 --- a/src/core/Akka.Streams.Tests/ScriptedTest.cs +++ b/src/core/Akka.Streams.Tests/ScriptedTest.cs @@ -142,7 +142,7 @@ protected class ScriptRunner : ChainSetup private readonly int _maximumRequests; private readonly int _maximumBuffer; - private readonly List _debugLog = new List(); + private readonly List _debugLog = new(); private Script _currentScript; private int _remainingDemand; diff --git a/src/core/Akka.Streams/Actors/ActorPublisher.cs b/src/core/Akka.Streams/Actors/ActorPublisher.cs index 41e5cba5a91..c9b0fde9d52 100644 --- a/src/core/Akka.Streams/Actors/ActorPublisher.cs +++ b/src/core/Akka.Streams/Actors/ActorPublisher.cs @@ -120,7 +120,7 @@ public sealed class Cancel : IActorPublisherMessage, INoSerializationVerificatio /// /// TBD /// - public static readonly Cancel Instance = new Cancel(); + public static readonly Cancel Instance = new(); private Cancel() { } } @@ -135,7 +135,7 @@ public sealed class SubscriptionTimeoutExceeded : IActorPublisherMessage, INoSer /// /// TBD /// - public static readonly SubscriptionTimeoutExceeded Instance = new SubscriptionTimeoutExceeded(); + public static readonly SubscriptionTimeoutExceeded Instance = new(); private SubscriptionTimeoutExceeded() { } } @@ -781,12 +781,12 @@ public State(IUntypedSubscriber subscriber, long demand, LifecycleState lifecycl } } - private readonly ConcurrentDictionary _state = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _state = new(); /// /// TBD /// - public static readonly ActorPublisherState Instance = new ActorPublisherState(); + public static readonly ActorPublisherState Instance = new(); private ActorPublisherState() { } @@ -823,6 +823,6 @@ public State Remove(IActorRef actorRef) /// /// TBD /// TBD - public override ActorPublisherState CreateExtension(ExtendedActorSystem system) => new ActorPublisherState(); + public override ActorPublisherState CreateExtension(ExtendedActorSystem system) => new(); } } diff --git a/src/core/Akka.Streams/Actors/ActorSubscriber.cs b/src/core/Akka.Streams/Actors/ActorSubscriber.cs index 4ab3b3737a0..69672af393b 100644 --- a/src/core/Akka.Streams/Actors/ActorSubscriber.cs +++ b/src/core/Akka.Streams/Actors/ActorSubscriber.cs @@ -91,7 +91,7 @@ public sealed class OnComplete : IActorSubscriberMessage /// /// TBD /// - public static readonly OnComplete Instance = new OnComplete(); + public static readonly OnComplete Instance = new(); private OnComplete() { } } @@ -417,11 +417,11 @@ public State(ISubscription subscription, long requested, bool isCanceled) /// /// TBD /// - public static readonly ActorSubscriberState Instance = new ActorSubscriberState(); + public static readonly ActorSubscriberState Instance = new(); private ActorSubscriberState() { } - private readonly ConcurrentDictionary _state = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _state = new(); /// /// TBD @@ -457,6 +457,6 @@ public State Remove(IActorRef actorRef) /// /// TBD /// TBD - public override ActorSubscriberState CreateExtension(ExtendedActorSystem system) => new ActorSubscriberState(); + public override ActorSubscriberState CreateExtension(ExtendedActorSystem system) => new(); } } diff --git a/src/core/Akka.Streams/Actors/RequestStrategies.cs b/src/core/Akka.Streams/Actors/RequestStrategies.cs index fb94920b699..bb2df0420ab 100644 --- a/src/core/Akka.Streams/Actors/RequestStrategies.cs +++ b/src/core/Akka.Streams/Actors/RequestStrategies.cs @@ -35,7 +35,7 @@ public sealed class OneByOneRequestStrategy : IRequestStrategy /// /// TBD /// - public static readonly OneByOneRequestStrategy Instance = new OneByOneRequestStrategy(); + public static readonly OneByOneRequestStrategy Instance = new(); private OneByOneRequestStrategy() { } /// @@ -54,7 +54,7 @@ public sealed class ZeroRequestStrategy : IRequestStrategy /// /// TBD /// - public static readonly ZeroRequestStrategy Instance = new ZeroRequestStrategy(); + public static readonly ZeroRequestStrategy Instance = new(); private ZeroRequestStrategy() { } /// diff --git a/src/core/Akka.Streams/Attributes.cs b/src/core/Akka.Streams/Attributes.cs index cca937d351a..7c6eb3d25c1 100644 --- a/src/core/Akka.Streams/Attributes.cs +++ b/src/core/Akka.Streams/Attributes.cs @@ -182,7 +182,7 @@ public sealed class AsyncBoundary : IAttribute, IEquatable /// /// TBD /// - public static readonly AsyncBoundary Instance = new AsyncBoundary(); + public static readonly AsyncBoundary Instance = new(); private AsyncBoundary() { } public bool Equals(AsyncBoundary other) => other is AsyncBoundary; public override bool Equals(object obj) => obj is AsyncBoundary; @@ -201,7 +201,7 @@ private AsyncBoundary() { } /// public sealed class CancellationStrategy : IMandatoryAttribute { - internal static CancellationStrategy Default { get; } = new CancellationStrategy(new PropagateFailure()); + internal static CancellationStrategy Default { get; } = new(new PropagateFailure()); public IStrategy Strategy { get; } @@ -273,7 +273,7 @@ public AfterDelay(TimeSpan delay, IStrategy strategy) /// /// TBD /// - public static readonly Attributes None = new Attributes(); + public static readonly Attributes None = new(); private readonly IAttribute[] _attributes; @@ -388,7 +388,7 @@ public Attributes And(Attributes other) /// /// TBD /// TBD - public Attributes And(IAttribute other) => new Attributes(_attributes.Concat(new[] { other }).ToArray()); + public Attributes And(IAttribute other) => new(_attributes.Concat(new[] { other }).ToArray()); /// /// Extracts Name attributes and concatenates them. @@ -455,13 +455,13 @@ public static Attributes CreateName(string name) /// TBD /// TBD /// TBD - public static Attributes CreateInputBuffer(int initial, int max) => new Attributes(new InputBuffer(initial, max)); + public static Attributes CreateInputBuffer(int initial, int max) => new(new InputBuffer(initial, max)); /// /// TBD /// /// TBD - public static Attributes CreateAsyncBoundary() => new Attributes(AsyncBoundary.Instance); + public static Attributes CreateAsyncBoundary() => new(AsyncBoundary.Instance); /// /// Configures stage log-levels to be used when logging. @@ -476,7 +476,7 @@ public static Attributes CreateName(string name) /// TBD public static Attributes CreateLogLevels(LogLevel onElement = LogLevel.DebugLevel, LogLevel onFinish = LogLevel.DebugLevel, LogLevel onError = LogLevel.ErrorLevel) - => new Attributes(new LogLevels(onElement, onFinish, onError)); + => new(new LogLevels(onElement, onFinish, onError)); // TODO: different than scala code, investigate later. /// @@ -554,7 +554,7 @@ public SupervisionStrategy(Decider decider) public override string ToString() => "SupervisionStrategy"; } - public static Dispatcher IODispatcher { get; } = new Dispatcher("akka.stream.materializer.blocking-io-dispatcher"); + public static Dispatcher IODispatcher { get; } = new("akka.stream.materializer.blocking-io-dispatcher"); /// /// Enables additional low level troubleshooting logging at DEBUG log level @@ -741,7 +741,7 @@ public bool Equals(SyncProcessingLimit other) /// /// TBD /// TBD - public static Attributes CreateDispatcher(string dispatcherName) => new Attributes(new Dispatcher(dispatcherName)); + public static Attributes CreateDispatcher(string dispatcherName) => new(new Dispatcher(dispatcherName)); /// /// Decides how exceptions from user are to be handled @@ -753,7 +753,7 @@ public bool Equals(SyncProcessingLimit other) /// TBD /// TBD public static Attributes CreateSupervisionStrategy(Decider strategy) - => new Attributes(new SupervisionStrategy(strategy)); + => new(new SupervisionStrategy(strategy)); /// /// Enables additional low level troubleshooting logging at DEBUG log level @@ -761,7 +761,7 @@ public static Attributes CreateSupervisionStrategy(Decider strategy) /// /// public static Attributes CreateDebugLogging(bool enabled) - => new Attributes(new DebugLogging(enabled)); + => new(new DebugLogging(enabled)); /// /// Defines a timeout for stream subscription and what action to take when that hits. @@ -772,7 +772,7 @@ public static Attributes CreateDebugLogging(bool enabled) public static Attributes CreateStreamSubscriptionTimeout( TimeSpan timeout, StreamSubscriptionTimeoutTerminationMode mode) - => new Attributes(new StreamSubscriptionTimeout(timeout, mode)); + => new(new StreamSubscriptionTimeout(timeout, mode)); /// /// Maximum number of elements emitted in batch if downstream signals large demand. @@ -780,7 +780,7 @@ public static Attributes CreateStreamSubscriptionTimeout( /// /// public static Attributes CreateOutputBurstLimit(int limit) - => new Attributes(new OutputBurstLimit(limit)); + => new(new OutputBurstLimit(limit)); /// /// Test utility: fuzzing mode means that GraphStage events are not processed @@ -789,7 +789,7 @@ public static Attributes CreateOutputBurstLimit(int limit) /// /// public static Attributes CreateFuzzingMode(bool enabled) - => new Attributes(new FuzzingMode(enabled)); + => new(new FuzzingMode(enabled)); /// /// Configure the maximum buffer size for which a FixedSizeBuffer will be preallocated. @@ -799,7 +799,7 @@ public static Attributes CreateFuzzingMode(bool enabled) /// /// public static Attributes CreateMaxFixedBufferSize(int size) - => new Attributes(new MaxFixedBufferSize(size)); + => new(new MaxFixedBufferSize(size)); /// /// Limit for number of messages that can be processed synchronously in stream to substream communication @@ -807,7 +807,7 @@ public static Attributes CreateMaxFixedBufferSize(int size) /// /// public static Attributes CreateSyncProcessingLimit(int limit) - => new Attributes(new SyncProcessingLimit(limit)); + => new(new SyncProcessingLimit(limit)); } /// @@ -934,25 +934,25 @@ public bool Equals(FinalTerminationSignalDeadline other) /// /// Specifies the subscription timeout within which the remote side MUST subscribe to the handed out stream reference. /// - public static Attributes CreateSubscriptionTimeout(TimeSpan timeout) => new Attributes(new SubscriptionTimeout(timeout)); + public static Attributes CreateSubscriptionTimeout(TimeSpan timeout) => new(new SubscriptionTimeout(timeout)); /// /// Specifies the size of the buffer on the receiving side that is eagerly filled even without demand. /// public static Attributes CreateBufferCapacity(int capacity) - => new Attributes(new BufferCapacity(capacity)); + => new(new BufferCapacity(capacity)); /// /// If no new elements arrive within this timeout, demand is redelivered. /// public static Attributes CreateDemandRedeliveryInterval(TimeSpan timeout) - => new Attributes(new DemandRedeliveryInterval(timeout)); + => new(new DemandRedeliveryInterval(timeout)); /// /// The time between the Terminated signal being received and when the local SourceRef determines to fail itself /// public static Attributes CreateFinalTerminationSignalDeadline(TimeSpan timeout) - => new Attributes(new FinalTerminationSignalDeadline(timeout)); + => new(new FinalTerminationSignalDeadline(timeout)); } } diff --git a/src/core/Akka.Streams/Dsl/AccumulateWhileUnchanged.cs b/src/core/Akka.Streams/Dsl/AccumulateWhileUnchanged.cs index 29711ebe42c..112ca3a22f3 100644 --- a/src/core/Akka.Streams/Dsl/AccumulateWhileUnchanged.cs +++ b/src/core/Akka.Streams/Dsl/AccumulateWhileUnchanged.cs @@ -27,7 +27,7 @@ public class AccumulateWhileUnchanged : GraphStage _currentState = Option.None; - private readonly List _buffer = new List(); + private readonly List _buffer = new(); public Logic(AccumulateWhileUnchanged accumulateWhileUnchanged) : base(accumulateWhileUnchanged.Shape) { diff --git a/src/core/Akka.Streams/Dsl/DelayFlow.cs b/src/core/Akka.Streams/Dsl/DelayFlow.cs index 8dd90646743..48a1aa54dec 100644 --- a/src/core/Akka.Streams/Dsl/DelayFlow.cs +++ b/src/core/Akka.Streams/Dsl/DelayFlow.cs @@ -110,7 +110,7 @@ public class DelayFlow : SimpleLinearGraphStage private sealed class Logic : TimerGraphStageLogic, IInHandler, IOutHandler { private readonly DelayFlow _delayFlow; - private readonly object _delayTimerKey = new object(); + private readonly object _delayTimerKey = new(); private readonly IDelayStrategy _strategy; private T _delayedElement; diff --git a/src/core/Akka.Streams/Dsl/FileIO.cs b/src/core/Akka.Streams/Dsl/FileIO.cs index 40976185554..181ecdfdc1b 100644 --- a/src/core/Akka.Streams/Dsl/FileIO.cs +++ b/src/core/Akka.Streams/Dsl/FileIO.cs @@ -36,7 +36,7 @@ public static class FileIO /// the start position to read from, defaults to 0 /// TBD public static Source> FromFile(FileInfo f, int chunkSize = 8192, long startPosition = 0) => - new Source>(new FileSource(f, chunkSize, startPosition, DefaultAttributes.FileSource, + new(new FileSource(f, chunkSize, startPosition, DefaultAttributes.FileSource, new SourceShape(new Outlet("FileSource")))); /// @@ -56,7 +56,7 @@ public static Source> FromFile(FileInfo f, int chunkS /// when passed an instance of , can be used to send a manual flush signal to the file sink /// TBD public static Sink> ToFile(FileInfo f, FileMode? fileMode = null, long startPosition = 0, bool autoFlush = false, FlushSignaler flushSignaler = null) => - new Sink>(new FileSink(f, startPosition, fileMode ?? FileMode.Create, DefaultAttributes.FileSink, + new(new FileSink(f, startPosition, fileMode ?? FileMode.Create, DefaultAttributes.FileSink, new SinkShape(new Inlet("FileSink")), autoFlush, flushSignaler)); } } diff --git a/src/core/Akka.Streams/Dsl/Flow.cs b/src/core/Akka.Streams/Dsl/Flow.cs index 4a00c3f6f05..2be898fc5f6 100644 --- a/src/core/Akka.Streams/Dsl/Flow.cs +++ b/src/core/Akka.Streams/Dsl/Flow.cs @@ -241,7 +241,7 @@ IFlow IFlow.MapMaterializedValue(FuncTBD /// TBD public Flow MapMaterializedValue(Func mapFunc) - => new Flow(Module.TransformMaterializedValue(mapFunc)); + => new(Module.TransformMaterializedValue(mapFunc)); /// /// Connect this to a , concatenating the processing steps of both. @@ -410,7 +410,7 @@ public static class Flow /// /// TBD /// TBD - public static Flow Identity() => new Flow(GraphStages.Identity().Module); + public static Flow Identity() => new(GraphStages.Identity().Module); /// /// TBD @@ -418,7 +418,7 @@ public static class Flow /// TBD /// TBD /// TBD - public static Flow Identity() => new Flow(GraphStages.Identity().Module); + public static Flow Identity() => new(GraphStages.Identity().Module); /// /// Creates flow from the Reactive Streams . @@ -439,7 +439,7 @@ public static Flow FromProcessor(FuncTBD /// TBD public static Flow FromProcessorMaterialized(Func<(IProcessor, TMat)> factory) - => new Flow(new ProcessorModule(factory)); + => new(new ProcessorModule(factory)); /// /// Helper to create a without a or . diff --git a/src/core/Akka.Streams/Dsl/FlowWithContext.cs b/src/core/Akka.Streams/Dsl/FlowWithContext.cs index 906d4a3c3da..57a0abaf277 100644 --- a/src/core/Akka.Streams/Dsl/FlowWithContext.cs +++ b/src/core/Akka.Streams/Dsl/FlowWithContext.cs @@ -89,6 +89,6 @@ public static FlowWithContext Create() /// public static FlowWithContext From( Flow<(TIn, TCtxIn), (TOut, TCtxOut), TMat> flow) => - new FlowWithContext(flow); + new(flow); } } diff --git a/src/core/Akka.Streams/Dsl/Graph.cs b/src/core/Akka.Streams/Dsl/Graph.cs index b7ac18d29d1..c2493b5aaa0 100644 --- a/src/core/Akka.Streams/Dsl/Graph.cs +++ b/src/core/Akka.Streams/Dsl/Graph.cs @@ -449,7 +449,7 @@ internal sealed class MergePrioritizedLogic : OutGraphStageLogic private readonly MergePrioritized _stage; private readonly List>> _allBuffers; private int _runningUpstreams; - private readonly Random _randomGen = new Random(); + private readonly Random _randomGen = new(); public MergePrioritizedLogic(MergePrioritized stage) : base(stage.Shape) { @@ -869,17 +869,17 @@ public MergeSorted(Func compare) /// /// TBD /// - public readonly Inlet Left = new Inlet("left"); + public readonly Inlet Left = new("left"); /// /// TBD /// - public readonly Inlet Right = new Inlet("right"); + public readonly Inlet Right = new("right"); /// /// TBD /// - public readonly Outlet Out = new Outlet("out"); + public readonly Outlet Out = new("out"); /// /// TBD @@ -1011,7 +1011,7 @@ public Broadcast(int outputPorts, bool eagerCancel = false) /// /// TBD /// - public readonly Inlet In = new Inlet("Broadcast.in"); + public readonly Inlet In = new("Broadcast.in"); /// /// TBD @@ -1171,7 +1171,7 @@ public Partition(int outputPorts, Func partitioner) /// /// TBD /// - public readonly Inlet In = new Inlet("Partition.in"); + public readonly Inlet In = new("Partition.in"); /// /// TBD @@ -1349,7 +1349,7 @@ public Balance(int outputPorts, bool waitForAllDownstreams = false) /// /// TBD /// - public Inlet In { get; } = new Inlet("Balance.in"); + public Inlet In { get; } = new("Balance.in"); /// /// TBD @@ -1427,7 +1427,7 @@ public sealed partial class ZipWith /// /// The singleton instance of . /// - public static readonly ZipWith Instance = new ZipWith(); + public static readonly ZipWith Instance = new(); private ZipWith() { } } @@ -1476,7 +1476,7 @@ public partial class UnzipWith /// /// The singleton instance of . /// - public static readonly UnzipWith Instance = new UnzipWith(); + public static readonly UnzipWith Instance = new(); private UnzipWith() { } } @@ -1780,7 +1780,7 @@ public Concat(int inputPorts = 2) /// /// TBD /// - public Outlet Out { get; } = new Outlet("Concat.out"); + public Outlet Out { get; } = new("Concat.out"); /// /// TBD @@ -1903,17 +1903,17 @@ public override void OnUpstreamFinish() /// /// TBD /// - public Inlet Primary { get; } = new Inlet("OrElse.primary"); + public Inlet Primary { get; } = new("OrElse.primary"); /// /// TBD /// - public Inlet Secondary { get; } = new Inlet("OrElse.secondary"); + public Inlet Secondary { get; } = new("OrElse.secondary"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("OrElse.out"); + public Outlet Out { get; } = new("OrElse.out"); /// /// TBD @@ -1941,7 +1941,7 @@ public static class WireTap /// /// TBD /// TBD - public static WireTap Create() => new WireTap(); + public static WireTap Create() => new(); } /// @@ -2007,9 +2007,9 @@ public Logic(WireTap stage) : base(stage.Shape) /// public WireTap() => Shape = new FanOutShape(In, OutMain, OutTap); - public Inlet In { get; } = new Inlet("WireTap.In"); - public Outlet OutMain { get; } = new Outlet("WireTap.OutMain"); - public Outlet OutTap { get; } = new Outlet("WireTap.OutTap"); + public Inlet In { get; } = new("WireTap.In"); + public Outlet OutMain { get; } = new("WireTap.OutMain"); + public Outlet OutTap { get; } = new("WireTap.OutTap"); public override FanOutShape Shape { get; } diff --git a/src/core/Akka.Streams/Dsl/Hub.cs b/src/core/Akka.Streams/Dsl/Hub.cs index 2614c911c56..8daa4cfe6f8 100644 --- a/src/core/Akka.Streams/Dsl/Hub.cs +++ b/src/core/Akka.Streams/Dsl/Hub.cs @@ -170,11 +170,11 @@ private sealed class HubLogic : OutGraphStageLogic /// too. Since the queue is read only if the output port has been pulled, downstream backpressure can delay /// processing of control messages. This causes no issues though, see the explanation in 'tryProcessNext'. /// - private readonly ConcurrentQueue _queue = new ConcurrentQueue(); + private readonly ConcurrentQueue _queue = new(); private readonly MergeHub _stage; private readonly AtomicCounterLong _producerCount; - private readonly Dictionary _demands = new Dictionary(); + private readonly Dictionary _demands = new(); private Action _wakeupCallback; private bool _needWakeup; private bool _shuttingDown; @@ -411,7 +411,7 @@ public HubSink(MergeHub hub, AtomicCounterLong idCounter, HubLogic logic) Shape = new SinkShape(In); } - private Inlet In { get; } = new Inlet("MergeHub.in"); + private Inlet In { get; } = new("MergeHub.in"); public override SinkShape Shape { get; } @@ -447,7 +447,7 @@ public MergeHub(int perProducerBufferSize) /// /// TBD /// - public Outlet Out { get; } = new Outlet("MergeHub.out"); + public Outlet Out { get; } = new("MergeHub.out"); /// /// TBD @@ -534,7 +534,7 @@ private interface IHubEvent { } private sealed class RegistrationPending : IHubEvent { - public static RegistrationPending Instance { get; } = new RegistrationPending(); + public static RegistrationPending Instance { get; } = new(); private RegistrationPending() { @@ -603,7 +603,7 @@ public Consumer(long id, Action callback) private sealed class Completed { - public static Completed Instance { get; } = new Completed(); + public static Completed Instance { get; } = new(); private Completed() { @@ -642,7 +642,7 @@ private interface IConsumerEvent { } private sealed class Wakeup : IConsumerEvent { - public static Wakeup Instance { get; } = new Wakeup(); + public static Wakeup Instance { get; } = new(); private Wakeup() { @@ -678,8 +678,7 @@ private sealed class HubLogic : InGraphStageLogic { private readonly BroadcastHub _stage; - private readonly TaskCompletionSource> _callbackCompletion = - new TaskCompletionSource>(); + private readonly TaskCompletionSource> _callbackCompletion = new(); private readonly Open _noRegistrationState; internal readonly AtomicReference State; @@ -1105,7 +1104,7 @@ public HubSourceLogic(BroadcastHub hub, HubLogic hubLogic, AtomicCounterLong Shape = new SourceShape(Out); } - private Outlet Out { get; } = new Outlet("HubSourceLogic.out"); + private Outlet Out { get; } = new("HubSourceLogic.out"); public override SourceShape Shape { get; } @@ -1147,7 +1146,7 @@ public BroadcastHub(int bufferSize) Shape = new SinkShape(In); } - private Inlet In { get; } = new Inlet("BroadcastHub.in"); + private Inlet In { get; } = new("BroadcastHub.in"); /// /// TBD @@ -1315,7 +1314,7 @@ private interface IPartitionQueue private sealed class ConsumerQueue { - public static ConsumerQueue Empty { get; } = new ConsumerQueue(ImmutableQueue.Empty, 0); + public static ConsumerQueue Empty { get; } = new(ImmutableQueue.Empty, 0); private readonly ImmutableQueue _queue; @@ -1325,21 +1324,21 @@ public ConsumerQueue(ImmutableQueue queue, int size) Size = size; } - public ConsumerQueue Enqueue(object element) => new ConsumerQueue(_queue.Enqueue(element), Size + 1); + public ConsumerQueue Enqueue(object element) => new(_queue.Enqueue(element), Size + 1); public bool IsEmpty => Size == 0; public object Head => _queue.First(); - public ConsumerQueue Tail => new ConsumerQueue(_queue.Dequeue(), Size - 1); + public ConsumerQueue Tail => new(_queue.Dequeue(), Size - 1); public int Size { get; } } private sealed class PartitionQueue : IPartitionQueue { - private readonly AtomicCounter _totalSize = new AtomicCounter(); - private readonly ConcurrentDictionary _queues = new ConcurrentDictionary(); + private readonly AtomicCounter _totalSize = new(); + private readonly ConcurrentDictionary _queues = new(); public void Init(long id) => _queues.TryAdd(id, ConsumerQueue.Empty); @@ -1406,14 +1405,14 @@ private interface IConsumerEvent { } private sealed class Wakeup : IConsumerEvent { - public static Wakeup Instance { get; } = new Wakeup(); + public static Wakeup Instance { get; } = new(); private Wakeup() { } } private sealed class Initialize : IConsumerEvent { - public static Initialize Instance { get; } = new Initialize(); + public static Initialize Instance { get; } = new(); private Initialize() { } } @@ -1433,7 +1432,7 @@ private interface IHubEvent { } private sealed class RegistrationPending : IHubEvent { - public static RegistrationPending Instance { get; } = new RegistrationPending(); + public static RegistrationPending Instance { get; } = new(); private RegistrationPending() { } } @@ -1473,14 +1472,14 @@ public Consumer(long id, Action callback) private sealed class TryPull : IHubEvent { - public static TryPull Instance { get; } = new TryPull(); + public static TryPull Instance { get; } = new(); private TryPull() { } } private sealed class Completed { - public static Completed Instance { get; } = new Completed(); + public static Completed Instance { get; } = new(); private Completed() { } } @@ -1540,13 +1539,13 @@ public ConsumerInfo(PartitionSinkLogic partitionSinkLogic, ImmutableList _hub; private readonly int _demandThreshold; private readonly Func _materializedPartitioner; - private readonly TaskCompletionSource> _callbackCompletion = new TaskCompletionSource>(); + private readonly TaskCompletionSource> _callbackCompletion = new(); private readonly IHubState _noRegistrationsState; private bool _initialized; private readonly IPartitionQueue _queue = new PartitionQueue(); - private readonly List _pending = new List(); + private readonly List _pending = new(); private ConsumerInfo _consumerInfo; - private readonly Dictionary _needWakeup = new Dictionary(); + private readonly Dictionary _needWakeup = new(); private long _callbackCount; public PartitionSinkLogic(PartitionHub hub) : base(hub.Shape) @@ -1832,7 +1831,7 @@ private void OnCommand(IConsumerEvent command) private readonly AtomicCounterLong _counter; private readonly PartitionSinkLogic _logic; - private readonly Outlet _out = new Outlet("PartitionHub.out"); + private readonly Outlet _out = new("PartitionHub.out"); public PartitionSource(AtomicCounterLong counter, PartitionSinkLogic logic) { @@ -1858,7 +1857,7 @@ public PartitionHub(Func> partitioner, Shape = new SinkShape(In); } - public Inlet In { get; } = new Inlet("PartitionHub.in"); + public Inlet In { get; } = new("PartitionHub.in"); public override SinkShape Shape { get; } diff --git a/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs b/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs index 076794e1f4c..c99c6984fee 100644 --- a/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs +++ b/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs @@ -159,10 +159,10 @@ private void SetOutOutletHandler() #endregion private readonly int _maxPending; - private readonly Inlet _inInlet = new Inlet("inIn"); - private readonly Outlet _inOutlet = new Outlet("inOut"); - private readonly Inlet _outInlet = new Inlet("outIn"); - private readonly Outlet _outOutlet = new Outlet("outOut"); + private readonly Inlet _inInlet = new("inIn"); + private readonly Outlet _inOutlet = new("inOut"); + private readonly Inlet _outInlet = new("outIn"); + private readonly Outlet _outOutlet = new("outOut"); /// /// TBD diff --git a/src/core/Akka.Streams/Dsl/RestartFlow.cs b/src/core/Akka.Streams/Dsl/RestartFlow.cs index 86e2ca9c0e5..3f7d8b814fd 100644 --- a/src/core/Akka.Streams/Dsl/RestartFlow.cs +++ b/src/core/Akka.Streams/Dsl/RestartFlow.cs @@ -184,9 +184,9 @@ public RestartWithBackoffFlow( Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("RestartWithBackoffFlow.in"); + public Inlet In { get; } = new("RestartWithBackoffFlow.in"); - public Outlet Out { get; } = new Outlet("RestartWithBackoffFlow.out"); + public Outlet Out { get; } = new("RestartWithBackoffFlow.out"); public override FlowShape Shape { get; } @@ -514,9 +514,9 @@ internal sealed class Deadline public bool IsOverdue => Time.Ticks - DateTime.UtcNow.Ticks < 0; - public static Deadline Now => new Deadline(new TimeSpan(DateTime.UtcNow.Ticks)); + public static Deadline Now => new(new TimeSpan(DateTime.UtcNow.Ticks)); - public static Deadline operator +(Deadline deadline, TimeSpan duration) => new Deadline(deadline.Time.Add(duration)); + public static Deadline operator +(Deadline deadline, TimeSpan duration) => new(deadline.Time.Add(duration)); } internal static class DeadlineExtensions diff --git a/src/core/Akka.Streams/Dsl/RestartSink.cs b/src/core/Akka.Streams/Dsl/RestartSink.cs index e75b59a85f4..ae35e384470 100644 --- a/src/core/Akka.Streams/Dsl/RestartSink.cs +++ b/src/core/Akka.Streams/Dsl/RestartSink.cs @@ -105,7 +105,7 @@ public RestartWithBackoffSink(Func> sinkFactory, RestartSettings s Shape = new SinkShape(In); } - public Inlet In { get; } = new Inlet("RestartWithBackoffSink.in"); + public Inlet In { get; } = new("RestartWithBackoffSink.in"); public override SinkShape Shape { get; } diff --git a/src/core/Akka.Streams/Dsl/RestartSource.cs b/src/core/Akka.Streams/Dsl/RestartSource.cs index dffc68ca922..a5075d09d38 100644 --- a/src/core/Akka.Streams/Dsl/RestartSource.cs +++ b/src/core/Akka.Streams/Dsl/RestartSource.cs @@ -151,7 +151,7 @@ public RestartWithBackoffSource(Func> sourceFactory, RestartSett Shape = new SourceShape(Out); } - public Outlet Out { get; } = new Outlet("RestartWithBackoffSource.out"); + public Outlet Out { get; } = new("RestartWithBackoffSource.out"); public override SourceShape Shape { get; } diff --git a/src/core/Akka.Streams/Dsl/Retry.cs b/src/core/Akka.Streams/Dsl/Retry.cs index 3357db4b6f1..f22185af098 100644 --- a/src/core/Akka.Streams/Dsl/Retry.cs +++ b/src/core/Akka.Streams/Dsl/Retry.cs @@ -223,7 +223,7 @@ private class RetryConcatCoordinator : GraphStage _retry; - private readonly Queue<(TIn, TState)> _queue = new Queue<(TIn, TState)>(); + private readonly Queue<(TIn, TState)> _queue = new(); private bool _elementInCycle; public Logic(RetryConcatCoordinator retry) : base(retry.Shape) diff --git a/src/core/Akka.Streams/Dsl/ReuseLatest.cs b/src/core/Akka.Streams/Dsl/ReuseLatest.cs index d6a3f22e753..6a7ed783f5e 100644 --- a/src/core/Akka.Streams/Dsl/ReuseLatest.cs +++ b/src/core/Akka.Streams/Dsl/ReuseLatest.cs @@ -20,10 +20,10 @@ namespace Akka.Streams.Dsl /// The output type. public sealed class ReuseLatest : GraphStage> { - private readonly Inlet _in = new Inlet("RepeatPrevious.in"); - private readonly Outlet _out = new Outlet("RepeatPrevious.out"); + private readonly Inlet _in = new("RepeatPrevious.in"); + private readonly Outlet _out = new("RepeatPrevious.out"); - public override FlowShape Shape => new FlowShape(_in, _out); + public override FlowShape Shape => new(_in, _out); private readonly Action _onItemChanged; /// diff --git a/src/core/Akka.Streams/Dsl/Sink.cs b/src/core/Akka.Streams/Dsl/Sink.cs index b8b69137ccf..e27229372fd 100644 --- a/src/core/Akka.Streams/Dsl/Sink.cs +++ b/src/core/Akka.Streams/Dsl/Sink.cs @@ -82,7 +82,7 @@ public TMat2 RunWith(IGraph, TMat2> source, IMaterialize /// TBD /// TBD public Sink MapMaterializedValue(Func fn) - => new Sink(Module.TransformMaterializedValue(fn)); + => new(Module.TransformMaterializedValue(fn)); /// /// Materializes this Sink immediately. @@ -118,7 +118,7 @@ IGraph, TMat> IGraph, TMat>.WithAttributes(Attribu /// TBD /// TBD public Sink WithAttributes(Attributes attributes) - => new Sink(Module.WithAttributes(attributes)); + => new(Module.WithAttributes(attributes)); /// /// Add the given attributes to this . @@ -183,7 +183,7 @@ public static class Sink /// TBD /// TBD /// TBD - public static SinkShape Shape(string name) => new SinkShape(new Inlet(name + ".in")); + public static SinkShape Shape(string name) => new(new Inlet(name + ".in")); /// /// A graph with the shape of a sink logically is a sink, this method makes @@ -205,7 +205,7 @@ public static Sink Wrap(IGraph, TMat> graph /// TBD /// TBD public static Sink Create(ISubscriber subscriber) - => new Sink(new SubscriberSink(subscriber, DefaultAttributes.SubscriberSink, Shape("SubscriberSink"))); + => new(new SubscriberSink(subscriber, DefaultAttributes.SubscriberSink, Shape("SubscriberSink"))); /// /// A that materializes into a of the first value received. @@ -276,7 +276,7 @@ public static Sink> LastOrDefault() /// TBD /// TBD public static Sink> Publisher() - => new Sink>(new PublisherSink(DefaultAttributes.PublisherSink, Shape("PublisherSink"))); + => new(new PublisherSink(DefaultAttributes.PublisherSink, Shape("PublisherSink"))); /// /// A that materializes into @@ -285,11 +285,11 @@ public static Sink> Publisher() /// TBD /// TBD public static Sink> FanoutPublisher() - => new Sink>(new FanoutPublisherSink>(DefaultAttributes.FanoutPublisherSink, Shape("FanoutPublisherSink"))); + => new(new FanoutPublisherSink>(DefaultAttributes.FanoutPublisherSink, Shape("FanoutPublisherSink"))); [InternalApi] public static Sink> DistinctRetainingFanOutPublisher(Action onTerminated = null) - => new Sink>(new FanoutPublisherSink>(DefaultAttributes.FanoutPublisherSink, Shape("DistinctRetainingFanOutPublisherSink"), onTerminated)); + => new(new FanoutPublisherSink>(DefaultAttributes.FanoutPublisherSink, Shape("DistinctRetainingFanOutPublisherSink"), onTerminated)); /// /// A that will consume the stream and discard the elements. @@ -550,7 +550,7 @@ public static Sink ActorRefWithAck(IActorRef actorRef, object /// TBD /// TBD public static Sink ActorSubscriber(Props props) - => new Sink(new ActorSubscriberSink(props, DefaultAttributes.ActorSubscriberSink, Shape("ActorSubscriberSink"))); + => new(new ActorSubscriberSink(props, DefaultAttributes.ActorSubscriberSink, Shape("ActorSubscriberSink"))); /// /// @@ -642,7 +642,7 @@ public static Sink FromGraph(IGraph, TMat> /// TBD /// TBD public static Sink FromSubscriber(ISubscriber subscriber) - => new Sink(new SubscriberSink(subscriber, DefaultAttributes.SubscriberSink, Shape("SubscriberSink"))); + => new(new SubscriberSink(subscriber, DefaultAttributes.SubscriberSink, Shape("SubscriberSink"))); /// /// A that immediately cancels its upstream after materialization. @@ -650,7 +650,7 @@ public static Sink FromSubscriber(ISubscriber subscriber /// TBD /// TBD public static Sink Cancelled() - => new Sink(new CancelSink(DefaultAttributes.CancelledSink, Shape("CancelledSink"))); + => new(new CancelSink(DefaultAttributes.CancelledSink, Shape("CancelledSink"))); /// /// A that materializes into a . diff --git a/src/core/Akka.Streams/Dsl/Source.cs b/src/core/Akka.Streams/Dsl/Source.cs index 30fff6a70cc..e60b768ba79 100644 --- a/src/core/Akka.Streams/Dsl/Source.cs +++ b/src/core/Akka.Streams/Dsl/Source.cs @@ -117,7 +117,7 @@ IGraph, TMat> IGraph, TMat>.WithAttributes(A /// The attributes to add /// A new Source with the added attributes public Source WithAttributes(Attributes attributes) - => new Source(Module.WithAttributes(attributes)); + => new(Module.WithAttributes(attributes)); /// /// Add the given attributes to this . @@ -279,7 +279,7 @@ IFlow IFlow.MapMaterializedValue(FuncTBD /// TBD public Source MapMaterializedValue(Func mapFunc) - => new Source(Module.TransformMaterializedValue(mapFunc)); + => new(Module.TransformMaterializedValue(mapFunc)); /// /// Materializes this Source immediately. @@ -577,7 +577,7 @@ public static class Source /// TBD /// TBD /// TBD - public static SourceShape Shape(string name) => new SourceShape(new Outlet(name + ".out")); + public static SourceShape Shape(string name) => new(new Outlet(name + ".out")); /// /// Helper to create from . @@ -591,7 +591,7 @@ public static class Source /// TBD /// TBD public static Source FromPublisher(IPublisher publisher) - => new Source(new PublisherSource(publisher, DefaultAttributes.PublisherSource, Shape("PublisherSource"))); + => new(new PublisherSource(publisher, DefaultAttributes.PublisherSource, Shape("PublisherSource"))); /// /// Helper to create from . diff --git a/src/core/Akka.Streams/Dsl/SourceOperations.cs b/src/core/Akka.Streams/Dsl/SourceOperations.cs index fe32214a218..7ceed16caae 100644 --- a/src/core/Akka.Streams/Dsl/SourceOperations.cs +++ b/src/core/Akka.Streams/Dsl/SourceOperations.cs @@ -2327,7 +2327,7 @@ public static Source OrElseMaterialized(this So /// Type of materialized value. /// public static SourceWithContext AsSourceWithContext(this Source flow, Func fn) => - new SourceWithContext(flow.Select(x => (x, fn(x)))); + new(flow.Select(x => (x, fn(x)))); /// /// The operator fails with an if the target actor is terminated. diff --git a/src/core/Akka.Streams/Dsl/SourceWithContext.cs b/src/core/Akka.Streams/Dsl/SourceWithContext.cs index 46214919588..314c4dd1eb2 100644 --- a/src/core/Akka.Streams/Dsl/SourceWithContext.cs +++ b/src/core/Akka.Streams/Dsl/SourceWithContext.cs @@ -16,7 +16,7 @@ public static class SourceWithContext /// Creates a from a regular source that operates on a tuple of `(data, context)` elements. /// public static SourceWithContext FromTuples(Source<(TOut, TCtxOut), TMat> source) => - new SourceWithContext(source); + new(source); } /// @@ -41,7 +41,7 @@ public SourceWithContext(Source<(TOut, TCtx), TMat> source) /// context propagation here. /// public SourceWithContext Via(IGraph, TMat2> viaFlow) => - new SourceWithContext(Source.FromGraph(Inner).Via(viaFlow)); + new(Source.FromGraph(Inner).Via(viaFlow)); /// /// Transform this flow by the regular flow. The given flow must support manual context propagation by @@ -55,7 +55,7 @@ public SourceWithContext Via(IGraph public SourceWithContext ViaMaterialized( IGraph, TMat2> viaFlow, Func combine) => - new SourceWithContext(Source.FromGraph(Inner).ViaMaterialized(viaFlow, combine)); + new(Source.FromGraph(Inner).ViaMaterialized(viaFlow, combine)); /// /// Connect this to a , @@ -75,7 +75,7 @@ public IRunnableGraph ToMaterialized(IGraph. /// public SourceWithContext MapMaterializedValue(Func combine) => - new SourceWithContext(Source.FromGraph(Inner).MapMaterializedValue(combine)); + new(Source.FromGraph(Inner).MapMaterializedValue(combine)); /// /// Connect this to a Sink and run it. The returned value is the materialized value of the Sink. diff --git a/src/core/Akka.Streams/Dsl/StreamRefs.cs b/src/core/Akka.Streams/Dsl/StreamRefs.cs index 1f28c99690c..5b76084ac71 100644 --- a/src/core/Akka.Streams/Dsl/StreamRefs.cs +++ b/src/core/Akka.Streams/Dsl/StreamRefs.cs @@ -89,7 +89,7 @@ public StreamRefSettings(int bufferCapacity, TimeSpan demandRedeliveryInterval, public StreamRefSettings Copy(int? bufferCapacity = null, TimeSpan? demandRedeliveryInterval = null, TimeSpan? subscriptionTimeout = null, - TimeSpan? finalTerminationSignalDeadline = null) => new StreamRefSettings( + TimeSpan? finalTerminationSignalDeadline = null) => new( bufferCapacity: bufferCapacity ?? this.BufferCapacity, demandRedeliveryInterval: demandRedeliveryInterval ?? this.DemandRedeliveryInterval, subscriptionTimeout: subscriptionTimeout ?? this.SubscriptionTimeout, diff --git a/src/core/Akka.Streams/Dsl/Tcp.cs b/src/core/Akka.Streams/Dsl/Tcp.cs index b7fc2e40db1..6f783781b96 100644 --- a/src/core/Akka.Streams/Dsl/Tcp.cs +++ b/src/core/Akka.Streams/Dsl/Tcp.cs @@ -28,7 +28,7 @@ public class Tcp : ExtensionIdProvider /// /// TBD /// TBD - public override TcpExt CreateExtension(ExtendedActorSystem system) => new TcpExt(system); + public override TcpExt CreateExtension(ExtendedActorSystem system) => new(system); /// /// Represents a successful TCP server binding. diff --git a/src/core/Akka.Streams/Extra/Timed.cs b/src/core/Akka.Streams/Extra/Timed.cs index d823d0ad054..a9b769e0c64 100644 --- a/src/core/Akka.Streams/Extra/Timed.cs +++ b/src/core/Akka.Streams/Extra/Timed.cs @@ -113,7 +113,7 @@ internal static class Timed /// internal sealed class TimedFlowContext { - private readonly Stopwatch _stopwatch = new Stopwatch(); + private readonly Stopwatch _stopwatch = new(); /// /// TBD diff --git a/src/core/Akka.Streams/FlowMonitor.cs b/src/core/Akka.Streams/FlowMonitor.cs index 1920da4cf84..6e5c6666754 100644 --- a/src/core/Akka.Streams/FlowMonitor.cs +++ b/src/core/Akka.Streams/FlowMonitor.cs @@ -41,7 +41,7 @@ public class Initialized : IStreamState /// /// TBD /// - public static Initialized Instance { get; } = new Initialized(); + public static Initialized Instance { get; } = new(); private Initialized() { @@ -98,7 +98,7 @@ public class Finished : IStreamState /// /// TBD /// - public static Finished Instance { get; } = new Finished(); + public static Finished Instance { get; } = new(); private Finished() { diff --git a/src/core/Akka.Streams/IO/IOResult.cs b/src/core/Akka.Streams/IO/IOResult.cs index 766712f122e..f68e542c16a 100644 --- a/src/core/Akka.Streams/IO/IOResult.cs +++ b/src/core/Akka.Streams/IO/IOResult.cs @@ -60,7 +60,7 @@ public Exception Error /// /// Numeric value depending on context, for example IO operations performed or bytes processed. /// Successful IOResult - public static IOResult Success(long count) => new IOResult(count, Result.Success(NotUsed.Instance)); + public static IOResult Success(long count) => new(count, Result.Success(NotUsed.Instance)); /// /// Creates failed IOResult, should be the number of bytes (or other unit, please document in your APIs) processed before failing @@ -69,7 +69,7 @@ public Exception Error /// The corresponding /// Failed IOResult public static IOResult Failed(long count, Exception reason) - => new IOResult(count, Result.Failure(reason)); + => new(count, Result.Failure(reason)); } /// diff --git a/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs b/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs index 87601b04bd8..b9ad642c513 100644 --- a/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs +++ b/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs @@ -174,7 +174,7 @@ protected override object MaterializeAtomic(AtomicModule atomic, Attributes effe private string StageName(Attributes attr) => $"{_flowName}-{_nextId++}-{attr.GetNameOrDefault()}"; private MaterializationContext CreateMaterializationContext(Attributes effectiveAttributes) - => new MaterializationContext(_materializer, effectiveAttributes, StageName(effectiveAttributes)); + => new(_materializer, effectiveAttributes, StageName(effectiveAttributes)); private void MaterializeGraph(GraphModule graph, Attributes effectiveAttributes, IDictionary materializedValues) { @@ -492,14 +492,14 @@ public static FlowNameCounter Instance(ActorSystem system) /// /// TBD /// - public readonly AtomicCounterLong Counter = new AtomicCounterLong(0); + public readonly AtomicCounterLong Counter = new(0); /// /// TBD /// /// TBD /// TBD - public override FlowNameCounter CreateExtension(ExtendedActorSystem system) => new FlowNameCounter(); + public override FlowNameCounter CreateExtension(ExtendedActorSystem system) => new(); } /// @@ -543,7 +543,7 @@ public sealed class GetChildren /// /// TBD /// - public static readonly GetChildren Instance = new GetChildren(); + public static readonly GetChildren Instance = new(); private GetChildren() { } } /// @@ -554,7 +554,7 @@ public sealed class StopChildren /// /// TBD /// - public static readonly StopChildren Instance = new StopChildren(); + public static readonly StopChildren Instance = new(); private StopChildren() { } } /// @@ -565,7 +565,7 @@ public sealed class StoppedChildren /// /// TBD /// - public static readonly StoppedChildren Instance = new StoppedChildren(); + public static readonly StoppedChildren Instance = new(); private StoppedChildren() { } } /// @@ -576,7 +576,7 @@ public sealed class PrintDebugDump /// /// TBD /// - public static readonly PrintDebugDump Instance = new PrintDebugDump(); + public static readonly PrintDebugDump Instance = new(); private PrintDebugDump() { } } /// diff --git a/src/core/Akka.Streams/Implementation/ActorPublisher.cs b/src/core/Akka.Streams/Implementation/ActorPublisher.cs index 70acb4996e8..312649ed708 100644 --- a/src/core/Akka.Streams/Implementation/ActorPublisher.cs +++ b/src/core/Akka.Streams/Implementation/ActorPublisher.cs @@ -29,7 +29,7 @@ internal sealed class SubscribePending /// /// TBD /// - public static readonly SubscribePending Instance = new SubscribePending(); + public static readonly SubscribePending Instance = new(); private SubscribePending() { } } @@ -151,7 +151,7 @@ public static class ActorPublisher /// /// TBD /// - public static readonly NormalShutdownException NormalShutdownReason = new NormalShutdownException(NormalShutdownReasonMessage); + public static readonly NormalShutdownException NormalShutdownReason = new(NormalShutdownReasonMessage); } /// @@ -175,7 +175,7 @@ public class ActorPublisher : IActorPublisher, IPublisher // called by the actor from postStop. Pending (unregistered) subscription attempts are denied by // the shutdown method. Subscription attempts after shutdown can be denied immediately. private readonly AtomicReference>> _pendingSubscribers = - new AtomicReference>>(ImmutableList>.Empty); + new(ImmutableList>.Empty); private volatile Exception _shutdownReason; diff --git a/src/core/Akka.Streams/Implementation/ActorRefBackpressureSinkStage.cs b/src/core/Akka.Streams/Implementation/ActorRefBackpressureSinkStage.cs index 2eaa1e6dc73..64d99dc5da5 100644 --- a/src/core/Akka.Streams/Implementation/ActorRefBackpressureSinkStage.cs +++ b/src/core/Akka.Streams/Implementation/ActorRefBackpressureSinkStage.cs @@ -133,7 +133,7 @@ public override void PostStop() #endregion - private readonly Inlet _inlet = new Inlet("ActorRefBackpressureSink.in"); + private readonly Inlet _inlet = new("ActorRefBackpressureSink.in"); private readonly IActorRef _actorRef; private readonly object _onInitMessage; diff --git a/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs b/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs index 0523b5dbc45..5b19672f677 100644 --- a/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs +++ b/src/core/Akka.Streams/Implementation/ActorRefSinkStage.cs @@ -88,7 +88,7 @@ public void OnUpstreamFailure(Exception ex) private readonly object _onCompleteMessage; private readonly Func _onFailureMessage; - public Inlet In { get; } = new Inlet("ActorRefSink.in"); + public Inlet In { get; } = new("ActorRefSink.in"); public ActorRefSinkStage(IActorRef actorRef, object onCompleteMessage, Func onFailureMessage) { diff --git a/src/core/Akka.Streams/Implementation/CompletedPublishers.cs b/src/core/Akka.Streams/Implementation/CompletedPublishers.cs index 7a2eb046ebb..d1f95268aba 100644 --- a/src/core/Akka.Streams/Implementation/CompletedPublishers.cs +++ b/src/core/Akka.Streams/Implementation/CompletedPublishers.cs @@ -198,7 +198,7 @@ internal sealed class CancelledSubscription : ISubscription /// /// TBD /// - public static readonly CancelledSubscription Instance = new CancelledSubscription(); + public static readonly CancelledSubscription Instance = new(); private CancelledSubscription() { } diff --git a/src/core/Akka.Streams/Implementation/ExposedPublisherReceive.cs b/src/core/Akka.Streams/Implementation/ExposedPublisherReceive.cs index eca41101917..30af24b8b47 100644 --- a/src/core/Akka.Streams/Implementation/ExposedPublisherReceive.cs +++ b/src/core/Akka.Streams/Implementation/ExposedPublisherReceive.cs @@ -26,7 +26,7 @@ public abstract class ExposedPublisherReceive /// public readonly Action Unhandled; - private readonly LinkedList _stash = new LinkedList(); + private readonly LinkedList _stash = new(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs b/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs index 41f1b1b2b00..9fb6ab710a8 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs @@ -769,7 +769,7 @@ public struct Abort : IBoundaryEvent private class ShellRegistered { - public static readonly ShellRegistered Instance = new ShellRegistered(); + public static readonly ShellRegistered Instance = new(); private ShellRegistered() { } @@ -1332,7 +1332,7 @@ private void Complete() public static Props Props(GraphInterpreterShell shell) => Actor.Props.Create(() => new ActorGraphInterpreter(shell)).WithDeploy(Deploy.Local); private ISet _activeInterpreters = new HashSet(); - private readonly Queue _newShells = new Queue(); + private readonly Queue _newShells = new(); private readonly SubFusingActorMaterializerImpl _subFusingMaterializerImpl; private readonly GraphInterpreterShell _initial; private ILoggingAdapter _log; diff --git a/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs b/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs index b64dfc9522f..e5c50f86675 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs @@ -585,7 +585,7 @@ internal sealed class BuildStructuralInfo /// /// The list of all groups of modules that are within each async boundary. /// - public readonly LinkedList> Groups = new LinkedList>(); + public readonly LinkedList> Groups = new(); /// /// A mapping from OutPort to its containing group, needed when determining whether an upstream connection is internal or not. @@ -630,7 +630,7 @@ internal sealed class BuildStructuralInfo /// /// A stack of materialized value sources, grouped by materialized computation context. /// - private readonly LinkedList> _materializedSources = new LinkedList>(); + private readonly LinkedList> _materializedSources = new(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs index 8286adff5b2..527ca99a4bc 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs @@ -110,7 +110,7 @@ public sealed class Empty /// /// TBD /// - public static readonly Empty Instance = new Empty(); + public static readonly Empty Instance = new(); private Empty() { @@ -360,7 +360,7 @@ public Connection(int id, int inOwnerId, GraphStageLogic inOwner, int outOwnerId // Using an Object-array avoids holding on to the GraphInterpreter class // when this accidentally leaks onto threads that are not stopped when this // class should be unloaded. - private static readonly ThreadLocal CurrentInterpreter = new ThreadLocal(() => new object[1]); + private static readonly ThreadLocal CurrentInterpreter = new(() => new object[1]); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/Fusing/GraphStages.cs b/src/core/Akka.Streams/Implementation/Fusing/GraphStages.cs index db9d2889829..f3e46e27776 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/GraphStages.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/GraphStages.cs @@ -186,7 +186,7 @@ public Logic(Identity stage) : base(stage.Shape) /// /// TBD /// - public static readonly Identity Instance = new Identity(); + public static readonly Identity Instance = new(); private Identity() { @@ -294,7 +294,7 @@ internal sealed class TerminationWatcher : GraphStageWithMaterializedValue /// TBD /// - public static readonly TerminationWatcher Instance = new TerminationWatcher(); + public static readonly TerminationWatcher Instance = new(); #region internal classes @@ -351,8 +351,8 @@ public override void PostStop() #endregion - private readonly Inlet _inlet = new Inlet("TerminationWatcher.in"); - private readonly Outlet _outlet = new Outlet("TerminationWatcher.out"); + private readonly Inlet _inlet = new("TerminationWatcher.in"); + private readonly Outlet _outlet = new("TerminationWatcher.out"); private TerminationWatcher() { @@ -490,12 +490,12 @@ public MonitorFlow() /// /// TBD /// - public Inlet In { get; } = new Inlet("MonitorFlow.in"); + public Inlet In { get; } = new("MonitorFlow.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("MonitorFlow.out"); + public Outlet Out { get; } = new("MonitorFlow.out"); /// /// TBD @@ -533,10 +533,9 @@ public sealed class TickSource : GraphStageWithMaterializedValue _stage; - private readonly AtomicBoolean _cancelled = new AtomicBoolean(); + private readonly AtomicBoolean _cancelled = new(); - private readonly AtomicReference> _cancelCallback = - new AtomicReference>(null); + private readonly AtomicReference> _cancelCallback = new(null); public Logic(TickSource stage) : base(stage.Shape) { @@ -608,7 +607,7 @@ public TickSource(TimeSpan initialDelay, TimeSpan interval, T tick) /// /// TBD /// - public Outlet Out { get; } = new Outlet("TimerSource.out"); + public Outlet Out { get; } = new("TimerSource.out"); /// /// TBD @@ -706,7 +705,7 @@ public override void PreStart() /// public readonly Outlet Outlet; - private readonly TaskCompletionSource _promise = new TaskCompletionSource(); + private readonly TaskCompletionSource _promise = new(); /// /// TBD @@ -748,7 +747,7 @@ public MaterializedValueSource(StreamLayout.IMaterializedValueNode computation, /// TBD /// /// TBD - public MaterializedValueSource CopySource() => new MaterializedValueSource(Computation, Outlet); + public MaterializedValueSource CopySource() => new(Computation, Outlet); IMaterializedValueSource IMaterializedValueSource.CopySource() => CopySource(); @@ -797,7 +796,7 @@ public override void OnPull() /// /// TBD /// - public readonly Outlet Outlet = new Outlet("single.out"); + public readonly Outlet Outlet = new("single.out"); /// /// TBD @@ -915,7 +914,7 @@ private Exception Flatten(AggregateException exception) => private readonly Task> _taskSource; - public readonly Outlet Outlet = new Outlet("TaskFlattenSource.out"); + public readonly Outlet Outlet = new("TaskFlattenSource.out"); public TaskFlattenSource(Task> taskSource) { @@ -979,7 +978,7 @@ private Exception Flatten(AggregateException exception) /// /// TBD /// - public readonly Outlet Outlet = new Outlet("TaskSource.out"); + public readonly Outlet Outlet = new("TaskSource.out"); /// /// TBD @@ -1057,7 +1056,7 @@ public override void OnUpstreamFailure(Exception e) protected override Attributes InitialAttributes { get; } = DefaultAttributes.IgnoreSink; - public Inlet Inlet { get; } = new Inlet("Ignore.in"); + public Inlet Inlet { get; } = new("Ignore.in"); public override SinkShape Shape { get; } diff --git a/src/core/Akka.Streams/Implementation/Fusing/Ops.cs b/src/core/Akka.Streams/Implementation/Fusing/Ops.cs index 4d6d6df9140..280ff345fdb 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/Ops.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/Ops.cs @@ -92,12 +92,12 @@ public Select(Func func) /// /// TBD /// - public Inlet In { get; } = new Inlet("Select.in"); + public Inlet In { get; } = new("Select.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("Select.out"); + public Outlet Out { get; } = new("Select.out"); /// /// TBD @@ -526,7 +526,7 @@ protected override void OnResume(Exception ex) private class NotApplied { - public static readonly NotApplied Instance = new NotApplied(); + public static readonly NotApplied Instance = new(); private NotApplied() { } } } @@ -559,12 +559,12 @@ public Collect(Func isDefined, Func collector) /// /// TBD /// - public Inlet In { get; } = new Inlet("Collect.in"); + public Inlet In { get; } = new("Collect.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("Collect.out"); + public Outlet Out { get; } = new("Collect.out"); /// /// TBD @@ -977,12 +977,12 @@ public Scan(TOut zero, Func aggregate) /// /// TBD /// - public Inlet In { get; } = new Inlet("Scan.in"); + public Inlet In { get; } = new("Scan.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("Scan.out"); + public Outlet Out { get; } = new("Scan.out"); /// /// TBD @@ -1160,12 +1160,12 @@ public ScanAsync(TOut zero, Func> aggregate) /// /// TBD /// - public Inlet In { get; } = new Inlet("ScanAsync.in"); + public Inlet In { get; } = new("ScanAsync.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("ScanAsync.out"); + public Outlet Out { get; } = new("ScanAsync.out"); /// /// TBD @@ -1286,12 +1286,12 @@ public Aggregate(TOut zero, Func aggregate) /// /// TBD /// - public Inlet In { get; } = new Inlet("Aggregate.in"); + public Inlet In { get; } = new("Aggregate.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("Aggregate.out"); + public Outlet Out { get; } = new("Aggregate.out"); /// /// TBD @@ -1459,12 +1459,12 @@ public AggregateAsync(TOut zero, Func> aggregate) /// /// TBD /// - public Inlet In { get; } = new Inlet("AggregateAsync.in"); + public Inlet In { get; } = new("AggregateAsync.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("AggregateAsync.out"); + public Outlet Out { get; } = new("AggregateAsync.out"); /// /// TBD @@ -1689,12 +1689,12 @@ public Grouped(int count) /// /// TBD /// - public Inlet In { get; } = new Inlet("Grouped.in"); + public Inlet In { get; } = new("Grouped.in"); /// /// TBD /// - public Outlet> Out { get; } = new Outlet>("Grouped.out"); + public Outlet> Out { get; } = new("Grouped.out"); /// /// TBD @@ -1911,12 +1911,12 @@ public Sliding(int count, int step) /// /// TBD /// - public Inlet In { get; } = new Inlet("Sliding.in"); + public Inlet In { get; } = new("Sliding.in"); /// /// TBD /// - public Outlet> Out { get; } = new Outlet>("Sliding.out"); + public Outlet> Out { get; } = new("Sliding.out"); /// /// TBD @@ -2149,9 +2149,9 @@ public OnCompleted(Action success, Action failure) Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("OnCompleted.in"); + public Inlet In { get; } = new("OnCompleted.in"); - public Outlet Out { get; } = new Outlet("OnCompleted.out"); + public Outlet Out { get; } = new("OnCompleted.out"); public override FlowShape Shape { get; } @@ -2485,12 +2485,12 @@ public Expand(Func> extrapolate) /// /// TBD /// - public Inlet In { get; } = new Inlet("expand.in"); + public Inlet In { get; } = new("expand.in"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("expand.out"); + public Outlet Out { get; } = new("expand.out"); /// /// TBD @@ -2661,11 +2661,11 @@ private void HolderCompleted(Holder holder) /// /// TBD /// - public readonly Inlet In = new Inlet("SelectAsync.in"); + public readonly Inlet In = new("SelectAsync.in"); /// /// TBD /// - public readonly Outlet Out = new Outlet("SelectAsync.out"); + public readonly Outlet Out = new("SelectAsync.out"); /// /// TBD @@ -2811,11 +2811,11 @@ private void TaskCompleted(Result result) /// /// TBD /// - public readonly Inlet In = new Inlet("SelectAsyncUnordered.in"); + public readonly Inlet In = new("SelectAsyncUnordered.in"); /// /// TBD /// - public readonly Outlet Out = new Outlet("SelectAsyncUnordered.out"); + public readonly Outlet Out = new("SelectAsyncUnordered.out"); /// /// TBD @@ -2855,7 +2855,7 @@ protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) [InternalApi] public sealed class Log : SimpleLinearGraphStage { - private static readonly Attributes.LogLevels DefaultLogLevels = new Attributes.LogLevels( + private static readonly Attributes.LogLevels DefaultLogLevels = new( onElement: LogLevel.DebugLevel, onFinish: LogLevel.DebugLevel, onFailure: LogLevel.ErrorLevel); @@ -3034,7 +3034,7 @@ private sealed class Logic : TimerGraphStageLogic, IInHandler, IOutHandler private readonly GroupedWeightedWithin _stage; - private readonly List _buffer = new List(); + private readonly List _buffer = new(); private T _pending = default; private long _pendingWeight = 0L; // True if: @@ -3203,8 +3203,8 @@ protected internal override void OnTimer(object timerKey) #endregion - private readonly Inlet _in = new Inlet("in"); - private readonly Outlet> _out = new Outlet>("out"); + private readonly Inlet _in = new("in"); + private readonly Outlet> _out = new("out"); private readonly long _maxWeight; private readonly int _maxNumber; private readonly Func _costFn; @@ -3879,7 +3879,7 @@ public override void OnDownstreamFinish(Exception cause) } #endregion - private readonly Outlet _outlet = new Outlet("EnumerableSource.out"); + private readonly Outlet _outlet = new("EnumerableSource.out"); private readonly Func> _factory; public AsyncEnumerable(Func> factory) @@ -3993,8 +3993,8 @@ private void PushPull() private readonly Func>> _concatFactory; - private readonly Inlet _in = new Inlet("StatefulSelectMany.in"); - private readonly Outlet _out = new Outlet("StatefulSelectMany.out"); + private readonly Inlet _in = new("StatefulSelectMany.in"); + private readonly Outlet _out = new("StatefulSelectMany.out"); /// /// TBD @@ -4250,12 +4250,12 @@ public LazyFlow(Func>> flowFactory) /// /// TBD /// - public Inlet In { get; } = new Inlet("lazySink.In"); + public Inlet In { get; } = new("lazySink.In"); /// /// TBD /// - public Outlet Out { get; } = new Outlet("lazySink.Out"); + public Outlet Out { get; } = new("lazySink.Out"); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs b/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs index 188f9dc6083..486e67c292f 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/StreamOfStreams.cs @@ -35,7 +35,7 @@ private sealed class Logic : InAndOutGraphStageLogic { private readonly FlattenMerge _stage; private readonly Attributes _enclosingAttributes; - private readonly HashSet> _sources = new HashSet>(); + private readonly HashSet> _sources = new(); private IBuffer> _q; private readonly Action _outHandler; @@ -133,8 +133,8 @@ private void AddSource(IGraph, TMat> source) #endregion - private readonly Inlet _in = new Inlet("flatten.in"); - private readonly Outlet _out = new Outlet("flatten.out"); + private readonly Inlet _in = new("flatten.in"); + private readonly Outlet _out = new("flatten.out"); private readonly int _breadth; @@ -315,8 +315,8 @@ public void OnDownstreamFinish(Exception cause) #endregion private readonly int _count; - private readonly Inlet _in = new Inlet("PrefixAndTail.in"); - private readonly Outlet<(IImmutableList, Source)> _out = new Outlet<(IImmutableList, Source)>("PrefixAndTail.out"); + private readonly Inlet _in = new("PrefixAndTail.in"); + private readonly Outlet<(IImmutableList, Source)> _out = new("PrefixAndTail.out"); /// /// TBD @@ -365,9 +365,9 @@ internal sealed class GroupBy : GraphStage _stage; - private readonly Dictionary _activeSubstreams = new Dictionary(); - private readonly HashSet _closedSubstreams = new HashSet(); - private readonly HashSet _substreamsJustStarted = new HashSet(); + private readonly Dictionary _activeSubstreams = new(); + private readonly HashSet _closedSubstreams = new(); + private readonly HashSet _substreamsJustStarted = new(); private readonly Lazy _decider; private TimeSpan _timeout; private Option _substreamWaitingToBePushed = Option.None; @@ -644,9 +644,9 @@ public GroupBy(int maxSubstreams, Func keyFor, bool allowClosedSubstrea Shape = new FlowShape>(In, Out); } - private Inlet In { get; } = new Inlet("GroupBy.in"); + private Inlet In { get; } = new("GroupBy.in"); - private Outlet> Out { get; } = new Outlet>("GroupBy.out"); + private Outlet> Out { get; } = new("GroupBy.out"); /// /// TBD @@ -947,8 +947,8 @@ private void PushSubstreamSource() #endregion - private readonly Inlet _in = new Inlet("Split.in"); - private readonly Outlet> _out = new Outlet>("Split.out"); + private readonly Inlet _in = new("Split.in"); + private readonly Outlet> _out = new("Split.out"); private readonly Split.SplitDecision _decision; private readonly Func _predicate; @@ -1002,7 +1002,7 @@ internal interface IState /// internal class Uninitialized : IState { - public static readonly Uninitialized Instance = new Uninitialized(); + public static readonly Uninitialized Instance = new(); private Uninitialized() { @@ -1027,7 +1027,7 @@ protected CommandScheduledBeforeMaterialization(ICommand command) /// internal class RequestOneScheduledBeforeMaterialization : CommandScheduledBeforeMaterialization { - public static readonly RequestOneScheduledBeforeMaterialization Instance = new RequestOneScheduledBeforeMaterialization(RequestOne.Instance); + public static readonly RequestOneScheduledBeforeMaterialization Instance = new(RequestOne.Instance); private RequestOneScheduledBeforeMaterialization(ICommand command) : base(command) { @@ -1056,7 +1056,7 @@ internal interface ICommand internal class RequestOne : ICommand { - public static readonly RequestOne Instance = new RequestOne(); + public static readonly RequestOne Instance = new(); private RequestOne() { @@ -1137,8 +1137,8 @@ public override void PreStart() #endregion - private readonly Inlet _in = new Inlet("SubSink.in"); - private readonly AtomicReference _status = new AtomicReference(SubSink.Uninitialized.Instance); + private readonly Inlet _in = new("SubSink.in"); + private readonly AtomicReference _status = new(SubSink.Uninitialized.Instance); private readonly string _name; private readonly Action _externalCallback; @@ -1267,8 +1267,8 @@ public override void PreStart() #endregion private readonly string _name; - private readonly Outlet _out = new Outlet("SubSource.out"); - private readonly AtomicReference _status = new AtomicReference(); + private readonly Outlet _out = new("SubSource.out"); + private readonly AtomicReference _status = new(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs b/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs index 9b4fb8e58f5..b9dd418527b 100644 --- a/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs +++ b/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs @@ -63,7 +63,7 @@ public static Props Props(FileInfo f, TaskCompletionSource completionP private struct Continue : IDeadLetterSuppression { - public static readonly Continue Instance = new Continue(); + public static readonly Continue Instance = new(); } private readonly FileInfo _f; diff --git a/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs b/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs index bb01e508bdf..d6bf2ce9911 100644 --- a/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs +++ b/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs @@ -209,7 +209,7 @@ private void CloseAndComplete(Try result) internal class FlushSignal { - public static readonly FlushSignal Instance = new FlushSignal(); + public static readonly FlushSignal Instance = new(); private FlushSignal() { } } } diff --git a/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs b/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs index 10c20adbfab..8605161191b 100644 --- a/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs +++ b/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs @@ -42,7 +42,7 @@ public static Props Props(Stream inputstream, TaskCompletionSource com private struct Continue : IDeadLetterSuppression { - public static Continue Instance { get; } = new Continue(); + public static Continue Instance { get; } = new(); } private readonly Stream _inputstream; diff --git a/src/core/Akka.Streams/Implementation/IO/InputStreamSinkStage.cs b/src/core/Akka.Streams/Implementation/IO/InputStreamSinkStage.cs index f8af1557a37..8836f41ce59 100644 --- a/src/core/Akka.Streams/Implementation/IO/InputStreamSinkStage.cs +++ b/src/core/Akka.Streams/Implementation/IO/InputStreamSinkStage.cs @@ -38,7 +38,7 @@ internal class ReadElementAcknowledgement : IAdapterToStageMessage /// /// TBD /// - public static readonly ReadElementAcknowledgement Instance = new ReadElementAcknowledgement(); + public static readonly ReadElementAcknowledgement Instance = new(); private ReadElementAcknowledgement() { @@ -54,7 +54,7 @@ internal class Close : IAdapterToStageMessage /// /// TBD /// - public static readonly Close Instance = new Close(); + public static readonly Close Instance = new(); private Close() { @@ -97,7 +97,7 @@ internal class Finished : IStreamToAdapterMessage /// /// TBD /// - public static readonly Finished Instance = new Finished(); + public static readonly Finished Instance = new(); private Finished() { @@ -113,7 +113,7 @@ internal class Initialized : IStreamToAdapterMessage /// /// TBD /// - public static readonly Initialized Instance = new Initialized(); + public static readonly Initialized Instance = new(); private Initialized() { @@ -221,7 +221,7 @@ private void SendPullIfAllowed() #endregion - private readonly Inlet _in = new Inlet("InputStreamSink.in"); + private readonly Inlet _in = new("InputStreamSink.in"); private readonly TimeSpan _readTimeout; private BlockingCollection _dataQueue; diff --git a/src/core/Akka.Streams/Implementation/IO/OutputStreamSourceStage.cs b/src/core/Akka.Streams/Implementation/IO/OutputStreamSourceStage.cs index bd51504b6b4..dadb54dbe67 100644 --- a/src/core/Akka.Streams/Implementation/IO/OutputStreamSourceStage.cs +++ b/src/core/Akka.Streams/Implementation/IO/OutputStreamSourceStage.cs @@ -42,7 +42,7 @@ internal class Flush : IAdapterToStageMessage /// /// TBD /// - public static readonly Flush Instance = new Flush(); + public static readonly Flush Instance = new(); private Flush() { @@ -57,7 +57,7 @@ internal class Close : IAdapterToStageMessage /// /// TBD /// - public static readonly Close Instance = new Close(); + public static readonly Close Instance = new(); private Close() { @@ -79,7 +79,7 @@ internal class Ok : IDownstreamStatus /// /// TBD /// - public static readonly Ok Instance = new Ok(); + public static readonly Ok Instance = new(); private Ok() { @@ -94,7 +94,7 @@ internal class Canceled : IDownstreamStatus /// /// TBD /// - public static readonly Canceled Instance = new Canceled(); + public static readonly Canceled Instance = new(); private Canceled() { @@ -121,7 +121,7 @@ private sealed class Logic : OutGraphStageLogic, IStageWithCallback private readonly string _dispatcherId; private readonly Action<(IAdapterToStageMessage, TaskCompletionSource)> _upstreamCallback; private readonly OnPullRunnable _pullTask; - private readonly CancellationTokenSource _cancellation = new CancellationTokenSource(); + private readonly CancellationTokenSource _cancellation = new(); private BlockingCollection _dataQueue; private TaskCompletionSource _flush; private TaskCompletionSource _close; @@ -264,7 +264,7 @@ private void SendResponseIfNeeded() #endregion private readonly TimeSpan _writeTimeout; - private readonly Outlet _out = new Outlet("OutputStreamSource.out"); + private readonly Outlet _out = new("OutputStreamSource.out"); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/IO/TcpStages.cs b/src/core/Akka.Streams/Implementation/IO/TcpStages.cs index cce2f2dc20a..190e6526cda 100644 --- a/src/core/Akka.Streams/Implementation/IO/TcpStages.cs +++ b/src/core/Akka.Streams/Implementation/IO/TcpStages.cs @@ -35,11 +35,11 @@ private sealed class ConnectionSourceStageLogic : TimerGraphStageLogic, IOutHand { private const string BindShutdownTimer = "BindTimer"; - private readonly AtomicCounterLong _connectionFlowsAwaitingInitialization = new AtomicCounterLong(); + private readonly AtomicCounterLong _connectionFlowsAwaitingInitialization = new(); private readonly ConnectionSourceStage _stage; private IActorRef _listener; private readonly TaskCompletionSource _bindingPromise; - private readonly TaskCompletionSource _unbindPromise = new TaskCompletionSource(); + private readonly TaskCompletionSource _unbindPromise = new(); private bool _unbindStarted = false; public ConnectionSourceStageLogic(Shape shape, ConnectionSourceStage stage, TaskCompletionSource bindingPromise) @@ -196,7 +196,7 @@ public override void PostStop() private readonly bool _halfClose; private readonly TimeSpan? _idleTimeout; private readonly TimeSpan _bindShutdownTimeout; - private readonly Outlet _out = new Outlet("IncomingConnections.out"); + private readonly Outlet _out = new("IncomingConnections.out"); /// /// TBD @@ -255,9 +255,9 @@ public class IncomingConnectionStage : GraphStage _bytesIn = new Inlet("IncomingTCP.in"); - private readonly Outlet _bytesOut = new Outlet("IncomingTCP.out"); + private readonly AtomicBoolean _hasBeenCreated = new(); + private readonly Inlet _bytesIn = new("IncomingTCP.in"); + private readonly Outlet _bytesOut = new("IncomingTCP.out"); /// /// TBD @@ -312,7 +312,7 @@ internal static class TcpConnectionStage { private class WriteAck : Tcp.Event { - public static readonly WriteAck Instance = new WriteAck(); + public static readonly WriteAck Instance = new(); private WriteAck() { @@ -582,8 +582,8 @@ internal sealed class OutgoingConnectionStage : private readonly IImmutableList _options; private readonly bool _halfClose; private readonly TimeSpan? _connectionTimeout; - private readonly Inlet _bytesIn = new Inlet("IncomingTCP.in"); - private readonly Outlet _bytesOut = new Outlet("IncomingTCP.out"); + private readonly Inlet _bytesIn = new("IncomingTCP.in"); + private readonly Outlet _bytesOut = new("IncomingTCP.out"); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs b/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs index d19753f4fc5..cfa728a8eff 100644 --- a/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs +++ b/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs @@ -23,7 +23,7 @@ public class NothingToReadException : Exception /// /// The singleton instance of this exception /// - public static readonly NothingToReadException Instance = new NothingToReadException(); + public static readonly NothingToReadException Instance = new(); private NothingToReadException() { diff --git a/src/core/Akka.Streams/Implementation/SetupStage.cs b/src/core/Akka.Streams/Implementation/SetupStage.cs index db9bf852fda..dcec7ab7d7d 100644 --- a/src/core/Akka.Streams/Implementation/SetupStage.cs +++ b/src/core/Akka.Streams/Implementation/SetupStage.cs @@ -84,9 +84,9 @@ public SetupFlowStage(Func> Shape = new FlowShape(In, Out); } - public Inlet In { get; } = new Inlet("SetupFlowStage.in"); + public Inlet In { get; } = new("SetupFlowStage.in"); - public Outlet Out { get; } = new Outlet("SetupFlowStage.out"); + public Outlet Out { get; } = new("SetupFlowStage.out"); public override FlowShape Shape { get; } @@ -160,7 +160,7 @@ public SetupSourceStage(Func> Shape = new SourceShape(Out); } - public Outlet Out { get; } = new Outlet("SetupSourceStage.out"); + public Outlet Out { get; } = new("SetupSourceStage.out"); public override SourceShape Shape { get; } diff --git a/src/core/Akka.Streams/Implementation/Sinks.cs b/src/core/Akka.Streams/Implementation/Sinks.cs index ffb513c0bbf..ec528bf28da 100644 --- a/src/core/Akka.Streams/Implementation/Sinks.cs +++ b/src/core/Akka.Streams/Implementation/Sinks.cs @@ -485,7 +485,7 @@ public override void OnUpstreamFailure(Exception e) /// /// TBD /// - public readonly Inlet In = new Inlet("LastOrDefault.in"); + public readonly Inlet In = new("LastOrDefault.in"); /// /// TBD @@ -570,7 +570,7 @@ public override void PostStop() /// /// TBD /// - public readonly Inlet In = new Inlet("FirstOrDefault.in"); + public readonly Inlet In = new("FirstOrDefault.in"); /// /// TBD @@ -674,7 +674,7 @@ public SeqStage() /// /// TBD /// - public readonly Inlet In = new Inlet("Seq.in"); + public readonly Inlet In = new("Seq.in"); /// /// TBD @@ -816,7 +816,7 @@ public Task> PullAsync() /// /// TBD /// - public readonly Inlet In = new Inlet("QueueSink.in"); + public readonly Inlet In = new("QueueSink.in"); /// /// TBD @@ -1037,7 +1037,7 @@ public LazySink(Func>> sinkFactory) /// /// TBD /// - public Inlet In { get; } = new Inlet("lazySink.in"); + public Inlet In { get; } = new("lazySink.in"); /// /// TBD @@ -1071,7 +1071,7 @@ private sealed class ObserverDisposable : IDisposable { private readonly ObservableLogic _logic; private readonly IObserver _observer; - private readonly AtomicBoolean _disposed = new AtomicBoolean(false); + private readonly AtomicBoolean _disposed = new(false); public ObserverDisposable(ObservableLogic logic, IObserver observer) { @@ -1147,7 +1147,7 @@ public ObservableSinkStage() Shape = new SinkShape(Inlet); } - public Inlet Inlet { get; } = new Inlet("observable.in"); + public Inlet Inlet { get; } = new("observable.in"); public override SinkShape Shape { get; } public override ILogicAndMaterializedValue> CreateLogicAndMaterializedValue(Attributes inheritedAttributes) { diff --git a/src/core/Akka.Streams/Implementation/Sources.cs b/src/core/Akka.Streams/Implementation/Sources.cs index 80365b0ede0..e5ee1cb2d07 100644 --- a/src/core/Akka.Streams/Implementation/Sources.cs +++ b/src/core/Akka.Streams/Implementation/Sources.cs @@ -69,7 +69,7 @@ internal sealed class Completion : IInput /// /// TBD /// - public static Completion Instance { get; } = new Completion(); + public static Completion Instance { get; } = new(); private Completion() { @@ -369,7 +369,7 @@ public QueueSource(int maxBuffer, OverflowStrategy overflowStrategy) /// /// TBD /// - public Outlet Out { get; } = new Outlet("queueSource.out"); + public Outlet Out { get; } = new("queueSource.out"); /// /// TBD @@ -521,7 +521,7 @@ public UnfoldResourceSource(Func create, Func> re /// /// TBD /// - public Outlet Out { get; } = new Outlet("UnfoldResourceSource.out"); + public Outlet Out { get; } = new("UnfoldResourceSource.out"); /// /// TBD @@ -740,7 +740,7 @@ public UnfoldResourceSourceAsync(Func> create, Func /// TBD /// - public Outlet Out { get; } = new Outlet("UnfoldResourceSourceAsync.out"); + public Outlet Out { get; } = new("UnfoldResourceSourceAsync.out"); /// /// TBD @@ -840,7 +840,7 @@ public LazySource(Func> sourceFactory) /// /// TBD /// - public Outlet Out { get; } = new Outlet("LazySource.out"); + public Outlet Out { get; } = new("LazySource.out"); /// /// TBD @@ -877,8 +877,7 @@ public static class LazySource /// /// Creates a new for the given factory /// - public static LazySource Create(Func> create) => - new LazySource(create); + public static LazySource Create(Func> create) => new(create); } /// @@ -900,7 +899,7 @@ public EmptySource() Shape = new SourceShape(Out); } - public Outlet Out { get; } = new Outlet("EmptySource.out"); + public Outlet Out { get; } = new("EmptySource.out"); public override SourceShape Shape { get; } @@ -1087,7 +1086,7 @@ public ObservableSourceStage(IObservable observable, int maxBufferCapacity, O Shape = new SourceShape(Outlet); } - public Outlet Outlet { get; } = new Outlet("observable.out"); + public Outlet Outlet { get; } = new("observable.out"); public override SourceShape Shape { get; } protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) => new Logic(this); } diff --git a/src/core/Akka.Streams/Implementation/Stages/Stages.cs b/src/core/Akka.Streams/Implementation/Stages/Stages.cs index aa155bb8699..c7607cce4fb 100644 --- a/src/core/Akka.Streams/Implementation/Stages/Stages.cs +++ b/src/core/Akka.Streams/Implementation/Stages/Stages.cs @@ -548,7 +548,7 @@ public sealed class FirstOrDefault : GraphStageWithMaterializedValue _stage; - private readonly TaskCompletionSource _promise = new TaskCompletionSource(); + private readonly TaskCompletionSource _promise = new(); public Task Task => _promise.Task; @@ -587,7 +587,7 @@ public override void OnUpstreamFailure(Exception e) #endregion private readonly bool _throwOnDefault; - private readonly Inlet _in = new Inlet("firstOrDefault.in"); + private readonly Inlet _in = new("firstOrDefault.in"); /// /// TBD @@ -601,7 +601,7 @@ public FirstOrDefault(bool throwOnDefault = false) /// /// TBD /// - public override SinkShape Shape => new SinkShape(_in); + public override SinkShape Shape => new(_in); /// /// TBD @@ -632,7 +632,7 @@ public sealed class LastOrDefault : GraphStageWithMaterializedValue _stage; - private readonly TaskCompletionSource _promise = new TaskCompletionSource(); + private readonly TaskCompletionSource _promise = new(); private TIn _prev; private bool _foundAtLeastOne; @@ -675,7 +675,7 @@ public override void OnUpstreamFailure(Exception e) #endregion private readonly bool _throwOnDefault; - private readonly Inlet _in = new Inlet("lastOrDefault.in"); + private readonly Inlet _in = new("lastOrDefault.in"); /// /// TBD @@ -689,7 +689,7 @@ public LastOrDefault(bool throwOnDefault = false) /// /// TBD /// - public override SinkShape Shape => new SinkShape(_in); + public override SinkShape Shape => new(_in); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/StreamLayout.cs b/src/core/Akka.Streams/Implementation/StreamLayout.cs index b20746a5fd3..54098a02735 100644 --- a/src/core/Akka.Streams/Implementation/StreamLayout.cs +++ b/src/core/Akka.Streams/Implementation/StreamLayout.cs @@ -148,7 +148,7 @@ public sealed class Ignore : IMaterializedValueNode /// /// TBD /// - public static readonly Ignore Instance = new Ignore(); + public static readonly Ignore Instance = new(); private Ignore() { @@ -912,7 +912,7 @@ public sealed class EmptyModule : Module /// /// TBD /// - public static readonly EmptyModule Instance = new EmptyModule(); + public static readonly EmptyModule Instance = new(); private EmptyModule() { @@ -1580,7 +1580,7 @@ private sealed class Inert { public static readonly ISubscriber Subscriber = new CancellingSubscriber(); - public static readonly Inert Instance = new Inert(); + public static readonly Inert Instance = new(); private Inert() { @@ -1615,7 +1615,7 @@ public Establishing Copy( ISubscriber subscriber = null, bool? onCompleteBuffered = null, Exception onErrorBuffered = null) - => new Establishing( + => new( subscriber ?? Subscriber, onCompleteBuffered ?? OnCompleteBuffered, onErrorBuffered ?? OnErrorBuffered); @@ -2050,7 +2050,7 @@ private interface ISubscriptionState private sealed class PassThrough : ISubscriptionState { - public static PassThrough Instance { get; } = new PassThrough(); + public static PassThrough Instance { get; } = new(); private PassThrough() { } @@ -2069,7 +2069,7 @@ public Buffering(long demand) private sealed class WrappedSubscription : AtomicReference, ISubscription { - private static readonly Buffering NoBufferedDemand = new Buffering(0); + private static readonly Buffering NoBufferedDemand = new(0); private readonly ISubscription _real; private readonly VirtualProcessor _processor; @@ -2176,7 +2176,7 @@ private sealed class Inert { public static readonly ISubscriber Subscriber = new CancellingSubscriber(); - public static readonly Inert Instance = new Inert(); + public static readonly Inert Instance = new(); private Inert() { @@ -2311,7 +2311,7 @@ protected MaterializationPanicException(SerializationInfo info, StreamingContext /// The reason why the encapsulated (copied) modules are stored as mutable state to save subclasses of this class /// from passing the current scope around or even knowing about it. /// - private readonly LinkedList _moduleStack = new LinkedList(); + private readonly LinkedList _moduleStack = new(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs index 866997409b8..b5946b31f1b 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs @@ -287,7 +287,7 @@ public SinkRefStageImpl(IActorRef initialPartnerRef) Shape = new SinkShape(Inlet); } - public Inlet Inlet { get; } = new Inlet("SinkRef.in"); + public Inlet Inlet { get; } = new("SinkRef.in"); public override SinkShape Shape { get; } public override ILogicAndMaterializedValue>> CreateLogicAndMaterializedValue(Attributes inheritedAttributes) { diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs index 4bdf3e22b41..5dc63f8f267 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs @@ -306,7 +306,7 @@ public SourceRefStageImpl(IActorRef initialPartnerRef) Shape = new SourceShape(Outlet); } - public Outlet Outlet { get; } = new Outlet("SourceRef.out"); + public Outlet Outlet { get; } = new("SourceRef.out"); public override SourceShape Shape { get; } public override ILogicAndMaterializedValue>> CreateLogicAndMaterializedValue(Attributes inheritedAttributes) diff --git a/src/core/Akka.Streams/Implementation/StreamRef/StreamRefs.cs b/src/core/Akka.Streams/Implementation/StreamRef/StreamRefs.cs index c85814d4568..6c8faad83b7 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/StreamRefs.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/StreamRefs.cs @@ -29,7 +29,6 @@ public StreamRefsMaster(ExtendedActorSystem system) internal sealed class StreamRefsMasterProvider : ExtensionIdProvider { - public override StreamRefsMaster CreateExtension(ExtendedActorSystem system) => - new StreamRefsMaster(system); + public override StreamRefsMaster CreateExtension(ExtendedActorSystem system) => new(system); } } diff --git a/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs b/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs index 7253b60f409..3feaab28cea 100644 --- a/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs +++ b/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs @@ -55,7 +55,7 @@ public sealed class CancelingSubscriber : ISubscriber /// /// TBD /// - public static readonly CancelingSubscriber Instance = new CancelingSubscriber(); + public static readonly CancelingSubscriber Instance = new(); private CancelingSubscriber() { } /// @@ -98,7 +98,7 @@ public sealed class NoopSubscriptionTimeout : ICancelable /// /// TBD /// - public static readonly NoopSubscriptionTimeout Instance = new NoopSubscriptionTimeout(); + public static readonly NoopSubscriptionTimeout Instance = new(); private NoopSubscriptionTimeout() { } /// diff --git a/src/core/Akka.Streams/Implementation/SubscriberManagement.cs b/src/core/Akka.Streams/Implementation/SubscriberManagement.cs index 81fb15b1fa5..3ec05872d62 100644 --- a/src/core/Akka.Streams/Implementation/SubscriberManagement.cs +++ b/src/core/Akka.Streams/Implementation/SubscriberManagement.cs @@ -70,7 +70,7 @@ public sealed class NotReached : IEndOfStream /// /// TBD /// - public static readonly NotReached Instance = new NotReached(); + public static readonly NotReached Instance = new(); private NotReached() { } /// @@ -93,7 +93,7 @@ public sealed class Completed : IEndOfStream /// /// TBD /// - public static readonly Completed Instance = new Completed(); + public static readonly Completed Instance = new(); private Completed() { } /// diff --git a/src/core/Akka.Streams/Implementation/Timers.cs b/src/core/Akka.Streams/Implementation/Timers.cs index 96564c908e2..f0e74706b7f 100644 --- a/src/core/Akka.Streams/Implementation/Timers.cs +++ b/src/core/Akka.Streams/Implementation/Timers.cs @@ -33,7 +33,7 @@ public static class Timers /// TBD /// TBD public static TimeSpan IdleTimeoutCheckInterval(TimeSpan timeout) - => new TimeSpan(Math.Min(Math.Max(timeout.Ticks/8, 100*TimeSpan.TicksPerMillisecond), timeout.Ticks/2)); + => new(Math.Min(Math.Max(timeout.Ticks/8, 100*TimeSpan.TicksPerMillisecond), timeout.Ticks/2)); /// /// TBD @@ -433,19 +433,19 @@ public override void PreStart() /// /// TBD /// - public readonly Inlet In1 = new Inlet("in1"); + public readonly Inlet In1 = new("in1"); /// /// TBD /// - public readonly Inlet In2 = new Inlet("in2"); + public readonly Inlet In2 = new("in2"); /// /// TBD /// - public readonly Outlet Out1 = new Outlet("out1"); + public readonly Outlet Out1 = new("out1"); /// /// TBD /// - public readonly Outlet Out2 = new Outlet("out2"); + public readonly Outlet Out2 = new("out2"); /// /// TBD @@ -654,8 +654,8 @@ protected internal override void OnTimer(object timerKey) private readonly TimeSpan _timeout; private readonly Func _inject; - private readonly Inlet _in = new Inlet("IdleInject.in"); - private readonly Outlet _out = new Outlet("IdleInject.out"); + private readonly Inlet _in = new("IdleInject.in"); + private readonly Outlet _out = new("IdleInject.out"); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/Transfer.cs b/src/core/Akka.Streams/Implementation/Transfer.cs index e12adf8ad1f..2a979e6d58d 100644 --- a/src/core/Akka.Streams/Implementation/Transfer.cs +++ b/src/core/Akka.Streams/Implementation/Transfer.cs @@ -259,7 +259,7 @@ internal sealed class Completed : TransferState /// /// TBD /// - public static readonly Completed Instance = new Completed(); + public static readonly Completed Instance = new(); private Completed() { @@ -284,7 +284,7 @@ internal sealed class NotInitialized : TransferState /// /// TBD /// - public static readonly NotInitialized Instance = new NotInitialized(); + public static readonly NotInitialized Instance = new(); private NotInitialized() { @@ -343,7 +343,7 @@ internal sealed class Always : TransferState /// /// TBD /// - public static readonly Always Instance = new Always(); + public static readonly Always Instance = new(); private Always() { @@ -539,7 +539,7 @@ public static void Init(this IPump self) /// /// This exception is thrown when the action of the completed phase tried to execute. /// - public static readonly TransferPhase CompletedPhase = new TransferPhase(Completed.Instance, () => + public static readonly TransferPhase CompletedPhase = new(Completed.Instance, () => { throw new IllegalStateException("The action of completed phase must never be executed"); }); diff --git a/src/core/Akka.Streams/Implementation/Unfold.cs b/src/core/Akka.Streams/Implementation/Unfold.cs index 471a3e4a308..da60c73cff3 100644 --- a/src/core/Akka.Streams/Implementation/Unfold.cs +++ b/src/core/Akka.Streams/Implementation/Unfold.cs @@ -61,7 +61,7 @@ public override void OnPull() /// /// TBD /// - public readonly Outlet Out = new Outlet("Unfold.out"); + public readonly Outlet Out = new("Unfold.out"); /// /// TBD @@ -152,7 +152,7 @@ public override void PreStart() /// /// TBD /// - public readonly Outlet Out = new Outlet("UnfoldAsync.out"); + public readonly Outlet Out = new("UnfoldAsync.out"); /// /// TBD @@ -222,7 +222,7 @@ public override void OnPull() /// /// TBD /// - public readonly Outlet Out = new Outlet("UnfoldInfinite.out"); + public readonly Outlet Out = new("UnfoldInfinite.out"); /// /// TBD diff --git a/src/core/Akka.Streams/KillSwitch.cs b/src/core/Akka.Streams/KillSwitch.cs index a94652254b0..6433b438310 100644 --- a/src/core/Akka.Streams/KillSwitch.cs +++ b/src/core/Akka.Streams/KillSwitch.cs @@ -30,7 +30,7 @@ public static class KillSwitches /// /// TBD /// TBD - public static SharedKillSwitch Shared(string name) => new SharedKillSwitch(name); + public static SharedKillSwitch Shared(string name) => new(name); /// /// Creates a new of that materializes to an external switch that allows external completion @@ -139,8 +139,8 @@ public CancellableKillSwitchStage(CancellationToken cancellationToken, bool canc Shape = new FlowShape(Inlet, Outlet); } - public Inlet Inlet { get; } = new Inlet("cancel.in"); - public Outlet Outlet { get; } = new Outlet("cancel.out"); + public Inlet Inlet { get; } = new("cancel.in"); + public Outlet Outlet { get; } = new("cancel.out"); public override FlowShape Shape { get; } protected override GraphStageLogic CreateLogic(Attributes inheritedAttributes) => new Logic(this); @@ -207,15 +207,15 @@ public Logic(Task terminationSignal, UniqueKillSwitchStage stage) : base(term #endregion - public static UniqueKillSwitchStage Instance { get; } = new UniqueKillSwitchStage(); + public static UniqueKillSwitchStage Instance { get; } = new(); private UniqueKillSwitchStage() => Shape = new FlowShape(In, Out); protected override Attributes InitialAttributes { get; } = Attributes.CreateName("breaker"); - private Inlet In { get; } = new Inlet("KillSwitch.in"); + private Inlet In { get; } = new("KillSwitch.in"); - private Outlet Out { get; } = new Outlet("KillSwitch.out"); + private Outlet Out { get; } = new("KillSwitch.out"); public override FlowShape Shape { get; } @@ -270,19 +270,19 @@ public Logic(Task terminationSignal, UniqueBidiKillSwitchStage killSwitc #endregion - public static UniqueBidiKillSwitchStage Instance { get; } = new UniqueBidiKillSwitchStage(); + public static UniqueBidiKillSwitchStage Instance { get; } = new(); private UniqueBidiKillSwitchStage() => Shape = new BidiShape(In1, Out1, In2, Out2); protected override Attributes InitialAttributes { get; } = Attributes.CreateName("breaker"); - private Inlet In1 { get; } = new Inlet("KillSwitchBidi.in1"); + private Inlet In1 { get; } = new("KillSwitchBidi.in1"); - private Outlet Out1 { get; } = new Outlet("KillSwitchBidi.out1"); + private Outlet Out1 { get; } = new("KillSwitchBidi.out1"); - private Inlet In2 { get; } = new Inlet("KillSwitchBidi.in2"); + private Inlet In2 { get; } = new("KillSwitchBidi.in2"); - private Outlet Out2 { get; } = new Outlet("KillSwitchBidi.out2"); + private Outlet Out2 { get; } = new("KillSwitchBidi.out2"); public override BidiShape Shape { get; } @@ -427,9 +427,9 @@ public SharedKillSwitchFlow(SharedKillSwitch killSwitch) Shape = new FlowShape(In, Out); } - private Inlet In { get; } = new Inlet("KillSwitch.in"); + private Inlet In { get; } = new("KillSwitch.in"); - private Outlet Out { get; } = new Outlet("KillSwitch.out"); + private Outlet Out { get; } = new("KillSwitch.out"); public override FlowShape Shape { get; } @@ -442,7 +442,7 @@ public override ILogicAndMaterializedValue CreateLogicAndMater #endregion - private readonly TaskCompletionSource _shutdownPromise = new TaskCompletionSource(); + private readonly TaskCompletionSource _shutdownPromise = new(); private readonly string _name; /// diff --git a/src/core/Akka.Streams/QueueOfferResult.cs b/src/core/Akka.Streams/QueueOfferResult.cs index 1e37e2580b9..d1e84cb9885 100644 --- a/src/core/Akka.Streams/QueueOfferResult.cs +++ b/src/core/Akka.Streams/QueueOfferResult.cs @@ -29,7 +29,7 @@ public sealed class Enqueued : IQueueOfferResult /// /// TBD /// - public static readonly Enqueued Instance = new Enqueued(); + public static readonly Enqueued Instance = new(); private Enqueued() { @@ -44,7 +44,7 @@ public sealed class Dropped : IQueueOfferResult /// /// TBD /// - public static readonly Dropped Instance = new Dropped(); + public static readonly Dropped Instance = new(); private Dropped() { @@ -79,7 +79,7 @@ public sealed class QueueClosed : IQueueOfferResult /// /// TBD /// - public static readonly QueueClosed Instance = new QueueClosed(); + public static readonly QueueClosed Instance = new(); private QueueClosed() { diff --git a/src/core/Akka.Streams/RestartSettings.cs b/src/core/Akka.Streams/RestartSettings.cs index 16b05f1c6cd..8d474799e3d 100644 --- a/src/core/Akka.Streams/RestartSettings.cs +++ b/src/core/Akka.Streams/RestartSettings.cs @@ -27,7 +27,7 @@ private RestartSettings(TimeSpan minBackoff, TimeSpan maxBackoff, double randomF } public static RestartSettings Create(TimeSpan minBackoff, TimeSpan maxBackoff, double randomFactor) => - new RestartSettings(minBackoff, maxBackoff, randomFactor, int.MaxValue, minBackoff); + new(minBackoff, maxBackoff, randomFactor, int.MaxValue, minBackoff); /// /// Minimum (initial) duration until the child actor will started again, if it is terminated @@ -58,6 +58,6 @@ public override string ToString() => $"RestartSettings(" + $"maxRestartsWithin={MaxRestartsWithin})"; private RestartSettings Copy(TimeSpan? minBackoff = null, TimeSpan? maxBackoff = null, double? randomFactor = null, int? maxRestarts = null, TimeSpan? maxRestartsWithin = null) => - new RestartSettings(minBackoff ?? MinBackoff, maxBackoff ?? MaxBackoff, randomFactor ?? RandomFactor, maxRestarts ?? MaxRestarts, maxRestartsWithin ?? MaxRestartsWithin); + new(minBackoff ?? MinBackoff, maxBackoff ?? MaxBackoff, randomFactor ?? RandomFactor, maxRestarts ?? MaxRestarts, maxRestartsWithin ?? MaxRestartsWithin); } } diff --git a/src/core/Akka.Streams/Serialization/SerializationTools.cs b/src/core/Akka.Streams/Serialization/SerializationTools.cs index a62461e2ba6..64f3a17c9a6 100644 --- a/src/core/Akka.Streams/Serialization/SerializationTools.cs +++ b/src/core/Akka.Streams/Serialization/SerializationTools.cs @@ -19,7 +19,7 @@ internal static class SerializationTools public static Type TypeFromProto(EventType eventType) => TypeFromString(eventType.TypeName); - public static EventType TypeToProto(Type clrType) => new EventType + public static EventType TypeToProto(Type clrType) => new() { TypeName = clrType.TypeQualifiedName() }; diff --git a/src/core/Akka.Streams/Shape.cs b/src/core/Akka.Streams/Shape.cs index 00d2ba0f7fa..eb95dae4dce 100644 --- a/src/core/Akka.Streams/Shape.cs +++ b/src/core/Akka.Streams/Shape.cs @@ -241,7 +241,7 @@ public class ClosedShape : Shape /// /// TBD /// - public static readonly ClosedShape Instance = new ClosedShape(); + public static readonly ClosedShape Instance = new(); private ClosedShape() { } @@ -695,6 +695,6 @@ public static class BidiShape /// TBD public static BidiShape FromFlows( FlowShape top, FlowShape bottom) - => new BidiShape(top.Inlet, top.Outlet, bottom.Inlet, bottom.Outlet); + => new(top.Inlet, top.Outlet, bottom.Inlet, bottom.Outlet); } } diff --git a/src/core/Akka.Streams/Stage/GraphStage.cs b/src/core/Akka.Streams/Stage/GraphStage.cs index a55df889f00..e8ad1b3debb 100644 --- a/src/core/Akka.Streams/Stage/GraphStage.cs +++ b/src/core/Akka.Streams/Stage/GraphStage.cs @@ -210,7 +210,7 @@ public sealed override ILogicAndMaterializedValue CreateLogicAndMateria public abstract class TimerGraphStageLogic : GraphStageLogic { private readonly IDictionary _keyToTimers = new Dictionary(); - private readonly AtomicCounter _timerIdGen = new AtomicCounter(0); + private readonly AtomicCounter _timerIdGen = new(0); private Action _timerAsyncCallback; /// @@ -1879,7 +1879,7 @@ public void Cancel(Exception cause) /// TBD /// TBD /// TBD - protected SubSinkInlet CreateSubSinkInlet(string name) => new SubSinkInlet(this, name); + protected SubSinkInlet CreateSubSinkInlet(string name) => new(this, name); /// /// INTERNAL API @@ -2263,7 +2263,7 @@ public class StageActorRefNotInitializedException : Exception /// /// The singleton instance of this exception /// - public static readonly StageActorRefNotInitializedException Instance = new StageActorRefNotInitializedException(); + public static readonly StageActorRefNotInitializedException Instance = new(); private StageActorRefNotInitializedException() : base("You must first call GetStageActorRef(StageActorRef.Receive), to initialize the actor's behavior") { } /// @@ -2282,7 +2282,7 @@ public sealed class EagerTerminateInput : InHandler /// /// TBD /// - public static readonly EagerTerminateInput Instance = new EagerTerminateInput(); + public static readonly EagerTerminateInput Instance = new(); private EagerTerminateInput() { } @@ -2300,7 +2300,7 @@ public sealed class IgnoreTerminateInput : InHandler /// /// TBD /// - public static readonly IgnoreTerminateInput Instance = new IgnoreTerminateInput(); + public static readonly IgnoreTerminateInput Instance = new(); private IgnoreTerminateInput() { } @@ -2350,7 +2350,7 @@ public sealed class TotallyIgnorantInput : InHandler /// /// TBD /// - public static readonly TotallyIgnorantInput Instance = new TotallyIgnorantInput(); + public static readonly TotallyIgnorantInput Instance = new(); private TotallyIgnorantInput() { } @@ -2377,7 +2377,7 @@ public sealed class EagerTerminateOutput : OutHandler /// /// TBD /// - public static readonly EagerTerminateOutput Instance = new EagerTerminateOutput(); + public static readonly EagerTerminateOutput Instance = new(); private EagerTerminateOutput() { } /// @@ -2394,7 +2394,7 @@ public sealed class IgnoreTerminateOutput : OutHandler /// /// TBD /// - public static readonly IgnoreTerminateOutput Instance = new IgnoreTerminateOutput(); + public static readonly IgnoreTerminateOutput Instance = new(); private IgnoreTerminateOutput() { } @@ -2567,8 +2567,7 @@ private sealed class Stopped : ICallbackState public Stopped(Action callback) => Callback = callback; } - private readonly AtomicReference _callbackState = - new AtomicReference(new NotInitialized(new List())); + private readonly AtomicReference _callbackState = new(new NotInitialized(new List())); /// /// TBD diff --git a/src/core/Akka.Streams/Stage/Stage.cs b/src/core/Akka.Streams/Stage/Stage.cs index 7b6260ec97f..6bb75c6c404 100644 --- a/src/core/Akka.Streams/Stage/Stage.cs +++ b/src/core/Akka.Streams/Stage/Stage.cs @@ -185,7 +185,7 @@ internal sealed class Finish : IAndThen /// /// TBD /// - public static readonly Finish Instance = new Finish(); + public static readonly Finish Instance = new(); private Finish() { } } @@ -221,7 +221,7 @@ internal sealed class Stay : IAndThen /// /// TBD /// - public static readonly Stay Instance = new Stay(); + public static readonly Stay Instance = new(); private Stay() { } } diff --git a/src/core/Akka.Streams/StreamRefs.cs b/src/core/Akka.Streams/StreamRefs.cs index 236d6106ee3..62111739e74 100644 --- a/src/core/Akka.Streams/StreamRefs.cs +++ b/src/core/Akka.Streams/StreamRefs.cs @@ -92,7 +92,7 @@ protected StreamRefSubscriptionTimeoutException(SerializationInfo info, Streamin public sealed class RemoteStreamRefActorTerminatedException : Exception { internal static readonly RemoteStreamRefActorTerminatedException Default = - new RemoteStreamRefActorTerminatedException("Remote target receiver of data terminated. Local stream terminating, message loss (on remote side) may have happened."); + new("Remote target receiver of data terminated. Local stream terminating, message loss (on remote side) may have happened."); public RemoteStreamRefActorTerminatedException(string message) : base(message) { diff --git a/src/core/Akka.Streams/StreamTcpException.cs b/src/core/Akka.Streams/StreamTcpException.cs index 6064b972193..b14dd4e0ded 100644 --- a/src/core/Akka.Streams/StreamTcpException.cs +++ b/src/core/Akka.Streams/StreamTcpException.cs @@ -51,7 +51,7 @@ public class StreamDetachedException : Exception /// /// Initializes a single instance of the class. /// - public static readonly StreamDetachedException Instance = new StreamDetachedException(); + public static readonly StreamDetachedException Instance = new(); public StreamDetachedException() : this("Stream is terminated. Materialized value is detached.") @@ -78,7 +78,7 @@ public class BindFailedException : StreamTcpException /// /// The single instance of this exception /// - public static readonly BindFailedException Instance = new BindFailedException(); + public static readonly BindFailedException Instance = new(); private BindFailedException() : base("bind failed") { diff --git a/src/core/Akka.Streams/SubscriptionWithCancelException.cs b/src/core/Akka.Streams/SubscriptionWithCancelException.cs index 312f4036fff..25508f584a3 100644 --- a/src/core/Akka.Streams/SubscriptionWithCancelException.cs +++ b/src/core/Akka.Streams/SubscriptionWithCancelException.cs @@ -21,13 +21,13 @@ public abstract class NonFailureCancellation : Exception public sealed class NoMoreElementsNeeded : NonFailureCancellation { - public static readonly NoMoreElementsNeeded Instance = new NoMoreElementsNeeded(); + public static readonly NoMoreElementsNeeded Instance = new(); private NoMoreElementsNeeded() { } } public sealed class StageWasCompleted : NonFailureCancellation { - public static readonly StageWasCompleted Instance = new StageWasCompleted(); + public static readonly StageWasCompleted Instance = new(); private StageWasCompleted() { } } } diff --git a/src/core/Akka.TestKit.Tests/TestActorRefTests/TestActorRefSpec.cs b/src/core/Akka.TestKit.Tests/TestActorRefTests/TestActorRefSpec.cs index 609cdd16cbb..ef34b74ebba 100644 --- a/src/core/Akka.TestKit.Tests/TestActorRefTests/TestActorRefSpec.cs +++ b/src/core/Akka.TestKit.Tests/TestActorRefTests/TestActorRefSpec.cs @@ -19,9 +19,9 @@ namespace Akka.TestKit.Tests.TestActorRefTests { public class TestActorRefSpec : AkkaSpec { - private readonly AtomicCounter _counter = new AtomicCounter(4); + private readonly AtomicCounter _counter = new(4); private readonly Thread _thread = Thread.CurrentThread; - private readonly AtomicReference _otherThread = new AtomicReference(null); + private readonly AtomicReference _otherThread = new(null); public TestActorRefSpec() : base(GetConfig()) diff --git a/src/core/Akka.TestKit/AutoPilots.cs b/src/core/Akka.TestKit/AutoPilots.cs index d98b27266a3..b3be102a05b 100644 --- a/src/core/Akka.TestKit/AutoPilots.cs +++ b/src/core/Akka.TestKit/AutoPilots.cs @@ -57,7 +57,7 @@ public sealed class NoAutoPilot : AutoPilot /// /// TBD /// - public static NoAutoPilot Instance = new NoAutoPilot(); + public static NoAutoPilot Instance = new(); private NoAutoPilot() { } @@ -82,7 +82,7 @@ public sealed class KeepRunning : AutoPilot /// /// TBD /// - public static KeepRunning Instance = new KeepRunning(); + public static KeepRunning Instance = new(); private KeepRunning(){ } diff --git a/src/core/Akka.TestKit/DelegatingSupervisorStrategy.cs b/src/core/Akka.TestKit/DelegatingSupervisorStrategy.cs index b71ca17d265..6368faf3582 100644 --- a/src/core/Akka.TestKit/DelegatingSupervisorStrategy.cs +++ b/src/core/Akka.TestKit/DelegatingSupervisorStrategy.cs @@ -15,7 +15,7 @@ namespace Akka.TestKit { public class DelegatingSupervisorStrategy : SupervisorStrategy { - private Dictionary Delegates { get; } = new Dictionary(); + private Dictionary Delegates { get; } = new(); public override IDecider Decider { get; } = DefaultDecider; diff --git a/src/core/Akka.TestKit/EventFilter/TestEventListener.cs b/src/core/Akka.TestKit/EventFilter/TestEventListener.cs index efc7295091c..00a1285f89c 100644 --- a/src/core/Akka.TestKit/EventFilter/TestEventListener.cs +++ b/src/core/Akka.TestKit/EventFilter/TestEventListener.cs @@ -21,7 +21,7 @@ namespace Akka.TestKit /// public class TestEventListener : DefaultLogger { - private readonly List _filters = new List(); + private readonly List _filters = new(); /// /// TBD diff --git a/src/core/Akka.TestKit/Internal/AsyncQueue.cs b/src/core/Akka.TestKit/Internal/AsyncQueue.cs index c656420bd66..b63a8c94491 100644 --- a/src/core/Akka.TestKit/Internal/AsyncQueue.cs +++ b/src/core/Akka.TestKit/Internal/AsyncQueue.cs @@ -16,13 +16,13 @@ namespace Akka.TestKit.Internal { public class AsyncQueue: ITestQueue where T: class { - private readonly AsyncPeekableCollection _collection = new AsyncPeekableCollection(new QueueCollection()); + private readonly AsyncPeekableCollection _collection = new(new QueueCollection()); public int Count => _collection.Count; public void Enqueue(T item) => EnqueueAsync(item).AsTask().WaitAndUnwrapException(); - public ValueTask EnqueueAsync(T item) => new ValueTask(_collection.AddAsync(item)); + public ValueTask EnqueueAsync(T item) => new(_collection.AddAsync(item)); public bool TryEnqueue(T item, int millisecondsTimeout, CancellationToken cancellationToken) { @@ -113,8 +113,7 @@ public T Take(CancellationToken cancellationToken) return item; } - public ValueTask TakeAsync(CancellationToken cancellationToken) - => new ValueTask(_collection.TakeAsync(cancellationToken)); + public ValueTask TakeAsync(CancellationToken cancellationToken) => new(_collection.TakeAsync(cancellationToken)); public bool TryPeek(out T item) => _collection.TryPeek(out item); @@ -166,8 +165,7 @@ public T Peek(CancellationToken cancellationToken) return item; } - public ValueTask PeekAsync(CancellationToken cancellationToken) - => new ValueTask(_collection.PeekAsync(cancellationToken)); + public ValueTask PeekAsync(CancellationToken cancellationToken) => new(_collection.PeekAsync(cancellationToken)); public List ToList() { @@ -176,7 +174,7 @@ public List ToList() private class QueueCollection : IPeekableProducerConsumerCollection { - private readonly Queue _queue = new Queue(); + private readonly Queue _queue = new(); public int Count { get @@ -267,7 +265,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } - public object SyncRoot { get; } = new object(); + public object SyncRoot { get; } = new(); public bool IsSynchronized => true; } diff --git a/src/core/Akka.TestKit/Internal/BlockingQueue.cs b/src/core/Akka.TestKit/Internal/BlockingQueue.cs index 8add39b72c5..0f81844931b 100644 --- a/src/core/Akka.TestKit/Internal/BlockingQueue.cs +++ b/src/core/Akka.TestKit/Internal/BlockingQueue.cs @@ -23,7 +23,7 @@ namespace Akka.TestKit.Internal /// The type of item to store. public class BlockingQueue : ITestQueue { - private readonly BlockingCollection _collection = new BlockingCollection(new QueueWithAddFirst()); + private readonly BlockingCollection _collection = new(new QueueWithAddFirst()); public int Count { get { return _collection.Count; } } @@ -200,7 +200,7 @@ public Positioned(T value, bool first = false) private class QueueWithAddFirst : IProducerConsumerCollection { - private readonly LinkedList _list = new LinkedList(); + private readonly LinkedList _list = new(); public int Count { get @@ -280,7 +280,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } - public object SyncRoot { get; } = new object(); + public object SyncRoot { get; } = new(); public bool IsSynchronized => true; } diff --git a/src/core/Akka.TestKit/Internal/InternalTestActor.cs b/src/core/Akka.TestKit/Internal/InternalTestActor.cs index b33d2488396..51b425b1935 100644 --- a/src/core/Akka.TestKit/Internal/InternalTestActor.cs +++ b/src/core/Akka.TestKit/Internal/InternalTestActor.cs @@ -21,7 +21,7 @@ public class InternalTestActor : ActorBase private readonly ITestActorQueue _queue; private TestKit.TestActor.Ignore _ignore; private AutoPilot _autoPilot; - private DelegatingSupervisorStrategy _supervisorStrategy = new DelegatingSupervisorStrategy(); + private DelegatingSupervisorStrategy _supervisorStrategy = new(); /// /// TBD diff --git a/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs b/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs index 0b46c1847ad..f03d73b8435 100644 --- a/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs +++ b/src/core/Akka.TestKit/Internal/InternalTestActorRef.cs @@ -27,7 +27,7 @@ namespace Akka.TestKit.Internal /// public class InternalTestActorRef : LocalActorRef { - private static readonly AtomicCounterLong _uniqueNameNumber = new AtomicCounterLong(0); + private static readonly AtomicCounterLong _uniqueNameNumber = new(0); /// INTERNAL /// Note! Part of internal API. Breaking changes may occur without notice. Use at own risk. @@ -261,8 +261,7 @@ public override ActorTaskScheduler TaskScheduler } - private readonly Dictionary> _testActorTasks = - new Dictionary>(); + private readonly Dictionary> _testActorTasks = new(); /// /// This is only intended to be called from TestKit's TestActorRef @@ -350,7 +349,7 @@ public class InternalGetActor : IAutoReceivedMessage, IPossiblyHarmful /// /// TBD /// - public static readonly InternalGetActor Instance = new InternalGetActor(); + public static readonly InternalGetActor Instance = new(); private InternalGetActor() { } } } diff --git a/src/core/Akka.TestKit/NullMessageEnvelope.cs b/src/core/Akka.TestKit/NullMessageEnvelope.cs index 6615963365a..0304e43a1de 100644 --- a/src/core/Akka.TestKit/NullMessageEnvelope.cs +++ b/src/core/Akka.TestKit/NullMessageEnvelope.cs @@ -17,7 +17,7 @@ public sealed class NullMessageEnvelope : MessageEnvelope /// /// TBD /// - public static NullMessageEnvelope Instance=new NullMessageEnvelope(); + public static NullMessageEnvelope Instance = new(); private NullMessageEnvelope(){} diff --git a/src/core/Akka.TestKit/TestKitBase.cs b/src/core/Akka.TestKit/TestKitBase.cs index 21a4ac54b39..0e760de6f3a 100644 --- a/src/core/Akka.TestKit/TestKitBase.cs +++ b/src/core/Akka.TestKit/TestKitBase.cs @@ -58,7 +58,7 @@ public TestState() akka.log-dead-letters = true akka.loglevel = DEBUG akka.stdout-loglevel = DEBUG"); - private static readonly AtomicCounter _testActorId = new AtomicCounter(0); + private static readonly AtomicCounter _testActorId = new(0); private readonly ITestKitAssertions _assertions; private TestState _testState; diff --git a/src/core/Akka.Tests.Performance/Actor/ActorMemoryFootprintSpec.cs b/src/core/Akka.Tests.Performance/Actor/ActorMemoryFootprintSpec.cs index fafe63d1629..cd4ea1dce1c 100644 --- a/src/core/Akka.Tests.Performance/Actor/ActorMemoryFootprintSpec.cs +++ b/src/core/Akka.Tests.Performance/Actor/ActorMemoryFootprintSpec.cs @@ -60,7 +60,7 @@ public MemoryReceiveActor() } #endregion - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); private ActorSystem _system; private Counter _createActorThroughput; diff --git a/src/core/Akka.Tests.Performance/Actor/ActorPathEqualitySpec.cs b/src/core/Akka.Tests.Performance/Actor/ActorPathEqualitySpec.cs index 0e3fe77da3a..490885b70c7 100644 --- a/src/core/Akka.Tests.Performance/Actor/ActorPathEqualitySpec.cs +++ b/src/core/Akka.Tests.Performance/Actor/ActorPathEqualitySpec.cs @@ -19,7 +19,7 @@ public class ActorPathEqualitySpec private const double MinimumAcceptableOperationsPerSecond = 1000000.0d; //million op / second - private static readonly RootActorPath RootAddress = new RootActorPath(Address.AllSystems); + private static readonly RootActorPath RootAddress = new(Address.AllSystems); private static readonly ActorPath TopLevelActorPath = RootAddress / "user" / "foo1"; private Counter _equalsThroughput; diff --git a/src/core/Akka.Tests.Performance/Actor/ActorPathSpec.cs b/src/core/Akka.Tests.Performance/Actor/ActorPathSpec.cs index fae2edc19f1..d9bdbddb729 100644 --- a/src/core/Akka.Tests.Performance/Actor/ActorPathSpec.cs +++ b/src/core/Akka.Tests.Performance/Actor/ActorPathSpec.cs @@ -18,7 +18,7 @@ public class ActorPathSpec { private const string ParseThroughputCounterName = "ParseOp"; private const double MinimumAcceptableOperationsPerSecond = 1000000.0d; //million op / second - private static readonly RootActorPath RootAddress = new RootActorPath(Address.AllSystems); + private static readonly RootActorPath RootAddress = new(Address.AllSystems); private Counter _parseThroughput; [PerfSetup] diff --git a/src/core/Akka.Tests.Performance/Actor/ActorSelectionSpecs.cs b/src/core/Akka.Tests.Performance/Actor/ActorSelectionSpecs.cs index ba51cd01678..1142fe79696 100644 --- a/src/core/Akka.Tests.Performance/Actor/ActorSelectionSpecs.cs +++ b/src/core/Akka.Tests.Performance/Actor/ActorSelectionSpecs.cs @@ -25,10 +25,10 @@ public class ActorSelectionSpecs private IActorRef _receiver; private ActorPath _receiverActorPath; - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); protected ActorSystem System; - private readonly ManualResetEventSlim _resetEvent = new ManualResetEventSlim(false); + private readonly ManualResetEventSlim _resetEvent = new(false); private Props _oneMessageBenchmarkProps; private class BenchmarkActor : UntypedActor diff --git a/src/core/Akka.Tests.Performance/Actor/ActorThroughputSpec.cs b/src/core/Akka.Tests.Performance/Actor/ActorThroughputSpec.cs index 8a409b42147..3d8e5b8ca53 100644 --- a/src/core/Akka.Tests.Performance/Actor/ActorThroughputSpec.cs +++ b/src/core/Akka.Tests.Performance/Actor/ActorThroughputSpec.cs @@ -145,20 +145,20 @@ public SimpleData(string name, int age) public int Age { get; } } - private SimpleData dataExample = new SimpleData("John", 25); + private SimpleData dataExample = new("John", 25); private int intExample = 343; private string stringExample = "just_string"; private const string MailboxCounterName = "MessageReceived"; private const long MailboxMessageCount = 10000000; private Counter _mailboxThroughput; - private readonly ManualResetEventSlim _resetEvent = new ManualResetEventSlim(false); + private readonly ManualResetEventSlim _resetEvent = new(false); private IActorRef _untypedActorRef; private IActorRef _receiveActorRef; private IActorRef _minimalActorRef; - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); protected ActorSystem System; [PerfSetup] diff --git a/src/core/Akka.Tests.Performance/Actor/Pattern/AskSpec.cs b/src/core/Akka.Tests.Performance/Actor/Pattern/AskSpec.cs index 5571021dd96..13e425d2086 100644 --- a/src/core/Akka.Tests.Performance/Actor/Pattern/AskSpec.cs +++ b/src/core/Akka.Tests.Performance/Actor/Pattern/AskSpec.cs @@ -29,7 +29,7 @@ public EmptyActor() private ActorSystem _sys; private IActorRef _target; - private static readonly Identify Msg = new Identify(null); + private static readonly Identify Msg = new(null); private static readonly TimeSpan AskTimeout = TimeSpan.FromSeconds(1); [PerfSetup] diff --git a/src/core/Akka.Tests.Performance/Dispatch/DispatcherThroughputSpecBase.cs b/src/core/Akka.Tests.Performance/Dispatch/DispatcherThroughputSpecBase.cs index 859590db737..911cb1d7304 100644 --- a/src/core/Akka.Tests.Performance/Dispatch/DispatcherThroughputSpecBase.cs +++ b/src/core/Akka.Tests.Performance/Dispatch/DispatcherThroughputSpecBase.cs @@ -37,7 +37,7 @@ public abstract class ColdDispatcherThroughputSpecBase /// /// Used to block the benchmark method from exiting before all scheduled work is completed /// - protected readonly ManualResetEventSlim EventBlock = new ManualResetEventSlim(false); + protected readonly ManualResetEventSlim EventBlock = new(false); protected Action ScheduledWork; diff --git a/src/core/Akka.Tests.Performance/Dispatch/GetMailboxTypeSpec.cs b/src/core/Akka.Tests.Performance/Dispatch/GetMailboxTypeSpec.cs index 63e89b750b7..17384c16a4a 100644 --- a/src/core/Akka.Tests.Performance/Dispatch/GetMailboxTypeSpec.cs +++ b/src/core/Akka.Tests.Performance/Dispatch/GetMailboxTypeSpec.cs @@ -25,7 +25,7 @@ protected override void OnReceive(object message) public static Props Props { get; } = Props.Create(() => new EchoActor()); } - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); private Counter _createActorThroughput; private const string CreateThroughputCounter = "GetMailboxTypeFootprint"; private const int GetMailboxTypeNumber = 1000000; diff --git a/src/core/Akka.Tests.Performance/Dispatch/ReceiveOnlyBenchmark.cs b/src/core/Akka.Tests.Performance/Dispatch/ReceiveOnlyBenchmark.cs index 2d69f126144..8c3589cf338 100644 --- a/src/core/Akka.Tests.Performance/Dispatch/ReceiveOnlyBenchmark.cs +++ b/src/core/Akka.Tests.Performance/Dispatch/ReceiveOnlyBenchmark.cs @@ -20,7 +20,7 @@ public class ReceiveOnlyBenchmark protected ActorSystem System; protected IActorRef TestActor; protected Counter MsgReceived; - protected ManualResetEventSlim ResetEvent = new ManualResetEventSlim(false); + protected ManualResetEventSlim ResetEvent = new(false); protected const int ExpectedMessages = 500000; diff --git a/src/core/Akka.Tests.Performance/Event/EventStreamThroughputSpec.cs b/src/core/Akka.Tests.Performance/Event/EventStreamThroughputSpec.cs index f2cdc521710..87077cf80ad 100644 --- a/src/core/Akka.Tests.Performance/Event/EventStreamThroughputSpec.cs +++ b/src/core/Akka.Tests.Performance/Event/EventStreamThroughputSpec.cs @@ -43,7 +43,7 @@ protected override void TellInternal(object message, IActorRef sender) private IActorRef _targetActor; - private static readonly AtomicCounter Counter = new AtomicCounter(0); + private static readonly AtomicCounter Counter = new(0); protected ActorSystem System; [PerfSetup] diff --git a/src/core/Akka.Tests.Performance/IO/TcpHorizontalScaleSpec.cs b/src/core/Akka.Tests.Performance/IO/TcpHorizontalScaleSpec.cs index f49a5819f44..9bb2d95d267 100644 --- a/src/core/Akka.Tests.Performance/IO/TcpHorizontalScaleSpec.cs +++ b/src/core/Akka.Tests.Performance/IO/TcpHorizontalScaleSpec.cs @@ -114,7 +114,7 @@ protected override void PreRestart(Exception reason, object message) private const string OutboundThroughputCounterName = "outbound ops"; private const string ClientConnectCounterName = "connected clients"; - private static readonly IPEndPoint TestEndPoint = new IPEndPoint(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); + private static readonly IPEndPoint TestEndPoint = new(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); private static readonly TimeSpan SleepInterval = TimeSpan.FromMilliseconds(100); private Counter _clientConnectedCounter; diff --git a/src/core/Akka.Tests.Performance/IO/TcpInboundOnlySpec.cs b/src/core/Akka.Tests.Performance/IO/TcpInboundOnlySpec.cs index 55d84a8242a..f5b35495f18 100644 --- a/src/core/Akka.Tests.Performance/IO/TcpInboundOnlySpec.cs +++ b/src/core/Akka.Tests.Performance/IO/TcpInboundOnlySpec.cs @@ -57,7 +57,7 @@ public TestHandler(IActorRef connection, Counter inboundCounter, ManualResetEven } const string InboundThroughputCounterName = "inbound ops"; - public static readonly IPEndPoint TestEndpoint = new IPEndPoint(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); + public static readonly IPEndPoint TestEndpoint = new(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); // The number of times we're going to warmup + run each benchmark public const int IterationCount = 3; @@ -69,8 +69,8 @@ public TestHandler(IActorRef connection, Counter inboundCounter, ManualResetEven private Counter inboundThroughputCounter; private ActorSystem system; - private ManualResetEventSlim resetEvent = new ManualResetEventSlim(false); - private CancellationTokenSource cancel = new CancellationTokenSource(); + private ManualResetEventSlim resetEvent = new(false); + private CancellationTokenSource cancel = new(); private Socket clientSocket; private NetworkStream stream; diff --git a/src/core/Akka.Tests.Performance/IO/TcpSingleConnectionSpec.cs b/src/core/Akka.Tests.Performance/IO/TcpSingleConnectionSpec.cs index 52712c7a0b3..7dd7701c811 100644 --- a/src/core/Akka.Tests.Performance/IO/TcpSingleConnectionSpec.cs +++ b/src/core/Akka.Tests.Performance/IO/TcpSingleConnectionSpec.cs @@ -115,7 +115,7 @@ private Action Connected(IActorRef connection, Counter counter, ManualResetEvent const string OutboundThroughputCounterName = "outbound ops"; const string InboundThroughputCounterName = "inbound ops"; - public static readonly IPEndPoint TestEndpoint = new IPEndPoint(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); + public static readonly IPEndPoint TestEndpoint = new(IPAddress.Loopback, ThreadLocalRandom.Current.Next(5000, 11000)); // The number of times we're going to warmup + run each benchmark public const int IterationCount = 3; @@ -129,7 +129,7 @@ private Action Connected(IActorRef connection, Counter counter, ManualResetEvent private ActorSystem system; private IActorRef client; - private ManualResetEventSlim resetEvent = new ManualResetEventSlim(false); + private ManualResetEventSlim resetEvent = new(false); private byte[] message; diff --git a/src/core/Akka.Tests.Shared.Internals/AkkaSpec.cs b/src/core/Akka.Tests.Shared.Internals/AkkaSpec.cs index 7d7b19f5b0c..fb73b6ae338 100644 --- a/src/core/Akka.Tests.Shared.Internals/AkkaSpec.cs +++ b/src/core/Akka.Tests.Shared.Internals/AkkaSpec.cs @@ -28,7 +28,7 @@ namespace Akka.TestKit { public abstract class AkkaSpec : Xunit2.TestKit //AkkaSpec is not part of TestKit { - private static Regex _nameReplaceRegex = new Regex("[^a-zA-Z0-9]", RegexOptions.Compiled); + private static Regex _nameReplaceRegex = new("[^a-zA-Z0-9]", RegexOptions.Compiled); private static readonly Config _akkaSpecConfig = ConfigurationFactory.ParseString(@" akka { loglevel = WARNING diff --git a/src/core/Akka.Tests.Shared.Internals/Helpers/XAssert.cs b/src/core/Akka.Tests.Shared.Internals/Helpers/XAssert.cs index 95092daf37c..41c56d296d3 100644 --- a/src/core/Akka.Tests.Shared.Internals/Helpers/XAssert.cs +++ b/src/core/Akka.Tests.Shared.Internals/Helpers/XAssert.cs @@ -16,7 +16,7 @@ namespace Akka.TestKit { public static class XAssert { - private static readonly XunitAssertions _assertions = new XunitAssertions(); + private static readonly XunitAssertions _assertions = new(); /// /// Fails the test with the specified reason. /// diff --git a/src/core/Akka.Tests/Actor/ActorProducerPipelineTests.cs b/src/core/Akka.Tests/Actor/ActorProducerPipelineTests.cs index e4689e50233..ed33730ee6e 100644 --- a/src/core/Akka.Tests/Actor/ActorProducerPipelineTests.cs +++ b/src/core/Akka.Tests/Actor/ActorProducerPipelineTests.cs @@ -97,7 +97,7 @@ public OrderedPlugin3() : base(3) { } internal sealed class StashStatus { - public static readonly StashStatus Instance = new StashStatus(); + public static readonly StashStatus Instance = new(); private StashStatus() { } } diff --git a/src/core/Akka.Tests/Actor/ActorSystemSpec.cs b/src/core/Akka.Tests/Actor/ActorSystemSpec.cs index e1643f0bc19..f077da4670e 100644 --- a/src/core/Akka.Tests/Actor/ActorSystemSpec.cs +++ b/src/core/Akka.Tests/Actor/ActorSystemSpec.cs @@ -460,7 +460,7 @@ public void ScheduleTellRepeatedly(TimeSpan initialDelay, TimeSpan interval, ICa public class Wave : ReceiveActor { private IActorRef _master = Nobody.Instance; - private readonly HashSet _terminaters = new HashSet(); + private readonly HashSet _terminaters = new(); public Wave() { diff --git a/src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs b/src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs index 7b57ca15bc6..902e06131f5 100644 --- a/src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs +++ b/src/core/Akka.Tests/Actor/ActorTelemetrySpecs.cs @@ -50,7 +50,7 @@ public GetTelemetry(int actorCreated, int actorStopped, int actorRestarted) public class GetTelemetryRequest { // make singleton - public static readonly GetTelemetryRequest Instance = new GetTelemetryRequest(); + public static readonly GetTelemetryRequest Instance = new(); private GetTelemetryRequest() { } } @@ -85,7 +85,7 @@ public CreateChildren(int count) public class RestartChildren { // make singleton - public static readonly RestartChildren Instance = new RestartChildren(); + public static readonly RestartChildren Instance = new(); private RestartChildren() { diff --git a/src/core/Akka.Tests/Actor/BugFix4376Spec.cs b/src/core/Akka.Tests/Actor/BugFix4376Spec.cs index 9f5903589f5..aae8de96a8c 100644 --- a/src/core/Akka.Tests/Actor/BugFix4376Spec.cs +++ b/src/core/Akka.Tests/Actor/BugFix4376Spec.cs @@ -31,7 +31,7 @@ public BugFix4376Spec(ITestOutputHelper output): base(output) { } private class SimpleActor : ReceiveActor { - private readonly object _lock = new object(); + private readonly object _lock = new(); private static int Counter = 0; public SimpleActor() @@ -51,7 +51,7 @@ public SimpleActor() private class SimpleBroadcastActor : ReceiveActor { private readonly AtomicCounter _counter = null; - private readonly object _lock = new object(); + private readonly object _lock = new(); private static int Counter = 0; public SimpleBroadcastActor(AtomicCounter counter) @@ -74,7 +74,7 @@ public SimpleBroadcastActor(AtomicCounter counter) private class ParentActor : ReceiveActor { private readonly AtomicCounter _counter; - private readonly List _children = new List(); + private readonly List _children = new(); public ParentActor(AtomicCounter counter) { diff --git a/src/core/Akka.Tests/Actor/ContextWatchWithSpec.cs b/src/core/Akka.Tests/Actor/ContextWatchWithSpec.cs index a4841701553..6f468d58f59 100644 --- a/src/core/Akka.Tests/Actor/ContextWatchWithSpec.cs +++ b/src/core/Akka.Tests/Actor/ContextWatchWithSpec.cs @@ -76,7 +76,7 @@ public LoadHandler() private class Iteration { - public static readonly Iteration Instance = new Iteration(); + public static readonly Iteration Instance = new(); private Iteration() { } } diff --git a/src/core/Akka.Tests/Actor/CoordinatedShutdownSpec.cs b/src/core/Akka.Tests/Actor/CoordinatedShutdownSpec.cs index 95d06b20a74..e01553e6af1 100644 --- a/src/core/Akka.Tests/Actor/CoordinatedShutdownSpec.cs +++ b/src/core/Akka.Tests/Actor/CoordinatedShutdownSpec.cs @@ -30,7 +30,7 @@ private Phase Phase(params string[] dependsOn) return new Phase(dependsOn?.ToImmutableHashSet() ?? ImmutableHashSet.Empty, TimeSpan.FromSeconds(10), true); } - private static readonly Phase EmptyPhase = new Phase(ImmutableHashSet.Empty, TimeSpan.FromSeconds(10), true); + private static readonly Phase EmptyPhase = new(ImmutableHashSet.Empty, TimeSpan.FromSeconds(10), true); private List CheckTopologicalSort(Dictionary phases) { diff --git a/src/core/Akka.Tests/Actor/Dispatch/ActorModelSpec.cs b/src/core/Akka.Tests/Actor/Dispatch/ActorModelSpec.cs index a2ad55493ab..02cde5781c4 100644 --- a/src/core/Akka.Tests/Actor/Dispatch/ActorModelSpec.cs +++ b/src/core/Akka.Tests/Actor/Dispatch/ActorModelSpec.cs @@ -146,7 +146,7 @@ sealed class Interrupt : IActorModelMessage { private Interrupt() { } - public static readonly Interrupt Instance = new Interrupt(); + public static readonly Interrupt Instance = new(); } sealed class InterruptNicely : IActorModelMessage @@ -163,21 +163,21 @@ sealed class Restart : IActorModelMessage { private Restart() { } - public static readonly Restart Instance = new Restart(); + public static readonly Restart Instance = new(); } sealed class DoubleStop : IActorModelMessage { private DoubleStop() { } - public static readonly DoubleStop Instance = new DoubleStop(); + public static readonly DoubleStop Instance = new(); } private class GetStats : IActorModelMessage { private GetStats(){} - public static readonly GetStats Instance = new GetStats(); + public static readonly GetStats Instance = new(); } sealed class ThrowException : IActorModelMessage @@ -195,7 +195,7 @@ public ThrowException(Exception e) class DispatcherActor : ReceiveActor { - private Switch _busy = new Switch(false); + private Switch _busy = new(false); private readonly ILoggingAdapter _log = Context.GetLogger(); private MessageDispatcherInterceptor _interceptor = Context.Dispatcher.AsInstanceOf(); @@ -244,13 +244,13 @@ public DispatcherActor() public class InterceptorStats { - public readonly AtomicCounterLong Suspensions = new AtomicCounterLong(0L); - public readonly AtomicCounterLong Resumes = new AtomicCounterLong(0L); - public readonly AtomicCounterLong Registers = new AtomicCounterLong(0L); - public readonly AtomicCounterLong Unregisters = new AtomicCounterLong(0L); - public readonly AtomicCounterLong MsgsReceived = new AtomicCounterLong(0L); - public readonly AtomicCounterLong MsgsProcessed = new AtomicCounterLong(0L); - public readonly AtomicCounterLong Restarts = new AtomicCounterLong(0L); + public readonly AtomicCounterLong Suspensions = new(0L); + public readonly AtomicCounterLong Resumes = new(0L); + public readonly AtomicCounterLong Registers = new(0L); + public readonly AtomicCounterLong Unregisters = new(0L); + public readonly AtomicCounterLong MsgsReceived = new(0L); + public readonly AtomicCounterLong MsgsProcessed = new(0L); + public readonly AtomicCounterLong Restarts = new(0L); public override string ToString() { @@ -261,8 +261,8 @@ public override string ToString() public class MessageDispatcherInterceptor : Dispatcher { - public readonly ConcurrentDictionary Stats = new ConcurrentDictionary(); - public readonly AtomicCounterLong Stops = new AtomicCounterLong(0L); + public readonly ConcurrentDictionary Stats = new(); + public readonly AtomicCounterLong Stops = new(0L); public MessageDispatcherInterceptor(MessageDispatcherConfigurator configurator, string id, int throughput, long? throughputDeadlineTime, ExecutorServiceFactory executorServiceFactory, TimeSpan shutdownTimeout) : base(configurator, id, throughput, throughputDeadlineTime, executorServiceFactory, shutdownTimeout) { diff --git a/src/core/Akka.Tests/Actor/Dispatch/Bug2640Spec.cs b/src/core/Akka.Tests/Actor/Dispatch/Bug2640Spec.cs index 03573fd7151..6cc6353da1e 100644 --- a/src/core/Akka.Tests/Actor/Dispatch/Bug2640Spec.cs +++ b/src/core/Akka.Tests/Actor/Dispatch/Bug2640Spec.cs @@ -32,7 +32,7 @@ public Bug2640Spec(ITestOutputHelper helper) : base(DispatcherConfig, helper) private class GetThread { - public static readonly GetThread Instance = new GetThread(); + public static readonly GetThread Instance = new(); private GetThread() { diff --git a/src/core/Akka.Tests/Actor/FSMActorSpec.cs b/src/core/Akka.Tests/Actor/FSMActorSpec.cs index ffce0025835..becc0ea6219 100644 --- a/src/core/Akka.Tests/Actor/FSMActorSpec.cs +++ b/src/core/Akka.Tests/Actor/FSMActorSpec.cs @@ -70,14 +70,14 @@ public CodeState(string soFar, string code) public class Hello { - public static Hello Instance { get; } = new Hello(); + public static Hello Instance { get; } = new(); private Hello() { } } public class Bye { - public static Bye Instance { get; } = new Bye(); + public static Bye Instance { get; } = new(); private Bye() { } } diff --git a/src/core/Akka.Tests/Actor/FSMTimingSpec.cs b/src/core/Akka.Tests/Actor/FSMTimingSpec.cs index a7e87f1a8af..6a45d335f71 100644 --- a/src/core/Akka.Tests/Actor/FSMTimingSpec.cs +++ b/src/core/Akka.Tests/Actor/FSMTimingSpec.cs @@ -233,25 +233,25 @@ public enum FsmState public class Tick { private Tick() { } - public static Tick Instance { get; } = new Tick(); + public static Tick Instance { get; } = new(); } public class Tock { private Tock() { } - public static Tock Instance { get; } = new Tock(); + public static Tock Instance { get; } = new(); } public class Cancel { private Cancel() { } - public static Cancel Instance { get; } = new Cancel(); + public static Cancel Instance { get; } = new(); } public class SetHandler { private SetHandler() { } - public static SetHandler Instance { get; } = new SetHandler(); + public static SetHandler Instance { get; } = new(); } public class Unhandled diff --git a/src/core/Akka.Tests/Actor/RootGuardianActorRef_Tests.cs b/src/core/Akka.Tests/Actor/RootGuardianActorRef_Tests.cs index d0b03037dca..daf5c2e3ec1 100644 --- a/src/core/Akka.Tests/Actor/RootGuardianActorRef_Tests.cs +++ b/src/core/Akka.Tests/Actor/RootGuardianActorRef_Tests.cs @@ -18,9 +18,9 @@ namespace Akka.Tests.Actor public class RootGuardianActorRef_Tests : AkkaSpec { - static RootActorPath _rootActorPath = new RootActorPath(new Address("akka", "test")); - DummyActorRef _deadLetters = new DummyActorRef(_rootActorPath / "deadLetters"); - ReadOnlyDictionary _emptyExtraNames = new ReadOnlyDictionary(new Dictionary()); + static RootActorPath _rootActorPath = new(new Address("akka", "test")); + DummyActorRef _deadLetters = new(_rootActorPath / "deadLetters"); + ReadOnlyDictionary _emptyExtraNames = new(new Dictionary()); MessageDispatcher _dispatcher; public RootGuardianActorRef_Tests() diff --git a/src/core/Akka.Tests/Actor/Scheduler/SchedulerShutdownSpec.cs b/src/core/Akka.Tests/Actor/Scheduler/SchedulerShutdownSpec.cs index 769683feccc..6b2f113138b 100644 --- a/src/core/Akka.Tests/Actor/Scheduler/SchedulerShutdownSpec.cs +++ b/src/core/Akka.Tests/Actor/Scheduler/SchedulerShutdownSpec.cs @@ -31,7 +31,7 @@ public class SchedulerShutdownSpec /// private class ShutdownScheduler : SchedulerBase, IDisposable { - public readonly AtomicCounter Shutdown = new AtomicCounter(0); + public readonly AtomicCounter Shutdown = new(0); diff --git a/src/core/Akka.Tests/Actor/TimerSpec.cs b/src/core/Akka.Tests/Actor/TimerSpec.cs index dc0f8285132..7223bc8cfca 100644 --- a/src/core/Akka.Tests/Actor/TimerSpec.cs +++ b/src/core/Akka.Tests/Actor/TimerSpec.cs @@ -206,7 +206,7 @@ public Tick(int n) internal class Bump : ICommand { - public static readonly Bump Instance = new Bump(); + public static readonly Bump Instance = new(); private Bump() { @@ -225,7 +225,7 @@ public SlowThenBump(TestLatch latch) internal class End : ICommand { - public static readonly End Instance = new End(); + public static readonly End Instance = new(); private End() { @@ -244,7 +244,7 @@ public Throw(Exception e) internal class Cancel : ICommand { - public static readonly Cancel Instance = new Cancel(); + public static readonly Cancel Instance = new(); private Cancel() { @@ -265,7 +265,7 @@ public SlowThenThrow(TestLatch latch, Exception e) internal class AutoReceive : ICommand { - public static readonly AutoReceive Instance = new AutoReceive(); + public static readonly AutoReceive Instance = new(); private AutoReceive() { @@ -440,7 +440,7 @@ protected override bool Receive(object message) internal class TheState { - public static readonly TheState Instance = new TheState(); + public static readonly TheState Instance = new(); private TheState() { @@ -553,7 +553,7 @@ public async Task Timers_combined_with_stashing_should_work() internal class StopStashing { - public static readonly StopStashing Instance = new StopStashing(); + public static readonly StopStashing Instance = new(); private StopStashing() { diff --git a/src/core/Akka.Tests/IO/TcpIntegrationSpec.cs b/src/core/Akka.Tests/IO/TcpIntegrationSpec.cs index 639929efb0c..5d285a54f1a 100644 --- a/src/core/Akka.Tests/IO/TcpIntegrationSpec.cs +++ b/src/core/Akka.Tests/IO/TcpIntegrationSpec.cs @@ -28,14 +28,14 @@ public class TcpIntegrationSpec : AkkaSpec { public const int InternalConnectionActorMaxQueueSize = 10000; - class Aye : Tcp.Event { public static readonly Aye Instance = new Aye(); } - class Yes : Tcp.Event { public static readonly Yes Instance = new Yes(); } - class Ack : Tcp.Event { public static readonly Ack Instance = new Ack(); } + class Aye : Tcp.Event { public static readonly Aye Instance = new(); } + class Yes : Tcp.Event { public static readonly Yes Instance = new(); } + class Ack : Tcp.Event { public static readonly Ack Instance = new(); } class AckWithValue : Tcp.Event { public object Value { get; } - public static AckWithValue Create(object value) => new AckWithValue(value); + public static AckWithValue Create(object value) => new(value); private AckWithValue(object value) { Value = value; } } diff --git a/src/core/Akka.Tests/Loggers/ShutdownLoggerSpec.cs b/src/core/Akka.Tests/Loggers/ShutdownLoggerSpec.cs index 6461132c213..c4973d8cb6f 100644 --- a/src/core/Akka.Tests/Loggers/ShutdownLoggerSpec.cs +++ b/src/core/Akka.Tests/Loggers/ShutdownLoggerSpec.cs @@ -50,7 +50,7 @@ public async Task StandardOutLoggerShouldNotBeCalled() internal class LogProbe : ReceiveActor { - public List Events { get; } = new List(); + public List Events { get; } = new(); public LogProbe() { diff --git a/src/core/Akka.Tests/MatchHandler/CachedMatchCompilerTests.cs b/src/core/Akka.Tests/MatchHandler/CachedMatchCompilerTests.cs index 49973e3b200..48c9a3f3d4c 100644 --- a/src/core/Akka.Tests/MatchHandler/CachedMatchCompilerTests.cs +++ b/src/core/Akka.Tests/MatchHandler/CachedMatchCompilerTests.cs @@ -130,8 +130,8 @@ private void AssertOneCall(IReadOnlyList to, string description, Func> BuildLambdaExpressionCalls = new List>(); - public readonly List> CreateArgumentValuesArrayCalls = new List>(); + public readonly List> BuildLambdaExpressionCalls = new(); + public readonly List> CreateArgumentValuesArrayCalls = new(); public MatchExpressionBuilderResult BuildLambdaExpressionResult; public object[] CreateArgumentValuesArrayResult; @@ -158,7 +158,7 @@ public void ResetCalls() private class DummyPartialActionBuilder : IPartialActionBuilder { public PartialAction BuildResult; - public List BuildCalls = new List(); + public List BuildCalls = new(); public PartialAction Build(CompiledMatchHandlerWithArguments handlerAndArgs) { @@ -176,7 +176,7 @@ public void ResetCalls() private class DummyLambdaExpressionCompiler : ILambdaExpressionCompiler { public Delegate CompileResult; - public List CompileCalls = new List(); + public List CompileCalls = new(); public Delegate Compile(LambdaExpression expression) { CompileCalls.Add(expression); diff --git a/src/core/Akka.Tests/Pattern/BackoffSupervisorSpec.cs b/src/core/Akka.Tests/Pattern/BackoffSupervisorSpec.cs index d140563b5f2..c036b35ad8f 100644 --- a/src/core/Akka.Tests/Pattern/BackoffSupervisorSpec.cs +++ b/src/core/Akka.Tests/Pattern/BackoffSupervisorSpec.cs @@ -332,7 +332,7 @@ public void BackoffSupervisor_must_correctly_calculate_the_delay(int restartCoun internal class DelayTable : IEnumerable { - private readonly List delayTable = new List + private readonly List delayTable = new() { new object[] { 0, TimeSpan.Zero, TimeSpan.Zero, 0.0, TimeSpan.Zero }, new object[] { 0, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(7), 0d, TimeSpan.FromMinutes(5) }, diff --git a/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs b/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs index c2f0bd560d7..6081231018f 100644 --- a/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs +++ b/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs @@ -380,23 +380,23 @@ protected static async Task InterceptException(Func actionThatThrows } public TestBreaker ShortCallTimeoutCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(50)), Dilated(TimeSpan.FromMilliseconds(500)))); + new(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(50)), Dilated(TimeSpan.FromMilliseconds(500)))); public TestBreaker ShortResetTimeoutCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(1000)), Dilated(TimeSpan.FromMilliseconds(50)))); + new(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(1000)), Dilated(TimeSpan.FromMilliseconds(50)))); public TestBreaker LongCallTimeoutCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 1, TimeSpan.FromSeconds(5), Dilated(TimeSpan.FromMilliseconds(500)))); + new(new CircuitBreaker(Sys.Scheduler, 1, TimeSpan.FromSeconds(5), Dilated(TimeSpan.FromMilliseconds(500)))); public TimeSpan LongResetTimeout = TimeSpan.FromSeconds(5); public TestBreaker LongResetTimeoutCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(100)), Dilated(LongResetTimeout))); + new(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(100)), Dilated(LongResetTimeout))); public TestBreaker MultiFailureCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 5, Dilated(TimeSpan.FromMilliseconds(200)), Dilated(TimeSpan.FromMilliseconds(500)))); + new(new CircuitBreaker(Sys.Scheduler, 5, Dilated(TimeSpan.FromMilliseconds(200)), Dilated(TimeSpan.FromMilliseconds(500)))); public TestBreaker NonOneFactorCb() => - new TestBreaker(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(2000)), Dilated(TimeSpan.FromMilliseconds(1000)), Dilated(TimeSpan.FromDays(1)), 5, 0)); + new(new CircuitBreaker(Sys.Scheduler, 1, Dilated(TimeSpan.FromMilliseconds(2000)), Dilated(TimeSpan.FromMilliseconds(1000)), Dilated(TimeSpan.FromDays(1)), 5, 0)); } internal class TestException : Exception diff --git a/src/core/Akka.Tests/Pattern/CircuitBreakerStressSpec.cs b/src/core/Akka.Tests/Pattern/CircuitBreakerStressSpec.cs index a25b071e4e9..d99f78b25ab 100644 --- a/src/core/Akka.Tests/Pattern/CircuitBreakerStressSpec.cs +++ b/src/core/Akka.Tests/Pattern/CircuitBreakerStressSpec.cs @@ -21,19 +21,19 @@ public class CircuitBreakerStressSpec : AkkaSpec { internal class RequestJob { - public static RequestJob Instance => new RequestJob(); + public static RequestJob Instance => new(); private RequestJob() { } } internal class JobDone { - public static JobDone Instance => new JobDone(); + public static JobDone Instance => new(); private JobDone() { } } internal class GetResult { - public static GetResult Instance => new GetResult(); + public static GetResult Instance => new(); private GetResult() { } } diff --git a/src/core/Akka.Tests/Routing/RandomSpec.cs b/src/core/Akka.Tests/Routing/RandomSpec.cs index 21b3150c71d..26369487653 100644 --- a/src/core/Akka.Tests/Routing/RandomSpec.cs +++ b/src/core/Akka.Tests/Routing/RandomSpec.cs @@ -42,7 +42,7 @@ private class RandomActor : ReceiveActor { private readonly TestLatch _doneLatch; private static AtomicCounter _counter; - private readonly Lazy id = new Lazy(() => _counter.GetAndIncrement()); + private readonly Lazy id = new(() => _counter.GetAndIncrement()); public RandomActor(TestLatch doneLatch, AtomicCounter counter) { diff --git a/src/core/Akka.Tests/Routing/RoundRobinSpec.cs b/src/core/Akka.Tests/Routing/RoundRobinSpec.cs index 41dc0bb12be..20d0ae4e874 100644 --- a/src/core/Akka.Tests/Routing/RoundRobinSpec.cs +++ b/src/core/Akka.Tests/Routing/RoundRobinSpec.cs @@ -50,7 +50,7 @@ private class RoundRobinPoolActor : ReceiveActor { private readonly TestLatch _doneLatch; private static AtomicCounter _counter; - private readonly Lazy id = new Lazy(() => _counter.GetAndIncrement()); + private readonly Lazy id = new(() => _counter.GetAndIncrement()); public RoundRobinPoolActor(TestLatch doneLatch, AtomicCounter counter) { diff --git a/src/core/Akka.Tests/Serialization/SerializationSetupSpec.cs b/src/core/Akka.Tests/Serialization/SerializationSetupSpec.cs index 6b92d0ad6a3..650a392ce38 100644 --- a/src/core/Akka.Tests/Serialization/SerializationSetupSpec.cs +++ b/src/core/Akka.Tests/Serialization/SerializationSetupSpec.cs @@ -37,8 +37,8 @@ public TestSerializer(ExtendedActorSystem system) : base(system) public override int Identifier => 666; - private AtomicCounter Counter { get; } = new AtomicCounter(0); - private ConcurrentDictionary Registry { get; } = new ConcurrentDictionary(); + private AtomicCounter Counter { get; } = new(0); + private ConcurrentDictionary Registry { get; } = new(); public override byte[] ToBinary(object obj) { @@ -64,7 +64,7 @@ public OverridenSerializer(ExtendedActorSystem system) : base(system) { } public override object FromBinary(byte[] bytes, Type type) => throw new NotImplementedException(); } - public static SerializationSetup SerializationSettings = new SerializationSetup(_ => + public static SerializationSetup SerializationSettings = new(_ => ImmutableHashSet.Empty.Add(SerializerDetails.Create("test", new TestSerializer(_), ImmutableHashSet.Empty.Add(typeof(ProgammaticDummy))))); diff --git a/src/core/Akka.Tests/Util/IndexSpec.cs b/src/core/Akka.Tests/Util/IndexSpec.cs index 708602a84d9..8991fc305c2 100644 --- a/src/core/Akka.Tests/Util/IndexSpec.cs +++ b/src/core/Akka.Tests/Util/IndexSpec.cs @@ -19,7 +19,7 @@ namespace Akka.Tests.Util { public class IndexSpec : AkkaSpec { - private Index Empty => new Index(); + private Index Empty => new(); private Index IndexWithValues { diff --git a/src/core/Akka/Actor/ActorBase.cs b/src/core/Akka/Actor/ActorBase.cs index a7ee3cf0809..ddcfdf717af 100644 --- a/src/core/Akka/Actor/ActorBase.cs +++ b/src/core/Akka/Actor/ActorBase.cs @@ -22,7 +22,7 @@ public abstract class Status /// public sealed class Success : Status { - public static readonly Success Instance = new Success(null); + public static readonly Success Instance = new(null); /// /// TBD diff --git a/src/core/Akka/Actor/ActorProducerPipeline.cs b/src/core/Akka/Actor/ActorProducerPipeline.cs index 21380ea9186..62e1537f006 100644 --- a/src/core/Akka/Actor/ActorProducerPipeline.cs +++ b/src/core/Akka/Actor/ActorProducerPipeline.cs @@ -118,13 +118,13 @@ public virtual void BeforeIncarnated(TActor actor, IActorContext context) { } public class ActorProducerPipelineResolver { private readonly Lazy _log; - private readonly List _plugins = new List + private readonly List _plugins = new() { // collection of plugins loaded by default new ActorStashPlugin() }; - private readonly ConcurrentDictionary _pipelines = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _pipelines = new(); /// /// Gets total number of unique plugins registered inside current resolver. diff --git a/src/core/Akka/Actor/ActorRef.cs b/src/core/Akka/Actor/ActorRef.cs index 278f5618268..fabab41f25c 100644 --- a/src/core/Akka/Actor/ActorRef.cs +++ b/src/core/Akka/Actor/ActorRef.cs @@ -590,7 +590,7 @@ public ISurrogated FromSurrogate(ActorSystem system) } } - private static readonly IgnoreActorRefSurrogate SurrogateInstance = new IgnoreActorRefSurrogate(); + private static readonly IgnoreActorRefSurrogate SurrogateInstance = new(); private const string fakeSystemName = "local"; @@ -652,9 +652,9 @@ public ISurrogated FromSurrogate(ActorSystem system) /// /// Singleton instance of . /// - public static Nobody Instance = new Nobody(); + public static Nobody Instance = new(); - private static readonly NobodySurrogate SurrogateInstance = new NobodySurrogate(); + private static readonly NobodySurrogate SurrogateInstance = new(); private readonly ActorPath _path = new RootActorPath(Address.AllSystems, "/Nobody"); private Nobody() { } @@ -736,7 +736,7 @@ internal class VirtualPathContainer : MinimalActorRef private readonly IActorRefProvider _provider; private readonly ActorPath _path; - private readonly ConcurrentDictionary _children = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _children = new(); /// /// TBD diff --git a/src/core/Akka/Actor/ActorRefProvider.cs b/src/core/Akka/Actor/ActorRefProvider.cs index 3061d4c2c73..800c8a2bbf4 100644 --- a/src/core/Akka/Actor/ActorRefProvider.cs +++ b/src/core/Akka/Actor/ActorRefProvider.cs @@ -173,8 +173,8 @@ public sealed class LocalActorRefProvider : IActorRefProvider private readonly AtomicCounterLong _tempNumber; private readonly ActorPath _tempNode; private ActorSystemImpl _system; - private readonly Dictionary _extraNames = new Dictionary(); - private readonly TaskCompletionSource _terminationPromise = new TaskCompletionSource(); + private readonly Dictionary _extraNames = new(); + private readonly TaskCompletionSource _terminationPromise = new(); private readonly SupervisorStrategy _systemGuardianStrategy; private readonly SupervisorStrategyConfigurator _userGuardianStrategyConfigurator; private VirtualPathContainer _tempContainer; diff --git a/src/core/Akka/Actor/ActorSelection.cs b/src/core/Akka/Actor/ActorSelection.cs index cfc37626b9e..a5dbecb852e 100644 --- a/src/core/Akka/Actor/ActorSelection.cs +++ b/src/core/Akka/Actor/ActorSelection.cs @@ -478,7 +478,7 @@ public override bool Equals(object obj) /// /// Use this instead of calling the default constructor /// - public static readonly SelectChildRecursive Instance = new SelectChildRecursive(); + public static readonly SelectChildRecursive Instance = new(); public override int GetHashCode() => "**".GetHashCode(); @@ -496,7 +496,7 @@ public class SelectParent : SelectionPathElement /// /// Use this instead of calling the default constructor /// - public static readonly SelectParent Instance = new SelectParent(); + public static readonly SelectParent Instance = new(); public override bool Equals(object obj) => !ReferenceEquals(obj, null) && obj is SelectParent; diff --git a/src/core/Akka/Actor/ActorSystem.cs b/src/core/Akka/Actor/ActorSystem.cs index 4e2c008e55c..8ba74b26568 100644 --- a/src/core/Akka/Actor/ActorSystem.cs +++ b/src/core/Akka/Actor/ActorSystem.cs @@ -45,7 +45,7 @@ private Local() : base("local", LocalActorRefProvider, false) { } - public static readonly Local Instance = new Local(); + public static readonly Local Instance = new(); } public sealed class Remote : ProviderSelection @@ -54,7 +54,7 @@ private Remote() : base("remote", RemoteActorRefProvider, false) { } - public static readonly Remote Instance = new Remote(); + public static readonly Remote Instance = new(); } public sealed class Cluster : ProviderSelection @@ -63,7 +63,7 @@ private Cluster() : base("cluster", ClusterActorRefProvider, true) { } - public static readonly Cluster Instance = new Cluster(); + public static readonly Cluster Instance = new(); } public sealed class Custom : ProviderSelection diff --git a/src/core/Akka/Actor/Address.cs b/src/core/Akka/Actor/Address.cs index 6cc8d2280d4..95eba7e3752 100644 --- a/src/core/Akka/Actor/Address.cs +++ b/src/core/Akka/Actor/Address.cs @@ -58,7 +58,7 @@ public int Compare(Address x, Address y) /// /// Pseudo address for all systems /// - public static readonly Address AllSystems = new Address("akka", "all-systems"); + public static readonly Address AllSystems = new("akka", "all-systems"); private string _toString; private readonly string _host; diff --git a/src/core/Akka/Actor/Cancellation/AlreadyCanceledCancelable.cs b/src/core/Akka/Actor/Cancellation/AlreadyCanceledCancelable.cs index 62fd69b7fda..d53b103a29f 100644 --- a/src/core/Akka/Actor/Cancellation/AlreadyCanceledCancelable.cs +++ b/src/core/Akka/Actor/Cancellation/AlreadyCanceledCancelable.cs @@ -15,7 +15,7 @@ namespace Akka.Actor /// internal sealed class AlreadyCanceledCancelable : ICancelable { - private static readonly AlreadyCanceledCancelable _instance = new AlreadyCanceledCancelable(); + private static readonly AlreadyCanceledCancelable _instance = new(); private AlreadyCanceledCancelable() { } @@ -34,7 +34,7 @@ public void Cancel() public static ICancelable Instance => _instance; /// - public CancellationToken Token => new CancellationToken(true); + public CancellationToken Token => new(true); void ICancelable.CancelAfter(TimeSpan delay) { diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs index 2413dd2b905..573bf49bf3e 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs @@ -22,7 +22,7 @@ public interface IChildStats /// public class ChildNameReserved : IChildStats { - private static readonly ChildNameReserved _instance = new ChildNameReserved(); + private static readonly ChildNameReserved _instance = new(); private ChildNameReserved() {/* Intentionally left blank */} /// diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/SuspendReason.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/SuspendReason.cs index 2cf4b45ea36..a54469e8958 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/SuspendReason.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/SuspendReason.cs @@ -66,7 +66,7 @@ private Termination() { } /// /// TBD /// - public static Termination Instance { get; } = new Termination(); + public static Termination Instance { get; } = new(); } /// @@ -79,7 +79,7 @@ private UserRequest() { } /// /// TBD /// - public static UserRequest Instance { get; } = new UserRequest(); + public static UserRequest Instance { get; } = new(); } } } diff --git a/src/core/Akka/Actor/CoordinatedShutdown.cs b/src/core/Akka/Actor/CoordinatedShutdown.cs index f3d4358e1c0..96029d19e0f 100644 --- a/src/core/Akka/Actor/CoordinatedShutdown.cs +++ b/src/core/Akka/Actor/CoordinatedShutdown.cs @@ -270,12 +270,12 @@ private ClusterJoinUnsuccessfulReason() { } /// internal readonly List OrderedPhases; - private readonly ConcurrentSet>> _clrShutdownTasks = new ConcurrentSet>>(); - private readonly ConcurrentDictionary>)>> _tasks = new ConcurrentDictionary>)>>(); - private readonly AtomicReference _runStarted = new AtomicReference(null); - private readonly AtomicBoolean _clrHooksStarted = new AtomicBoolean(false); - private readonly TaskCompletionSource _runPromise = new TaskCompletionSource(); - private readonly TaskCompletionSource _hooksRunPromise = new TaskCompletionSource(); + private readonly ConcurrentSet>> _clrShutdownTasks = new(); + private readonly ConcurrentDictionary>)>> _tasks = new(); + private readonly AtomicReference _runStarted = new(null); + private readonly AtomicBoolean _clrHooksStarted = new(false); + private readonly TaskCompletionSource _runPromise = new(); + private readonly TaskCompletionSource _hooksRunPromise = new(); private volatile bool _runningClrHook = false; diff --git a/src/core/Akka/Actor/Deploy.cs b/src/core/Akka/Actor/Deploy.cs index 26732cf704f..1a577e176b4 100644 --- a/src/core/Akka/Actor/Deploy.cs +++ b/src/core/Akka/Actor/Deploy.cs @@ -20,7 +20,7 @@ public class Deploy : IEquatable, ISurrogated /// /// A deployment configuration that is bound to the scope. /// - public static readonly Deploy Local = new Deploy(Scope.Local); + public static readonly Deploy Local = new(Scope.Local); /// /// This deployment does not have a dispatcher associated with it. /// @@ -44,7 +44,7 @@ public class Deploy : IEquatable, ISurrogated /// /// A deployment configuration where none of the options have been configured. /// - public static readonly Deploy None = new Deploy(); + public static readonly Deploy None = new(); private readonly Config _config; private readonly string _dispatcher; private readonly string _mailbox; diff --git a/src/core/Akka/Actor/Deployer.cs b/src/core/Akka/Actor/Deployer.cs index 442c39c1018..a3b7e15caa0 100644 --- a/src/core/Akka/Actor/Deployer.cs +++ b/src/core/Akka/Actor/Deployer.cs @@ -26,8 +26,7 @@ public class Deployer /// protected readonly Config Default; private readonly Settings _settings; - private readonly AtomicReference> _deployments = - new AtomicReference>(new WildcardIndex()); + private readonly AtomicReference> _deployments = new(new WildcardIndex()); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka/Actor/FSM.cs b/src/core/Akka/Actor/FSM.cs index 71309a59d8c..be4fd5ed0cb 100644 --- a/src/core/Akka/Actor/FSM.cs +++ b/src/core/Akka/Actor/FSM.cs @@ -211,7 +211,7 @@ private Normal() { } /// /// Singleton instance of Normal /// - public static Normal Instance { get; } = new Normal(); + public static Normal Instance { get; } = new(); } /// @@ -225,7 +225,7 @@ private Shutdown() { } /// /// Singleton instance of Shutdown /// - public static Shutdown Instance { get; } = new Shutdown(); + public static Shutdown Instance { get; } = new(); } /// @@ -263,7 +263,7 @@ private StateTimeout() { } /// /// Singleton instance of StateTimeout /// - public static StateTimeout Instance { get; } = new StateTimeout(); + public static StateTimeout Instance { get; } = new(); } /// @@ -837,7 +837,7 @@ public StateFunction Using(Func, State> andT /// /// TBD /// TBD - public TransformHelper Transform(StateFunction func) => new TransformHelper(func); + public TransformHelper Transform(StateFunction func) => new(func); /// /// Schedule named timer to deliver message after given delay, possibly repeating. @@ -1003,7 +1003,7 @@ public TData NextStateData /// /// Retrieves the support needed to interact with an actor's listeners. /// - public ListenerSupport Listeners { get; } = new ListenerSupport(); + public ListenerSupport Listeners { get; } = new(); /// /// Can be set to enable debugging on certain actions taken by the FSM @@ -1023,13 +1023,13 @@ public TData NextStateData /// Timer handling /// private readonly IDictionary _timers = new Dictionary(); - private readonly AtomicCounter _timerGen = new AtomicCounter(0); + private readonly AtomicCounter _timerGen = new(0); /// /// State definitions /// - private readonly Dictionary _stateFunctions = new Dictionary(); - private readonly Dictionary _stateTimeouts = new Dictionary(); + private readonly Dictionary _stateFunctions = new(); + private readonly Dictionary _stateTimeouts = new(); private void Register(TState name, StateFunction function, TimeSpan? timeout) { diff --git a/src/core/Akka/Actor/Futures.cs b/src/core/Akka/Actor/Futures.cs index 564027e3f82..8a7123760a6 100644 --- a/src/core/Akka/Actor/Futures.cs +++ b/src/core/Akka/Actor/Futures.cs @@ -240,7 +240,7 @@ private PromiseActorRef(IActorRefProvider provider, TaskCompletionSource * StoppedWithPath(path) => stopped, path available * Stopped => stopped, path not yet created */ - private AtomicReference _stateDoNotCallMeDirectly = new AtomicReference(null); + private AtomicReference _stateDoNotCallMeDirectly = new(null); /// /// TBD @@ -253,7 +253,7 @@ private Registering() { } /// /// TBD /// - public static Registering Instance { get; } = new Registering(); + public static Registering Instance { get; } = new(); } /// @@ -267,7 +267,7 @@ private Stopped() { } /// /// Singleton instance. /// - public static Stopped Instance { get; } = new Stopped(); + public static Stopped Instance { get; } = new(); } /// @@ -320,7 +320,7 @@ public override int GetHashCode() #region Static methods - private static readonly Status.Failure ActorStopResult = new Status.Failure(new ActorKilledException("Stopped")); + private static readonly Status.Failure ActorStopResult = new(new ActorKilledException("Stopped")); // use a static delegate to avoid allocations private static readonly Action CancelAction = o => ((TaskCompletionSource)o).TrySetCanceled(); @@ -410,7 +410,7 @@ async Task ExecPromise() #endregion - private readonly AtomicReference> _watchedByDoNotCallMeDirectly = new AtomicReference>(ImmutableHashSet.Empty); + private readonly AtomicReference> _watchedByDoNotCallMeDirectly = new(ImmutableHashSet.Empty); private ImmutableHashSet WatchedBy { diff --git a/src/core/Akka/Actor/IAutoReceivedMessage.cs b/src/core/Akka/Actor/IAutoReceivedMessage.cs index c5c7fe28b84..00078a8ee5e 100644 --- a/src/core/Akka/Actor/IAutoReceivedMessage.cs +++ b/src/core/Akka/Actor/IAutoReceivedMessage.cs @@ -204,7 +204,7 @@ private PoisonPill() { } /// /// The singleton instance of PoisonPill. /// - public static PoisonPill Instance { get; } = new PoisonPill(); + public static PoisonPill Instance { get; } = new(); public override string ToString() @@ -227,7 +227,7 @@ private Kill() { } /// /// The singleton instance of Kill. /// - public static Kill Instance { get; } = new Kill(); + public static Kill Instance { get; } = new(); public override string ToString() diff --git a/src/core/Akka/Actor/Inbox.Actor.cs b/src/core/Akka/Actor/Inbox.Actor.cs index 52a2cb27d76..0d80a0bcf48 100644 --- a/src/core/Akka/Actor/Inbox.Actor.cs +++ b/src/core/Akka/Actor/Inbox.Actor.cs @@ -17,8 +17,8 @@ namespace Akka.Actor /// internal class InboxActor : ActorBase { - private readonly InboxQueue _messages = new InboxQueue(); - private readonly InboxQueue _clients = new InboxQueue(); + private readonly InboxQueue _messages = new(); + private readonly InboxQueue _clients = new(); private readonly ISet _clientsByTimeout = new SortedSet(DeadlineComparer.Instance); private bool _printedWarning; diff --git a/src/core/Akka/Actor/Inbox.cs b/src/core/Akka/Actor/Inbox.cs index 0b527218786..a75877e8362 100644 --- a/src/core/Akka/Actor/Inbox.cs +++ b/src/core/Akka/Actor/Inbox.cs @@ -177,7 +177,7 @@ internal class InboxQueue : ICollection // a specific predicate (even if it's in middle of queue), and current queue implementation won't provide that in easy way. - private readonly LinkedList _inner = new LinkedList(); + private readonly LinkedList _inner = new(); /// public IEnumerator GetEnumerator() @@ -315,7 +315,7 @@ public T DequeueFirstOrDefault(Predicate predicate) /// internal class DeadlineComparer : IComparer { - private static readonly DeadlineComparer _instance = new DeadlineComparer(); + private static readonly DeadlineComparer _instance = new(); /// /// The singleton instance of this comparer diff --git a/src/core/Akka/Actor/Internal/ActorSystemImpl.cs b/src/core/Akka/Actor/Internal/ActorSystemImpl.cs index b05f38f2d25..8525451f5d8 100644 --- a/src/core/Akka/Actor/Internal/ActorSystemImpl.cs +++ b/src/core/Akka/Actor/Internal/ActorSystemImpl.cs @@ -37,7 +37,7 @@ internal interface ISupportSerializationConfigReload public class ActorSystemImpl : ExtendedActorSystem, ISupportSerializationConfigReload { private IActorRef _logDeadLetterListener; - private readonly ConcurrentDictionary> _extensions = new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _extensions = new(); private ILoggingAdapter _log; private IActorRefProvider _provider; diff --git a/src/core/Akka/Actor/Internal/InternalSupportsTestFSMRef.cs b/src/core/Akka/Actor/Internal/InternalSupportsTestFSMRef.cs index 62fef4f3986..4e000b8952e 100644 --- a/src/core/Akka/Actor/Internal/InternalSupportsTestFSMRef.cs +++ b/src/core/Akka/Actor/Internal/InternalSupportsTestFSMRef.cs @@ -40,7 +40,7 @@ public interface IInternalSupportsTestFSMRef [InternalApi] public class InternalActivateFsmLogging { - private static readonly InternalActivateFsmLogging _instance = new InternalActivateFsmLogging(); + private static readonly InternalActivateFsmLogging _instance = new(); private InternalActivateFsmLogging(){} /// diff --git a/src/core/Akka/Actor/LocalScope.cs b/src/core/Akka/Actor/LocalScope.cs index 48dfa6763c6..1d4b93709ab 100644 --- a/src/core/Akka/Actor/LocalScope.cs +++ b/src/core/Akka/Actor/LocalScope.cs @@ -32,7 +32,7 @@ public ISurrogated FromSurrogate(ActorSystem system) } private LocalScope() { } - private static readonly LocalScope _instance = new LocalScope(); + private static readonly LocalScope _instance = new(); /// /// The singleton instance of this scope. diff --git a/src/core/Akka/Actor/Props.cs b/src/core/Akka/Actor/Props.cs index e6381bdc3d5..502c92c9504 100644 --- a/src/core/Akka/Actor/Props.cs +++ b/src/core/Akka/Actor/Props.cs @@ -659,7 +659,7 @@ private class DefaultProducer : IIndirectActorProducer { private DefaultProducer(){} - public static readonly DefaultProducer Instance = new DefaultProducer(); + public static readonly DefaultProducer Instance = new(); public ActorBase Produce() { diff --git a/src/core/Akka/Actor/ReceiveActor.cs b/src/core/Akka/Actor/ReceiveActor.cs index 6da2eeadc47..6ec27a5cb60 100644 --- a/src/core/Akka/Actor/ReceiveActor.cs +++ b/src/core/Akka/Actor/ReceiveActor.cs @@ -20,7 +20,7 @@ namespace Akka.Actor public abstract class ReceiveActor : UntypedActor, IInitializableActor { private bool _shouldUnhandle = true; - private readonly Stack _matchHandlerBuilders = new Stack(); + private readonly Stack _matchHandlerBuilders = new(); private PartialAction _partialReceive = _ => false; private bool _hasBeenInitialized; diff --git a/src/core/Akka/Actor/ReceiveTimeout.cs b/src/core/Akka/Actor/ReceiveTimeout.cs index 4d4dcac6032..ddf00f6d790 100644 --- a/src/core/Akka/Actor/ReceiveTimeout.cs +++ b/src/core/Akka/Actor/ReceiveTimeout.cs @@ -17,7 +17,7 @@ namespace Akka.Actor public class ReceiveTimeout : IPossiblyHarmful { private ReceiveTimeout() { } - private static readonly ReceiveTimeout _instance = new ReceiveTimeout(); + private static readonly ReceiveTimeout _instance = new(); /// diff --git a/src/core/Akka/Actor/RepointableActorRef.cs b/src/core/Akka/Actor/RepointableActorRef.cs index 7b2765e5a5f..ff2b3fa9349 100644 --- a/src/core/Akka/Actor/RepointableActorRef.cs +++ b/src/core/Akka/Actor/RepointableActorRef.cs @@ -343,10 +343,10 @@ public class UnstartedCell : ICell private readonly RepointableActorRef _self; private readonly Props _props; private readonly IInternalActorRef _supervisor; - private readonly object _lock = new object(); + private readonly object _lock = new(); /* Both queues must be accessed via lock */ - private readonly LinkedList _messageQueue = new LinkedList(); + private readonly LinkedList _messageQueue = new(); private LatestFirstSystemMessageList _sysMsgQueue = SystemMessageList.LNil; private readonly TimeSpan _timeout; diff --git a/src/core/Akka/Actor/RootGuardianSupervisor.cs b/src/core/Akka/Actor/RootGuardianSupervisor.cs index a8c703617e8..3f8b5189060 100644 --- a/src/core/Akka/Actor/RootGuardianSupervisor.cs +++ b/src/core/Akka/Actor/RootGuardianSupervisor.cs @@ -22,7 +22,7 @@ public class RootGuardianSupervisor : MinimalActorRef private readonly ILoggingAdapter _log; private readonly TaskCompletionSource _terminationPromise; private readonly ActorPath _path; - private readonly Switch _stopped = new Switch(false); + private readonly Switch _stopped = new(false); private readonly IActorRefProvider _provider; private bool IsWalking => !_terminationPromise.Task.IsCompleted; diff --git a/src/core/Akka/Actor/Scheduler/DateTimeNowTimeProvider.cs b/src/core/Akka/Actor/Scheduler/DateTimeNowTimeProvider.cs index 16111b16ce2..92c37ab825a 100644 --- a/src/core/Akka/Actor/Scheduler/DateTimeNowTimeProvider.cs +++ b/src/core/Akka/Actor/Scheduler/DateTimeNowTimeProvider.cs @@ -14,7 +14,7 @@ namespace Akka.Actor /// public class DateTimeOffsetNowTimeProvider : ITimeProvider, IDateTimeOffsetNowTimeProvider { - private static readonly DateTimeOffsetNowTimeProvider _instance = new DateTimeOffsetNowTimeProvider(); + private static readonly DateTimeOffsetNowTimeProvider _instance = new(); private DateTimeOffsetNowTimeProvider() { } /// /// TBD diff --git a/src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs b/src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs index 90c0d17be07..dfe8c743758 100644 --- a/src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs +++ b/src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs @@ -71,8 +71,8 @@ public HashedWheelTimerScheduler(Config scheduler, ILoggingAdapter log) : base(s private long _startTime = 0; private long _tick; private readonly int _mask; - private readonly CountdownEvent _workerInitialized = new CountdownEvent(1); - private readonly ConcurrentQueue _registrations = new ConcurrentQueue(); + private readonly CountdownEvent _workerInitialized = new(1); + private readonly ConcurrentQueue _registrations = new(); private readonly Bucket[] _wheel; private const int WORKER_STATE_INIT = 0; @@ -111,8 +111,8 @@ private static int NormalizeTicksPerWheel(int ticksPerWheel) return normalizedTicksPerWheel; } - private readonly HashSet _unprocessedRegistrations = new HashSet(); - private readonly HashSet _rescheduleRegistrations = new HashSet(); + private readonly HashSet _unprocessedRegistrations = new(); + private readonly HashSet _rescheduleRegistrations = new(); private Thread _worker; @@ -350,7 +350,7 @@ protected override void InternalScheduleRepeatedly(TimeSpan initialDelay, TimeSp InternalSchedule(initialDelay, interval, action, cancelable); } - private AtomicReference>> _stopped = new AtomicReference>>(); + private AtomicReference>> _stopped = new(); private static readonly Task> Completed = Task.FromResult((IEnumerable)new List()); diff --git a/src/core/Akka/Actor/Scheduler/TimerScheduler.cs b/src/core/Akka/Actor/Scheduler/TimerScheduler.cs index cdc12c06ade..21ea3fe8dac 100644 --- a/src/core/Akka/Actor/Scheduler/TimerScheduler.cs +++ b/src/core/Akka/Actor/Scheduler/TimerScheduler.cs @@ -76,8 +76,8 @@ public TimerMsgNotInfluenceReceiveTimeout(object key, int generation, TimerSched } private readonly IActorContext ctx; - private readonly Dictionary timers = new Dictionary(); - private AtomicCounter timerGen = new AtomicCounter(0); + private readonly Dictionary timers = new(); + private AtomicCounter timerGen = new(0); public TimerScheduler(IActorContext ctx) diff --git a/src/core/Akka/Actor/Scope.cs b/src/core/Akka/Actor/Scope.cs index 5bb0517ecc3..72a987daf33 100644 --- a/src/core/Akka/Actor/Scope.cs +++ b/src/core/Akka/Actor/Scope.cs @@ -53,7 +53,7 @@ internal class NoScopeGiven : Scope { private NoScopeGiven() { } - private static readonly NoScopeGiven _instance = new NoScopeGiven(); + private static readonly NoScopeGiven _instance = new(); /// /// The singleton instance of this scope. diff --git a/src/core/Akka/Actor/Setup/ActorSystemSetup.cs b/src/core/Akka/Actor/Setup/ActorSystemSetup.cs index d61da9a70b4..2f9acebc84b 100644 --- a/src/core/Akka/Actor/Setup/ActorSystemSetup.cs +++ b/src/core/Akka/Actor/Setup/ActorSystemSetup.cs @@ -43,7 +43,7 @@ public ActorSystemSetup And(Setup other) /// public sealed class ActorSystemSetup { - public static readonly ActorSystemSetup Empty = new ActorSystemSetup(ImmutableDictionary.Empty); + public static readonly ActorSystemSetup Empty = new(ImmutableDictionary.Empty); public static ActorSystemSetup Create(params Setup[] setup) { diff --git a/src/core/Akka/Actor/SupervisorStrategy.cs b/src/core/Akka/Actor/SupervisorStrategy.cs index 3e045152954..14d70a77b26 100644 --- a/src/core/Akka/Actor/SupervisorStrategy.cs +++ b/src/core/Akka/Actor/SupervisorStrategy.cs @@ -193,7 +193,7 @@ private static void Publish(IActorContext context, LogEvent logEvent) /// This strategy resembles Erlang in that failing children are always /// terminated (one-for-one). /// - public static readonly OneForOneStrategy StoppingStrategy = new OneForOneStrategy(_ => Directive.Stop); + public static readonly OneForOneStrategy StoppingStrategy = new(_ => Directive.Stop); /// /// This method is called after the child has been removed from the set of children. diff --git a/src/core/Akka/ActorState.cs b/src/core/Akka/ActorState.cs index 53a6d1bec51..1d4a884fd14 100644 --- a/src/core/Akka/ActorState.cs +++ b/src/core/Akka/ActorState.cs @@ -403,10 +403,10 @@ public Receive GetCurrentBehavior() /// internal class FullActorState : IActorState { - private readonly Dictionary> _watching = new Dictionary>(); - private readonly HashSet _watchedBy = new HashSet(); - private readonly Dictionary> _terminatedQueue = new Dictionary>(); //terminatedqueue should never be used outside the message loop - private Stack _behaviorStack = new Stack(2); + private readonly Dictionary> _watching = new(); + private readonly HashSet _watchedBy = new(); + private readonly Dictionary> _terminatedQueue = new(); //terminatedqueue should never be used outside the message loop + private Stack _behaviorStack = new(2); /// /// TBD /// diff --git a/src/core/Akka/Configuration/Hocon/HoconObject.cs b/src/core/Akka/Configuration/Hocon/HoconObject.cs index 193459e8665..37846bfc74a 100644 --- a/src/core/Akka/Configuration/Hocon/HoconObject.cs +++ b/src/core/Akka/Configuration/Hocon/HoconObject.cs @@ -33,7 +33,7 @@ namespace Akka.Configuration.Hocon /// public class HoconObject : IHoconElement { - private static readonly Regex EscapeRegex = new Regex("[ \t:]{1}", RegexOptions.Compiled); + private static readonly Regex EscapeRegex = new("[ \t:]{1}", RegexOptions.Compiled); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka/Configuration/Hocon/HoconParser.cs b/src/core/Akka/Configuration/Hocon/HoconParser.cs index e91e7640294..9c81d712591 100644 --- a/src/core/Akka/Configuration/Hocon/HoconParser.cs +++ b/src/core/Akka/Configuration/Hocon/HoconParser.cs @@ -17,7 +17,7 @@ namespace Akka.Configuration.Hocon /// public class Parser { - private readonly List _substitutions = new List(); + private readonly List _substitutions = new(); private HoconTokenizer _reader; private HoconValue _root; private Func _includeCallback; diff --git a/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs b/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs index fbee2577096..3772f587bb1 100644 --- a/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs +++ b/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs @@ -20,7 +20,7 @@ public class Tokenizer { private readonly string _text; private int _index; - private readonly Stack _indexStack = new Stack(); + private readonly Stack _indexStack = new(); /// /// Adds the current index to the tokenizer's bookkeeping stack. diff --git a/src/core/Akka/Configuration/Hocon/HoconValue.cs b/src/core/Akka/Configuration/Hocon/HoconValue.cs index 73b4c35bbc8..14e26615245 100644 --- a/src/core/Akka/Configuration/Hocon/HoconValue.cs +++ b/src/core/Akka/Configuration/Hocon/HoconValue.cs @@ -20,8 +20,8 @@ namespace Akka.Configuration.Hocon /// public class HoconValue : IMightBeAHoconObject { - private static readonly Regex EscapeRegex = new Regex("[ \t:]{1}", RegexOptions.Compiled); - private static readonly Regex TimeSpanRegex = new Regex(@"^(?([0-9]+(\.[0-9]+)?))\s*(?(nanoseconds|nanosecond|nanos|nano|ns|microseconds|microsecond|micros|micro|us|milliseconds|millisecond|millis|milli|ms|seconds|second|s|minutes|minute|m|hours|hour|h|days|day|d))$", RegexOptions.Compiled); + private static readonly Regex EscapeRegex = new("[ \t:]{1}", RegexOptions.Compiled); + private static readonly Regex TimeSpanRegex = new(@"^(?([0-9]+(\.[0-9]+)?))\s*(?(nanoseconds|nanosecond|nanos|nano|ns|microseconds|microsecond|micros|micro|us|milliseconds|millisecond|millis|milli|ms|seconds|second|s|minutes|minute|m|hours|hour|h|days|day|d))$", RegexOptions.Compiled); /// /// Initializes a new instance of the class. @@ -448,19 +448,19 @@ private struct ByteSize private static ByteSize[] ByteSizes { get; } = new ByteSize[] { - new ByteSize { Factor = 1024L * 1024L * 1024L * 1024L * 1024 * 1024L, Suffixes = new string[] { "E", "e", "Ei", "EiB", "exbibyte", "exbibytes" } }, - new ByteSize { Factor = 1000L * 1000L * 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "EB", "exabyte", "exabytes" } }, - new ByteSize { Factor = 1024L * 1024L * 1024L * 1024L * 1024L, Suffixes = new string[] { "P", "p", "Pi", "PiB", "pebibyte", "pebibytes" } }, - new ByteSize { Factor = 1000L * 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "PB", "petabyte", "petabytes" } }, - new ByteSize { Factor = 1024L * 1024L * 1024L * 1024L, Suffixes = new string[] { "T", "t", "Ti", "TiB", "tebibyte", "tebibytes" } }, - new ByteSize { Factor = 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "TB", "terabyte", "terabytes" } }, - new ByteSize { Factor = 1024L * 1024L * 1024L, Suffixes = new string[] { "G", "g", "Gi", "GiB", "gibibyte", "gibibytes" } }, - new ByteSize { Factor = 1000L * 1000L * 1000L, Suffixes = new string[] { "GB", "gigabyte", "gigabytes" } }, - new ByteSize { Factor = 1024L * 1024L, Suffixes = new string[] { "M", "m", "Mi", "MiB", "mebibyte", "mebibytes" } }, - new ByteSize { Factor = 1000L * 1000L, Suffixes = new string[] { "MB", "megabyte", "megabytes" } }, - new ByteSize { Factor = 1024L, Suffixes = new string[] { "K", "k", "Ki", "KiB", "kibibyte", "kibibytes" } }, - new ByteSize { Factor = 1000L, Suffixes = new string[] { "kB", "kilobyte", "kilobytes" } }, - new ByteSize { Factor = 1, Suffixes = new string[] { "b", "B", "byte", "bytes" } } + new() { Factor = 1024L * 1024L * 1024L * 1024L * 1024 * 1024L, Suffixes = new string[] { "E", "e", "Ei", "EiB", "exbibyte", "exbibytes" } }, + new() { Factor = 1000L * 1000L * 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "EB", "exabyte", "exabytes" } }, + new() { Factor = 1024L * 1024L * 1024L * 1024L * 1024L, Suffixes = new string[] { "P", "p", "Pi", "PiB", "pebibyte", "pebibytes" } }, + new() { Factor = 1000L * 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "PB", "petabyte", "petabytes" } }, + new() { Factor = 1024L * 1024L * 1024L * 1024L, Suffixes = new string[] { "T", "t", "Ti", "TiB", "tebibyte", "tebibytes" } }, + new() { Factor = 1000L * 1000L * 1000L * 1000L, Suffixes = new string[] { "TB", "terabyte", "terabytes" } }, + new() { Factor = 1024L * 1024L * 1024L, Suffixes = new string[] { "G", "g", "Gi", "GiB", "gibibyte", "gibibytes" } }, + new() { Factor = 1000L * 1000L * 1000L, Suffixes = new string[] { "GB", "gigabyte", "gigabytes" } }, + new() { Factor = 1024L * 1024L, Suffixes = new string[] { "M", "m", "Mi", "MiB", "mebibyte", "mebibytes" } }, + new() { Factor = 1000L * 1000L, Suffixes = new string[] { "MB", "megabyte", "megabytes" } }, + new() { Factor = 1024L, Suffixes = new string[] { "K", "k", "Ki", "KiB", "kibibyte", "kibibytes" } }, + new() { Factor = 1000L, Suffixes = new string[] { "kB", "kilobyte", "kilobytes" } }, + new() { Factor = 1, Suffixes = new string[] { "b", "B", "byte", "bytes" } } }; private static char[] Digits { get; } = "0123456789".ToCharArray(); diff --git a/src/core/Akka/Dispatch/AbstractDispatcher.cs b/src/core/Akka/Dispatch/AbstractDispatcher.cs index 48eb0426e27..4198d51c320 100644 --- a/src/core/Akka/Dispatch/AbstractDispatcher.cs +++ b/src/core/Akka/Dispatch/AbstractDispatcher.cs @@ -372,8 +372,7 @@ private const bool /// TBD /// internal static readonly Lazy> Actors = - new Lazy>( - () => new Index(), LazyThreadSafetyMode.PublicationOnly); + new(() => new Index(), LazyThreadSafetyMode.PublicationOnly); #pragma warning disable CS0162 // Disabled since the flag can be set while debugging /// diff --git a/src/core/Akka/Dispatch/ChannelSchedulerExtension.cs b/src/core/Akka/Dispatch/ChannelSchedulerExtension.cs index 4cbe2d1b452..b0e7af54e4e 100644 --- a/src/core/Akka/Dispatch/ChannelSchedulerExtension.cs +++ b/src/core/Akka/Dispatch/ChannelSchedulerExtension.cs @@ -39,7 +39,7 @@ public sealed class ChannelTaskScheduler : IExtension, IDisposable private static TaskSchedulerPriority _threadPriority = TaskSchedulerPriority.None; private readonly Task _controlTask; //the main worker - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); //main cancellation token + private readonly CancellationTokenSource _cts = new(); //main cancellation token private readonly Timer _timer; //timer to schedule coworkers private readonly Task[] _coworkers; //the coworkers private readonly int _maximumConcurrencyLevel; //max count of workers diff --git a/src/core/Akka/Dispatch/Dispatchers.cs b/src/core/Akka/Dispatch/Dispatchers.cs index bcf409e923e..c9115ddb830 100644 --- a/src/core/Akka/Dispatch/Dispatchers.cs +++ b/src/core/Akka/Dispatch/Dispatchers.cs @@ -107,7 +107,7 @@ public PartialTrustThreadPoolExecutorService(string id) : base(id) internal sealed class FixedConcurrencyTaskScheduler : TaskScheduler { [ThreadStatic] private static bool _threadRunning = false; - private ConcurrentQueue _tasks = new ConcurrentQueue(); + private ConcurrentQueue _tasks = new(); private int _readers = 0; @@ -334,8 +334,7 @@ public sealed class Dispatchers /// /// Has to be thread-safe, as this collection can be accessed concurrently by many actors. /// - private readonly ConcurrentDictionary _dispatcherConfigurators = - new ConcurrentDictionary(); + private readonly ConcurrentDictionary _dispatcherConfigurators = new(); /// /// Get (possibly aliased) dispatcher config. Returns empty config if not found. diff --git a/src/core/Akka/Dispatch/Mailboxes.cs b/src/core/Akka/Dispatch/Mailboxes.cs index 49f2b6606e6..84ad0c59abb 100644 --- a/src/core/Akka/Dispatch/Mailboxes.cs +++ b/src/core/Akka/Dispatch/Mailboxes.cs @@ -43,7 +43,7 @@ public class Mailboxes private readonly Dictionary _mailboxBindings; private readonly Config _defaultMailboxConfig; - private readonly ConcurrentDictionary _mailboxTypeConfigurators = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _mailboxTypeConfigurators = new(); private Settings Settings => _system.Settings; diff --git a/src/core/Akka/Dispatch/MessageQueues/BlockingMessageQueue.cs b/src/core/Akka/Dispatch/MessageQueues/BlockingMessageQueue.cs index 68bea6217d3..234565402bc 100644 --- a/src/core/Akka/Dispatch/MessageQueues/BlockingMessageQueue.cs +++ b/src/core/Akka/Dispatch/MessageQueues/BlockingMessageQueue.cs @@ -16,7 +16,7 @@ namespace Akka.Dispatch.MessageQueues /// public abstract class BlockingMessageQueue : IMessageQueue, IBlockingMessageQueueSemantics { - private readonly object _lock = new object(); + private readonly object _lock = new(); private TimeSpan _blockTimeOut = TimeSpan.FromSeconds(1); /// /// TBD diff --git a/src/core/Akka/Dispatch/MessageQueues/DequeWrapperMessageQueue.cs b/src/core/Akka/Dispatch/MessageQueues/DequeWrapperMessageQueue.cs index c0152871ce5..12f5bf335cf 100644 --- a/src/core/Akka/Dispatch/MessageQueues/DequeWrapperMessageQueue.cs +++ b/src/core/Akka/Dispatch/MessageQueues/DequeWrapperMessageQueue.cs @@ -18,7 +18,7 @@ namespace Akka.Dispatch.MessageQueues public class DequeWrapperMessageQueue : IMessageQueue, IDequeBasedMessageQueueSemantics { // doesn't need to be threadsafe - only called from within actor - private readonly Stack _prependBuffer = new Stack(); + private readonly Stack _prependBuffer = new(); /// /// The underlying . diff --git a/src/core/Akka/Dispatch/MessageQueues/UnboundedMessageQueue.cs b/src/core/Akka/Dispatch/MessageQueues/UnboundedMessageQueue.cs index bb6d50281f8..9e9dd4cc495 100644 --- a/src/core/Akka/Dispatch/MessageQueues/UnboundedMessageQueue.cs +++ b/src/core/Akka/Dispatch/MessageQueues/UnboundedMessageQueue.cs @@ -13,7 +13,7 @@ namespace Akka.Dispatch.MessageQueues /// An unbounded mailbox message queue. public class UnboundedMessageQueue : IMessageQueue, IUnboundedMessageQueueSemantics { - private readonly TQueue _queue = new TQueue(); + private readonly TQueue _queue = new(); /// public bool HasMessages diff --git a/src/core/Akka/Dispatch/MessageQueues/UnboundedPriorityMessageQueue.cs b/src/core/Akka/Dispatch/MessageQueues/UnboundedPriorityMessageQueue.cs index 3bfd6c77602..8fd50726641 100644 --- a/src/core/Akka/Dispatch/MessageQueues/UnboundedPriorityMessageQueue.cs +++ b/src/core/Akka/Dispatch/MessageQueues/UnboundedPriorityMessageQueue.cs @@ -19,7 +19,7 @@ public class UnboundedPriorityMessageQueue : BlockingMessageQueue, IUnboundedDeq { private readonly ListPriorityQueue _prioQueue; // doesn't need to be threadsafe - only called from within actor - private readonly Stack _prependBuffer = new Stack(); + private readonly Stack _prependBuffer = new(); /// /// Creates a new unbounded priority message queue. diff --git a/src/core/Akka/Dispatch/MessageQueues/UnboundedStablePriorityMessageQueue.cs b/src/core/Akka/Dispatch/MessageQueues/UnboundedStablePriorityMessageQueue.cs index b2c3d72f05c..52f6a990b53 100644 --- a/src/core/Akka/Dispatch/MessageQueues/UnboundedStablePriorityMessageQueue.cs +++ b/src/core/Akka/Dispatch/MessageQueues/UnboundedStablePriorityMessageQueue.cs @@ -19,7 +19,7 @@ public class UnboundedStablePriorityMessageQueue : BlockingMessageQueue, IUnboun { private readonly StableListPriorityQueue _prioQueue; // doesn't need to be threadsafe - only called from within actor - private readonly Stack _prependBuffer = new Stack(); + private readonly Stack _prependBuffer = new(); /// diff --git a/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs b/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs index cc37c4341e9..fcec943c974 100644 --- a/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs +++ b/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs @@ -24,11 +24,11 @@ internal static class SystemMessageList /// /// TBD /// - public static readonly LatestFirstSystemMessageList LNil = new LatestFirstSystemMessageList(null); + public static readonly LatestFirstSystemMessageList LNil = new(null); /// /// TBD /// - public static readonly EarliestFirstSystemMessageList ENil = new EarliestFirstSystemMessageList(null); + public static readonly EarliestFirstSystemMessageList ENil = new(null); /// /// TBD @@ -118,14 +118,14 @@ public LatestFirstSystemMessageList(SystemMessage head) /// should be taken when passing the tail to other methods. should be /// called on the head if one wants to detach the tail permanently. /// - public LatestFirstSystemMessageList Tail => new LatestFirstSystemMessageList(Head.Next); + public LatestFirstSystemMessageList Tail => new(Head.Next); /// /// Reverses the list. This operation mutates the underlying list. The cost of the call is O(N), where N is the number of elements. /// /// The type of the returned list ios the opposite order: . /// - public EarliestFirstSystemMessageList Reverse => new EarliestFirstSystemMessageList(SystemMessageList.ReverseInner(Head, null)); + public EarliestFirstSystemMessageList Reverse => new(SystemMessageList.ReverseInner(Head, null)); /// /// Attaches a message to the current head of the list. This operation has constant cost. @@ -192,14 +192,14 @@ public EarliestFirstSystemMessageList(SystemMessage head) /// should be taken when passing the tail to other methods. should be /// called on the head if one wants to detach the tail permanently. /// - public EarliestFirstSystemMessageList Tail => new EarliestFirstSystemMessageList(Head.Next); + public EarliestFirstSystemMessageList Tail => new(Head.Next); /// /// Reverses the list. This operation mutates the underlying list. The cost of the call is O(N), where N is the number of elements. /// /// The type of the returned list ios the opposite order: . /// - public LatestFirstSystemMessageList Reverse => new LatestFirstSystemMessageList(SystemMessageList.ReverseInner(Head, null)); + public LatestFirstSystemMessageList Reverse => new(SystemMessageList.ReverseInner(Head, null)); /// /// Attaches a message to the current head of the list. This operation has constant cost. @@ -864,7 +864,7 @@ public override string ToString() public sealed class RegisterTerminationHook { private RegisterTerminationHook() { } - private static readonly RegisterTerminationHook _instance = new RegisterTerminationHook(); + private static readonly RegisterTerminationHook _instance = new(); /// /// TBD /// @@ -892,7 +892,7 @@ public override string ToString() public sealed class TerminationHook { private TerminationHook() { } - private static readonly TerminationHook _instance = new TerminationHook(); + private static readonly TerminationHook _instance = new(); /// /// TBD /// @@ -920,7 +920,7 @@ public override string ToString() public sealed class TerminationHookDone { private TerminationHookDone() { } - private static readonly TerminationHookDone _instance = new TerminationHookDone(); + private static readonly TerminationHookDone _instance = new(); /// /// TBD /// diff --git a/src/core/Akka/Dispatch/ThreadPoolBuilder.cs b/src/core/Akka/Dispatch/ThreadPoolBuilder.cs index ea9cab7d8d4..8815e1bcea9 100644 --- a/src/core/Akka/Dispatch/ThreadPoolBuilder.cs +++ b/src/core/Akka/Dispatch/ThreadPoolBuilder.cs @@ -45,7 +45,7 @@ internal static ThreadType ConfigureThreadType(string threadType) /// /// Default settings for SingleThreadDispatcher instances. /// - internal static readonly DedicatedThreadPoolSettings DefaultSingleThreadPoolSettings = new DedicatedThreadPoolSettings(1, "DefaultSingleThreadPool"); + internal static readonly DedicatedThreadPoolSettings DefaultSingleThreadPoolSettings = new(1, "DefaultSingleThreadPool"); } /// diff --git a/src/core/Akka/Done.cs b/src/core/Akka/Done.cs index c8a6baf324d..c3c7c087bbe 100644 --- a/src/core/Akka/Done.cs +++ b/src/core/Akka/Done.cs @@ -18,7 +18,7 @@ public sealed class Done /// /// The singleton instance of /// - public static readonly Done Instance = new Done(); + public static readonly Done Instance = new(); private Done() { } } diff --git a/src/core/Akka/Event/AddressTerminatedTopic.cs b/src/core/Akka/Event/AddressTerminatedTopic.cs index 6466f041510..744a2ec9be7 100644 --- a/src/core/Akka/Event/AddressTerminatedTopic.cs +++ b/src/core/Akka/Event/AddressTerminatedTopic.cs @@ -37,7 +37,7 @@ public override AddressTerminatedTopic CreateExtension(ExtendedActorSystem syste /// internal sealed class AddressTerminatedTopic : IExtension { - private readonly HashSet _subscribers = new HashSet(); + private readonly HashSet _subscribers = new(); /// /// Retrieves the extension from the specified actor system. diff --git a/src/core/Akka/Event/DeadLetterListener.cs b/src/core/Akka/Event/DeadLetterListener.cs index bead769f195..b4ca2158794 100644 --- a/src/core/Akka/Event/DeadLetterListener.cs +++ b/src/core/Akka/Event/DeadLetterListener.cs @@ -280,7 +280,7 @@ public override bool Equals(object obj) => /// /// A deadline that is due /// - public static Deadline Now => new Deadline(DateTime.UtcNow); + public static Deadline Now => new(DateTime.UtcNow); /// /// Adds a given to the due time of this diff --git a/src/core/Akka/Event/DefaultLogMessageFormatter.cs b/src/core/Akka/Event/DefaultLogMessageFormatter.cs index 4eed91a49bf..7c184222a08 100644 --- a/src/core/Akka/Event/DefaultLogMessageFormatter.cs +++ b/src/core/Akka/Event/DefaultLogMessageFormatter.cs @@ -15,7 +15,7 @@ namespace Akka.Event /// public class DefaultLogMessageFormatter : ILogMessageFormatter { - public static readonly DefaultLogMessageFormatter Instance = new DefaultLogMessageFormatter(); + public static readonly DefaultLogMessageFormatter Instance = new(); private DefaultLogMessageFormatter(){} public string Format(string format, params object[] args) diff --git a/src/core/Akka/Event/EventStream.cs b/src/core/Akka/Event/EventStream.cs index 2f221c073ce..84086d8a7f1 100644 --- a/src/core/Akka/Event/EventStream.cs +++ b/src/core/Akka/Event/EventStream.cs @@ -31,12 +31,12 @@ public class EventStream : LoggingBus private readonly bool _debug; // used to uniquely name unsubscribers instances, should there be more than one ActorSystem / EventStream - private static readonly AtomicCounter UnsubscribersCounter = new AtomicCounter(0); - private readonly AtomicReference _unsubscriber = new AtomicReference(ActorRefs.NoSender); + private static readonly AtomicCounter UnsubscribersCounter = new(0); + private readonly AtomicReference _unsubscriber = new(ActorRefs.NoSender); // in the event that an actor subscribers to the EventStream prior to ActorSystemImpl.Init is called // we register them here and then move them all - private readonly ConcurrentSet _pendingUnsubscribers = new ConcurrentSet(); + private readonly ConcurrentSet _pendingUnsubscribers = new(); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka/Event/LoggingBus.cs b/src/core/Akka/Event/LoggingBus.cs index a58cfcb10ca..8f19da3c46d 100644 --- a/src/core/Akka/Event/LoggingBus.cs +++ b/src/core/Akka/Event/LoggingBus.cs @@ -40,10 +40,10 @@ public LoggerStartInfo(string loggerName, Type loggerType, IActorRef actorRef) private static readonly LogLevel[] AllLogLevels = Enum.GetValues(typeof(LogLevel)).Cast().ToArray(); private static int _loggerId; - private readonly List _loggers = new List(); + private readonly List _loggers = new(); // Async load support - private readonly CancellationTokenSource _shutdownCts = new CancellationTokenSource(); + private readonly CancellationTokenSource _shutdownCts = new(); /// /// The minimum log level that this bus will subscribe to, any LogEvents with a log level below will not be subscribed to. diff --git a/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs b/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs index d636fdcbb89..2b7146ffe4a 100644 --- a/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs +++ b/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs @@ -108,7 +108,7 @@ internal class DedicatedThreadPoolTaskScheduler : TaskScheduler /// private volatile int _parallelWorkers = 0; - private readonly LinkedList _tasks = new LinkedList(); + private readonly LinkedList _tasks = new(); private readonly DedicatedThreadPool _pool; @@ -411,8 +411,8 @@ private class ThreadPoolWorkQueue private static readonly int ProcessorCount = Environment.ProcessorCount; private const int CompletedState = 1; - private readonly ConcurrentQueue _queue = new ConcurrentQueue(); - private readonly UnfairSemaphore _semaphore = new UnfairSemaphore(); + private readonly ConcurrentQueue _queue = new(); + private readonly UnfairSemaphore _semaphore = new(); private int _outstandingRequests; private int _isAddingCompleted; diff --git a/src/core/Akka/IO/Buffers/DirectBufferPool.cs b/src/core/Akka/IO/Buffers/DirectBufferPool.cs index 0799384b797..89082be9083 100644 --- a/src/core/Akka/IO/Buffers/DirectBufferPool.cs +++ b/src/core/Akka/IO/Buffers/DirectBufferPool.cs @@ -110,14 +110,14 @@ public interface IBufferPool internal sealed class DirectBufferPool : IBufferPool { private const int Retries = 30; - private readonly object _syncRoot = new object(); + private readonly object _syncRoot = new(); private readonly int _bufferSize; private readonly int _buffersPerSegment; private readonly int _segmentSize; private readonly int _maxSegmentCount; - private readonly ConcurrentStack _buffers = new ConcurrentStack(); + private readonly ConcurrentStack _buffers = new(); private readonly List _segments; /// @@ -153,7 +153,7 @@ public DirectBufferPool(int bufferSize, int buffersPerSegment, int initialSegmen } public BufferPoolInfo Diagnostics() - => new BufferPoolInfo( + => new( type: typeof(DirectBufferPool), totalSize: _segments.Count * _segmentSize, free: _buffers.Count * _bufferSize, diff --git a/src/core/Akka/IO/Buffers/DisabledBufferPool.cs b/src/core/Akka/IO/Buffers/DisabledBufferPool.cs index 68e2c7d7137..553edd8aa1b 100644 --- a/src/core/Akka/IO/Buffers/DisabledBufferPool.cs +++ b/src/core/Akka/IO/Buffers/DisabledBufferPool.cs @@ -50,8 +50,7 @@ public void Release(IEnumerable buffers) } } - public BufferPoolInfo Diagnostics() - => new BufferPoolInfo(typeof(DisabledBufferPool), 0, 0, 0); + public BufferPoolInfo Diagnostics() => new(typeof(DisabledBufferPool), 0, 0, 0); private ByteBuffer RentOfSize(int size) { diff --git a/src/core/Akka/IO/Dns.cs b/src/core/Akka/IO/Dns.cs index d85250861eb..03aaa868e3c 100644 --- a/src/core/Akka/IO/Dns.cs +++ b/src/core/Akka/IO/Dns.cs @@ -56,7 +56,7 @@ public class Dns : ExtensionIdProvider /// /// TBD /// - public static readonly Dns Instance = new Dns(); + public static readonly Dns Instance = new(); /// /// TBD diff --git a/src/core/Akka/IO/SimpleDnsCache.cs b/src/core/Akka/IO/SimpleDnsCache.cs index 61a91cb1841..c1bf878bad7 100644 --- a/src/core/Akka/IO/SimpleDnsCache.cs +++ b/src/core/Akka/IO/SimpleDnsCache.cs @@ -90,7 +90,7 @@ class Cache private readonly SortedSet _queue; private readonly Dictionary _cache; private readonly Func _clock; - private readonly object _queueCleanupLock = new object(); + private readonly object _queueCleanupLock = new(); public Cache(SortedSet queue, Dictionary cache, Func clock) { @@ -115,7 +115,7 @@ public Cache Put(Dns.Resolved answer, long ttl) cache[answer.Name] = new CacheEntry(answer, until); return new Cache( - queue: new SortedSet(_queue, new ExpiryEntryComparer()) { new ExpiryEntry(answer.Name, until) }, + queue: new SortedSet(_queue, new ExpiryEntryComparer()) { new(answer.Name, until) }, cache: cache, clock: _clock); } diff --git a/src/core/Akka/IO/SimpleDnsManager.cs b/src/core/Akka/IO/SimpleDnsManager.cs index dd878970dbf..dd9b24b07c0 100644 --- a/src/core/Akka/IO/SimpleDnsManager.cs +++ b/src/core/Akka/IO/SimpleDnsManager.cs @@ -82,7 +82,7 @@ internal class CacheCleanup /// /// TBD /// - public static readonly CacheCleanup Instance = new CacheCleanup(); + public static readonly CacheCleanup Instance = new(); } } } diff --git a/src/core/Akka/IO/Tcp.cs b/src/core/Akka/IO/Tcp.cs index 43a6c4693d3..cc902f58fe5 100644 --- a/src/core/Akka/IO/Tcp.cs +++ b/src/core/Akka/IO/Tcp.cs @@ -28,7 +28,7 @@ public class Tcp : ExtensionIdProvider /// /// TBD /// - public static readonly Tcp Instance = new Tcp(); + public static readonly Tcp Instance = new(); /// /// TBD @@ -57,25 +57,25 @@ internal abstract class SocketCompleted : INoSerializationVerificationNeeded, ID internal sealed class SocketSent : SocketCompleted { - public static readonly SocketSent Instance = new SocketSent(); + public static readonly SocketSent Instance = new(); private SocketSent() { } } internal sealed class SocketReceived : SocketCompleted { - public static readonly SocketReceived Instance = new SocketReceived(); + public static readonly SocketReceived Instance = new(); private SocketReceived() { } } internal sealed class SocketAccepted : SocketCompleted { - public static readonly SocketAccepted Instance = new SocketAccepted(); + public static readonly SocketAccepted Instance = new(); private SocketAccepted() { } } internal sealed class SocketConnected : SocketCompleted { - public static readonly SocketConnected Instance = new SocketConnected(); + public static readonly SocketConnected Instance = new(); private SocketConnected() { } } @@ -268,7 +268,7 @@ public class Unbind : Command /// /// TBD /// - public static readonly Unbind Instance = new Unbind(); + public static readonly Unbind Instance = new(); private Unbind() { } @@ -296,7 +296,7 @@ public class Close : CloseCommand /// /// TBD /// - public static readonly Close Instance = new Close(); + public static readonly Close Instance = new(); private Close() { @@ -319,7 +319,7 @@ public class ConfirmedClose : CloseCommand /// /// TBD /// - public static readonly ConfirmedClose Instance = new ConfirmedClose(); + public static readonly ConfirmedClose Instance = new(); private ConfirmedClose() { @@ -343,7 +343,7 @@ public class Abort : CloseCommand /// /// TBD /// - public static readonly Abort Instance = new Abort(); + public static readonly Abort Instance = new(); private Abort() { @@ -366,7 +366,7 @@ public class NoAck : Event /// /// TBD /// - public static readonly NoAck Instance = new NoAck(null); + public static readonly NoAck Instance = new(null); /// /// TBD @@ -484,7 +484,7 @@ public class Write : SimpleWriteCommand /// /// TBD /// - public static readonly Write Empty = new Write(ByteString.Empty, NoAck.Instance); + public static readonly Write Empty = new(ByteString.Empty, NoAck.Instance); /// /// TBD @@ -668,7 +668,7 @@ public class ResumeWriting : Command /// /// TBD /// - public static readonly ResumeWriting Instance = new ResumeWriting(); + public static readonly ResumeWriting Instance = new(); private ResumeWriting() { @@ -685,7 +685,7 @@ public class SuspendReading : Command /// /// TBD /// - public static readonly SuspendReading Instance = new SuspendReading(); + public static readonly SuspendReading Instance = new(); private SuspendReading() { @@ -701,7 +701,7 @@ public class ResumeReading : Command /// /// TBD /// - public static readonly ResumeReading Instance = new ResumeReading(); + public static readonly ResumeReading Instance = new(); private ResumeReading() { @@ -850,7 +850,7 @@ public class WritingResumed : Event /// /// TBD /// - public static readonly WritingResumed Instance = new WritingResumed(); + public static readonly WritingResumed Instance = new(); private WritingResumed() { @@ -891,7 +891,7 @@ public class Unbound : Event /// /// Singleton instance /// - public static readonly Unbound Instance = new Unbound(); + public static readonly Unbound Instance = new(); private Unbound() { @@ -938,7 +938,7 @@ public class Closed : ConnectionClosed /// /// TBD /// - public static readonly Closed Instance = new Closed(); + public static readonly Closed Instance = new(); private Closed() { @@ -953,7 +953,7 @@ public class Aborted : ConnectionClosed /// /// TBD /// - public static readonly Aborted Instance = new Aborted(); + public static readonly Aborted Instance = new(); private Aborted() { @@ -974,7 +974,7 @@ public class ConfirmedClosed : ConnectionClosed /// /// TBD /// - public static readonly ConfirmedClosed Instance = new ConfirmedClosed(); + public static readonly ConfirmedClosed Instance = new(); private ConfirmedClosed() { @@ -994,7 +994,7 @@ public class PeerClosed : ConnectionClosed /// /// TBD /// - public static readonly PeerClosed Instance = new PeerClosed(); + public static readonly PeerClosed Instance = new(); private PeerClosed() { diff --git a/src/core/Akka/IO/TcpConnection.cs b/src/core/Akka/IO/TcpConnection.cs index 23f371509bd..17298473d35 100644 --- a/src/core/Akka/IO/TcpConnection.cs +++ b/src/core/Akka/IO/TcpConnection.cs @@ -97,18 +97,16 @@ enum ConnectionStatus private bool _isOutputShutdown; - private readonly ConcurrentQueue<(IActorRef Commander, object Ack)> _pendingAcks = new ConcurrentQueue<(IActorRef, object)>(); + private readonly ConcurrentQueue<(IActorRef Commander, object Ack)> _pendingAcks = new(); private bool _peerClosed; private IActorRef _interestedInResume; private CloseInformation _closedMessage; // for ConnectionClosed message in postStop private IActorRef _watchedActor = Context.System.DeadLetters; - private readonly IOException droppingWriteBecauseWritingIsSuspendedException = - new IOException("Dropping write because writing is suspended"); + private readonly IOException droppingWriteBecauseWritingIsSuspendedException = new("Dropping write because writing is suspended"); - private readonly IOException droppingWriteBecauseQueueIsFullException = - new IOException("Dropping write because queue is full"); + private readonly IOException droppingWriteBecauseQueueIsFullException = new("Dropping write because queue is full"); protected TcpConnection(TcpExt tcp, Socket socket, bool pullMode, Option writeCommandsBufferMaxSize) { @@ -836,8 +834,8 @@ private enum ReadResultType private struct ReadResult { - public static readonly ReadResult EndOfStream = new ReadResult(ReadResultType.EndOfStream, SocketError.Success); - public static readonly ReadResult AllRead = new ReadResult(ReadResultType.AllRead, SocketError.Success); + public static readonly ReadResult EndOfStream = new(ReadResultType.EndOfStream, SocketError.Success); + public static readonly ReadResult AllRead = new(ReadResultType.AllRead, SocketError.Success); public readonly ReadResultType Type; public readonly SocketError Error; diff --git a/src/core/Akka/IO/TcpOutgoingConnection.cs b/src/core/Akka/IO/TcpOutgoingConnection.cs index 94755a6a8a0..fbe22c0fc4e 100644 --- a/src/core/Akka/IO/TcpOutgoingConnection.cs +++ b/src/core/Akka/IO/TcpOutgoingConnection.cs @@ -30,7 +30,7 @@ internal sealed class TcpOutgoingConnection : TcpConnection private SocketAsyncEventArgs _connectArgs; private readonly ConnectException finishConnectNeverReturnedTrueException = - new ConnectException("Could not establish connection because finishConnect never returned true"); + new("Could not establish connection because finishConnect never returned true"); public TcpOutgoingConnection(TcpExt tcp, IActorRef commander, Tcp.Connect connect) : base( diff --git a/src/core/Akka/IO/Udp.cs b/src/core/Akka/IO/Udp.cs index 5ed2290bf82..b0a00e42073 100644 --- a/src/core/Akka/IO/Udp.cs +++ b/src/core/Akka/IO/Udp.cs @@ -87,7 +87,7 @@ public SocketConnected(SocketAsyncEventArgs eventArgs): base(eventArgs) /// /// TBD /// - public static readonly Udp Instance = new Udp(); + public static readonly Udp Instance = new(); /// /// TBD @@ -138,7 +138,7 @@ public sealed class NoAck : Event /// Default instance which is used when no acknowledgment information is /// explicitly provided. Its "token" is . /// - public static readonly NoAck Instance = new NoAck(null); + public static readonly NoAck Instance = new(null); /// /// TBD @@ -224,7 +224,7 @@ public override string ToString() => /// Binary payload to be send. /// An endpoint of the message receiver. /// TBD - public static Send Create(ByteString data, EndPoint target) => new Send(data, target, NoAck.Instance); + public static Send Create(ByteString data, EndPoint target) => new(data, target, NoAck.Instance); } /// @@ -275,7 +275,7 @@ public sealed class Unbind : Command /// /// TBD /// - public static readonly Unbind Instance = new Unbind(); + public static readonly Unbind Instance = new(); private Unbind() { } } @@ -295,7 +295,7 @@ public sealed class SimpleSender : Command /// /// TBD /// - public static readonly SimpleSender Instance = new SimpleSender(); + public static readonly SimpleSender Instance = new(); /// /// TBD @@ -323,7 +323,7 @@ public sealed class SuspendReading : Command /// /// TBD /// - public static readonly SuspendReading Instance = new SuspendReading(); + public static readonly SuspendReading Instance = new(); private SuspendReading() { } @@ -338,7 +338,7 @@ public sealed class ResumeReading : Command /// /// TBD /// - public static readonly ResumeReading Instance = new ResumeReading(); + public static readonly ResumeReading Instance = new(); private ResumeReading() { } @@ -431,7 +431,7 @@ public sealed class SimpleSenderReady : Event /// /// TBD /// - public static readonly SimpleSenderReady Instance = new SimpleSenderReady(); + public static readonly SimpleSenderReady Instance = new(); private SimpleSenderReady() { } } @@ -445,7 +445,7 @@ public sealed class Unbound /// /// TBD /// - public static readonly Unbound Instance = new Unbound(); + public static readonly Unbound Instance = new(); private Unbound() { } } diff --git a/src/core/Akka/IO/UdpConnected.cs b/src/core/Akka/IO/UdpConnected.cs index f4da78d8391..ae634fadd41 100644 --- a/src/core/Akka/IO/UdpConnected.cs +++ b/src/core/Akka/IO/UdpConnected.cs @@ -90,7 +90,7 @@ public SocketConnected(SocketAsyncEventArgs eventArgs) : base(eventArgs) /// /// TBD /// - public static readonly UdpConnected Instance = new UdpConnected(); + public static readonly UdpConnected Instance = new(); /// /// TBD @@ -138,7 +138,7 @@ public class NoAck : Event /// Default instance which is used when no acknowledgment information is /// explicitly provided. Its "token" is . /// - public static readonly NoAck Instance = new NoAck(null); + public static readonly NoAck Instance = new(null); /// /// TBD @@ -200,7 +200,7 @@ public Send(ByteString payload, object ack) /// object. /// /// Binary payload to be send. - public static Send Create(ByteString payload) => new Send(payload, NoAck.Instance); + public static Send Create(ByteString payload) => new(payload, NoAck.Instance); } /// @@ -257,7 +257,7 @@ public class Disconnect : Command /// /// TBD /// - public static readonly Disconnect Instance = new Disconnect(); + public static readonly Disconnect Instance = new(); private Disconnect() { @@ -275,7 +275,7 @@ public class SuspendReading : Command /// /// TBD /// - public static readonly SuspendReading Instance = new SuspendReading(); + public static readonly SuspendReading Instance = new(); private SuspendReading() { } @@ -290,7 +290,7 @@ public class ResumeReading : Command /// /// TBD /// - public static readonly ResumeReading Instance = new ResumeReading(); + public static readonly ResumeReading Instance = new(); private ResumeReading() { } @@ -353,7 +353,7 @@ public class Connected : Event /// /// TBD /// - public static readonly Connected Instance = new Connected(); + public static readonly Connected Instance = new(); private Connected() { } @@ -368,7 +368,7 @@ public class Disconnected : Event /// /// TBD /// - public static readonly Disconnected Instance = new Disconnected(); + public static readonly Disconnected Instance = new(); private Disconnected() { } diff --git a/src/core/Akka/NotUsed.cs b/src/core/Akka/NotUsed.cs index 66d5b0803af..9534fdc4af2 100644 --- a/src/core/Akka/NotUsed.cs +++ b/src/core/Akka/NotUsed.cs @@ -21,7 +21,7 @@ public sealed class NotUsed : IEquatable, IComparable /// /// The singleton instance of . /// - public static readonly NotUsed Instance = new NotUsed(); + public static readonly NotUsed Instance = new(); private NotUsed() { diff --git a/src/core/Akka/Pattern/BackoffOptions.cs b/src/core/Akka/Pattern/BackoffOptions.cs index aa4d184d92f..4fa7890523e 100644 --- a/src/core/Akka/Pattern/BackoffOptions.cs +++ b/src/core/Akka/Pattern/BackoffOptions.cs @@ -226,13 +226,13 @@ internal interface IBackoffType internal sealed class StopImpliesFailure : IBackoffType { - public static readonly StopImpliesFailure Instance = new StopImpliesFailure(); + public static readonly StopImpliesFailure Instance = new(); private StopImpliesFailure() { } } internal sealed class RestartImpliesFailure : IBackoffType { - public static readonly RestartImpliesFailure Instance = new RestartImpliesFailure(); + public static readonly RestartImpliesFailure Instance = new(); private RestartImpliesFailure() { } } diff --git a/src/core/Akka/Pattern/BackoffSupervisor.cs b/src/core/Akka/Pattern/BackoffSupervisor.cs index e4cc8758275..596e4bc8dcf 100644 --- a/src/core/Akka/Pattern/BackoffSupervisor.cs +++ b/src/core/Akka/Pattern/BackoffSupervisor.cs @@ -30,7 +30,7 @@ public sealed class GetCurrentChild /// /// TBD /// - public static readonly GetCurrentChild Instance = new GetCurrentChild(); + public static readonly GetCurrentChild Instance = new(); private GetCurrentChild() { } } @@ -58,14 +58,14 @@ public CurrentChild(IActorRef @ref) [Serializable] public sealed class Reset { - public static readonly Reset Instance = new Reset(); + public static readonly Reset Instance = new(); private Reset() { } } [Serializable] public sealed class GetRestartCount { - public static readonly GetRestartCount Instance = new GetRestartCount(); + public static readonly GetRestartCount Instance = new(); private GetRestartCount() { } } @@ -86,7 +86,7 @@ public sealed class StartChild : IDeadLetterSuppression /// /// TBD /// - public static readonly StartChild Instance = new StartChild(); + public static readonly StartChild Instance = new(); private StartChild() { } } diff --git a/src/core/Akka/Pattern/CircuitBreaker.cs b/src/core/Akka/Pattern/CircuitBreaker.cs index 598a9b07efb..309337a4421 100644 --- a/src/core/Akka/Pattern/CircuitBreaker.cs +++ b/src/core/Akka/Pattern/CircuitBreaker.cs @@ -335,14 +335,14 @@ public CircuitBreaker OnClose(Action callback) /// /// The upper bound of public CircuitBreaker WithExponentialBackoff(TimeSpan maxResetTimeout) => - new CircuitBreaker(Scheduler, MaxFailures, CallTimeout, ResetTimeout, maxResetTimeout, 2.0, RandomFactor); + new(Scheduler, MaxFailures, CallTimeout, ResetTimeout, maxResetTimeout, 2.0, RandomFactor); /// /// Adds jitter to the delay. /// /// after calculation of the back-off an additional random delay based on this factor is added, e.g. 0.2 adds up to 20% delay. In order to skip this additional delay pass in 0. public CircuitBreaker WithRandomFactor(double randomFactor) => - new CircuitBreaker(Scheduler, MaxFailures, CallTimeout, ResetTimeout, MaxResetTimeout, ExponentialBackoffFactor, randomFactor); + new(Scheduler, MaxFailures, CallTimeout, ResetTimeout, MaxResetTimeout, ExponentialBackoffFactor, randomFactor); /// /// Implements consistent transition between states. Throws IllegalStateException if an invalid transition is attempted. diff --git a/src/core/Akka/Routing/ConsistentHashRouter.cs b/src/core/Akka/Routing/ConsistentHashRouter.cs index d7ddd86e4ae..d31470a4bf9 100644 --- a/src/core/Akka/Routing/ConsistentHashRouter.cs +++ b/src/core/Akka/Routing/ConsistentHashRouter.cs @@ -118,8 +118,7 @@ public sealed class ConsistentHashingRoutingLogic : RoutingLogic private readonly ActorSystem _system; private readonly AtomicReference>> _consistentHashRef = - new AtomicReference>>( - (Tuple.Create>(null, null))); + new(Tuple.Create>(null, null)); private readonly Address _selfAddress; private readonly int _vnodes; diff --git a/src/core/Akka/Routing/Listeners.cs b/src/core/Akka/Routing/Listeners.cs index 542469b2dc5..6f9ef7fee0d 100644 --- a/src/core/Akka/Routing/Listeners.cs +++ b/src/core/Akka/Routing/Listeners.cs @@ -112,7 +112,7 @@ public class ListenerSupport /// /// The collection of registered listeners that is listening for messages from an actor. /// - protected readonly HashSet Listeners = new HashSet(); + protected readonly HashSet Listeners = new(); /// /// Retrieves the wiring needed to implement listening functionality. diff --git a/src/core/Akka/Routing/RouterConfig.cs b/src/core/Akka/Routing/RouterConfig.cs index 1bb43b989bc..d9d2eba3cac 100644 --- a/src/core/Akka/Routing/RouterConfig.cs +++ b/src/core/Akka/Routing/RouterConfig.cs @@ -433,7 +433,7 @@ public FromConfig(Resizer resizer, SupervisorStrategy supervisorStrategy, string /// This router is set to use the default dispatcher . /// /// - public static FromConfig Instance { get; } = new FromConfig(); + public static FromConfig Instance { get; } = new(); /// /// N/A @@ -628,7 +628,7 @@ public Props Props(Props routeeProps) /// /// TBD /// - public static NoRouter Instance { get; } = new NoRouter(); + public static NoRouter Instance { get; } = new(); /// /// This class represents a surrogate of a router. diff --git a/src/core/Akka/Routing/RouterMsg.cs b/src/core/Akka/Routing/RouterMsg.cs index 76a0d69207b..7187af8b5d2 100644 --- a/src/core/Akka/Routing/RouterMsg.cs +++ b/src/core/Akka/Routing/RouterMsg.cs @@ -42,7 +42,7 @@ public sealed class GetRoutees : RouterManagementMessage /// /// The singleton instance of GetRoutees. /// - public static GetRoutees Instance { get; } = new GetRoutees(); + public static GetRoutees Instance { get; } = new(); } /// diff --git a/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs b/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs index 2ba6ec36a5a..cbed204e893 100644 --- a/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs +++ b/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs @@ -31,7 +31,7 @@ public sealed class NewtonSoftJsonSerializerSettings /// /// A default instance of used when no custom configuration has been provided. /// - public static readonly NewtonSoftJsonSerializerSettings Default = new NewtonSoftJsonSerializerSettings( + public static readonly NewtonSoftJsonSerializerSettings Default = new( encodeTypeNames: true, preserveObjectReferences: true, converters: Enumerable.Empty(), diff --git a/src/core/Akka/Serialization/NewtonSoftJsonSerializerSetup.cs b/src/core/Akka/Serialization/NewtonSoftJsonSerializerSetup.cs index f7b730676e9..0bcc63c876d 100644 --- a/src/core/Akka/Serialization/NewtonSoftJsonSerializerSetup.cs +++ b/src/core/Akka/Serialization/NewtonSoftJsonSerializerSetup.cs @@ -26,8 +26,7 @@ namespace Akka.Serialization /// public sealed class NewtonSoftJsonSerializerSetup : Setup { - public static NewtonSoftJsonSerializerSetup Create(Action settings) - => new NewtonSoftJsonSerializerSetup(settings); + public static NewtonSoftJsonSerializerSetup Create(Action settings) => new(settings); public Action ApplySettings { get; } diff --git a/src/core/Akka/Serialization/Serialization.cs b/src/core/Akka/Serialization/Serialization.cs index 8293a70d803..84b518e6bd4 100644 --- a/src/core/Akka/Serialization/Serialization.cs +++ b/src/core/Akka/Serialization/Serialization.cs @@ -143,9 +143,9 @@ public static T WithTransport(ActorSystem system, Address address, Func ac private readonly Serializer _nullSerializer; - private readonly ConcurrentDictionary _serializerMap = new ConcurrentDictionary(); - private readonly Dictionary _serializersById = new Dictionary(); - private readonly Dictionary _serializersByName = new Dictionary(); + private readonly ConcurrentDictionary _serializerMap = new(); + private readonly Dictionary _serializersById = new(); + private readonly Dictionary _serializersByName = new(); private readonly ImmutableHashSet _serializerDetails; private readonly MinimalLogger _initializationLogger; diff --git a/src/core/Akka/Serialization/SerializerErrorCode.cs b/src/core/Akka/Serialization/SerializerErrorCode.cs index 1f31d7fbaae..3087f360da7 100644 --- a/src/core/Akka/Serialization/SerializerErrorCode.cs +++ b/src/core/Akka/Serialization/SerializerErrorCode.cs @@ -12,27 +12,27 @@ namespace Akka.Serialization { internal class SerializerErrorCode { - public static readonly Dictionary ErrorCodes = new Dictionary + public static readonly Dictionary ErrorCodes = new() { - [1] = new SerializerErrorCode(1, "Akka.Serialization.NewtonSoftJsonSerializer, Akka", "ConfigurationFactory.Default()", "ActorSystem.Create()"), - [2] = new SerializerErrorCode(2, "Akka.Remote.Serialization.ProtobufSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), - [3] = new SerializerErrorCode(3, "Akka.Remote.Serialization.DaemonMsgCreateSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), - [4] = new SerializerErrorCode(4, "Akka.Serialization.ByteArraySerializer, Akka", "ConfigurationFactory.Default()", "ActorSystem.Create()"), - [5] = new SerializerErrorCode(5, "Akka.Cluster.Serialization.ClusterMessageSerializer, Akka.Cluster", "ClusterConfigFactory.Default()", "ClusterSharding.Get()"), - [6] = new SerializerErrorCode(6, "Akka.Remote.Serialization.MessageContainerSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), - [7] = new SerializerErrorCode(7, "Akka.Persistence.Serialization.PersistenceMessageSerializer, Akka.Persistence", "Persistence.DefaultConfig()", "Persistence.Instance.Apply()"), - [8] = new SerializerErrorCode(8, "Akka.Persistence.Serialization.PersistenceSnapshotSerializer, Akka.Persistence", "Persistence.DefaultConfig()", "Persistence.Instance.Apply()"), - [10] = new SerializerErrorCode(10, "Akka.Cluster.Metrics.Serialization.ClusterMetricsMessageSerializer, Akka.Cluster.Metrics", "ClusterMetrics.DefaultConfig()", "ClusterMetrics.Get()"), - [11] = new SerializerErrorCode(11, "Akka.DistributedData.Serialization.ReplicatedDataSerializer, Akka.DistributedData", "DistributedData.DefaultConfig() or ClusterSharding.DefaultConfig()", "ClusterSharding.Get(), DistributedData.Get()"), - [12] = new SerializerErrorCode(12, "Akka.DistributedData.Serialization.ReplicatorMessageSerializer, Akka.DistributedData", "DistributedData.DefaultConfig() or ClusterSharding.DefaultConfig()", "ClusterSharding.Get(), DistributedData.Get()"), - [13] = new SerializerErrorCode(13, "Akka.Cluster.Sharding.Serialization.ClusterShardingMessageSerializer, Akka.Cluster.Sharding", "ClusterSharding.DefaultConfig()", "ClusterSharding.Get()"), - [14] = new SerializerErrorCode(14, "Akka.Cluster.Tools.Singleton.Serialization.ClusterSingletonMessageSerializer, Akka.Cluster.Tools", "DistributedPubSub.DefaultConfig(), ClusterSingletonProxy.DefaultConfig(), or ClusterSingletonManager.DefaultConfig()", "DistributedPubSub.Get(), ClusterSharding.Get()"), - [15] = new SerializerErrorCode(15, "Akka.Cluster.Tools.Client.Serialization.ClusterClientMessageSerializer, Akka.Cluster.Tools", "ClusterClientReceptionist.DefaultConfig()", "ClusterClientReceptionist.Get()"), - [16] = new SerializerErrorCode(16, "Akka.Remote.Serialization.MiscMessageSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), - [17] = new SerializerErrorCode(17, "Akka.Remote.Serialization.PrimitiveSerializers, Akka.Remote", "RemoteConfigFactory.Default()", null), - [22] = new SerializerErrorCode(22, "Akka.Remote.Serialization.SystemMessageSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), - [30] = new SerializerErrorCode(30, "Akka.Streams.Serialization.StreamRefSerializer, Akka.Streams", "ActorMaterializer.DefaultConfig()", "ActorSystem.Materializer()"), - [48] = new SerializerErrorCode(48, "Akka.Persistence.Redis.Serialization.PersistentSnapshotSerializer, Akka.Persistence.Redis", "RedisPersistence.DefaultConfig()", "RedisPersistence.Get()"), + [1] = new(1, "Akka.Serialization.NewtonSoftJsonSerializer, Akka", "ConfigurationFactory.Default()", "ActorSystem.Create()"), + [2] = new(2, "Akka.Remote.Serialization.ProtobufSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), + [3] = new(3, "Akka.Remote.Serialization.DaemonMsgCreateSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), + [4] = new(4, "Akka.Serialization.ByteArraySerializer, Akka", "ConfigurationFactory.Default()", "ActorSystem.Create()"), + [5] = new(5, "Akka.Cluster.Serialization.ClusterMessageSerializer, Akka.Cluster", "ClusterConfigFactory.Default()", "ClusterSharding.Get()"), + [6] = new(6, "Akka.Remote.Serialization.MessageContainerSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), + [7] = new(7, "Akka.Persistence.Serialization.PersistenceMessageSerializer, Akka.Persistence", "Persistence.DefaultConfig()", "Persistence.Instance.Apply()"), + [8] = new(8, "Akka.Persistence.Serialization.PersistenceSnapshotSerializer, Akka.Persistence", "Persistence.DefaultConfig()", "Persistence.Instance.Apply()"), + [10] = new(10, "Akka.Cluster.Metrics.Serialization.ClusterMetricsMessageSerializer, Akka.Cluster.Metrics", "ClusterMetrics.DefaultConfig()", "ClusterMetrics.Get()"), + [11] = new(11, "Akka.DistributedData.Serialization.ReplicatedDataSerializer, Akka.DistributedData", "DistributedData.DefaultConfig() or ClusterSharding.DefaultConfig()", "ClusterSharding.Get(), DistributedData.Get()"), + [12] = new(12, "Akka.DistributedData.Serialization.ReplicatorMessageSerializer, Akka.DistributedData", "DistributedData.DefaultConfig() or ClusterSharding.DefaultConfig()", "ClusterSharding.Get(), DistributedData.Get()"), + [13] = new(13, "Akka.Cluster.Sharding.Serialization.ClusterShardingMessageSerializer, Akka.Cluster.Sharding", "ClusterSharding.DefaultConfig()", "ClusterSharding.Get()"), + [14] = new(14, "Akka.Cluster.Tools.Singleton.Serialization.ClusterSingletonMessageSerializer, Akka.Cluster.Tools", "DistributedPubSub.DefaultConfig(), ClusterSingletonProxy.DefaultConfig(), or ClusterSingletonManager.DefaultConfig()", "DistributedPubSub.Get(), ClusterSharding.Get()"), + [15] = new(15, "Akka.Cluster.Tools.Client.Serialization.ClusterClientMessageSerializer, Akka.Cluster.Tools", "ClusterClientReceptionist.DefaultConfig()", "ClusterClientReceptionist.Get()"), + [16] = new(16, "Akka.Remote.Serialization.MiscMessageSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), + [17] = new(17, "Akka.Remote.Serialization.PrimitiveSerializers, Akka.Remote", "RemoteConfigFactory.Default()", null), + [22] = new(22, "Akka.Remote.Serialization.SystemMessageSerializer, Akka.Remote", "RemoteConfigFactory.Default()", null), + [30] = new(30, "Akka.Streams.Serialization.StreamRefSerializer, Akka.Streams", "ActorMaterializer.DefaultConfig()", "ActorSystem.Materializer()"), + [48] = new(48, "Akka.Persistence.Redis.Serialization.PersistentSnapshotSerializer, Akka.Persistence.Redis", "RedisPersistence.DefaultConfig()", "RedisPersistence.Get()"), }; public static string GetErrorForSerializerId(int id) diff --git a/src/core/Akka/Util/AppVersion.cs b/src/core/Akka/Util/AppVersion.cs index c528869309b..32d19aebe11 100644 --- a/src/core/Akka/Util/AppVersion.cs +++ b/src/core/Akka/Util/AppVersion.cs @@ -33,7 +33,7 @@ namespace Akka.Util /// public class AppVersion : IComparable, IEquatable { - public static readonly AppVersion Zero = new AppVersion("0.0.0"); + public static readonly AppVersion Zero = new("0.0.0"); // made internal for testing purposes internal const string AssemblyVersionMarker = "assembly-version"; diff --git a/src/core/Akka/Util/Index.cs b/src/core/Akka/Util/Index.cs index 985697f43d5..7b1741382fc 100644 --- a/src/core/Akka/Util/Index.cs +++ b/src/core/Akka/Util/Index.cs @@ -33,7 +33,7 @@ public Index() } private readonly ConcurrentDictionary> _container; - private readonly ConcurrentSet _emptySet = new ConcurrentSet(); + private readonly ConcurrentSet _emptySet = new(); /// /// Associates the value of with key of type . diff --git a/src/core/Akka/Util/Internal/SynchronizationContextManager.cs b/src/core/Akka/Util/Internal/SynchronizationContextManager.cs index dc3daf8727e..04ab92e301f 100644 --- a/src/core/Akka/Util/Internal/SynchronizationContextManager.cs +++ b/src/core/Akka/Util/Internal/SynchronizationContextManager.cs @@ -36,7 +36,7 @@ namespace Akka.Util.Internal [InternalApi] internal static class SynchronizationContextManager { - public static ContextRemover RemoveContext { get; } = new ContextRemover(); + public static ContextRemover RemoveContext { get; } = new(); } [InternalApi] diff --git a/src/core/Akka/Util/MatchHandler/CachedMatchCompiler.cs b/src/core/Akka/Util/MatchHandler/CachedMatchCompiler.cs index a76d66bbfaf..12758d05bb8 100644 --- a/src/core/Akka/Util/MatchHandler/CachedMatchCompiler.cs +++ b/src/core/Akka/Util/MatchHandler/CachedMatchCompiler.cs @@ -23,11 +23,11 @@ internal class CachedMatchCompiler : IMatchCompiler private readonly IMatchExpressionBuilder _expressionBuilder; private readonly IPartialActionBuilder _actionBuilder; private readonly ILambdaExpressionCompiler _expressionCompiler; - private readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _cache = new(); /// /// TBD /// - public static readonly CachedMatchCompiler Instance = new CachedMatchCompiler(new MatchExpressionBuilder(), new PartialActionBuilder(), new LambdaExpressionCompiler()); + public static readonly CachedMatchCompiler Instance = new(new MatchExpressionBuilder(), new PartialActionBuilder(), new LambdaExpressionCompiler()); /// /// TBD diff --git a/src/core/Akka/Util/MatchHandler/MatchBuilder.cs b/src/core/Akka/Util/MatchHandler/MatchBuilder.cs index 506f6a0e837..cabb6cd4ddb 100644 --- a/src/core/Akka/Util/MatchHandler/MatchBuilder.cs +++ b/src/core/Akka/Util/MatchHandler/MatchBuilder.cs @@ -38,9 +38,9 @@ internal class MatchBuilder // builder2: action = s=>G(s); predicate = s=>s!="" private static readonly Type _itemType = typeof(TItem); - private readonly List _typeHandlers = new List(); //Contains all handlers, with the handled types and predicates - private readonly List _arguments = new List(); //Contains Actions,Predicates and Funcs that has been added - private readonly List _signature = new List(); + private readonly List _typeHandlers = new(); //Contains all handlers, with the handled types and predicates + private readonly List _arguments = new(); //Contains Actions,Predicates and Funcs that has been added + private readonly List _signature = new(); private readonly IMatchCompiler _compiler; private State _state; diff --git a/src/core/Akka/Util/MatchHandler/TypeHandler.cs b/src/core/Akka/Util/MatchHandler/TypeHandler.cs index 8d9d26b9998..f2d6895b7c3 100644 --- a/src/core/Akka/Util/MatchHandler/TypeHandler.cs +++ b/src/core/Akka/Util/MatchHandler/TypeHandler.cs @@ -17,7 +17,7 @@ namespace Akka.Tools.MatchHandler internal class TypeHandler { private readonly Type _handlesType; - private readonly List _handlers = new List(); + private readonly List _handlers = new(); /// /// Initializes a new instance of the class. diff --git a/src/core/Akka/Util/MessageBuffer.cs b/src/core/Akka/Util/MessageBuffer.cs index 323201a4fd4..4bc1be44f32 100644 --- a/src/core/Akka/Util/MessageBuffer.cs +++ b/src/core/Akka/Util/MessageBuffer.cs @@ -23,9 +23,9 @@ internal sealed class MessageBuffer : IEnumerable<(object Message, IActorRef Ref /// Create an empty message buffer. /// /// an empty message buffer - public static MessageBuffer Empty() => new MessageBuffer(); + public static MessageBuffer Empty() => new(); - private readonly LinkedList<(object Message, IActorRef Ref)> _buffer = new LinkedList<(object Message, IActorRef Ref)>(); + private readonly LinkedList<(object Message, IActorRef Ref)> _buffer = new(); private MessageBuffer() { @@ -94,7 +94,7 @@ IEnumerator IEnumerable.GetEnumerator() /// Id type internal sealed class MessageBufferMap : IEnumerable>, IReadOnlyCollection> { - private readonly Dictionary _bufferMap = new Dictionary(); + private readonly Dictionary _bufferMap = new(); /// /// Check if the buffer map is empty. diff --git a/src/core/Akka/Util/Option.cs b/src/core/Akka/Util/Option.cs index c22639a08a5..5eb5c24d8d4 100644 --- a/src/core/Akka/Util/Option.cs +++ b/src/core/Akka/Util/Option.cs @@ -28,7 +28,7 @@ public static Option Create(T value) /// /// None. /// - public static readonly Option None = new Option(); + public static readonly Option None = new(); // TODO: Change this to private constructor in the future [Obsolete("Use Option.Create() instead")] diff --git a/src/core/Akka/Util/Reflection/ExpressionExtensions.cs b/src/core/Akka/Util/Reflection/ExpressionExtensions.cs index f546db95aea..483f9e898ce 100644 --- a/src/core/Akka/Util/Reflection/ExpressionExtensions.cs +++ b/src/core/Akka/Util/Reflection/ExpressionExtensions.cs @@ -33,14 +33,11 @@ public static object[] GetArguments(this NewExpression newExpression) } internal static class ExpressionBasedParser { - private static readonly ConcurrentDictionary - paramNameDictionary = - new ConcurrentDictionary(); + private static readonly ConcurrentDictionary paramNameDictionary = new(); private static readonly Type _objectType = typeof(object); - private static readonly Type _multicastDelegateType = - typeof(MulticastDelegate); + private static readonly Type _multicastDelegateType = typeof(MulticastDelegate); public static object[] ParseExpressionArgs( this NewExpression newExpr) diff --git a/src/core/Akka/Util/Reflection/TypeCache.cs b/src/core/Akka/Util/Reflection/TypeCache.cs index cb9e012ea68..43ecb9e32e5 100644 --- a/src/core/Akka/Util/Reflection/TypeCache.cs +++ b/src/core/Akka/Util/Reflection/TypeCache.cs @@ -16,7 +16,7 @@ namespace Akka.Util.Reflection /// public static class TypeCache { - private static readonly ConcurrentDictionary TypeMap = new ConcurrentDictionary(new[] { new KeyValuePair("null", null), }); + private static readonly ConcurrentDictionary TypeMap = new(new[] { new KeyValuePair("null", null), }); /// /// Gets the with the specified name, performing a case-sensitive search and throw an exception if the type is not found. diff --git a/src/core/Akka/Util/StandardOutWriter.cs b/src/core/Akka/Util/StandardOutWriter.cs index f0bef52d9ee..d0f24e846a6 100644 --- a/src/core/Akka/Util/StandardOutWriter.cs +++ b/src/core/Akka/Util/StandardOutWriter.cs @@ -15,7 +15,7 @@ namespace Akka.Util /// public static class StandardOutWriter { - private static readonly object _lock = new object(); + private static readonly object _lock = new(); /// /// Writes the specified value to the standard output stream. Optionally diff --git a/src/core/Akka/Util/Switch.cs b/src/core/Akka/Util/Switch.cs index 45f42fd3fe3..7c200a02c2f 100644 --- a/src/core/Akka/Util/Switch.cs +++ b/src/core/Akka/Util/Switch.cs @@ -15,7 +15,7 @@ namespace Akka.Util public class Switch { private readonly Util.AtomicBoolean _switch; - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// TBD diff --git a/src/core/Akka/Util/ThreadLocalRandom.cs b/src/core/Akka/Util/ThreadLocalRandom.cs index 5e556dbe02c..cc9e3873255 100644 --- a/src/core/Akka/Util/ThreadLocalRandom.cs +++ b/src/core/Akka/Util/ThreadLocalRandom.cs @@ -19,7 +19,7 @@ public static class ThreadLocalRandom { private static int _seed = Environment.TickCount; - private static ThreadLocal _rng = new ThreadLocal(() => new Random(Interlocked.Increment(ref _seed))); + private static ThreadLocal _rng = new(() => new Random(Interlocked.Increment(ref _seed))); /// /// The current random number seed available to this thread diff --git a/src/core/Akka/Util/TypeExtensions.cs b/src/core/Akka/Util/TypeExtensions.cs index f5cd1f15204..f4d3816b6fe 100644 --- a/src/core/Akka/Util/TypeExtensions.cs +++ b/src/core/Akka/Util/TypeExtensions.cs @@ -42,9 +42,9 @@ public static bool Implements(this Type type, Type moreGeneralType) return moreGeneralType.IsAssignableFrom(type); } - private static readonly ConcurrentDictionary ShortenedTypeNames = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary ShortenedTypeNames = new(); - private static readonly Regex cleanAssemblyVersionRegex = new Regex( + private static readonly Regex cleanAssemblyVersionRegex = new( @"(, Version=([\d\.]+))?(, Culture=[^,\] \t]+)?(, PublicKeyToken=(null|[\da-f]+))?", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); diff --git a/src/core/Akka/Util/WildcardTree.cs b/src/core/Akka/Util/WildcardTree.cs index 4eae7c0e196..394654ae6e5 100644 --- a/src/core/Akka/Util/WildcardTree.cs +++ b/src/core/Akka/Util/WildcardTree.cs @@ -119,7 +119,7 @@ public override int GetHashCode() /// /// TBD /// - public static readonly WildcardTree Empty = new WildcardTree(); + public static readonly WildcardTree Empty = new(); #endregion } diff --git a/src/examples/Chat/ChatServer/Program.cs b/src/examples/Chat/ChatServer/Program.cs index b534c056668..075cd70afc7 100644 --- a/src/examples/Chat/ChatServer/Program.cs +++ b/src/examples/Chat/ChatServer/Program.cs @@ -43,7 +43,7 @@ static void Main(string[] args) class ChatServerActor : ReceiveActor, ILogReceive { - private readonly HashSet _clients = new HashSet(); + private readonly HashSet _clients = new(); public ChatServerActor() { diff --git a/src/examples/Cluster/ClusterSharding/ShoppingCart/Customers.cs b/src/examples/Cluster/ClusterSharding/ShoppingCart/Customers.cs index 1e6ddb64b50..7d60d744345 100644 --- a/src/examples/Cluster/ClusterSharding/ShoppingCart/Customers.cs +++ b/src/examples/Cluster/ClusterSharding/ShoppingCart/Customers.cs @@ -35,7 +35,7 @@ public PurchaseItem(string itemName) } // - private readonly List _purchasedItems = new List(); + private readonly List _purchasedItems = new(); private readonly IActorRef _consumerController; // use to guarantee reliable delivery of messages public Customer(string persistenceId, IActorRef consumerController) diff --git a/src/examples/Cluster/ClusterSharding/ShoppingCart/Producer.cs b/src/examples/Cluster/ClusterSharding/ShoppingCart/Producer.cs index bf59cf13aec..7e8772fa66d 100644 --- a/src/examples/Cluster/ClusterSharding/ShoppingCart/Producer.cs +++ b/src/examples/Cluster/ClusterSharding/ShoppingCart/Producer.cs @@ -35,7 +35,7 @@ public sealed class Producer : ReceiveActor, IWithTimers private sealed class Produce { - public static readonly Produce Instance = new Produce(); + public static readonly Produce Instance = new(); private Produce() {} } diff --git a/src/examples/Cluster/Roles/Samples.Cluster.Transformation/TransformationFrontend.cs b/src/examples/Cluster/Roles/Samples.Cluster.Transformation/TransformationFrontend.cs index 38992379ea4..32c4b9c37e8 100644 --- a/src/examples/Cluster/Roles/Samples.Cluster.Transformation/TransformationFrontend.cs +++ b/src/examples/Cluster/Roles/Samples.Cluster.Transformation/TransformationFrontend.cs @@ -12,7 +12,7 @@ namespace Samples.Cluster.Transformation { public class TransformationFrontend : UntypedActor { - protected List Backends = new List(); + protected List Backends = new(); protected int Jobs = 0; protected override void OnReceive(object message)