From 05d898b6a6b0beb155cd6c36fb3ef643304a4850 Mon Sep 17 00:00:00 2001 From: ravengerUA Date: Thu, 30 Jun 2016 09:51:19 +0300 Subject: [PATCH] Moving Akka to NetStandard. Part 1 --- .../ClusterShardingSpec.cs | 2 +- .../ClusterShardingMessageSerializer.cs | 2 +- .../DistributedPubSubMessageSerializer.cs | 2 +- .../Akka.Persistence.Sql.Common.csproj | 4 +-- .../InternalExtensions.cs | 3 +- .../Journal/QueryApi.cs | 18 ++++++++++ .../Journal/QueryExecutor.cs | 2 ++ .../Journal/SqlJournal.cs | 6 ++-- .../Queries/Hints.cs | 6 ++++ .../Queries/Query.cs | 8 +++++ .../Snapshot/SqlSnapshotStore.cs | 13 ++++--- .../Akka.TestKit.Xunit2.csproj | 4 +-- .../Internals/AkkaEqualException.cs | 5 +-- .../Configuration/ClusterConfigFactory.cs | 3 +- .../Proto/ClusterMessageSerializer.cs | 2 +- .../Akka.Persistence.Query.csproj | 4 +-- .../Akka.Persistence.Query/EventEnvelope.cs | 2 ++ .../PersistenceQuery.cs | 8 ++--- .../Akka.Persistence/Akka.Persistence.csproj | 4 +-- .../AtLeastOnceDeliverySemantic.cs | 10 ++++++ .../Journal/AsyncWriteProxy.cs | 16 +++++++++ .../Akka.Persistence/Journal/EventAdapters.cs | 21 ++++++++---- .../Journal/EventSequences.cs | 6 ++++ src/core/Akka.Persistence/JournalProtocol.cs | 34 +++++++++++++++++++ src/core/Akka.Persistence/Persistence.cs | 3 +- src/core/Akka.Persistence/Persistent.cs | 2 ++ src/core/Akka.Persistence/PersistentActor.cs | 4 +++ src/core/Akka.Persistence/PersistentView.cs | 4 +++ .../Snapshot/LocalSnapshotStore.cs | 2 +- .../Snapshot/NoSnapshotStore.cs | 3 +- src/core/Akka.Persistence/SnapshotProtocol.cs | 30 ++++++++++++++++ .../Configuration/RemoteConfigFactory.cs | 3 +- src/core/Akka.Remote/MessageSerializer.cs | 3 +- .../DaemonMsgCreateSerializer.cs | 3 +- .../MessageContainerSerializer.cs | 3 +- src/core/Akka.Streams/ActorMaterializer.cs | 6 ++++ .../Akka.Streams/Actors/ActorPublisher.cs | 8 +++++ .../Akka.Streams/Actors/ActorSubscriber.cs | 10 ++++++ src/core/Akka.Streams/Akka.Streams.csproj | 4 +-- src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs | 4 +-- src/core/Akka.Streams/Dsl/Source.cs | 3 +- src/core/Akka.Streams/Dsl/Tcp.cs | 2 +- src/core/Akka.Streams/FanInShape.cs | 4 +++ src/core/Akka.Streams/FanOutShape.cs | 4 +++ .../Implementation/ActorMaterializerImpl.cs | 10 +++--- .../Implementation/ActorPublisher.cs | 15 +++++++- src/core/Akka.Streams/Implementation/FanIn.cs | 8 +++++ .../Akka.Streams/Implementation/FanOut.cs | 8 +++++ .../Implementation/Fusing/Fusing.cs | 5 +-- .../Implementation/Fusing/GraphInterpreter.cs | 2 +- .../Implementation/IO/FilePublisher.cs | 2 +- .../Implementation/IO/FileSubscriber.cs | 2 +- .../Implementation/IO/InputStreamPublisher.cs | 2 +- .../IO/OutputStreamSubscriber.cs | 2 +- .../ReactiveStreamsCompliance.cs | 4 +++ .../ResizableMultiReaderRingBuffer.cs | 4 +++ .../Implementation/StreamLayout.cs | 5 ++- .../StreamOfStreamProcessors.cs | 25 ++++++++++++-- .../StreamSubscriptionTimeout.cs | 2 ++ src/core/Akka.Streams/OverflowStrategy.cs | 4 +++ src/core/Akka.Streams/Stage/GraphStage.cs | 6 ++++ src/core/Akka.Streams/Stage/Stage.cs | 6 ++++ .../StreamLimitReachedException.cs | 2 ++ src/core/Akka.Streams/StreamTcpException.cs | 6 ++++ src/core/Akka.Streams/Util/TypeExtensions.cs | 13 +++---- .../ActorCellKeepingSynchronizationContext.cs | 4 +++ src/core/Akka.TestKit/Akka.TestKit.csproj | 8 ++--- .../EventFilter/EventFilterFactory.cs | 5 +-- .../Actor/LocalActorRefProviderSpec.cs | 2 +- src/core/Akka.Tests/Akka.Tests.csproj | 20 ++++++----- .../Configuration/ConfigurationSpec.cs | 5 +-- src/core/Akka.Tests/Event/EventBusSpec.cs | 5 +-- src/core/Akka.Tests/IO/SimpleDnsCacheSpec.cs | 8 ++--- .../MatchHandler/PartialActionBuilderTests.cs | 3 +- .../Akka.Tests/Pattern/CircuitBreakerSpec.cs | 4 ++- src/core/Akka.Tests/TestUtils/Comparable.cs | 2 +- src/core/Akka.Tests/packages.config | 2 +- src/core/Akka/Actor/ActorCell.cs | 3 +- src/core/Akka/Actor/ActorProducerPipeline.cs | 3 +- src/core/Akka/Actor/ActorSelection.cs | 2 +- src/core/Akka/Actor/Exceptions.cs | 26 ++++++++++++++ src/core/Akka/Actor/Inbox.cs | 2 ++ .../Akka/Actor/Internal/ActorSystemImpl.cs | 6 ++-- src/core/Akka/Actor/Props.cs | 5 +-- src/core/Akka/Actor/Settings.cs | 3 +- src/core/Akka/Actor/Stash/IActorStash.cs | 3 +- .../Actor/Stash/StashOverflowException.cs | 2 ++ src/core/Akka/Actor/SupervisorStrategy.cs | 3 +- src/core/Akka/Actor/TypedActor.cs | 2 +- src/core/Akka/Akka.csproj | 8 ++--- .../Configuration/ConfigurationException.cs | 2 ++ .../Configuration/ConfigurationFactory.cs | 19 ++++++----- .../Hocon/AkkaConfigurationSection.cs | 4 +-- .../Hocon/CDataConfigurationElement.cs | 3 +- .../Hocon/HoconConfigurationElement.cs | 4 +-- .../Configuration/Hocon/HoconTokenizer.cs | 2 +- src/core/Akka/Dispatch/AbstractDispatcher.cs | 4 +++ src/core/Akka/Dispatch/Dispatchers.cs | 2 ++ src/core/Akka/Dispatch/Mailbox.cs | 7 ++++ src/core/Akka/Dispatch/Mailboxes.cs | 26 +++++++------- .../Akka/Dispatch/SysMsg/ISystemMessage.cs | 2 ++ src/core/Akka/Dispatch/ThreadPoolBuilder.cs | 8 +++-- src/core/Akka/Event/LoggingBus.cs | 5 +-- .../Helios.Concurrency.DedicatedThreadPool.cs | 27 +++++++++++++++ src/core/Akka/IO/DirectByteBufferPool.cs | 5 +-- src/core/Akka/IO/InetAddressDnsResolver.cs | 2 +- src/core/Akka/IO/SocketChannel.cs | 3 +- src/core/Akka/NotUsed.cs | 2 ++ src/core/Akka/Pattern/BackoffSupervisor.cs | 8 +++++ .../Akka/Pattern/IllegalStateException.cs | 2 ++ src/core/Akka/Pattern/OpenCircuitException.cs | 2 ++ .../Serialization/NewtonSoftJsonSerializer.cs | 2 +- src/core/Akka/Serialization/Serialization.cs | 5 +-- src/core/Akka/Serialization/Serializer.cs | 3 +- src/core/Akka/Util/ByteString.cs | 2 ++ .../Akka/Util/MatchHandler/MatchBuilder.cs | 2 +- .../MatchHandler/MatchExpressionBuilder.cs | 3 +- src/core/Akka/Util/MurmurHash.cs | 4 +-- src/core/Akka/Util/TypeExtensions.cs | 3 +- .../Chat/ChatMessages/ChatMessages.csproj | 8 ++--- .../Chat/ChatMessages/packages.config | 1 - .../SymbolLookup/Actors/TickerActors.cs | 2 +- .../Stocks/SymbolLookup/SymbolLookup.csproj | 8 +++-- .../Stocks/SymbolLookup/packages.config | 2 +- 124 files changed, 575 insertions(+), 168 deletions(-) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs index e8f3515298c..9a867b786f6 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs @@ -295,7 +295,7 @@ private void CreateCoordinator() foreach (var typeName in typeNames) { - var rebalanceEnabled = string.Equals(typeName, "rebalancing", StringComparison.InvariantCultureIgnoreCase); + var rebalanceEnabled = string.Equals(typeName, "rebalancing", StringComparison.OrdinalIgnoreCase); var singletonProps = Props.Create(() => new BackoffSupervisor( CoordinatorProps(typeName, rebalanceEnabled), "coordinator", diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/ClusterShardingMessageSerializer.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/ClusterShardingMessageSerializer.cs index 822135941da..49a94b00e31 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/ClusterShardingMessageSerializer.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/ClusterShardingMessageSerializer.cs @@ -325,7 +325,7 @@ private static byte[] Compress(IMessageLite message) using (var gzipStream = new GZipStream(bos, CompressionMode.Compress)) { message.WriteTo(gzipStream); - gzipStream.Close(); + gzipStream.Dispose(); return bos.ToArray(); } } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Serialization/DistributedPubSubMessageSerializer.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Serialization/DistributedPubSubMessageSerializer.cs index 6b48487827c..7b8b1bfa64a 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Serialization/DistributedPubSubMessageSerializer.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Serialization/DistributedPubSubMessageSerializer.cs @@ -93,7 +93,7 @@ private byte[] Compress(IMessageLite message) using (var gzipStream = new GZipStream(bos, CompressionMode.Compress)) { message.WriteTo(gzipStream); - gzipStream.Close(); + gzipStream.Dispose(); return bos.ToArray(); } } diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Akka.Persistence.Sql.Common.csproj b/src/contrib/persistence/Akka.Persistence.Sql.Common/Akka.Persistence.Sql.Common.csproj index d63f6976c3f..51ab364996f 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Akka.Persistence.Sql.Common.csproj +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Akka.Persistence.Sql.Common.csproj @@ -17,7 +17,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION;CONFIGURATION prompt 4 @@ -25,7 +25,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION;CONFIGURATION prompt 4 bin\Release\Akka.Persistence.Sql.Common.xml diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/InternalExtensions.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/InternalExtensions.cs index bdb0d3ea8f3..5dbfbe16f2c 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/InternalExtensions.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/InternalExtensions.cs @@ -6,6 +6,7 @@ //----------------------------------------------------------------------- using System; +using System.Reflection; namespace Akka.Persistence.Sql.Common { @@ -13,7 +14,7 @@ internal static class InternalExtensions { public static string QualifiedTypeName(this Type type) { - return type.FullName + ", " + type.Assembly.GetName().Name; + return type.FullName + ", " + type.GetTypeInfo().Assembly.GetName().Name; } } } \ No newline at end of file diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryApi.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryApi.cs index 575cc651e28..b77356d6d5c 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryApi.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryApi.cs @@ -20,7 +20,9 @@ public interface ISubscriptionCommand { } /// Used by query-side. The journal will send messages to /// the subscriber when has been called. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SubscribePersistenceId : ISubscriptionCommand { public readonly string PersistenceId; @@ -31,7 +33,9 @@ public SubscribePersistenceId(string persistenceId) } } +#if SERIALIZATION [Serializable] +#endif public sealed class EventAppended { public readonly string PersistenceId; @@ -48,14 +52,18 @@ public EventAppended(string persistenceId) /// subscriber followed by messages when new persistenceIds /// are created. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SubscribeAllPersistenceIds : ISubscriptionCommand { public static readonly SubscribeAllPersistenceIds Instance = new SubscribeAllPersistenceIds(); private SubscribeAllPersistenceIds() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class CurrentPersistenceIds { public readonly IEnumerable AllPersistenceIds; @@ -66,7 +74,9 @@ public CurrentPersistenceIds(IEnumerable allPersistenceIds) } } +#if SERIALIZATION [Serializable] +#endif public sealed class PersistenceIdAdded { public readonly string PersistenceId; @@ -84,7 +94,9 @@ public PersistenceIdAdded(string persistenceId) /// Events are tagged by wrapping in /// via an . /// +#if SERIALIZATION [Serializable] +#endif public sealed class SubscribeTag : ISubscriptionCommand { public readonly string Tag; @@ -95,7 +107,9 @@ public SubscribeTag(string tag) } } +#if SERIALIZATION [Serializable] +#endif public sealed class TaggedEventAppended { public readonly string Tag; @@ -106,7 +120,9 @@ public TaggedEventAppended(string tag) } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayTaggedMessages { public readonly long FromOffset; @@ -130,7 +146,9 @@ public ReplayTaggedMessages(long fromOffset, long toOffset, long max, string tag } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayedTaggedMessage : INoSerializationVerificationNeeded { public readonly IPersistentRepresentation Persistent; diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryExecutor.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryExecutor.cs index 6ea22bcfe8f..2a79dd79f26 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryExecutor.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/QueryExecutor.cs @@ -74,7 +74,9 @@ public interface IJournalQueryExecutor Task SelectEventsAsync(DbConnection connection, CancellationToken cancellationToken, IEnumerable hints, Action callback); } +#if SERIALIZATION [Serializable] +#endif public class QueryConfiguration { public readonly string TagsColumnName; diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/SqlJournal.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/SqlJournal.cs index 8f23127abf3..9ea3b73cff5 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/SqlJournal.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Journal/SqlJournal.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Configuration; using System.Data.Common; using System.Linq; using System.Threading; @@ -404,10 +403,13 @@ public override async Task ReadHighestSequenceNrAsync(string persistenceId protected virtual string GetConnectionString() { var connectionString = _settings.ConnectionString; + +#if CONFIGURATION if (string.IsNullOrEmpty(connectionString)) { - connectionString = ConfigurationManager.ConnectionStrings[_settings.ConnectionStringName].ConnectionString; + connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[_settings.ConnectionStringName].ConnectionString; } +#endif return connectionString; } diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Hints.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Hints.cs index 162df4af260..51b44a929e6 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Hints.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Hints.cs @@ -93,7 +93,9 @@ public static IHint TimestampBetween(long from, long to) /// /// Hint for the SQL journal used to filter journal entries returned in the response based on the manifest. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class WithManifest : IHint, IEquatable { @@ -130,7 +132,9 @@ public override string ToString() /// /// Hint for the SQL journal used to filter journal entries returned in the response based on set of perisistence ids provided. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class PersistenceIdRange : IHint, IEquatable { @@ -170,7 +174,9 @@ public override string ToString() /// Desired behavior of timestamp range is <from, to) - left side inclusive, right side exclusive. /// Timestamp is generated by method, which may be overloaded. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class TimestampRange : IHint, IEquatable { diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Query.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Query.cs index 8bd90e210c9..ed66995df90 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Query.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Queries/Query.cs @@ -24,7 +24,9 @@ public interface IQueryReply { } /// set of events not based on any partition key. Therefore query request don't need to contain /// partition id of the persistent actor. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class Query: IEquatable { @@ -73,7 +75,9 @@ public override string ToString() /// Message send back from SQL-based journal to sender, /// when the query execution has been completed and result is returned. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class QueryResponse : IQueryReply, IEquatable { @@ -116,7 +120,9 @@ public override string ToString() /// /// Message send back from SQL-based journal, when has been successfully responded. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class QuerySuccess : IQueryReply, IEquatable { @@ -153,7 +159,9 @@ public override string ToString() /// /// Message send back from SQL-based journal to sender, when the query execution has failed. /// +#if SERIALIZATION [Serializable] +#endif [Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")] public sealed class QueryFailure : IQueryReply, IEquatable { diff --git a/src/contrib/persistence/Akka.Persistence.Sql.Common/Snapshot/SqlSnapshotStore.cs b/src/contrib/persistence/Akka.Persistence.Sql.Common/Snapshot/SqlSnapshotStore.cs index 4ff8621c612..65bc5adf0ea 100644 --- a/src/contrib/persistence/Akka.Persistence.Sql.Common/Snapshot/SqlSnapshotStore.cs +++ b/src/contrib/persistence/Akka.Persistence.Sql.Common/Snapshot/SqlSnapshotStore.cs @@ -6,7 +6,6 @@ //----------------------------------------------------------------------- using System; -using System.Configuration; using System.Data.Common; using System.Threading; using System.Threading.Tasks; @@ -113,9 +112,15 @@ private bool WaitingForInitialization(object message) => message.Match() protected virtual string GetConnectionString() { var connectionString = _settings.ConnectionString; - return string.IsNullOrEmpty(connectionString) - ? ConfigurationManager.ConnectionStrings[_settings.ConnectionStringName].ConnectionString - : connectionString; + +#if CONFIGURATION + if (string.IsNullOrEmpty(connectionString)) + { + return System.Configuration.ConfigurationManager.ConnectionStrings[_settings.ConnectionStringName].ConnectionString; + } +#endif + + return connectionString; } /// diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/Akka.TestKit.Xunit2.csproj b/src/contrib/testkits/Akka.TestKit.Xunit2/Akka.TestKit.Xunit2.csproj index 07f3e43d953..11cfe86642a 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/Akka.TestKit.Xunit2.csproj +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/Akka.TestKit.Xunit2.csproj @@ -22,7 +22,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION prompt 4 @@ -30,7 +30,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION prompt 4 diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/AkkaEqualException.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/AkkaEqualException.cs index fa0ead3191f..4851f77e910 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/AkkaEqualException.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/Internals/AkkaEqualException.cs @@ -6,7 +6,6 @@ //----------------------------------------------------------------------- using System; -using System.Runtime.Serialization; using Xunit.Sdk; namespace Akka.TestKit.Xunit2.Internals @@ -23,10 +22,12 @@ public AkkaEqualException(object expected, object actual, string format = "", pa _args = args; } - protected AkkaEqualException(SerializationInfo info, StreamingContext context) +#if SERIALIZATION + protected AkkaEqualException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } +#endif public override string Message { diff --git a/src/core/Akka.Cluster/Configuration/ClusterConfigFactory.cs b/src/core/Akka.Cluster/Configuration/ClusterConfigFactory.cs index 0c75d201d60..42f2d7eea54 100644 --- a/src/core/Akka.Cluster/Configuration/ClusterConfigFactory.cs +++ b/src/core/Akka.Cluster/Configuration/ClusterConfigFactory.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.IO; using Akka.Configuration; +using System.Reflection; namespace Akka.Cluster.Configuration { @@ -34,7 +35,7 @@ public static Config Default() /// The configuration defined in the current executing assembly. internal static Config FromResource(string resourceName) { - var assembly = typeof(ClusterConfigFactory).Assembly; + var assembly = typeof(ClusterConfigFactory).GetTypeInfo().Assembly; using (var stream = assembly.GetManifestResourceStream(resourceName)) { diff --git a/src/core/Akka.Cluster/Proto/ClusterMessageSerializer.cs b/src/core/Akka.Cluster/Proto/ClusterMessageSerializer.cs index 39242f46c28..6325da86365 100644 --- a/src/core/Akka.Cluster/Proto/ClusterMessageSerializer.cs +++ b/src/core/Akka.Cluster/Proto/ClusterMessageSerializer.cs @@ -105,7 +105,7 @@ public byte[] Compress(IMessageLite message) using (var gzipStream = new GZipStream(bos, CompressionMode.Compress)) { message.WriteTo(gzipStream); - gzipStream.Close(); + gzipStream.Dispose(); return bos.ToArray(); } } diff --git a/src/core/Akka.Persistence.Query/Akka.Persistence.Query.csproj b/src/core/Akka.Persistence.Query/Akka.Persistence.Query.csproj index dbcc8e167fb..053477d8a78 100644 --- a/src/core/Akka.Persistence.Query/Akka.Persistence.Query.csproj +++ b/src/core/Akka.Persistence.Query/Akka.Persistence.Query.csproj @@ -18,7 +18,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION prompt 4 @@ -26,7 +26,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION prompt 4 bin\Release\Akka.Persistence.Query.XML diff --git a/src/core/Akka.Persistence.Query/EventEnvelope.cs b/src/core/Akka.Persistence.Query/EventEnvelope.cs index 6f953699d40..d90d3607ae1 100644 --- a/src/core/Akka.Persistence.Query/EventEnvelope.cs +++ b/src/core/Akka.Persistence.Query/EventEnvelope.cs @@ -13,7 +13,9 @@ namespace Akka.Persistence.Query /// Event wrapper adding meta data for the events in the result stream of /// query, or similar queries. /// +#if SERIALIZATION [Serializable] +#endif public sealed class EventEnvelope : IEquatable { public readonly long Offset; diff --git a/src/core/Akka.Persistence.Query/PersistenceQuery.cs b/src/core/Akka.Persistence.Query/PersistenceQuery.cs index 1dab2ff557f..38ebeb18d8c 100644 --- a/src/core/Akka.Persistence.Query/PersistenceQuery.cs +++ b/src/core/Akka.Persistence.Query/PersistenceQuery.cs @@ -55,13 +55,13 @@ private IReadJournalProvider CreatePlugin(string configPath, Config config) private IReadJournalProvider CreateType(Type pluginType, object[] parameters) { - var ctor = pluginType.GetConstructor(new Type[] { typeof(ExtendedActorSystem), typeof(Config) }); + var ctor = pluginType.GetTypeInfo().GetConstructor(new Type[] { typeof(ExtendedActorSystem), typeof(Config) }); if (ctor != null) return (IReadJournalProvider)ctor.Invoke(parameters); - ctor = pluginType.GetConstructor(new Type[] { typeof(ExtendedActorSystem) }); + ctor = pluginType.GetTypeInfo().GetConstructor(new Type[] { typeof(ExtendedActorSystem) }); if (ctor != null) return (IReadJournalProvider)ctor.Invoke(new[] { parameters[0] }); - ctor = pluginType.GetConstructor(new Type[0]); + ctor = pluginType.GetTypeInfo().GetConstructor(new Type[0]); if (ctor != null) return (IReadJournalProvider)ctor.Invoke(new object[0]); throw new ArgumentException($"Unable to create read journal plugin instance type {pluginType}!"); @@ -69,7 +69,7 @@ private IReadJournalProvider CreateType(Type pluginType, object[] parameters) public static Config GetDefaultConfig() { - var defaultConfigMethod = typeof(TJournal).GetMethod("DefaultConfiguration", BindingFlags.Public | BindingFlags.Static); + var defaultConfigMethod = typeof(TJournal).GetTypeInfo().GetMethod("DefaultConfiguration", BindingFlags.Public | BindingFlags.Static); return defaultConfigMethod?.Invoke(null, null) as Config; } } diff --git a/src/core/Akka.Persistence/Akka.Persistence.csproj b/src/core/Akka.Persistence/Akka.Persistence.csproj index 2267dc5898d..eb5f64ed90e 100644 --- a/src/core/Akka.Persistence/Akka.Persistence.csproj +++ b/src/core/Akka.Persistence/Akka.Persistence.csproj @@ -19,7 +19,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION prompt 4 @@ -27,7 +27,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION prompt 4 bin\Release\Akka.Persistence.xml diff --git a/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs b/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs index e37174f11e3..8960ac9e339 100644 --- a/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs +++ b/src/core/Akka.Persistence/AtLeastOnceDeliverySemantic.cs @@ -75,7 +75,9 @@ public override string ToString() /// Message should be sent after /// limit will is reached. /// +#if SERIALIZATION [Serializable] +#endif public sealed class UnconfirmedWarning : IEquatable { public readonly UnconfirmedDelivery[] UnconfirmedDeliveries; @@ -118,7 +120,9 @@ public override string ToString() /// It's included inside and . /// /// +#if SERIALIZATION [Serializable] +#endif public sealed class UnconfirmedDelivery : IEquatable { public readonly long DeliveryId; @@ -182,9 +186,11 @@ public MaxUnconfirmedMessagesExceededException(string message, Exception innerEx { } +#if SERIALIZATION protected MaxUnconfirmedMessagesExceededException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } #endregion @@ -192,7 +198,9 @@ protected MaxUnconfirmedMessagesExceededException(SerializationInfo info, Stream public class AtLeastOnceDeliverySemantic { +#if SERIALIZATION [Serializable] +#endif internal sealed class Delivery : IEquatable { public readonly int Attempt; @@ -249,7 +257,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif internal sealed class RedeliveryTick { public static readonly RedeliveryTick Instance = new RedeliveryTick(); diff --git a/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs b/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs index 87b69bf905f..cca1ddbc07e 100644 --- a/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs +++ b/src/core/Akka.Persistence/Journal/AsyncWriteProxy.cs @@ -18,7 +18,9 @@ namespace Akka.Persistence.Journal /// /// This exception is thrown when the replay inactivity exceeds a specified timeout. /// +#if SERIALIZATION [Serializable] +#endif public class AsyncReplayTimeoutException : AkkaException { /// @@ -37,6 +39,7 @@ public AsyncReplayTimeoutException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -46,9 +49,12 @@ protected AsyncReplayTimeoutException(SerializationInfo info, StreamingContext c : base(info, context) { } +#endif } +#if SERIALIZATION [Serializable] +#endif public sealed class SetStore { public SetStore(IActorRef store) @@ -67,7 +73,9 @@ public static class AsyncWriteTarget #region Internal Messages +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayFailure { public ReplayFailure(Exception cause) @@ -81,7 +89,9 @@ public ReplayFailure(Exception cause) public Exception Cause { get; private set; } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReplaySuccess : IEquatable { public ReplaySuccess(long highestSequenceNr) @@ -99,7 +109,9 @@ public bool Equals(ReplaySuccess other) } } +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessages { public WriteMessages(IEnumerable messages) @@ -110,7 +122,9 @@ public WriteMessages(IEnumerable messages) public AtomicWrite[] Messages { get; private set; } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayMessages : IEquatable { public ReplayMessages(string persistenceId, long fromSequenceNr, long toSequenceNr, long max) @@ -137,7 +151,9 @@ public bool Equals(ReplayMessages other) } } +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteMessagesTo : IEquatable { public DeleteMessagesTo(string persistenceId, long toSequenceNr) diff --git a/src/core/Akka.Persistence/Journal/EventAdapters.cs b/src/core/Akka.Persistence/Journal/EventAdapters.cs index 634437e99e2..110275a9034 100644 --- a/src/core/Akka.Persistence/Journal/EventAdapters.cs +++ b/src/core/Akka.Persistence/Journal/EventAdapters.cs @@ -9,6 +9,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Akka.Actor; using Akka.Configuration; using Akka.Configuration.Hocon; @@ -86,7 +87,9 @@ public interface IReadEventAdapter IEventSequence FromJournal(object evt, string manifest); } +#if SERIALIZATION [Serializable] +#endif public class IdentityEventAdapter : IEventAdapter { public static readonly IdentityEventAdapter Instance = new IdentityEventAdapter(); @@ -109,7 +112,9 @@ public IEventSequence FromJournal(object evt, string manifest) } } +#if SERIALIZATION [Serializable] +#endif internal class NoopWriteEventAdapter : IEventAdapter { private readonly IReadEventAdapter _readEventAdapter; @@ -137,7 +142,9 @@ public IEventSequence FromJournal(object evt, string manifest) } } +#if SERIALIZATION [Serializable] +#endif internal class NoopReadEventAdapter : IEventAdapter { private readonly IWriteEventAdapter _writeEventAdapter; @@ -165,7 +172,9 @@ public IEventSequence FromJournal(object evt, string manifest) } } +#if SERIALIZATION [Serializable] +#endif public sealed class CombinedReadEventAdapter : IEventAdapter { private static readonly Exception OnlyReadSideException = new IllegalStateException( @@ -267,7 +276,7 @@ private static EventAdapters Create(ExtendedActorSystem system, IDictionary>(bindings.Count), (buf, ca) => { - var idx = IndexWhere(buf, x => x.Key.IsAssignableFrom(ca.Key)); + var idx = IndexWhere(buf, x => x.Key.GetTypeInfo().IsAssignableFrom(ca.Key)); if (idx == -1) buf.Add(ca); @@ -305,7 +314,7 @@ public virtual IEventAdapter Get(Type type) return adapter; // bindings are ordered from most specific to least specific - var pair = _bindings.FirstOrDefault(kv => kv.Key.IsAssignableFrom(type)); + var pair = _bindings.FirstOrDefault(kv => kv.Key.GetTypeInfo().IsAssignableFrom(type)); var value = !pair.Equals(default(KeyValuePair)) ? pair.Value : IdentityEventAdapter.Instance; adapter = _map.GetOrAdd(type, value); @@ -315,11 +324,11 @@ public virtual IEventAdapter Get(Type type) private static IEventAdapter InstantiateAdapter(string qualifiedName, ExtendedActorSystem system) { var type = Type.GetType(qualifiedName, true); - if (typeof(IEventAdapter).IsAssignableFrom(type)) + if (typeof(IEventAdapter).GetTypeInfo().IsAssignableFrom(type)) return Instantiate(qualifiedName, system); - if (typeof (IWriteEventAdapter).IsAssignableFrom(type)) + if (typeof (IWriteEventAdapter).GetTypeInfo().IsAssignableFrom(type)) return new NoopReadEventAdapter(Instantiate(qualifiedName, system)); - if (typeof (IReadEventAdapter).IsAssignableFrom(type)) + if (typeof (IReadEventAdapter).GetTypeInfo().IsAssignableFrom(type)) return new NoopWriteEventAdapter(Instantiate(qualifiedName, system)); throw new ArgumentException("Configured " + qualifiedName + " does not implement any EventAdapter interface!"); } @@ -327,7 +336,7 @@ private static IEventAdapter InstantiateAdapter(string qualifiedName, ExtendedAc private static T Instantiate(string qualifiedName, ExtendedActorSystem system) { var type = Type.GetType(qualifiedName); - if (!typeof(T).IsAssignableFrom(type)) + if (!typeof(T).GetTypeInfo().IsAssignableFrom(type)) throw new ArgumentException(string.Format("Couldn't create instance of [{0}] from provided qualified type name [{1}], because it's not assignable from it", typeof(T), qualifiedName)); diff --git a/src/core/Akka.Persistence/Journal/EventSequences.cs b/src/core/Akka.Persistence/Journal/EventSequences.cs index 7f7e35479ac..f7c7801c1d3 100644 --- a/src/core/Akka.Persistence/Journal/EventSequences.cs +++ b/src/core/Akka.Persistence/Journal/EventSequences.cs @@ -18,7 +18,9 @@ public interface IEventSequence public interface IEmptyEventSequence : IEventSequence { } +#if SERIALIZATION [Serializable] +#endif public sealed class EmptyEventSequence : IEmptyEventSequence, IEquatable { public static readonly EmptyEventSequence Instance = new EmptyEventSequence(); @@ -38,7 +40,9 @@ public override bool Equals(object obj) } } +#if SERIALIZATION [Serializable] +#endif public class EventSequence : IEventSequence, IEquatable { private readonly IList _events; @@ -60,7 +64,9 @@ public override bool Equals(object obj) } } +#if SERIALIZATION [Serializable] +#endif public struct SingleEventSequence : IEventSequence, IEquatable { private readonly object[] _events; diff --git a/src/core/Akka.Persistence/JournalProtocol.cs b/src/core/Akka.Persistence/JournalProtocol.cs index 7c372041d03..15eeafa87cd 100644 --- a/src/core/Akka.Persistence/JournalProtocol.cs +++ b/src/core/Akka.Persistence/JournalProtocol.cs @@ -26,7 +26,9 @@ public interface IJournalRequest : IJournalMessage { } /// public interface IJournalResponse : IJournalMessage { } +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteMessagesSuccess : IJournalResponse, IEquatable { public DeleteMessagesSuccess(long toSequenceNr) @@ -63,7 +65,9 @@ public override string ToString() /// /// Reply message to failed request. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteMessagesFailure : IJournalResponse, IEquatable { public DeleteMessagesFailure(Exception cause, long toSequenceNr) @@ -108,7 +112,9 @@ public override string ToString() /// /// Request to delete all persistent messages with sequence numbers up to `toSequenceNr` (inclusive). /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteMessagesTo : IJournalRequest, IEquatable { public DeleteMessagesTo(string persistenceId, long toSequenceNr, IActorRef persistentActor) @@ -156,7 +162,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessages : IJournalRequest, IEquatable { public WriteMessages(IEnumerable messages, IActorRef persistentActor, @@ -207,7 +215,9 @@ public override string ToString() /// Reply message to a successful request. This reply is sent /// to the requestor before all subsequent replies. /// +#if SERIALIZATION [Serializable] +#endif public class WriteMessagesSuccessful : IJournalResponse, IEquatable { public static readonly WriteMessagesSuccessful Instance = new WriteMessagesSuccessful(); @@ -236,7 +246,9 @@ public override string ToString() /// Reply message to a failed request. This reply is sent /// to the requestor before all subsequent replies. /// +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessagesFailed : IJournalResponse, IEquatable { public WriteMessagesFailed(Exception cause) @@ -277,7 +289,9 @@ public override string ToString() /// Reply message to a successful request. For each contained /// message in the request, a separate reply is sent to the requestor. /// +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessageSuccess : IJournalResponse, IEquatable { public WriteMessageSuccess(IPersistentRepresentation persistent, int actorInstanceId) @@ -325,7 +339,9 @@ public override string ToString() /// before it was stored, e.g. because it could not be serialized. For each contained /// message in the request, a separate reply is sent to the requestor. /// +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessageRejected : IJournalResponse, IEquatable { public WriteMessageRejected(IPersistentRepresentation persistent, Exception cause, int actorInstanceId) @@ -386,7 +402,9 @@ public override string ToString() /// Reply message to a failed request. For each contained /// message in the request, a separate reply is sent to the requestor. /// +#if SERIALIZATION [Serializable] +#endif public sealed class WriteMessageFailure : IJournalResponse, IEquatable { public WriteMessageFailure(IPersistentRepresentation persistent, Exception cause, int actorInstanceId) @@ -446,7 +464,9 @@ public override string ToString() /// /// Reply message to a with a non-persistent message. /// +#if SERIALIZATION [Serializable] +#endif public sealed class LoopMessageSuccess : IJournalResponse, IEquatable { public LoopMessageSuccess(object message, int actorInstanceId) @@ -492,7 +512,9 @@ public override string ToString() /// /// Request to replay messages to the . /// +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayMessages : IJournalRequest, IEquatable { public ReplayMessages(long fromSequenceNr, long toSequenceNr, long max, string persistenceId, @@ -564,7 +586,9 @@ public override int GetHashCode() /// /// Reply message to a request. A separate reply is sent to the requestor for each replayed message. /// +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayedMessage : IJournalResponse, IEquatable { public ReplayedMessage(IPersistentRepresentation persistent) @@ -605,7 +629,9 @@ public override string ToString() /// It includes the highest stored sequence number of a given persistent actor. /// Note that the replay might have been limited to a lower sequence number. /// +#if SERIALIZATION [Serializable] +#endif public class RecoverySuccess : IJournalResponse, IEquatable { public RecoverySuccess(long highestSequenceNr) @@ -639,7 +665,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReplayMessagesFailure : IJournalResponse, IEquatable { public ReplayMessagesFailure(Exception cause) @@ -676,7 +704,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReadHighestSequenceNr : IEquatable { public ReadHighestSequenceNr(long fromSequenceNr, string persistenceId, IActorRef persistentActor) @@ -724,7 +754,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReadHighestSequenceNrSuccess : IEquatable, IComparable { @@ -765,7 +797,9 @@ public override string ToString() } } +#if SERIALIZATION [Serializable] +#endif public sealed class ReadHighestSequenceNrFailure : IEquatable { public ReadHighestSequenceNrFailure(Exception cause) diff --git a/src/core/Akka.Persistence/Persistence.cs b/src/core/Akka.Persistence/Persistence.cs index 6f7da922f73..1653e2a6024 100644 --- a/src/core/Akka.Persistence/Persistence.cs +++ b/src/core/Akka.Persistence/Persistence.cs @@ -14,6 +14,7 @@ using Akka.Event; using Akka.Persistence.Journal; using Akka.Util.Internal; +using System.Reflection; namespace Akka.Persistence { @@ -206,7 +207,7 @@ private static IActorRef CreatePlugin(ExtendedActorSystem system, string configP throw new ArgumentException(string.Format("Plugin class name must be defined in config property [{0}.class]", configPath)); var pluginType = Type.GetType(pluginTypeName, true); var pluginDispatcherId = pluginConfig.GetString("plugin-dispatcher"); - object[] pluginActorArgs = pluginType.GetConstructor(new[] {typeof (Config)}) != null ? new object[] {pluginConfig} : null; + object[] pluginActorArgs = pluginType.GetTypeInfo().GetConstructor(new[] {typeof (Config)}) != null ? new object[] {pluginConfig} : null; var pluginActorProps = new Props(pluginType, pluginActorArgs).WithDispatcher(pluginDispatcherId); return system.SystemActorOf(pluginActorProps, pluginActorName); diff --git a/src/core/Akka.Persistence/Persistent.cs b/src/core/Akka.Persistence/Persistent.cs index 8b446c2eeb4..34aa4b0b413 100644 --- a/src/core/Akka.Persistence/Persistent.cs +++ b/src/core/Akka.Persistence/Persistent.cs @@ -214,7 +214,9 @@ public interface IPersistentRepresentation : IMessage IPersistentRepresentation Update(long sequenceNr, string persistenceId, bool isDeleted, IActorRef sender, string writerGuid); } +#if SERIALIZATION [Serializable] +#endif public class Persistent : IPersistentRepresentation, IEquatable { public static readonly string Undefined = string.Empty; diff --git a/src/core/Akka.Persistence/PersistentActor.cs b/src/core/Akka.Persistence/PersistentActor.cs index 4a7c4007644..d7bb161f703 100644 --- a/src/core/Akka.Persistence/PersistentActor.cs +++ b/src/core/Akka.Persistence/PersistentActor.cs @@ -14,7 +14,9 @@ namespace Akka.Persistence { +#if SERIALIZATION [Serializable] +#endif public sealed class RecoveryCompleted { public static readonly RecoveryCompleted Instance = new RecoveryCompleted(); @@ -39,7 +41,9 @@ public override bool Equals(object obj) /// message, followed by replayed messages, if any, that are younger than the snapshot, up to the /// specified upper sequence number bound (). /// +#if SERIALIZATION [Serializable] +#endif public sealed class Recovery { public static readonly Recovery Default = new Recovery(SnapshotSelectionCriteria.Latest); diff --git a/src/core/Akka.Persistence/PersistentView.cs b/src/core/Akka.Persistence/PersistentView.cs index bc756587ac2..7d5e3935415 100644 --- a/src/core/Akka.Persistence/PersistentView.cs +++ b/src/core/Akka.Persistence/PersistentView.cs @@ -18,7 +18,9 @@ namespace Akka.Persistence /// To update a view with messages that have been written after handling this request, another /// request must be sent to the view. /// +#if SERIALIZATION [Serializable] +#endif public sealed class Update { public Update() @@ -53,7 +55,9 @@ public Update(bool isAwait, long replayMax) public long ReplayMax { get; private set; } } +#if SERIALIZATION [Serializable] +#endif public sealed class ScheduledUpdate { public ScheduledUpdate(long replayMax) diff --git a/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs b/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs index 314eb55be38..d17596d6555 100644 --- a/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs +++ b/src/core/Akka.Persistence/Snapshot/LocalSnapshotStore.cs @@ -196,7 +196,7 @@ private T WithStream(Stream stream, Func p) try { var result = p(stream); - stream.Close(); + stream.Dispose(); return result; } finally diff --git a/src/core/Akka.Persistence/Snapshot/NoSnapshotStore.cs b/src/core/Akka.Persistence/Snapshot/NoSnapshotStore.cs index 7c0dca8e8d6..40f649f3640 100644 --- a/src/core/Akka.Persistence/Snapshot/NoSnapshotStore.cs +++ b/src/core/Akka.Persistence/Snapshot/NoSnapshotStore.cs @@ -33,10 +33,11 @@ public NoSnapshotStoreException(string message) : base(message) public NoSnapshotStoreException(string message, Exception innerException) : base(message, innerException) { } - +#if SERIALIZATION protected NoSnapshotStoreException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } protected override Task LoadAsync(string persistenceId, SnapshotSelectionCriteria criteria) diff --git a/src/core/Akka.Persistence/SnapshotProtocol.cs b/src/core/Akka.Persistence/SnapshotProtocol.cs index 5a4ca32cd85..083b9add216 100644 --- a/src/core/Akka.Persistence/SnapshotProtocol.cs +++ b/src/core/Akka.Persistence/SnapshotProtocol.cs @@ -26,7 +26,9 @@ public interface ISnapshotRequest : ISnapshotMessage { } /// public interface ISnapshotResponse : ISnapshotMessage { } +#if SERIALIZATION [Serializable] +#endif public sealed class SnapshotMetadata : IEquatable { internal class SnapshotMetadataComparer : IComparer @@ -108,7 +110,9 @@ public override string ToString() /// /// Sent to after successful saving of a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SaveSnapshotSuccess : ISnapshotResponse, IEquatable { public SaveSnapshotSuccess(SnapshotMetadata metadata) @@ -145,7 +149,9 @@ public override string ToString() /// /// Sent to after successful deletion of a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshotSuccess : ISnapshotResponse, IEquatable { public DeleteSnapshotSuccess(SnapshotMetadata metadata) @@ -182,7 +188,9 @@ public override string ToString() /// /// Sent to after successful deletion of a specified range of snapshots. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshotsSuccess : ISnapshotResponse, IEquatable { public DeleteSnapshotsSuccess(SnapshotSelectionCriteria criteria) @@ -219,7 +227,9 @@ public override string ToString() /// /// Sent to after failed saving a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SaveSnapshotFailure : ISnapshotResponse, IEquatable { public SaveSnapshotFailure(SnapshotMetadata metadata, Exception cause) @@ -268,7 +278,9 @@ public override string ToString() /// /// Sent to after failed deletion of a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshotFailure : ISnapshotResponse, IEquatable { public DeleteSnapshotFailure(SnapshotMetadata metadata, Exception cause) @@ -317,7 +329,9 @@ public override string ToString() /// /// Sent to after failed deletion of a range of snapshots. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshotsFailure : ISnapshotResponse, IEquatable { public DeleteSnapshotsFailure(SnapshotSelectionCriteria criteria, Exception cause) @@ -367,7 +381,9 @@ public override string ToString() /// Offers a a previously saved snapshot during recovery. /// This offer is received before any further replayed messages. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SnapshotOffer : IEquatable { public SnapshotOffer(SnapshotMetadata metadata, object snapshot) @@ -409,7 +425,9 @@ public override string ToString() /// /// Selection criteria for loading and deleting a snapshots. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SnapshotSelectionCriteria : IEquatable { public static readonly SnapshotSelectionCriteria Latest = new SnapshotSelectionCriteria(long.MaxValue, DateTime.MaxValue); @@ -478,7 +496,9 @@ public override string ToString() /// /// A selected snapshot matching . /// +#if SERIALIZATION [Serializable] +#endif public sealed class SelectedSnapshot : IEquatable { public SelectedSnapshot(SnapshotMetadata metadata, object snapshot) @@ -523,7 +543,9 @@ public override string ToString() /// /// Instructs a snapshot store to load the snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class LoadSnapshot: ISnapshotRequest, IEquatable { public LoadSnapshot(string persistenceId, SnapshotSelectionCriteria criteria, long toSequenceNr) @@ -583,7 +605,9 @@ public override string ToString() /// /// Response to a message. /// +#if SERIALIZATION [Serializable] +#endif public sealed class LoadSnapshotResult : ISnapshotResponse, IEquatable { public LoadSnapshotResult(SelectedSnapshot snapshot, long toSequenceNr) @@ -629,7 +653,9 @@ public override string ToString() /// /// Instructs a snapshot store to save a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SaveSnapshot : ISnapshotRequest, IEquatable { public SaveSnapshot(SnapshotMetadata metadata, object snapshot) @@ -674,7 +700,9 @@ public override string ToString() /// /// Instructs a snapshot store to delete a snapshot. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshot : ISnapshotRequest, IEquatable { public DeleteSnapshot(SnapshotMetadata metadata) @@ -714,7 +742,9 @@ public override string ToString() /// /// Instructs a snapshot store to delete all snapshots that match provided criteria. /// +#if SERIALIZATION [Serializable] +#endif public sealed class DeleteSnapshots : ISnapshotRequest, IEquatable { public DeleteSnapshots(string persistenceId, SnapshotSelectionCriteria criteria) diff --git a/src/core/Akka.Remote/Configuration/RemoteConfigFactory.cs b/src/core/Akka.Remote/Configuration/RemoteConfigFactory.cs index ff2cc2f27cd..5aeba36c651 100644 --- a/src/core/Akka.Remote/Configuration/RemoteConfigFactory.cs +++ b/src/core/Akka.Remote/Configuration/RemoteConfigFactory.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.IO; +using System.Reflection; using Akka.Configuration; namespace Akka.Remote.Configuration @@ -34,7 +35,7 @@ public static Config Default() /// The configuration defined in the current executing assembly. internal static Config FromResource(string resourceName) { - var assembly = typeof (RemoteConfigFactory).Assembly; + var assembly = typeof(RemoteConfigFactory).GetTypeInfo().Assembly; using (var stream = assembly.GetManifestResourceStream(resourceName)) { diff --git a/src/core/Akka.Remote/MessageSerializer.cs b/src/core/Akka.Remote/MessageSerializer.cs index c0b137e2e83..52200508dfe 100644 --- a/src/core/Akka.Remote/MessageSerializer.cs +++ b/src/core/Akka.Remote/MessageSerializer.cs @@ -9,6 +9,7 @@ using Akka.Actor; using Akka.Serialization; using Google.ProtocolBuffers; +using System.Reflection; namespace Akka.Remote { @@ -58,7 +59,7 @@ public static SerializedMessage Serialize(ActorSystem system, Address address, o else { if (serializer.IncludeManifest) - messageBuilder.SetMessageManifest(ByteString.CopyFromUtf8(message.GetType().AssemblyQualifiedName)); + messageBuilder.SetMessageManifest(ByteString.CopyFromUtf8(message.GetType().GetTypeInfo().AssemblyQualifiedName)); } return messageBuilder.Build(); diff --git a/src/core/Akka.Remote/Serialization/DaemonMsgCreateSerializer.cs b/src/core/Akka.Remote/Serialization/DaemonMsgCreateSerializer.cs index 409b204e157..283cf063f8f 100644 --- a/src/core/Akka.Remote/Serialization/DaemonMsgCreateSerializer.cs +++ b/src/core/Akka.Remote/Serialization/DaemonMsgCreateSerializer.cs @@ -12,6 +12,7 @@ using Akka.Routing; using Akka.Serialization; using Google.ProtocolBuffers; +using System.Reflection; namespace Akka.Remote.Serialization { @@ -96,7 +97,7 @@ public override byte[] ToBinary(object obj) private PropsData GetPropsData(Props props) { var builder = PropsData.CreateBuilder() - .SetClazz(props.Type.AssemblyQualifiedName) + .SetClazz(props.Type.GetTypeInfo().AssemblyQualifiedName) .SetDeploy(GetDeployData(props.Deploy)); foreach (object arg in props.Arguments) diff --git a/src/core/Akka.Remote/Serialization/MessageContainerSerializer.cs b/src/core/Akka.Remote/Serialization/MessageContainerSerializer.cs index 10b31de8115..7994f8293bf 100644 --- a/src/core/Akka.Remote/Serialization/MessageContainerSerializer.cs +++ b/src/core/Akka.Remote/Serialization/MessageContainerSerializer.cs @@ -10,6 +10,7 @@ using Akka.Actor; using Akka.Serialization; using Google.ProtocolBuffers; +using System.Reflection; namespace Akka.Remote.Serialization { @@ -96,7 +97,7 @@ private byte[] SerializeSelection(ActorSelectionMessage sel) else { if (serializer.IncludeManifest) - builder.SetMessageManifest(ByteString.CopyFromUtf8(message.GetType().AssemblyQualifiedName)); + builder.SetMessageManifest(ByteString.CopyFromUtf8(message.GetType().GetTypeInfo().AssemblyQualifiedName)); } foreach (SelectionPathElement element in sel.Elements) diff --git a/src/core/Akka.Streams/ActorMaterializer.cs b/src/core/Akka.Streams/ActorMaterializer.cs index a723da2e0ed..4ec643bd5fe 100644 --- a/src/core/Akka.Streams/ActorMaterializer.cs +++ b/src/core/Akka.Streams/ActorMaterializer.cs @@ -134,7 +134,9 @@ private static ActorSystem ActorSystemOf(IActorRefFactory context) /// has been terminated without being notified by an onError, onComplete or cancel signal. This usually happens /// when an ActorSystem is shut down while stream processing actors are still running. /// +#if SERIALIZATION [Serializable] +#endif public class AbruptTerminationException : Exception { public readonly IActorRef Actor; @@ -145,10 +147,12 @@ public AbruptTerminationException(IActorRef actor) Actor = actor; } +#if SERIALIZATION protected AbruptTerminationException(SerializationInfo info, StreamingContext context) : base(info, context) { Actor = (IActorRef)info.GetValue("Actor", typeof(IActorRef)); } +#endif } /// @@ -158,7 +162,9 @@ public class MaterializationException : Exception { public MaterializationException(string message, Exception innerException) : base(message, innerException) { } +#if SERIALIZATION protected MaterializationException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// diff --git a/src/core/Akka.Streams/Actors/ActorPublisher.cs b/src/core/Akka.Streams/Actors/ActorPublisher.cs index b37a7e0ab63..318f5e1d34e 100644 --- a/src/core/Akka.Streams/Actors/ActorPublisher.cs +++ b/src/core/Akka.Streams/Actors/ActorPublisher.cs @@ -27,7 +27,9 @@ public Subscribe(ISubscriber subscriber) } } +#if SERIALIZATION [Serializable] +#endif public enum LifecycleState { PreSubscriber, @@ -46,7 +48,9 @@ public interface IActorPublisherMessage { } /// This message is delivered to the actor when the stream /// subscriber requests more elements. /// +#if SERIALIZATION [Serializable] +#endif public sealed class Request : IActorPublisherMessage { public readonly long Count; @@ -60,7 +64,9 @@ public Request(long count) /// This message is delivered to the actor when the stream /// subscriber cancels the subscription. /// +#if SERIALIZATION [Serializable] +#endif public sealed class Cancel : IActorPublisherMessage { public static readonly Cancel Instance = new Cancel(); @@ -72,7 +78,9 @@ public sealed class Cancel : IActorPublisherMessage /// the exceeding of an subscription timeout. Once the actor receives this message, this /// publisher will already be in cancelled state, thus the actor should clean-up and stop itself. /// +#if SERIALIZATION [Serializable] +#endif public sealed class SubscriptionTimeoutExceeded : IActorPublisherMessage { public static readonly SubscriptionTimeoutExceeded Instance = new SubscriptionTimeoutExceeded(); diff --git a/src/core/Akka.Streams/Actors/ActorSubscriber.cs b/src/core/Akka.Streams/Actors/ActorSubscriber.cs index 4750ec8f211..b9480ff251e 100644 --- a/src/core/Akka.Streams/Actors/ActorSubscriber.cs +++ b/src/core/Akka.Streams/Actors/ActorSubscriber.cs @@ -13,7 +13,9 @@ namespace Akka.Streams.Actors { +#if SERIALIZATION [Serializable] +#endif public sealed class OnSubscribe : INoSerializationVerificationNeeded { public readonly ISubscription Subscription; @@ -26,7 +28,9 @@ public OnSubscribe(ISubscription subscription) public interface IActorSubscriberMessage : INoSerializationVerificationNeeded { } +#if SERIALIZATION [Serializable] +#endif public sealed class OnNext : IActorSubscriberMessage { public readonly object Element; @@ -37,7 +41,9 @@ public OnNext(object element) } } +#if SERIALIZATION [Serializable] +#endif public sealed class OnError : IActorSubscriberMessage { public readonly Exception Cause; @@ -48,7 +54,9 @@ public OnError(Exception cause) } } +#if SERIALIZATION [Serializable] +#endif public sealed class OnComplete : IActorSubscriberMessage { public static readonly OnComplete Instance = new OnComplete(); @@ -268,7 +276,9 @@ public void OnError(Exception cause) public sealed class ActorSubscriberState : ExtensionIdProvider, IExtension { +#if SERIALIZATION [Serializable] +#endif public sealed class State { public readonly ISubscription Subscription; diff --git a/src/core/Akka.Streams/Akka.Streams.csproj b/src/core/Akka.Streams/Akka.Streams.csproj index 4e516fdf348..9ab84d98a41 100644 --- a/src/core/Akka.Streams/Akka.Streams.csproj +++ b/src/core/Akka.Streams/Akka.Streams.csproj @@ -17,7 +17,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION prompt 4 @@ -25,7 +25,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION prompt 4 bin\Release\Akka.Streams.XML diff --git a/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs b/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs index cdcd4d5c0d6..1d4d9473942 100644 --- a/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs +++ b/src/core/Akka.Streams/Dsl/One2OneBidiFlow.cs @@ -18,7 +18,7 @@ public static class One2OneBidiFlow } } - public class UnexpectedOutputException : SystemException + public class UnexpectedOutputException : Exception { public UnexpectedOutputException(object element) : base(element.ToString()) { @@ -26,7 +26,7 @@ public UnexpectedOutputException(object element) : base(element.ToString()) } } - public class OutputTruncationException : SystemException + public class OutputTruncationException : Exception { } diff --git a/src/core/Akka.Streams/Dsl/Source.cs b/src/core/Akka.Streams/Dsl/Source.cs index 1879670a654..96339ef3690 100644 --- a/src/core/Akka.Streams/Dsl/Source.cs +++ b/src/core/Akka.Streams/Dsl/Source.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using Akka.Actor; using Akka.Streams.Dsl.Internal; @@ -427,7 +428,7 @@ public static class Source /// public static Source ActorPublisher(Props props) { - if (!typeof(Actors.ActorPublisher).IsAssignableFrom(props.Type)) + if (!typeof(Actors.ActorPublisher).GetTypeInfo().IsAssignableFrom(props.Type)) throw new ArgumentException("Actor must be ActorPublisher"); return new Source(new ActorPublisherSource(props, DefaultAttributes.ActorPublisherSource, Shape("ActorPublisherSource"))); diff --git a/src/core/Akka.Streams/Dsl/Tcp.cs b/src/core/Akka.Streams/Dsl/Tcp.cs index e8298b9d99b..3a9d5e215ae 100644 --- a/src/core/Akka.Streams/Dsl/Tcp.cs +++ b/src/core/Akka.Streams/Dsl/Tcp.cs @@ -118,7 +118,7 @@ public TcpExt(ExtendedActorSystem system) IImmutableList options = null, bool halfClose = false, TimeSpan? idleTimeout = null) { // DnsEnpoint isn't allowed - var ipAddresses = System.Net.Dns.GetHostAddresses(host); + var ipAddresses = System.Net.Dns.GetHostAddressesAsync(host).Result; if (ipAddresses.Length == 0) throw new ArgumentException($"Couldn't resolve IpAdress for host {host}", nameof(host)); diff --git a/src/core/Akka.Streams/FanInShape.cs b/src/core/Akka.Streams/FanInShape.cs index 916d15a1634..4c63c2cc35c 100644 --- a/src/core/Akka.Streams/FanInShape.cs +++ b/src/core/Akka.Streams/FanInShape.cs @@ -23,7 +23,9 @@ public interface IInit string Name { get; } } +#if SERIALIZATION [Serializable] +#endif public sealed class InitName : IInit { private readonly string _name; @@ -42,7 +44,9 @@ public InitName(string name) public string Name => _name; } +#if SERIALIZATION [Serializable] +#endif public sealed class InitPorts : IInit { private readonly Outlet _outlet; diff --git a/src/core/Akka.Streams/FanOutShape.cs b/src/core/Akka.Streams/FanOutShape.cs index 4f7b1ffc059..ccb3a1c3e5a 100644 --- a/src/core/Akka.Streams/FanOutShape.cs +++ b/src/core/Akka.Streams/FanOutShape.cs @@ -23,7 +23,9 @@ public interface IInit string Name { get; } } +#if SERIALIZATION [Serializable] +#endif public sealed class InitName : IInit { public InitName(string name) @@ -40,7 +42,9 @@ public InitName(string name) public string Name { get; } } +#if SERIALIZATION [Serializable] +#endif public sealed class InitPorts : IInit { public InitPorts(Inlet inlet, IEnumerable outlets) diff --git a/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs b/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs index 77b9cc4245c..22c329dfe72 100644 --- a/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs +++ b/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs @@ -29,7 +29,7 @@ public sealed class ActorMaterializerImpl : ActorMaterializer private sealed class ActorMaterializerSession : MaterializerSession { private static readonly MethodInfo ProcessorForMethod = - typeof(ActorMaterializerSession).GetMethod("ProcessorFor", + typeof(ActorMaterializerSession).GetTypeInfo().GetMethod("ProcessorFor", BindingFlags.NonPublic | BindingFlags.Instance); private readonly ActorMaterializerImpl _materializer; private readonly Func _subflowFuser; @@ -68,7 +68,7 @@ public ActorMaterializerSession(ActorMaterializerImpl materializer, IModule topL // FIXME: Remove this, only stream-of-stream ops need it var stage = (IStageModule) atomic; // assumes BaseType is StageModule<> - var methodInfo = ProcessorForMethod.MakeGenericMethod(atomic.GetType().BaseType.GenericTypeArguments); + var methodInfo = ProcessorForMethod.MakeGenericMethod(atomic.GetType().GetTypeInfo().BaseType.GenericTypeArguments); var parameters = new object[] {stage, effectiveAttributes, _materializer.EffectiveSettings(effectiveAttributes), null}; var processor = methodInfo.Invoke(this, parameters); @@ -121,7 +121,7 @@ private void MaterializeGraph(GraphModule graph, Attributes effectiveAttributes, while (inletsEnumerator.MoveNext()) { var inlet = inletsEnumerator.Current; - var elementType = inlet.GetType().GetGenericArguments().First(); + var elementType = inlet.GetType().GetTypeInfo().GetGenericArguments().First(); var subscriber = typeof(ActorGraphInterpreter.BoundarySubscriber<>).Instantiate(elementType, impl, shell, i); AssignPort(inlet, UntypedSubscriber.FromTyped(subscriber)); i++; @@ -132,7 +132,7 @@ private void MaterializeGraph(GraphModule graph, Attributes effectiveAttributes, while (outletsEnumerator.MoveNext()) { var outlet = outletsEnumerator.Current; - var elementType = outlet.GetType().GetGenericArguments().First(); + var elementType = outlet.GetType().GetTypeInfo().GetGenericArguments().First(); var publisher = typeof(ActorGraphInterpreter.BoundaryPublisher<>).Instantiate(elementType, impl, shell, i); var message = new ActorGraphInterpreter.ExposedPublisher(shell, i, (IActorPublisher)publisher); impl.Tell(message); @@ -424,7 +424,7 @@ internal static class ActorProcessorFactory var groupBy = (IGroupBy) op; result = GroupByProcessorImpl.Props(settings, groupBy.MaxSubstreams, groupBy.Extractor); } - else if (op.GetType().IsGenericType && op.GetType().GetGenericTypeDefinition() == typeof(DirectProcessor<,>)) + else if (op.GetType().GetTypeInfo().IsGenericType && op.GetType().GetGenericTypeDefinition() == typeof(DirectProcessor<,>)) throw new ArgumentException("DirectProcessor cannot end up in ActorProcessorFactory"); else throw new ArgumentException($"StageModule type {op.GetType()} is not supported"); diff --git a/src/core/Akka.Streams/Implementation/ActorPublisher.cs b/src/core/Akka.Streams/Implementation/ActorPublisher.cs index 332257e4940..0a23f5038df 100644 --- a/src/core/Akka.Streams/Implementation/ActorPublisher.cs +++ b/src/core/Akka.Streams/Implementation/ActorPublisher.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using System.Reflection; using System.Runtime.Serialization; using Akka.Actor; using Akka.Pattern; @@ -17,14 +18,18 @@ namespace Akka.Streams.Implementation { +#if SERIALIZATION [Serializable] +#endif internal sealed class SubscribePending { public static readonly SubscribePending Instance = new SubscribePending(); private SubscribePending() { } } +#if SERIALIZATION [Serializable] +#endif internal sealed class RequestMore { public readonly IActorSubscription Subscription; @@ -37,7 +42,9 @@ public RequestMore(IActorSubscription subscription, long demand) } } +#if SERIALIZATION [Serializable] +#endif internal sealed class Cancel { public readonly IActorSubscription Subscription; @@ -48,7 +55,9 @@ public Cancel(IActorSubscription subscription) } } +#if SERIALIZATION [Serializable] +#endif internal sealed class ExposedPublisher { public readonly IActorPublisher Publisher; @@ -59,11 +68,15 @@ public ExposedPublisher(IActorPublisher publisher) } } +#if SERIALIZATION [Serializable] +#endif public class NormalShutdownException : IllegalStateException { public NormalShutdownException(string message) : base(message) { } +#if SERIALIZATION protected NormalShutdownException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } internal interface IActorPublisher : IUntypedPublisher @@ -181,7 +194,7 @@ public static class ActorSubscription { internal static IActorSubscription Create(IActorRef implementor, IUntypedSubscriber subscriber) { - var subscribedType = subscriber.GetType().GetGenericArguments().First(); // assumes type is UntypedSubscriberWrapper + var subscribedType = subscriber.GetType().GetTypeInfo().GetGenericArguments().First(); // assumes type is UntypedSubscriberWrapper var subscriptionType = typeof(ActorSubscription<>).MakeGenericType(subscribedType); return (IActorSubscription) Activator.CreateInstance(subscriptionType, implementor, UntypedSubscriber.ToTyped(subscriber)); } diff --git a/src/core/Akka.Streams/Implementation/FanIn.cs b/src/core/Akka.Streams/Implementation/FanIn.cs index 9eef798ce1c..5afa0f8e7e1 100644 --- a/src/core/Akka.Streams/Implementation/FanIn.cs +++ b/src/core/Akka.Streams/Implementation/FanIn.cs @@ -286,7 +286,9 @@ private void RegisterCompleted(int index) internal static class FanIn { +#if SERIALIZATION [Serializable] +#endif public struct OnError : INoSerializationVerificationNeeded { public readonly int Id; @@ -299,7 +301,9 @@ public OnError(int id, Exception cause) } } +#if SERIALIZATION [Serializable] +#endif public struct OnComplete : INoSerializationVerificationNeeded { public readonly int Id; @@ -310,7 +314,9 @@ public OnComplete(int id) } } +#if SERIALIZATION [Serializable] +#endif public struct OnNext : INoSerializationVerificationNeeded { public readonly int Id; @@ -323,7 +329,9 @@ public OnNext(int id, object element) } } +#if SERIALIZATION [Serializable] +#endif public struct OnSubscribe : INoSerializationVerificationNeeded { public readonly int Id; diff --git a/src/core/Akka.Streams/Implementation/FanOut.cs b/src/core/Akka.Streams/Implementation/FanOut.cs index 94949e479c6..79ef7165103 100644 --- a/src/core/Akka.Streams/Implementation/FanOut.cs +++ b/src/core/Akka.Streams/Implementation/FanOut.cs @@ -289,7 +289,9 @@ public TransferState DemandOrCancelAvailableFor(int id) /// internal static class FanOut { +#if SERIALIZATION [Serializable] +#endif public struct SubstreamRequestMore : INoSerializationVerificationNeeded { public readonly int Id; @@ -302,7 +304,9 @@ public SubstreamRequestMore(int id, long demand) } } +#if SERIALIZATION [Serializable] +#endif public struct SubstreamCancel : INoSerializationVerificationNeeded { public readonly int Id; @@ -313,7 +317,9 @@ public SubstreamCancel(int id) } } +#if SERIALIZATION [Serializable] +#endif public struct SubstreamSubscribePending : INoSerializationVerificationNeeded { public readonly int Id; @@ -342,7 +348,9 @@ public SubstreamSubscription(IActorRef parent, int id) public override string ToString() => "SubstreamSubscription" + GetHashCode(); } +#if SERIALIZATION [Serializable] +#endif public struct ExposedPublishers : INoSerializationVerificationNeeded { public readonly ImmutableList> Publishers; diff --git a/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs b/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs index ec1f8dfa671..df7d521be68 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs @@ -17,6 +17,7 @@ using Combine = Akka.Streams.Implementation.StreamLayout.Combine; using IMaterializedValueNode = Akka.Streams.Implementation.StreamLayout.IMaterializedValueNode; using Transform = Akka.Streams.Implementation.StreamLayout.Transform; +using System.Reflection; namespace Akka.Streams.Implementation.Fusing { @@ -440,7 +441,7 @@ private static GraphModule FuseGroup(BuildStructuralInfo info, ISet gro ? subMat[((Atomic) ms.Computation).Module] : matNodeMapping[ms.Computation]; - var outputType = ms.Outlet.GetType().GetGenericArguments().First(); + var outputType = ms.Outlet.GetType().GetTypeInfo().GetGenericArguments().First(); var materializedValueSourceType = typeof(MaterializedValueSource<>).MakeGenericType(outputType); var newSrc = (IMaterializedValueSource) Activator.CreateInstance(materializedValueSourceType, mapped, ms.Outlet); var replacement = new CopiedModule(c.Shape, c.Attributes, newSrc.Module); @@ -793,7 +794,7 @@ private bool IsCopiedModuleWithGraphStageAndMaterializedValue(IModule module) Type stageType; return copiedModule != null && (graphStageModule = copiedModule.CopyOf as GraphStageModule) != null - && (stageType = graphStageModule.Stage.GetType()).IsGenericType + && (stageType = graphStageModule.Stage.GetType()).GetTypeInfo().IsGenericType && stageType.GetGenericTypeDefinition() == typeof(MaterializedValueSource<>); } diff --git a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs index 8e14d2aff96..a2d373e3f65 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs @@ -165,7 +165,7 @@ public static GraphInterpreter Current get { if (CurrentInterpreter.Value[0] == null) - throw new ApplicationException("Something went terribly wrong!"); + throw new InvalidOperationException("Something went terribly wrong!"); return (GraphInterpreter) CurrentInterpreter.Value[0]; } } diff --git a/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs b/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs index 1d910a2914e..d4d9e1e7fec 100644 --- a/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs +++ b/src/core/Akka.Streams/Implementation/IO/FilePublisher.cs @@ -156,7 +156,7 @@ protected override void PostStop() try { - _chan?.Close(); + _chan?.Dispose(); } catch (Exception ex) { diff --git a/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs b/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs index e7c7d2e502c..44f2f8559ea 100644 --- a/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs +++ b/src/core/Akka.Streams/Implementation/IO/FileSubscriber.cs @@ -107,7 +107,7 @@ protected override void PostStop() try { if(_chan != null) - _chan.Close(); + _chan.Dispose(); } catch (Exception ex) { diff --git a/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs b/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs index 4fdacfb1a48..250e3a36f06 100644 --- a/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs +++ b/src/core/Akka.Streams/Implementation/IO/InputStreamPublisher.cs @@ -63,7 +63,7 @@ protected override void PostStop() base.PostStop(); try { - _inputstream?.Close(); + _inputstream?.Dispose(); } catch (Exception ex) { diff --git a/src/core/Akka.Streams/Implementation/IO/OutputStreamSubscriber.cs b/src/core/Akka.Streams/Implementation/IO/OutputStreamSubscriber.cs index c33db79b406..a6e2dd08a5b 100644 --- a/src/core/Akka.Streams/Implementation/IO/OutputStreamSubscriber.cs +++ b/src/core/Akka.Streams/Implementation/IO/OutputStreamSubscriber.cs @@ -88,7 +88,7 @@ protected override void PostStop() { try { - _outputStream?.Close(); + _outputStream?.Dispose(); } catch (Exception ex) { diff --git a/src/core/Akka.Streams/Implementation/ReactiveStreamsCompliance.cs b/src/core/Akka.Streams/Implementation/ReactiveStreamsCompliance.cs index 599e97437cc..39b5cae6b83 100644 --- a/src/core/Akka.Streams/Implementation/ReactiveStreamsCompliance.cs +++ b/src/core/Akka.Streams/Implementation/ReactiveStreamsCompliance.cs @@ -14,11 +14,15 @@ namespace Akka.Streams.Implementation { public interface ISpecViolation { } +#if SERIALIZATION [Serializable] +#endif public class SignalThrewException : IllegalStateException, ISpecViolation { public SignalThrewException(string message, Exception cause) : base(message, cause) { } +#if SERIALIZATION protected SignalThrewException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } public static class ReactiveStreamsCompliance diff --git a/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs b/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs index a7d7123890a..8efaa4af73f 100644 --- a/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs +++ b/src/core/Akka.Streams/Implementation/ResizableMultiReaderRingBuffer.cs @@ -13,7 +13,9 @@ namespace Akka.Streams.Implementation { +#if SERIALIZATION [Serializable] +#endif public class NothingToReadException : Exception { public static readonly NothingToReadException Instance = new NothingToReadException(); @@ -22,10 +24,12 @@ private NothingToReadException() { } +#if SERIALIZATION protected NothingToReadException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } public interface ICursors diff --git a/src/core/Akka.Streams/Implementation/StreamLayout.cs b/src/core/Akka.Streams/Implementation/StreamLayout.cs index e8b3b735250..e1fb31109ae 100644 --- a/src/core/Akka.Streams/Implementation/StreamLayout.cs +++ b/src/core/Akka.Streams/Implementation/StreamLayout.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using System.Reflection; using System.Runtime.Serialization; using Akka.Pattern; using Akka.Streams.Dsl; @@ -962,9 +963,11 @@ public MaterializationPanicException(Exception innerException) : base("Materiali { } +#if SERIALIZATION protected MaterializationPanicException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } protected readonly IModule TopLevel; @@ -1103,7 +1106,7 @@ protected object MaterializeModule(IModule module, Attributes effectiveAttribute GraphStageModule graphStageModule; Type stageType; if (((graphStageModule = submodule as GraphStageModule) != null) && - (stageType = graphStageModule.Stage.GetType()).IsGenericType && + (stageType = graphStageModule.Stage.GetType()).GetTypeInfo().IsGenericType && stageType.GetGenericTypeDefinition() == typeof(MaterializedValueSource<>)) { var copy = new MaterializedValueSource(graphStageModule.MaterializedValueComputation).CopySource(); diff --git a/src/core/Akka.Streams/Implementation/StreamOfStreamProcessors.cs b/src/core/Akka.Streams/Implementation/StreamOfStreamProcessors.cs index 8cdd10045d8..b8ddf30fc32 100644 --- a/src/core/Akka.Streams/Implementation/StreamOfStreamProcessors.cs +++ b/src/core/Akka.Streams/Implementation/StreamOfStreamProcessors.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Akka.Actor; using Akka.Event; using Akka.Pattern; @@ -20,7 +21,9 @@ internal abstract class MultiStreamOutputProcessor : ActorProcessorImpl, IStr { #region internal classes +#if SERIALIZATION [Serializable] +#endif internal struct SubstreamKey : IEquatable { public readonly long Id; @@ -41,7 +44,9 @@ public SubstreamKey(long id) public static bool operator !=(SubstreamKey x, SubstreamKey y) => !(x == y); } +#if SERIALIZATION [Serializable] +#endif internal struct SubstreamRequestMore : INoSerializationVerificationNeeded { public readonly SubstreamKey Substream; @@ -54,7 +59,9 @@ public SubstreamRequestMore(SubstreamKey substream, long demand) } } +#if SERIALIZATION [Serializable] +#endif internal struct SubstreamCancel : INoSerializationVerificationNeeded { public readonly SubstreamKey Substream; @@ -65,7 +72,9 @@ public SubstreamCancel(SubstreamKey substream) } } +#if SERIALIZATION [Serializable] +#endif internal struct SubstreamSubscribe : INoSerializationVerificationNeeded { public readonly SubstreamKey Substream; @@ -78,7 +87,9 @@ public SubstreamSubscribe(SubstreamKey substream, ISubscriber subscriber) } } +#if SERIALIZATION [Serializable] +#endif internal struct SubstreamSubscriptionTimeout : INoSerializationVerificationNeeded { public readonly SubstreamKey Substream; @@ -127,14 +138,18 @@ internal class SubstreamOutput : SimpleOutputs, IPublisher public interface IPublisherState { } public interface ICompletedState : IPublisherState { } +#if SERIALIZATION [Serializable] +#endif public sealed class Open : IPublisherState { public static readonly Open Instance = new Open(); private Open() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class Attached : IPublisherState { public readonly ISubscriber Subscriber; @@ -145,21 +160,27 @@ public Attached(ISubscriber subscriber) } } +#if SERIALIZATION [Serializable] +#endif public sealed class Completed : ICompletedState { public static readonly Completed Instance = new Completed(); private Completed() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class Cancelled : ICompletedState { public static readonly Cancelled Instance = new Cancelled(); private Cancelled() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class Failed : ICompletedState { public readonly Exception Reason; @@ -433,8 +454,8 @@ private void Cancel(IUntypedPublisher target, TimeSpan timeout) var typedTarget = UntypedPublisher.ToTyped(target); if ( typedTarget.GetType() - .GetInterfaces() - .Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IProcessor<,>))) + .GetTypeInfo().GetInterfaces() + .Any(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IProcessor<,>))) { if (Log.IsDebugEnabled) Log.Debug( diff --git a/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs b/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs index e9f0471110e..496a29cc407 100644 --- a/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs +++ b/src/core/Akka.Streams/Implementation/StreamSubscriptionTimeout.cs @@ -23,9 +23,11 @@ public SubscriptionTimeoutException(string message, Exception innerException) : { } +#if SERIALIZATION protected SubscriptionTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// diff --git a/src/core/Akka.Streams/OverflowStrategy.cs b/src/core/Akka.Streams/OverflowStrategy.cs index 5bb06db9beb..2adafdfd0a5 100644 --- a/src/core/Akka.Streams/OverflowStrategy.cs +++ b/src/core/Akka.Streams/OverflowStrategy.cs @@ -84,7 +84,9 @@ public enum DelayOverflowStrategy Fail } +#if SERIALIZATION [Serializable] +#endif public class BufferOverflowException : Exception { public BufferOverflowException(string message) : base(message) @@ -95,8 +97,10 @@ public BufferOverflowException(string message, Exception inner) : base(message, { } +#if SERIALIZATION protected BufferOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } \ No newline at end of file diff --git a/src/core/Akka.Streams/Stage/GraphStage.cs b/src/core/Akka.Streams/Stage/GraphStage.cs index 8f0158ab091..0bd1cafaeb8 100644 --- a/src/core/Akka.Streams/Stage/GraphStage.cs +++ b/src/core/Akka.Streams/Stage/GraphStage.cs @@ -230,7 +230,9 @@ protected internal override void AfterPostStop() internal static class TimerMessages { +#if SERIALIZATION [Serializable] +#endif public sealed class Scheduled { public readonly object TimerKey; @@ -1531,12 +1533,16 @@ public abstract class InAndOutHandler : IInHandler, IOutHandler } +#if SERIALIZATION [Serializable] +#endif public class StageActorRefNotInitializedException : Exception { public static readonly StageActorRefNotInitializedException Instance = new StageActorRefNotInitializedException(); private StageActorRefNotInitializedException() : base("You must first call getStageActorRef, to initialize the Actors behaviour") { } +#if SERIALIZATION protected StageActorRefNotInitializedException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// diff --git a/src/core/Akka.Streams/Stage/Stage.cs b/src/core/Akka.Streams/Stage/Stage.cs index 07fdd76de7f..ea10c361cff 100644 --- a/src/core/Akka.Streams/Stage/Stage.cs +++ b/src/core/Akka.Streams/Stage/Stage.cs @@ -144,14 +144,18 @@ public static class StatefulStage internal interface IAndThen { } +#if SERIALIZATION [Serializable] +#endif internal sealed class Finish : IAndThen { public static readonly Finish Instance = new Finish(); private Finish() { } } +#if SERIALIZATION [Serializable] +#endif internal sealed class Become : IAndThen { public readonly StageState State; @@ -162,7 +166,9 @@ public Become(StageState state) } } +#if SERIALIZATION [Serializable] +#endif internal sealed class Stay : IAndThen { public static readonly Stay Instance = new Stay(); diff --git a/src/core/Akka.Streams/StreamLimitReachedException.cs b/src/core/Akka.Streams/StreamLimitReachedException.cs index 42141e60b0d..6378d65d8ab 100644 --- a/src/core/Akka.Streams/StreamLimitReachedException.cs +++ b/src/core/Akka.Streams/StreamLimitReachedException.cs @@ -16,8 +16,10 @@ public StreamLimitReachedException(long max) : base($"Limit of {max} reached") { } +#if SERIALIZATION protected StreamLimitReachedException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } \ No newline at end of file diff --git a/src/core/Akka.Streams/StreamTcpException.cs b/src/core/Akka.Streams/StreamTcpException.cs index 3e5550fb8ac..7f94c8ff1ea 100644 --- a/src/core/Akka.Streams/StreamTcpException.cs +++ b/src/core/Akka.Streams/StreamTcpException.cs @@ -20,9 +20,11 @@ public StreamTcpException(string message, Exception innerException) : base(messa { } +#if SERIALIZATION protected StreamTcpException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } public class BindFailedException : StreamTcpException @@ -33,9 +35,11 @@ private BindFailedException() : base("bind failed") { } +#if SERIALIZATION protected BindFailedException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } public class ConnectionException : StreamTcpException @@ -48,8 +52,10 @@ public ConnectionException(string message, Exception innerException) : base(mess { } +#if SERIALIZATION protected ConnectionException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } \ No newline at end of file diff --git a/src/core/Akka.Streams/Util/TypeExtensions.cs b/src/core/Akka.Streams/Util/TypeExtensions.cs index 810d0024d0f..887b93e6bb3 100644 --- a/src/core/Akka.Streams/Util/TypeExtensions.cs +++ b/src/core/Akka.Streams/Util/TypeExtensions.cs @@ -7,6 +7,7 @@ using System; using System.Linq; +using System.Reflection; using Reactive.Streams; namespace Akka.Streams.Util @@ -17,9 +18,9 @@ public static Type GetSubscribedType(this Type type) { return type - .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (ISubscriber<>)) - .GetGenericArguments() + .GetTypeInfo().GetInterfaces() + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof (ISubscriber<>)) + .GetTypeInfo().GetGenericArguments() .First(); } @@ -27,9 +28,9 @@ public static Type GetPublishedType(this Type type) { return type - .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (IPublisher<>)) - .GetGenericArguments() + .GetTypeInfo().GetInterfaces() + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof (IPublisher<>)) + .GetTypeInfo().GetGenericArguments() .First(); } } diff --git a/src/core/Akka.TestKit/ActorCellKeepingSynchronizationContext.cs b/src/core/Akka.TestKit/ActorCellKeepingSynchronizationContext.cs index 7b0b864939c..1a3bbc73673 100644 --- a/src/core/Akka.TestKit/ActorCellKeepingSynchronizationContext.cs +++ b/src/core/Akka.TestKit/ActorCellKeepingSynchronizationContext.cs @@ -28,7 +28,11 @@ public ActorCellKeepingSynchronizationContext(ActorCell cell) public override void Post(SendOrPostCallback d, object state) { +#if UNSAFE_THREADING ThreadPool.UnsafeQueueUserWorkItem(_ => +#else + ThreadPool.QueueUserWorkItem(_ => +#endif { var oldCell = InternalCurrentActorCellKeeper.Current; var oldContext = Current; diff --git a/src/core/Akka.TestKit/Akka.TestKit.csproj b/src/core/Akka.TestKit/Akka.TestKit.csproj index 21e25311a7b..23154119ebe 100644 --- a/src/core/Akka.TestKit/Akka.TestKit.csproj +++ b/src/core/Akka.TestKit/Akka.TestKit.csproj @@ -18,7 +18,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;UNSAFE_THREADING prompt 4 @@ -26,14 +26,14 @@ pdbonly true bin\Release\ - TRACE + TRACE;UNSAFE_THREADING prompt 4 bin\Release\Akka.TestKit.xml bin\Release Mono\ - TRACE + TRACE;UNSAFE_THREADING true pdbonly AnyCPU @@ -44,7 +44,7 @@ true bin\Debug Mono\ - DEBUG;TRACE + DEBUG;TRACE;UNSAFE_THREADING full AnyCPU prompt diff --git a/src/core/Akka.TestKit/EventFilter/EventFilterFactory.cs b/src/core/Akka.TestKit/EventFilter/EventFilterFactory.cs index faf94a31e21..5d2546e0533 100644 --- a/src/core/Akka.TestKit/EventFilter/EventFilterFactory.cs +++ b/src/core/Akka.TestKit/EventFilter/EventFilterFactory.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Text.RegularExpressions; using Akka.Actor; using Akka.Event; @@ -250,7 +251,7 @@ public IEventFilterApplier DeadLetter(Func isMatch, st /// public IEventFilterApplier DeadLetter(Type type, string source = null) { - return DeadLetter(deadLetter => type.IsInstanceOfType(deadLetter.Message), source); + return DeadLetter(deadLetter => type.GetTypeInfo().IsInstanceOfType(deadLetter.Message), source); } /// @@ -259,7 +260,7 @@ public IEventFilterApplier DeadLetter(Type type, string source = null) /// public IEventFilterApplier DeadLetter(Type type, Func isMatch, string source = null) { - return DeadLetter(deadLetter => type.IsInstanceOfType(deadLetter.Message) && isMatch(deadLetter.Message), source); + return DeadLetter(deadLetter => type.GetTypeInfo().IsInstanceOfType(deadLetter.Message) && isMatch(deadLetter.Message), source); } private IEventFilterApplier DeadLetter(Predicate isMatch, string source = null) diff --git a/src/core/Akka.Tests/Actor/LocalActorRefProviderSpec.cs b/src/core/Akka.Tests/Actor/LocalActorRefProviderSpec.cs index d1bf5c38599..d4efd39aeb0 100644 --- a/src/core/Akka.Tests/Actor/LocalActorRefProviderSpec.cs +++ b/src/core/Akka.Tests/Actor/LocalActorRefProviderSpec.cs @@ -88,7 +88,7 @@ public void An_ActorRefFactory_must_throw_suitable_exceptions_for_malformed_acto { Sys.ActorOf(Props.Empty, name); }); - Assert.Contains(expectedExceptionMessageSubstring, exception.Message, StringComparison.InvariantCultureIgnoreCase); + Assert.Contains(expectedExceptionMessageSubstring, exception.Message, StringComparison.OrdinalIgnoreCase); } private class ActorWithDuplicateChild : ActorBase diff --git a/src/core/Akka.Tests/Akka.Tests.csproj b/src/core/Akka.Tests/Akka.Tests.csproj index b7d0d0952ec..a52b4e95942 100644 --- a/src/core/Akka.Tests/Akka.Tests.csproj +++ b/src/core/Akka.Tests/Akka.Tests.csproj @@ -22,7 +22,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION;CONFIGURATION prompt 4 @@ -30,13 +30,13 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION;CONFIGURATION prompt 4 bin\Release Mono\ - TRACE + TRACE;SERIALIZATION;CONFIGURATION true pdbonly AnyCPU @@ -47,7 +47,7 @@ true bin\Debug Mono\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION;CONFIGURATION full AnyCPU prompt @@ -56,10 +56,6 @@ false - - ..\..\packages\fastJSON.2.0.27.1\lib\net40\fastjson.dll - True - ..\..\packages\FluentAssertions.3.3.0\lib\net45\FluentAssertions.dll True @@ -76,6 +72,10 @@ ..\..\packages\FSharp.Core.3.1.2.5\lib\net40\FSharp.Core.dll True + + ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + True + @@ -230,7 +230,9 @@ - + + Designer + diff --git a/src/core/Akka.Tests/Configuration/ConfigurationSpec.cs b/src/core/Akka.Tests/Configuration/ConfigurationSpec.cs index 688ea064178..bed35c8bdf3 100644 --- a/src/core/Akka.Tests/Configuration/ConfigurationSpec.cs +++ b/src/core/Akka.Tests/Configuration/ConfigurationSpec.cs @@ -7,7 +7,6 @@ using System; using Akka.Configuration.Hocon; -using System.Configuration; using System.Linq; using System.Threading; using Akka.Actor; @@ -65,15 +64,17 @@ public void The_default_configuration_file_contain_all_configuration_properties( settings.SchedulerClass.ShouldBe(typeof(DedicatedThreadScheduler).FullName); } +#if CONFIGURATION [Fact] public void Deserializes_hocon_configuration_from_net_config_file() { - var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka"); + var section = (AkkaConfigurationSection)System.Configuration.ConfigurationManager.GetSection("akka"); Assert.NotNull(section); Assert.False(string.IsNullOrEmpty(section.Hocon.Content)); var akkaConfig = section.AkkaConfig; Assert.NotNull(akkaConfig); } +#endif [Fact] public void Can_create_config_from_source_object() diff --git a/src/core/Akka.Tests/Event/EventBusSpec.cs b/src/core/Akka.Tests/Event/EventBusSpec.cs index ae58c7819c8..b2167488526 100644 --- a/src/core/Akka.Tests/Event/EventBusSpec.cs +++ b/src/core/Akka.Tests/Event/EventBusSpec.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Akka.Actor; using Akka.Event; using Akka.TestKit; @@ -23,7 +24,7 @@ internal class TestActorEventBus : ActorEventBus { protected override bool IsSubClassification(Type parent, Type child) { - return child.IsAssignableFrom(parent); + return child.GetTypeInfo().IsAssignableFrom(parent); } protected override void Publish(object evt, IActorRef subscriber) @@ -33,7 +34,7 @@ protected override void Publish(object evt, IActorRef subscriber) protected override bool Classify(object evt, Type classifier) { - return evt.GetType().IsAssignableFrom(classifier); + return evt.GetType().GetTypeInfo().IsAssignableFrom(classifier); } protected override Type GetClassifier(object @event) diff --git a/src/core/Akka.Tests/IO/SimpleDnsCacheSpec.cs b/src/core/Akka.Tests/IO/SimpleDnsCacheSpec.cs index 5a974d4d8dd..cf3c0dfdbb8 100644 --- a/src/core/Akka.Tests/IO/SimpleDnsCacheSpec.cs +++ b/src/core/Akka.Tests/IO/SimpleDnsCacheSpec.cs @@ -35,7 +35,7 @@ public void Cache_should_not_reply_with_expired_but_not_yet_swept_out_entries() { var localClock = new AtomicReference(0); var cache = new SimpleDnsCacheTestDouble(localClock); - var cacheEntry = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntry("127.0.0.1").AddressList); + var cacheEntry = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntryAsync("127.0.0.1").Result.AddressList); cache.Put(cacheEntry, 5000); cache.Cached("test.local").ShouldBe(cacheEntry); @@ -51,7 +51,7 @@ public void Cache_should_sweep_out_expired_entries_on_cleanup() { var localClock = new AtomicReference(0); var cache = new SimpleDnsCacheTestDouble(localClock); - var cacheEntry = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntry("127.0.0.1").AddressList); + var cacheEntry = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntryAsync("127.0.0.1").Result.AddressList); cache.Put(cacheEntry, 5000); cache.Cached("test.local").ShouldBe(cacheEntry); @@ -72,8 +72,8 @@ public void Cache_should_be_updated_with_the_latest_resolved() { var localClock = new AtomicReference(0); var cache = new SimpleDnsCacheTestDouble(localClock); - var cacheEntryOne = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntry("127.0.0.1").AddressList); - var cacheEntryTwo = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntry("127.0.0.1").AddressList); + var cacheEntryOne = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntryAsync("127.0.0.1").Result.AddressList); + var cacheEntryTwo = Dns.Resolved.Create("test.local", System.Net.Dns.GetHostEntryAsync("127.0.0.1").Result.AddressList); long ttl = 500; cache.Put(cacheEntryOne, ttl); cache.Cached("test.local").ShouldBe(cacheEntryOne); diff --git a/src/core/Akka.Tests/MatchHandler/PartialActionBuilderTests.cs b/src/core/Akka.Tests/MatchHandler/PartialActionBuilderTests.cs index 4ba8e707ef1..b6b9437afa2 100644 --- a/src/core/Akka.Tests/MatchHandler/PartialActionBuilderTests.cs +++ b/src/core/Akka.Tests/MatchHandler/PartialActionBuilderTests.cs @@ -9,6 +9,7 @@ using Akka.TestKit; using Akka.Tools.MatchHandler; using Xunit; +using System.Reflection; namespace Akka.Tests.MatchHandler { @@ -447,7 +448,7 @@ private static void AssertAreSame(object[] delegateArguments, object[] updatedAr { for(int i = 0; i < delegateArguments.Length; i++) { - if(delegateArguments[i].GetType().IsValueType) + if(delegateArguments[i].GetType().GetTypeInfo().IsValueType) Assert.Equal(delegateArguments[i], updatedArgs[i]); else Assert.Same(delegateArguments[i], updatedArgs[i]); diff --git a/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs b/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs index 735ce98f58b..8ccb6aa089c 100644 --- a/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs +++ b/src/core/Akka.Tests/Pattern/CircuitBreakerSpec.cs @@ -326,7 +326,7 @@ public TestBreaker MultiFailureCb( ) } - internal class TestException : ApplicationException + internal class TestException : Exception { public TestException( ) { @@ -342,10 +342,12 @@ public TestException( string message, Exception innerException ) { } +#if SERIALIZATION protected TestException( SerializationInfo info, StreamingContext context ) : base( info, context ) { } +#endif } } \ No newline at end of file diff --git a/src/core/Akka.Tests/TestUtils/Comparable.cs b/src/core/Akka.Tests/TestUtils/Comparable.cs index d7736e20ae7..0d61f9db118 100644 --- a/src/core/Akka.Tests/TestUtils/Comparable.cs +++ b/src/core/Akka.Tests/TestUtils/Comparable.cs @@ -23,7 +23,7 @@ public override int GetHashCode() public override string ToString() { - var res = fastJSON.JSON.Instance.ToJSON(this); + var res = Newtonsoft.Json.JsonConvert.SerializeObject(this); return res; } } diff --git a/src/core/Akka.Tests/packages.config b/src/core/Akka.Tests/packages.config index 09bb0a85065..1d6d5e47947 100644 --- a/src/core/Akka.Tests/packages.config +++ b/src/core/Akka.Tests/packages.config @@ -1,9 +1,9 @@  - + diff --git a/src/core/Akka/Actor/ActorCell.cs b/src/core/Akka/Actor/ActorCell.cs index 52f70824b53..65ed4ae2173 100644 --- a/src/core/Akka/Actor/ActorCell.cs +++ b/src/core/Akka/Actor/ActorCell.cs @@ -15,6 +15,7 @@ using Akka.Serialization; using Akka.Util; using Assert = System.Diagnostics.Debug; +using System.Reflection; namespace Akka.Actor { @@ -129,7 +130,7 @@ public void Init(bool sendSupervise, MailboxType mailboxType) if (System.Mailboxes.ProducesMessageQueue(mailboxType.GetType()) && System.Mailboxes.HasRequiredType(actorClass)) { var req = System.Mailboxes.GetRequiredType(actorClass); - if (req.IsInstanceOfType(mailbox.MessageQueue)) createMessage = new Create(null); //success + if (req.GetTypeInfo().IsInstanceOfType(mailbox.MessageQueue)) createMessage = new Create(null); //success else { var gotType = mailbox.MessageQueue == null ? "null" : mailbox.MessageQueue.GetType().FullName; diff --git a/src/core/Akka/Actor/ActorProducerPipeline.cs b/src/core/Akka/Actor/ActorProducerPipeline.cs index 9d1836e7f93..13cad2c0f67 100644 --- a/src/core/Akka/Actor/ActorProducerPipeline.cs +++ b/src/core/Akka/Actor/ActorProducerPipeline.cs @@ -10,6 +10,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Akka.Event; namespace Akka.Actor @@ -69,7 +70,7 @@ public abstract class ActorProducerPluginBase : IActorProducerPlugin whe /// public virtual bool CanBeAppliedTo(Type actorType) { - return typeof(TActor).IsAssignableFrom(actorType); + return typeof(TActor).GetTypeInfo().IsAssignableFrom(actorType); } void IActorProducerPlugin.AfterIncarnated(ActorBase actor, IActorContext context) diff --git a/src/core/Akka/Actor/ActorSelection.cs b/src/core/Akka/Actor/ActorSelection.cs index 35cbcf5e304..6a1e48e1c90 100644 --- a/src/core/Akka/Actor/ActorSelection.cs +++ b/src/core/Akka/Actor/ActorSelection.cs @@ -328,7 +328,7 @@ public SelectChildPattern(string patternStr) /// A that represents this instance. public override string ToString() { - return PatternStr.ToString(CultureInfo.InvariantCulture); + return PatternStr.ToString(); } } diff --git a/src/core/Akka/Actor/Exceptions.cs b/src/core/Akka/Actor/Exceptions.cs index eef609c6e48..2c4e59012a1 100644 --- a/src/core/Akka/Actor/Exceptions.cs +++ b/src/core/Akka/Actor/Exceptions.cs @@ -32,6 +32,7 @@ protected AkkaException(string message, Exception cause = null) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -41,6 +42,7 @@ protected AkkaException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif /// /// The exception that is the cause of the current exception. @@ -72,6 +74,7 @@ public InvalidActorNameException(string message, Exception innerException) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -81,6 +84,7 @@ protected InvalidActorNameException(SerializationInfo info, StreamingContext con : base(info, context) { } +#endif } /// @@ -97,6 +101,7 @@ public AskTimeoutException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -106,6 +111,7 @@ protected AskTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// @@ -164,6 +170,7 @@ public ActorInitializationException(IActorRef actor, string message, Exception c _actor = actor; } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -173,6 +180,7 @@ protected ActorInitializationException(SerializationInfo info, StreamingContext : base(info, context) { } +#endif /// /// Retrieves the actor whose initialization logic failed. @@ -224,6 +232,7 @@ public LoggerInitializationException(string message, Exception cause = null) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -233,6 +242,7 @@ protected LoggerInitializationException(SerializationInfo info, StreamingContext : base(info, context) { } +#endif } /// @@ -250,6 +260,7 @@ public ActorKilledException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -259,6 +270,7 @@ protected ActorKilledException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// @@ -276,6 +288,7 @@ public IllegalActorStateException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -285,6 +298,7 @@ protected IllegalActorStateException(SerializationInfo info, StreamingContext co : base(info, context) { } +#endif } /// @@ -301,6 +315,7 @@ public IllegalActorNameException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -310,6 +325,7 @@ protected IllegalActorNameException(SerializationInfo info, StreamingContext con : base(info, context) { } +#endif } /// @@ -330,6 +346,7 @@ public DeathPactException(IActorRef deadActor) _deadActor = deadActor; } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -339,6 +356,7 @@ protected DeathPactException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif /// /// Retrieves the actor that has been terminated. @@ -379,6 +397,7 @@ public PreRestartException(IActorRef actor, Exception restartException, Exceptio this.optionalMessage = optionalMessage; } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -388,6 +407,7 @@ protected PreRestartException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } /// @@ -410,6 +430,7 @@ public PostRestartException(IActorRef actor, Exception cause, Exception original _originalCause = originalCause; } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -419,6 +440,7 @@ protected PostRestartException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif /// /// Retrieves the exception which caused the restart in the first place. @@ -439,6 +461,7 @@ public ActorNotFoundException() { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -448,6 +471,7 @@ protected ActorNotFoundException(SerializationInfo info, StreamingContext contex : base(info, context) { } +#endif /// /// that takes a descriptive and optional . @@ -483,6 +507,7 @@ public InvalidMessageException(string message) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -492,6 +517,7 @@ protected InvalidMessageException(SerializationInfo info, StreamingContext conte : base(info, context) { } +#endif } } diff --git a/src/core/Akka/Actor/Inbox.cs b/src/core/Akka/Actor/Inbox.cs index a4e78de5f1d..dc0a3db59a9 100644 --- a/src/core/Akka/Actor/Inbox.cs +++ b/src/core/Akka/Actor/Inbox.cs @@ -84,7 +84,9 @@ internal struct Kick { } // LinkedList wrapper instead of Queue? While it's used for queueing, however I expect a lot of churn around // adding-removing elements. Additionally we have to get a functionality of dequeueing element meeting // a specific predicate (even if it's in middle of queue), and current queue implementation won't provide that in easy way. +#if SERIALIZATION [Serializable] +#endif internal class InboxQueue : ICollection { private readonly LinkedList _inner = new LinkedList(); diff --git a/src/core/Akka/Actor/Internal/ActorSystemImpl.cs b/src/core/Akka/Actor/Internal/ActorSystemImpl.cs index 8131029e620..c871d0e9337 100644 --- a/src/core/Akka/Actor/Internal/ActorSystemImpl.cs +++ b/src/core/Akka/Actor/Internal/ActorSystemImpl.cs @@ -17,7 +17,7 @@ using Akka.Event; using Akka.Serialization; using Akka.Util; - +using System.Reflection; namespace Akka.Actor.Internal { @@ -172,7 +172,7 @@ private void LoadExtensions() foreach(var extensionFqn in _settings.Config.GetStringList("akka.extensions")) { var extensionType = Type.GetType(extensionFqn); - if(extensionType == null || !typeof(IExtensionId).IsAssignableFrom(extensionType) || extensionType.IsAbstract || !extensionType.IsClass) + if(extensionType == null || !typeof(IExtensionId).GetTypeInfo().IsAssignableFrom(extensionType) || extensionType.GetTypeInfo().IsAbstract || !extensionType.GetTypeInfo().IsClass) { _log.Error("[{0}] is not an 'ExtensionId', skipping...", extensionFqn); continue; @@ -242,7 +242,7 @@ public override T GetExtension() public override bool HasExtension(Type t) { - if(typeof(IExtension).IsAssignableFrom(t)) + if(typeof(IExtension).GetTypeInfo().IsAssignableFrom(t)) { return _extensions.ContainsKey(t); } diff --git a/src/core/Akka/Actor/Props.cs b/src/core/Akka/Actor/Props.cs index 7359b5ad07f..0ffe9b61237 100644 --- a/src/core/Akka/Actor/Props.cs +++ b/src/core/Akka/Actor/Props.cs @@ -15,6 +15,7 @@ using Akka.Routing; using Akka.Util; using Newtonsoft.Json; +using System.Reflection; namespace Akka.Actor { @@ -674,10 +675,10 @@ private static IIndirectActorProducer CreateProducer(Type type, object[] args) if (type == null) { return defaultProducer; } - if (typeof(IIndirectActorProducer).IsAssignableFrom(type)) { + if (typeof(IIndirectActorProducer).GetTypeInfo().IsAssignableFrom(type)) { return Activator.CreateInstance(type, args).AsInstanceOf(); } - if (typeof(ActorBase).IsAssignableFrom(type)) { + if (typeof(ActorBase).GetTypeInfo().IsAssignableFrom(type)) { return new ActivatorProducer(type, args); } throw new ArgumentException(string.Format("Unknown actor producer [{0}]", type.FullName)); diff --git a/src/core/Akka/Actor/Settings.cs b/src/core/Akka/Actor/Settings.cs index 7eb3e9e303f..7d9a61e7351 100644 --- a/src/core/Akka/Actor/Settings.cs +++ b/src/core/Akka/Actor/Settings.cs @@ -10,6 +10,7 @@ using Akka.Configuration; using Akka.Dispatch; using Akka.Routing; +using System.Reflection; namespace Akka.Actor { @@ -63,7 +64,7 @@ public Settings(ActorSystem system, Config config) var providerType = Type.GetType(ProviderClass); if (providerType == null) throw new ConfigurationException(string.Format("'akka.actor.provider' is not a valid type name : '{0}'", ProviderClass)); - if (!typeof(IActorRefProvider).IsAssignableFrom(providerType)) + if (!typeof(IActorRefProvider).GetTypeInfo().IsAssignableFrom(providerType)) throw new ConfigurationException(string.Format("'akka.actor.provider' is not a valid actor ref provider: '{0}'", ProviderClass)); SupervisorStrategyClass = Config.GetString("akka.actor.guardian-supervisor-strategy"); diff --git a/src/core/Akka/Actor/Stash/IActorStash.cs b/src/core/Akka/Actor/Stash/IActorStash.cs index 28cf3b88ef5..ee69d0e7a62 100644 --- a/src/core/Akka/Actor/Stash/IActorStash.cs +++ b/src/core/Akka/Actor/Stash/IActorStash.cs @@ -6,6 +6,7 @@ //----------------------------------------------------------------------- using System; +using System.Reflection; namespace Akka.Actor { @@ -32,7 +33,7 @@ public class ActorStashPlugin : ActorProducerPluginBase /// public override bool CanBeAppliedTo(Type actorType) { - return typeof (IActorStash).IsAssignableFrom(actorType); + return typeof (IActorStash).GetTypeInfo().IsAssignableFrom(actorType); } /// diff --git a/src/core/Akka/Actor/Stash/StashOverflowException.cs b/src/core/Akka/Actor/Stash/StashOverflowException.cs index c42ea05d650..7a92c9bb911 100644 --- a/src/core/Akka/Actor/Stash/StashOverflowException.cs +++ b/src/core/Akka/Actor/Stash/StashOverflowException.cs @@ -22,6 +22,7 @@ public class StashOverflowException : AkkaException /// The exception that is the cause of the current exception. public StashOverflowException(string message, Exception cause = null) : base(message, cause) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -31,5 +32,6 @@ protected StashOverflowException(SerializationInfo info, StreamingContext contex : base(info, context) { } +#endif } } diff --git a/src/core/Akka/Actor/SupervisorStrategy.cs b/src/core/Akka/Actor/SupervisorStrategy.cs index 727c7de141b..79af92c4257 100644 --- a/src/core/Akka/Actor/SupervisorStrategy.cs +++ b/src/core/Akka/Actor/SupervisorStrategy.cs @@ -14,6 +14,7 @@ using Akka.Event; using Akka.Util; using Akka.Util.Internal; +using System.Reflection; namespace Akka.Actor { @@ -749,7 +750,7 @@ public Directive Decide(Exception cause) foreach (var kvp in Pairs) { //emulate if (cause is SomeType) - if (kvp.Key.IsInstanceOfType(cause)) + if (kvp.Key.GetTypeInfo().IsInstanceOfType(cause)) { return kvp.Value; } diff --git a/src/core/Akka/Actor/TypedActor.cs b/src/core/Akka/Actor/TypedActor.cs index d5bf929241c..d3670cfe85e 100644 --- a/src/core/Akka/Actor/TypedActor.cs +++ b/src/core/Akka/Actor/TypedActor.cs @@ -33,7 +33,7 @@ public abstract class TypedActor : ActorBase /// The message. protected override sealed bool Receive(object message) { - MethodInfo method = GetType().GetMethod("Handle", new[] {message.GetType()}); + MethodInfo method = GetType().GetTypeInfo().GetMethod("Handle", new[] {message.GetType()}); if (method == null) { return false; diff --git a/src/core/Akka/Akka.csproj b/src/core/Akka/Akka.csproj index 83117d5bd58..081eb09d315 100644 --- a/src/core/Akka/Akka.csproj +++ b/src/core/Akka/Akka.csproj @@ -19,7 +19,7 @@ full false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;SERIALIZATION;CONFIGURATION;UNSAFE_THREADING prompt 4 @@ -27,14 +27,14 @@ pdbonly true bin\Release\ - TRACE + TRACE;SERIALIZATION;CONFIGURATION;UNSAFE_THREADING prompt 4 bin\Release\Akka.xml bin\Release Mono\ - TRACE;MONO + TRACE;MONO;SERIALIZATION;CONFIGURATION;UNSAFE_THREADING true pdbonly AnyCPU @@ -45,7 +45,7 @@ true bin\Debug Mono\ - TRACE;DEBUG;MONO + TRACE;DEBUG;MONO;SERIALIZATION;CONFIGURATION;UNSAFE_THREADING full AnyCPU prompt diff --git a/src/core/Akka/Configuration/ConfigurationException.cs b/src/core/Akka/Configuration/ConfigurationException.cs index cfa8167e0fa..553d4f0c187 100644 --- a/src/core/Akka/Configuration/ConfigurationException.cs +++ b/src/core/Akka/Configuration/ConfigurationException.cs @@ -33,6 +33,7 @@ public ConfigurationException(string message, Exception exception): base(message { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -42,6 +43,7 @@ protected ConfigurationException(SerializationInfo info, StreamingContext contex : base(info, context) { } +#endif } } diff --git a/src/core/Akka/Configuration/ConfigurationFactory.cs b/src/core/Akka/Configuration/ConfigurationFactory.cs index 4d4dc829658..0480ef8fd05 100644 --- a/src/core/Akka/Configuration/ConfigurationFactory.cs +++ b/src/core/Akka/Configuration/ConfigurationFactory.cs @@ -6,7 +6,6 @@ //----------------------------------------------------------------------- using System; -using System.Configuration; using System.Diagnostics; using System.IO; using System.Reflection; @@ -62,10 +61,12 @@ public static Config ParseString(string hocon) /// The configuration defined in the configuration file. public static Config Load() { - var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka") ?? new AkkaConfigurationSection(); - var config = section.AkkaConfig; - - return config; +#if CONFIGURATION + var section = (AkkaConfigurationSection)System.Configuration.ConfigurationManager.GetSection("akka") ?? new AkkaConfigurationSection(); + return section.AkkaConfig; +#else + return ConfigurationFactory.Empty; +#endif } /// @@ -86,7 +87,7 @@ public static Config Default() /// The configuration defined in the current executing assembly. internal static Config FromResource(string resourceName) { - Assembly assembly = Assembly.GetExecutingAssembly(); + Assembly assembly = typeof(ConfigurationFactory).GetTypeInfo().Assembly; return FromResource(resourceName, assembly); } @@ -102,11 +103,11 @@ public static Config FromResource(string resourceName, object instanceInAssembly { var type = instanceInAssembly as Type; if(type != null) - return FromResource(resourceName, type.Assembly); + return FromResource(resourceName, type.GetTypeInfo().Assembly); var assembly = instanceInAssembly as Assembly; if(assembly != null) return FromResource(resourceName, assembly); - return FromResource(resourceName, instanceInAssembly.GetType().Assembly); + return FromResource(resourceName, instanceInAssembly.GetType().GetTypeInfo().Assembly); } /// @@ -118,7 +119,7 @@ public static Config FromResource(string resourceName, object instanceInAssembly /// The configuration defined in the assembly that contains the type . public static Config FromResource(string resourceName) { - return FromResource(resourceName, typeof(TAssembly).Assembly); + return FromResource(resourceName, typeof(TAssembly).GetTypeInfo().Assembly); } /// diff --git a/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs b/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs index 92b921cc387..c510ef9ea96 100644 --- a/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs +++ b/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs @@ -4,7 +4,7 @@ // Copyright (C) 2013-2016 Akka.NET project // //----------------------------------------------------------------------- - +#if CONFIGURATION using System.Configuration; namespace Akka.Configuration.Hocon @@ -64,4 +64,4 @@ public HoconConfigurationElement Hocon } } } - +#endif diff --git a/src/core/Akka/Configuration/Hocon/CDataConfigurationElement.cs b/src/core/Akka/Configuration/Hocon/CDataConfigurationElement.cs index 62def24a750..36dbe56f6c5 100644 --- a/src/core/Akka/Configuration/Hocon/CDataConfigurationElement.cs +++ b/src/core/Akka/Configuration/Hocon/CDataConfigurationElement.cs @@ -4,7 +4,7 @@ // Copyright (C) 2013-2016 Akka.NET project // //----------------------------------------------------------------------- - +#if CONFIGURATION using System.Configuration; using System.Xml; @@ -60,3 +60,4 @@ protected override void DeserializeElement(XmlReader reader, bool serializeColle } } } +#endif \ No newline at end of file diff --git a/src/core/Akka/Configuration/Hocon/HoconConfigurationElement.cs b/src/core/Akka/Configuration/Hocon/HoconConfigurationElement.cs index 239b615a736..ef6d6cb8618 100644 --- a/src/core/Akka/Configuration/Hocon/HoconConfigurationElement.cs +++ b/src/core/Akka/Configuration/Hocon/HoconConfigurationElement.cs @@ -4,7 +4,7 @@ // Copyright (C) 2013-2016 Akka.NET project // //----------------------------------------------------------------------- - +#if CONFIGURATION using System.Configuration; namespace Akka.Configuration.Hocon @@ -41,4 +41,4 @@ public string Content } } } - +#endif diff --git a/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs b/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs index 6238ac222f6..741580e022e 100644 --- a/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs +++ b/src/core/Akka/Configuration/Hocon/HoconTokenizer.cs @@ -559,7 +559,7 @@ private string PullEscapeSequence() case 'u': string hex = "0x" + Take(4); int j = Convert.ToInt32(hex, 16); - return ((char) j).ToString(CultureInfo.InvariantCulture); + return ((char) j).ToString(); default: throw new NotSupportedException(string.Format("Unknown escape code: {0}", escaped)); } diff --git a/src/core/Akka/Dispatch/AbstractDispatcher.cs b/src/core/Akka/Dispatch/AbstractDispatcher.cs index f3f2a5275d9..33b77f7102c 100644 --- a/src/core/Akka/Dispatch/AbstractDispatcher.cs +++ b/src/core/Akka/Dispatch/AbstractDispatcher.cs @@ -191,12 +191,16 @@ private static DedicatedThreadPoolSettings ConfigureSettings(Config config) /// internal sealed class ThreadPoolExecutorServiceFactory : ExecutorServiceConfigurator { +#if UNSAFE_THREADING private static readonly bool IsFullTrusted = AppDomain.CurrentDomain.IsFullyTrusted; +#endif public override ExecutorService Produce(string id) { +#if UNSAFE_THREADING if (IsFullTrusted) return new FullThreadPoolExecutorServiceImpl(id); +#endif return new PartialTrustThreadPoolExecutorService(id); } diff --git a/src/core/Akka/Dispatch/Dispatchers.cs b/src/core/Akka/Dispatch/Dispatchers.cs index 1e083802c9b..76b3dee1dd2 100644 --- a/src/core/Akka/Dispatch/Dispatchers.cs +++ b/src/core/Akka/Dispatch/Dispatchers.cs @@ -33,6 +33,7 @@ protected ThreadPoolExecutorService(string id) : base(id) } } +#if UNSAFE_THREADING /// /// INTERNAL API /// @@ -47,6 +48,7 @@ public FullThreadPoolExecutorServiceImpl(string id) : base(id) { } } +#endif /// /// INTERNAL API diff --git a/src/core/Akka/Dispatch/Mailbox.cs b/src/core/Akka/Dispatch/Mailbox.cs index e611dc23f3a..52c472c89a8 100644 --- a/src/core/Akka/Dispatch/Mailbox.cs +++ b/src/core/Akka/Dispatch/Mailbox.cs @@ -338,10 +338,12 @@ private void ProcessAllSystemMessages() msg.Unlink(); DebugPrint("{0} processing system message {1} with {2}", Actor.Self, msg, string.Join(",", Actor.GetChildren())); // we know here that SystemInvoke ensures that only "fatal" exceptions get rethrown +#if UNSAFE_THREADING try { Actor.SystemInvoke(msg); } + catch (ThreadInterruptedException ex) // thrown only if thread is explicitly interrupted, which should never happen { @@ -351,6 +353,9 @@ private void ProcessAllSystemMessages() { interruption = ex; } +#else + Actor.SystemInvoke(msg); +#endif // don't ever execute normal message when system message present! if (messageList.IsEmpty && !IsClosed()) @@ -371,6 +376,7 @@ private void ProcessAllSystemMessages() { dlm.SystemEnqueue(Actor.Self, msg); } +#if UNSAFE_THREADING catch (ThreadInterruptedException ex) // thrown only if thread is explicitly interrupted, which should never happen { @@ -380,6 +386,7 @@ private void ProcessAllSystemMessages() { interruption = ex; } +#endif catch (Exception ex) { Actor.System.EventStream.Publish(new Error(ex, GetType().FullName, GetType(), $"error while enqueuing {msg} to deadletters: {ex.Message}")); diff --git a/src/core/Akka/Dispatch/Mailboxes.cs b/src/core/Akka/Dispatch/Mailboxes.cs index 45918ce285a..4a111832aa8 100644 --- a/src/core/Akka/Dispatch/Mailboxes.cs +++ b/src/core/Akka/Dispatch/Mailboxes.cs @@ -8,8 +8,8 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Configuration; using System.Linq; +using System.Reflection; using Akka.Actor; using Akka.Configuration; using Akka.Util.Reflection; @@ -73,8 +73,8 @@ public Mailboxes(ActorSystem system) /// true if this actor has a message queue type requirement. false otherwise. public bool HasRequiredType(Type actorType) { - return actorType.GetInterfaces() - .Where(i => i.IsGenericType) + return actorType.GetTypeInfo().GetInterfaces() + .Where(i => i.GetTypeInfo().IsGenericType) .Any(i => i.GetGenericTypeDefinition() == RequiresMessageQueueGenericType); } @@ -85,8 +85,8 @@ public bool HasRequiredType(Type actorType) /// true if this mailboxtype produces queues. false otherwise. public bool ProducesMessageQueue(Type mailboxType) { - return mailboxType.GetInterfaces() - .Where(i => i.IsGenericType) + return mailboxType.GetTypeInfo().GetInterfaces() + .Where(i => i.GetTypeInfo().IsGenericType) .Any(i => i.GetGenericTypeDefinition() == ProducesMessageQueueGenericType); } @@ -174,20 +174,20 @@ private Config Config(string id) private static readonly Type RequiresMessageQueueGenericType = typeof (IRequiresMessageQueue<>); public Type GetRequiredType(Type actorType) { - return actorType.GetInterfaces() - .Where(i => i.IsGenericType) + return actorType.GetTypeInfo().GetInterfaces() + .Where(i => i.GetTypeInfo().IsGenericType) .Where(i => i.GetGenericTypeDefinition() == RequiresMessageQueueGenericType) - .Select(i => i.GetGenericArguments().First()) + .Select(i => i.GetTypeInfo().GetGenericArguments().First()) .FirstOrDefault(); } private static readonly Type ProducesMessageQueueGenericType = typeof (IProducesMessageQueue<>); private Type GetProducedMessageQueueType(MailboxType mailboxType) { - var queueType = mailboxType.GetType().GetInterfaces() - .Where(i => i.IsGenericType) + var queueType = mailboxType.GetType().GetTypeInfo().GetInterfaces() + .Where(i => i.GetTypeInfo().IsGenericType) .Where(i => i.GetGenericTypeDefinition() == ProducesMessageQueueGenericType) - .Select(i => i.GetGenericArguments().First()) + .Select(i => i.GetTypeInfo().GetGenericArguments().First()) .FirstOrDefault(); if(queueType == null) @@ -225,10 +225,10 @@ public MailboxType GetMailboxType(Props props, Config dispatcherConfig) Func verifyRequirements = mailboxType => { Lazy mqType = new Lazy(() => GetProducedMessageQueueType(mailboxType)); - if(hasMailboxRequirement && !mailboxRequirement.IsAssignableFrom(mqType.Value)) + if(hasMailboxRequirement && !mailboxRequirement.GetTypeInfo().IsAssignableFrom(mqType.Value)) throw new ArgumentException($"produced message queue type [{mqType.Value}] does not fulfill requirement for dispatcher [{id}]." + $"Must be a subclass of [{mailboxRequirement}]"); - if(HasRequiredType(actorType) && !actorRequirement.Value.IsAssignableFrom(mqType.Value)) + if(HasRequiredType(actorType) && !actorRequirement.Value.GetTypeInfo().IsAssignableFrom(mqType.Value)) throw new ArgumentException($"produced message queue type of [{mqType.Value}] does not fulfill requirement for actor class [{actorType}]." + $"Must be a subclass of [{mailboxRequirement}]"); return mailboxType; diff --git a/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs b/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs index 45d29be061b..0678539a536 100644 --- a/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs +++ b/src/core/Akka/Dispatch/SysMsg/ISystemMessage.cs @@ -251,7 +251,9 @@ public interface ISystemMessage : INoSerializationVerificationNeeded /// public abstract class SystemMessage : ISystemMessage { +#if SERIALIZATION [NonSerialized] +#endif internal SystemMessage Next; public void Unlink() diff --git a/src/core/Akka/Dispatch/ThreadPoolBuilder.cs b/src/core/Akka/Dispatch/ThreadPoolBuilder.cs index 77c05afcd5e..7d5104a1f79 100644 --- a/src/core/Akka/Dispatch/ThreadPoolBuilder.cs +++ b/src/core/Akka/Dispatch/ThreadPoolBuilder.cs @@ -28,19 +28,21 @@ internal static class DedicatedThreadPoolConfigHelpers internal static ThreadType ConfigureThreadType(string threadType) { - return string.Compare(threadType, ThreadType.Foreground.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0 ? + return string.Compare(threadType, ThreadType.Foreground.ToString(), StringComparison.OrdinalIgnoreCase) == 0 ? ThreadType.Foreground : ThreadType.Background; } +#if UNSAFE_THREADING internal static ApartmentState GetApartmentState(Config cfg) { var s = cfg.GetString("apartment"); - return string.Compare(s, "sta", StringComparison.InvariantCultureIgnoreCase) == 0 + return string.Compare(s, "sta", StringComparison.OrdinalIgnoreCase) == 0 ? ApartmentState.STA - : string.Compare(s, "mta", StringComparison.InvariantCultureIgnoreCase) == 0 + : string.Compare(s, "mta", StringComparison.OrdinalIgnoreCase) == 0 ? ApartmentState.MTA : ApartmentState.Unknown; } +#endif /// /// Default settings for instances. diff --git a/src/core/Akka/Event/LoggingBus.cs b/src/core/Akka/Event/LoggingBus.cs index a909b53f4ef..6aad1875921 100644 --- a/src/core/Akka/Event/LoggingBus.cs +++ b/src/core/Akka/Event/LoggingBus.cs @@ -13,6 +13,7 @@ using Akka.Actor; using Akka.Actor.Internal; using Akka.Configuration; +using System.Reflection; namespace Akka.Event { @@ -39,7 +40,7 @@ public class LoggingBus : ActorEventBus /// true if the classifier is a subclass of ; otherwise false. protected override bool IsSubClassification(Type parent, Type child) { - return parent.IsAssignableFrom(child); + return parent.GetTypeInfo().IsAssignableFrom(child); } /// @@ -60,7 +61,7 @@ protected override void Publish(object @event, IActorRef subscriber) /// true if the classification succeeds; otherwise false. protected override bool Classify(object @event, Type classifier) { - return classifier.IsAssignableFrom(GetClassifier(@event)); + return classifier.GetTypeInfo().IsAssignableFrom(GetClassifier(@event)); } /// diff --git a/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs b/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs index 0225ae0ab5f..035b44912bb 100644 --- a/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs +++ b/src/core/Akka/Helios.Concurrency.DedicatedThreadPool.cs @@ -39,6 +39,7 @@ internal class DedicatedThreadPoolSettings /// public const ThreadType DefaultThreadType = ThreadType.Background; +#if UNSAFE_THREADING public DedicatedThreadPoolSettings(int numThreads, string name = null, TimeSpan? deadlockTimeout = null, @@ -60,7 +61,9 @@ internal class DedicatedThreadPoolSettings ThreadType = threadType; NumThreads = numThreads; DeadlockTimeout = deadlockTimeout; + ApartmentState = apartmentState; + ExceptionHandler = exceptionHandler ?? (ex => { }); ThreadMaxStackSize = threadMaxStackSize; @@ -69,7 +72,23 @@ internal class DedicatedThreadPoolSettings if (numThreads <= 0) throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads)); } +#else + public DedicatedThreadPoolSettings(int numThreads, string name = null, TimeSpan? deadlockTimeout = null) + : this(numThreads, DefaultThreadType, name, deadlockTimeout) + { } + public DedicatedThreadPoolSettings(int numThreads, ThreadType threadType, string name = null, TimeSpan? deadlockTimeout = null) + { + Name = name ?? ("DedicatedThreadPool-" + Guid.NewGuid()); + ThreadType = threadType; + NumThreads = numThreads; + DeadlockTimeout = deadlockTimeout; + if (deadlockTimeout.HasValue && deadlockTimeout.Value.TotalMilliseconds <= 0) + throw new ArgumentOutOfRangeException("deadlockTimeout", string.Format("deadlockTimeout must be null or at least 1ms. Was {0}.", deadlockTimeout)); + if (numThreads <= 0) + throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads)); + } +#endif /// /// The total number of threads to run in this thread pool. /// @@ -80,10 +99,12 @@ internal class DedicatedThreadPoolSettings /// public ThreadType ThreadType { get; private set; } +#if UNSAFE_THREADING /// /// Apartment state for threads to run in this thread pool /// public ApartmentState ApartmentState { get; private set; } +#endif /// /// Interval to check for thread deadlocks. @@ -311,15 +332,21 @@ public PoolWorker(DedicatedThreadPool pool, int workerId) _pool = pool; _threadExit = new TaskCompletionSource(); +#if UNSAFE_THREADING var thread = new Thread(RunThread, pool.Settings.ThreadMaxStackSize); +#else + var thread = new Thread(RunThread); +#endif thread.IsBackground = pool.Settings.ThreadType == ThreadType.Background; if (pool.Settings.Name != null) thread.Name = string.Format("{0}_{1}", pool.Settings.Name, workerId); +#if UNSAFE_THREADING if (pool.Settings.ApartmentState != ApartmentState.Unknown) thread.SetApartmentState(pool.Settings.ApartmentState); +#endif thread.Start(); } diff --git a/src/core/Akka/IO/DirectByteBufferPool.cs b/src/core/Akka/IO/DirectByteBufferPool.cs index 200af0acc62..4b2d6da998d 100644 --- a/src/core/Akka/IO/DirectByteBufferPool.cs +++ b/src/core/Akka/IO/DirectByteBufferPool.cs @@ -27,6 +27,7 @@ internal class DirectByteBufferPool : IBufferPool private readonly int _defaultBufferSize; private readonly int _maxPoolEntries; private readonly ByteBuffer[] _pool; + private readonly object poolLock = new object(); private int _buffersInPool; public DirectByteBufferPool(int defaultBufferSize, int maxPoolEntries) @@ -55,7 +56,7 @@ private ByteBuffer Allocate(int size) private ByteBuffer TakeBufferFromPool() { ByteBuffer buffer = null; - lock (_pool.SyncRoot) + lock (poolLock) { if (_buffersInPool > 0) { @@ -71,7 +72,7 @@ private ByteBuffer TakeBufferFromPool() private void OfferBufferToPool(ByteBuffer buf) { - lock (_pool.SyncRoot) + lock (poolLock) { if (_buffersInPool < _maxPoolEntries) { diff --git a/src/core/Akka/IO/InetAddressDnsResolver.cs b/src/core/Akka/IO/InetAddressDnsResolver.cs index 23fcc10962b..ea5501f96f3 100644 --- a/src/core/Akka/IO/InetAddressDnsResolver.cs +++ b/src/core/Akka/IO/InetAddressDnsResolver.cs @@ -37,7 +37,7 @@ protected override bool Receive(object message) try { //TODO: IP6 - answer = Dns.Resolved.Create(resolve.Name, System.Net.Dns.GetHostEntry(resolve.Name).AddressList.Where(x => x.AddressFamily == AddressFamily.InterNetwork)); + answer = Dns.Resolved.Create(resolve.Name, System.Net.Dns.GetHostAddressesAsync(resolve.Name).Result.Where(x => x.AddressFamily == AddressFamily.InterNetwork)); _cache.Put(answer, _positiveTtl); } catch (SocketException ex) diff --git a/src/core/Akka/IO/SocketChannel.cs b/src/core/Akka/IO/SocketChannel.cs index 12508029ee2..465e19f6c71 100644 --- a/src/core/Akka/IO/SocketChannel.cs +++ b/src/core/Akka/IO/SocketChannel.cs @@ -68,6 +68,7 @@ public bool Connect(EndPoint address) } return false; } + public bool FinishConnect() { if (_connectResult.CompletedSynchronously) @@ -112,7 +113,7 @@ public int Write(ByteBuffer buffer) public void Close() { _connected = false; - _socket.Close(); + _socket.Dispose(); } internal IActorRef Connection { get { return _connection; } } } diff --git a/src/core/Akka/NotUsed.cs b/src/core/Akka/NotUsed.cs index 4711222954c..d530f530b29 100644 --- a/src/core/Akka/NotUsed.cs +++ b/src/core/Akka/NotUsed.cs @@ -15,7 +15,9 @@ namespace Akka /// used from the other language. An example use-case is the materialized value of an Akka Stream for cases /// where no result shall be returned from materialization. /// +#if SERIALIZATION [Serializable] +#endif public sealed class NotUsed : IEquatable, IComparable { public static readonly NotUsed Instance = new NotUsed(); diff --git a/src/core/Akka/Pattern/BackoffSupervisor.cs b/src/core/Akka/Pattern/BackoffSupervisor.cs index ab7be00c010..b0970298031 100644 --- a/src/core/Akka/Pattern/BackoffSupervisor.cs +++ b/src/core/Akka/Pattern/BackoffSupervisor.cs @@ -23,14 +23,18 @@ public class BackoffSupervisor : UntypedActor /// /// Request with this message to receive response with current child. /// +#if SERIALIZATION [Serializable] +#endif public sealed class GetCurrentChild { public static readonly GetCurrentChild Instance = new GetCurrentChild(); private GetCurrentChild() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class CurrentChild { public readonly IActorRef Ref; @@ -41,14 +45,18 @@ public CurrentChild(IActorRef @ref) } } +#if SERIALIZATION [Serializable] +#endif public sealed class StartChild { public static readonly StartChild Instance = new StartChild(); private StartChild() { } } +#if SERIALIZATION [Serializable] +#endif public sealed class ResetRestartCount { public readonly int Current; diff --git a/src/core/Akka/Pattern/IllegalStateException.cs b/src/core/Akka/Pattern/IllegalStateException.cs index 7a1b398a4c8..75008e6a6f1 100644 --- a/src/core/Akka/Pattern/IllegalStateException.cs +++ b/src/core/Akka/Pattern/IllegalStateException.cs @@ -33,6 +33,7 @@ public IllegalStateException(string message, Exception innerEx) : base(message, { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -42,5 +43,6 @@ protected IllegalStateException(SerializationInfo info, StreamingContext context : base(info, context) { } +#endif } } diff --git a/src/core/Akka/Pattern/OpenCircuitException.cs b/src/core/Akka/Pattern/OpenCircuitException.cs index 1f1a4715bcc..f7f64c48148 100644 --- a/src/core/Akka/Pattern/OpenCircuitException.cs +++ b/src/core/Akka/Pattern/OpenCircuitException.cs @@ -40,6 +40,7 @@ public OpenCircuitException(string message, Exception cause) { } +#if SERIALIZATION /// /// Initializes a new instance of the class. /// @@ -49,5 +50,6 @@ protected OpenCircuitException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } diff --git a/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs b/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs index 06f0ece6602..d74a9463e72 100644 --- a/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs +++ b/src/core/Akka/Serialization/NewtonSoftJsonSerializer.cs @@ -171,7 +171,7 @@ public override bool CanConvert(Type objectType) if (objectType == typeof (int) || objectType == typeof (float) || objectType == typeof (decimal)) return true; - if (typeof (ISurrogated).IsAssignableFrom(objectType)) + if (typeof (ISurrogated).GetTypeInfo().IsAssignableFrom(objectType)) return true; if (objectType == typeof (object)) diff --git a/src/core/Akka/Serialization/Serialization.cs b/src/core/Akka/Serialization/Serialization.cs index 5e0ca3c5c29..d3d5b757f4c 100644 --- a/src/core/Akka/Serialization/Serialization.cs +++ b/src/core/Akka/Serialization/Serialization.cs @@ -11,6 +11,7 @@ using System.Runtime.Serialization; using Akka.Actor; using Akka.Util.Internal; +using System.Reflection; namespace Akka.Serialization { @@ -155,12 +156,12 @@ public Serializer FindSerializerForType(Type objectType) foreach (var serializerType in _serializerMap) { //force deferral of the base "object" serializer until all other higher-level types have been evaluated - if (serializerType.Key.IsAssignableFrom(type) && serializerType.Key != _objectType) + if (serializerType.Key.GetTypeInfo().IsAssignableFrom(type) && serializerType.Key != _objectType) return serializerType.Value; } //do a final check for the "object" serializer - if (_serializerMap.ContainsKey(_objectType) && _objectType.IsAssignableFrom(type)) + if (_serializerMap.ContainsKey(_objectType) && _objectType.GetTypeInfo().IsAssignableFrom(type)) return _serializerMap[_objectType]; throw new Exception("Serializer not found for type " + objectType.Name); diff --git a/src/core/Akka/Serialization/Serializer.cs b/src/core/Akka/Serialization/Serializer.cs index 08e69272538..aa8c1b57175 100644 --- a/src/core/Akka/Serialization/Serializer.cs +++ b/src/core/Akka/Serialization/Serializer.cs @@ -7,6 +7,7 @@ using System; using System.Linq; +using System.Reflection; using Akka.Actor; namespace Akka.Serialization @@ -101,7 +102,7 @@ public byte[] ToBinaryWithAddress(Address address, object obj) /// protected static string TypeQualifiedNameForManifest(Type type) { - return type == null ? string.Empty : string.Format("{0},{1}", type.FullName, type.Assembly.GetName().Name); + return type == null ? string.Empty : string.Format("{0},{1}", type.FullName, type.GetTypeInfo().Assembly.GetName().Name); } } diff --git a/src/core/Akka/Util/ByteString.cs b/src/core/Akka/Util/ByteString.cs index cb105f31bf2..4acbbc7d9cd 100644 --- a/src/core/Akka/Util/ByteString.cs +++ b/src/core/Akka/Util/ByteString.cs @@ -563,7 +563,9 @@ public static ByteString FromArray(byte[] array, int offset, int length) } } +#if SERIALIZATION [Serializable] +#endif public abstract partial class CompactByteString : ByteString { public override bool IsCompact() diff --git a/src/core/Akka/Util/MatchHandler/MatchBuilder.cs b/src/core/Akka/Util/MatchHandler/MatchBuilder.cs index 2b33850e09d..33cd4d5b734 100644 --- a/src/core/Akka/Util/MatchHandler/MatchBuilder.cs +++ b/src/core/Akka/Util/MatchHandler/MatchBuilder.cs @@ -144,7 +144,7 @@ public void BuildToMethod(TypeBuilder typeBuilder, string methodName, MethodAttr private static void EnsureCanHandleType(Type handlesType) { - if(!_itemType.IsAssignableFrom(handlesType)) + if(!_itemType.GetTypeInfo().IsAssignableFrom(handlesType)) throw new ArgumentException("The specified type (" + handlesType + ") must implement " + _itemType, "handlesType"); } diff --git a/src/core/Akka/Util/MatchHandler/MatchExpressionBuilder.cs b/src/core/Akka/Util/MatchHandler/MatchExpressionBuilder.cs index 3a5190fdadc..157334aa867 100644 --- a/src/core/Akka/Util/MatchHandler/MatchExpressionBuilder.cs +++ b/src/core/Akka/Util/MatchHandler/MatchExpressionBuilder.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Reflection; namespace Akka.Tools.MatchHandler { @@ -59,7 +60,7 @@ public MatchExpressionBuilderResult BuildLambdaExpression(IReadOnlyList public static byte[] ToBytes(this BitArray arr) { - if (arr.Count != 8) + if (arr.Length != 8) { throw new ArgumentException("Not enough bits to make a byte!"); } var bytes = new byte[(arr.Length - 1) / 8 + 1]; - arr.CopyTo(bytes, 0); + ((ICollection)arr).CopyTo(bytes, 0); return bytes; } } diff --git a/src/core/Akka/Util/TypeExtensions.cs b/src/core/Akka/Util/TypeExtensions.cs index 793f849638a..9ae3a5ac9e3 100644 --- a/src/core/Akka/Util/TypeExtensions.cs +++ b/src/core/Akka/Util/TypeExtensions.cs @@ -6,6 +6,7 @@ //----------------------------------------------------------------------- using System; +using System.Reflection; namespace Akka.Util { @@ -35,7 +36,7 @@ public static bool Implements(this Type type) /// true if XXXX, false otherwise. public static bool Implements(this Type type, Type moreGeneralType) { - return moreGeneralType.IsAssignableFrom(type); + return moreGeneralType.GetTypeInfo().IsAssignableFrom(type); } } } diff --git a/src/examples/Chat/ChatMessages/ChatMessages.csproj b/src/examples/Chat/ChatMessages/ChatMessages.csproj index bb36171c085..2301cc33bd6 100644 --- a/src/examples/Chat/ChatMessages/ChatMessages.csproj +++ b/src/examples/Chat/ChatMessages/ChatMessages.csproj @@ -56,10 +56,6 @@ false - - ..\..\..\packages\fastJSON.2.0.27.1\lib\net40\fastjson.dll - True - @@ -88,7 +84,9 @@ - + + Designer + diff --git a/src/examples/Chat/ChatMessages/packages.config b/src/examples/Chat/ChatMessages/packages.config index fda430cff2d..deb4fe40574 100644 --- a/src/examples/Chat/ChatMessages/packages.config +++ b/src/examples/Chat/ChatMessages/packages.config @@ -1,6 +1,5 @@  - diff --git a/src/examples/Stocks/SymbolLookup/Actors/TickerActors.cs b/src/examples/Stocks/SymbolLookup/Actors/TickerActors.cs index 147b20a5eba..ea949ca9ac0 100644 --- a/src/examples/Stocks/SymbolLookup/Actors/TickerActors.cs +++ b/src/examples/Stocks/SymbolLookup/Actors/TickerActors.cs @@ -107,7 +107,7 @@ protected override void OnReceive(object msg) var quoteStrTask = _client.GetStringAsync(StockUriHelper.CreateStockQuoteUri(symboldata.Symbol)); quoteStrTask.Wait(); var quoteStr = quoteStrTask.Result; - var quoteData = fastJSON.JSON.Instance.ToObject(quoteStr); + var quoteData = Newtonsoft.Json.JsonConvert.DeserializeObject(quoteStr); if (quoteData == null || quoteData.query == null || quoteData.query.results == null) { //request failed for whatever reason, diff --git a/src/examples/Stocks/SymbolLookup/SymbolLookup.csproj b/src/examples/Stocks/SymbolLookup/SymbolLookup.csproj index e05c0a5f49c..37e2f065bda 100644 --- a/src/examples/Stocks/SymbolLookup/SymbolLookup.csproj +++ b/src/examples/Stocks/SymbolLookup/SymbolLookup.csproj @@ -57,8 +57,8 @@ false - - ..\..\..\packages\fastJSON.2.0.27.1\lib\net40\fastjson.dll + + ..\..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll True @@ -103,7 +103,9 @@ True Resources.resx - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/src/examples/Stocks/SymbolLookup/packages.config b/src/examples/Stocks/SymbolLookup/packages.config index ca8f7380506..ee1fd4f067f 100644 --- a/src/examples/Stocks/SymbolLookup/packages.config +++ b/src/examples/Stocks/SymbolLookup/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file