Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Moving towards .NET Standard/.NET Core compatibility #2134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MS recommends to replace InvariantCultureIgnoreCase to OrdinalIgnoreCase in many cases

var singletonProps = Props.Create(() => new BackoffSupervisor(
CoordinatorProps(typeName, rebalanceEnabled),
"coordinator",
Expand Down
Expand Up @@ -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();
}
}
Expand Down
Expand Up @@ -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();
}
}
Expand Down
Expand Up @@ -17,15 +17,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;SERIALIZATION;CONFIGURATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;SERIALIZATION;CONFIGURATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Akka.Persistence.Sql.Common.xml</DocumentationFile>
Expand Down
Expand Up @@ -6,14 +6,15 @@
//-----------------------------------------------------------------------

using System;
using System.Reflection;

namespace Akka.Persistence.Sql.Common
{
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;
}
}
}
Expand Up @@ -20,7 +20,9 @@ public interface ISubscriptionCommand { }
/// Used by query-side. The journal will send <see cref="EventAppended"/> messages to
/// the subscriber when <see cref="AsyncWriteJournal.WriteMessagesAsync"/> has been called.
/// </summary>
#if SERIALIZATION
[Serializable]
#endif
public sealed class SubscribePersistenceId : ISubscriptionCommand
{
public readonly string PersistenceId;
Expand All @@ -31,7 +33,9 @@ public SubscribePersistenceId(string persistenceId)
}
}

#if SERIALIZATION
[Serializable]
#endif
public sealed class EventAppended
{
public readonly string PersistenceId;
Expand All @@ -48,14 +52,18 @@ public EventAppended(string persistenceId)
/// subscriber followed by <see cref="PersistenceIdAdded"/> messages when new persistenceIds
/// are created.
/// </summary>
#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<string> AllPersistenceIds;
Expand All @@ -66,7 +74,9 @@ public CurrentPersistenceIds(IEnumerable<string> allPersistenceIds)
}
}

#if SERIALIZATION
[Serializable]
#endif
public sealed class PersistenceIdAdded
{
public readonly string PersistenceId;
Expand All @@ -84,7 +94,9 @@ public PersistenceIdAdded(string persistenceId)
/// Events are tagged by wrapping in <see cref="Tagged"/>
/// via an <see cref="IEventAdapter"/>.
/// </summary>
#if SERIALIZATION
[Serializable]
#endif
public sealed class SubscribeTag : ISubscriptionCommand
{
public readonly string Tag;
Expand All @@ -95,7 +107,9 @@ public SubscribeTag(string tag)
}
}

#if SERIALIZATION
[Serializable]
#endif
public sealed class TaggedEventAppended
{
public readonly string Tag;
Expand All @@ -106,7 +120,9 @@ public TaggedEventAppended(string tag)
}
}

#if SERIALIZATION
[Serializable]
#endif
public sealed class ReplayTaggedMessages
{
public readonly long FromOffset;
Expand All @@ -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;
Expand Down
Expand Up @@ -74,7 +74,9 @@ public interface IJournalQueryExecutor
Task SelectEventsAsync(DbConnection connection, CancellationToken cancellationToken, IEnumerable<IHint> hints, Action<IPersistentRepresentation> callback);
}

#if SERIALIZATION
[Serializable]
#endif
public class QueryConfiguration
{
public readonly string TagsColumnName;
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -404,10 +403,13 @@ public override async Task<long> 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;
}
Expand Down
Expand Up @@ -93,7 +93,9 @@ public static IHint TimestampBetween(long from, long to)
/// <summary>
/// Hint for the SQL journal used to filter journal entries returned in the response based on the manifest.
/// </summary>
#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<WithManifest>
{
Expand Down Expand Up @@ -130,7 +132,9 @@ public override string ToString()
/// <summary>
/// Hint for the SQL journal used to filter journal entries returned in the response based on set of perisistence ids provided.
/// </summary>
#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<PersistenceIdRange>
{
Expand Down Expand Up @@ -170,7 +174,9 @@ public override string ToString()
/// Desired behavior of timestamp range is &lt;from, to) - left side inclusive, right side exclusive.
/// Timestamp is generated by <see cref="JournalDbEngine.GenerateTimestamp"/> method, which may be overloaded.
/// </summary>
#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<TimestampRange>
{
Expand Down
Expand Up @@ -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.
/// </summary>
#if SERIALIZATION
[Serializable]
#endif
[Obsolete("Existing SQL persistence query will be obsoleted, once Akka.Persistence.Query will came out")]
public sealed class Query: IEquatable<Query>
{
Expand Down Expand Up @@ -73,7 +75,9 @@ public override string ToString()
/// Message send back from SQL-based journal to <see cref="Query"/> sender,
/// when the query execution has been completed and result is returned.
/// </summary>
#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<QueryResponse>
{
Expand Down Expand Up @@ -116,7 +120,9 @@ public override string ToString()
/// <summary>
/// Message send back from SQL-based journal, when <see cref="Query"/> has been successfully responded.
/// </summary>
#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<QuerySuccess>
{
Expand Down Expand Up @@ -153,7 +159,9 @@ public override string ToString()
/// <summary>
/// Message send back from SQL-based journal to <see cref="Query"/> sender, when the query execution has failed.
/// </summary>
#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<QueryFailure>
{
Expand Down
Expand Up @@ -6,7 +6,6 @@
//-----------------------------------------------------------------------

using System;
using System.Configuration;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -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;
}

/// <summary>
Expand Down
Expand Up @@ -22,15 +22,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down
Expand Up @@ -6,7 +6,6 @@
//-----------------------------------------------------------------------

using System;
using System.Runtime.Serialization;
using Xunit.Sdk;

namespace Akka.TestKit.Xunit2.Internals
Expand All @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion src/core/Akka.Cluster/Configuration/ClusterConfigFactory.cs
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics;
using System.IO;
using Akka.Configuration;
using System.Reflection;

namespace Akka.Cluster.Configuration
{
Expand All @@ -34,7 +35,7 @@ public static Config Default()
/// <returns>The configuration defined in the current executing assembly.</returns>
internal static Config FromResource(string resourceName)
{
var assembly = typeof(ClusterConfigFactory).Assembly;
var assembly = typeof(ClusterConfigFactory).GetTypeInfo().Assembly;

using (var stream = assembly.GetManifestResourceStream(resourceName))
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/Proto/ClusterMessageSerializer.cs
Expand Up @@ -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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Persistence.Query/Akka.Persistence.Query.csproj
Expand Up @@ -18,15 +18,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Akka.Persistence.Query.XML</DocumentationFile>
Expand Down
2 changes: 2 additions & 0 deletions src/core/Akka.Persistence.Query/EventEnvelope.cs
Expand Up @@ -13,7 +13,9 @@ namespace Akka.Persistence.Query
/// Event wrapper adding meta data for the events in the result stream of
/// <see cref="IEventsByTagQuery"/> query, or similar queries.
/// </summary>
#if SERIALIZATION
[Serializable]
#endif
public sealed class EventEnvelope : IEquatable<EventEnvelope>
{
public readonly long Offset;
Expand Down