diff --git a/NEventSocket.sln b/NEventSocket.sln index 48101af..37c24ce 100755 --- a/NEventSocket.sln +++ b/NEventSocket.sln @@ -1,27 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket", "src\NEventSocket\NEventSocket.csproj", "{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{E15B83EF-2CE1-4479-A457-D340DCA80869}" - ProjectSection(SolutionItems) = preProject - BREAKING CHANGES.md = BREAKING CHANGES.md - default.ps1 = default.ps1 - src\NEventSocket\NEventSocket.nuspec = src\NEventSocket\NEventSocket.nuspec - Settings.StyleCop = Settings.StyleCop - SharedAssemblyInfo.cs = SharedAssemblyInfo.cs - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A973BD1-83E8-4794-A81A-538CC7069BDC}" - ProjectSection(SolutionItems) = preProject - test\Settings.StyleCop = test\Settings.StyleCop - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket.Tests", "test\NEventSocket.Tests\NEventSocket.Tests.csproj", "{731A678B-6827-468A-BFA1-AB2533947D61}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket.Examples", "src\NEventSocket.Examples\NEventSocket.Examples.csproj", "{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NEventSocket", "src\NEventSocket\NEventSocket.xproj", "{2197E806-F41A-40F0-A720-D45FE5C9ED77}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,23 +11,12 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Release|Any CPU.Build.0 = Release|Any CPU - {731A678B-6827-468A-BFA1-AB2533947D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {731A678B-6827-468A-BFA1-AB2533947D61}.Debug|Any CPU.Build.0 = Debug|Any CPU - {731A678B-6827-468A-BFA1-AB2533947D61}.Release|Any CPU.ActiveCfg = Release|Any CPU - {731A678B-6827-468A-BFA1-AB2533947D61}.Release|Any CPU.Build.0 = Release|Any CPU - {D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Release|Any CPU.Build.0 = Release|Any CPU + {2197E806-F41A-40F0-A720-D45FE5C9ED77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2197E806-F41A-40F0-A720-D45FE5C9ED77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2197E806-F41A-40F0-A720-D45FE5C9ED77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2197E806-F41A-40F0-A720-D45FE5C9ED77}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {731A678B-6827-468A-BFA1-AB2533947D61} = {8A973BD1-83E8-4794-A81A-538CC7069BDC} - EndGlobalSection EndGlobal diff --git a/src/NEventSocket/App_Packages/LibLog.4.2/LibLog.cs b/src/NEventSocket/App_Packages/LibLog.4.2/LibLog.cs index e183c54..53c7f31 100644 --- a/src/NEventSocket/App_Packages/LibLog.4.2/LibLog.cs +++ b/src/NEventSocket/App_Packages/LibLog.4.2/LibLog.cs @@ -39,6 +39,7 @@ #pragma warning disable 1591 using System.Diagnostics.CodeAnalysis; +using System.Linq; [assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NEventSocket.Logging")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "NEventSocket.Logging.Logger.#Invoke(NEventSocket.Logging.LogLevel,System.Func`1,System.Exception,System.Object[])")] @@ -506,10 +507,14 @@ static ILog For() #else internal #endif - static ILog GetCurrentClassLogger() + static ILog GetCurrentClassLogger([CallerMemberName]string name="") { +#if NETSTANDARD16 + return GetLogger(name); +#else var stackFrame = new StackFrame(1, false); return GetLogger(stackFrame.GetMethod().DeclaringType); +#endif } #endif @@ -690,6 +695,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception return false; } #if !LIBLOG_PORTABLE + var envVar = Environment.GetEnvironmentVariable(LogProvider.DisableLoggingEnvironmentVariable); if (envVar != null && envVar.Equals("true", StringComparison.OrdinalIgnoreCase)) @@ -1205,9 +1211,24 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception lock (CallerStackBoundaryTypeSync) { #if !LIBLOG_PORTABLE +#if NETSTANDARD16 + StackTrace stack = new StackTrace(exception, true); +#else StackTrace stack = new StackTrace(); +#endif Type thisType = GetType(); s_callerStackBoundaryType = Type.GetType("LoggerExecutionWrapper"); +#if NETSTANDARD16 + var frames = stack.GetFrames(); + for (var i = 1; i < frames.Length; i++) + { + if (!IsInTypeHierarchy(thisType, frames[i].GetMethod().DeclaringType)) + { + s_callerStackBoundaryType = frames[i - 1].GetMethod().DeclaringType; + break; + } + } +#else for (var i = 1; i < stack.FrameCount; i++) { if (!IsInTypeHierarchy(thisType, stack.GetFrame(i).GetMethod().DeclaringType)) @@ -1216,6 +1237,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception break; } } +#endif #else s_callerStackBoundaryType = typeof (LoggerExecutionWrapper); #endif @@ -1996,8 +2018,12 @@ internal static Type GetBaseTypePortable(this Type type) { #if LIBLOG_PORTABLE return type.GetTypeInfo().BaseType; +#else +#if NETSTANDARD16 + return type.GetTypeInfo().BaseType; #else return type.BaseType; +#endif #endif } @@ -2016,7 +2042,11 @@ internal static MethodInfo GetSetMethod(this PropertyInfo propertyInfo) #if !LIBLOG_PORTABLE internal static object CreateDelegate(this MethodInfo methodInfo, Type delegateType) { +#if NETSTANDARD16 + return null; +#else return Delegate.CreateDelegate(delegateType, methodInfo); +#endif } #endif @@ -2024,8 +2054,12 @@ internal static Assembly GetAssemblyPortable(this Type type) { #if LIBLOG_PORTABLE return type.GetTypeInfo().Assembly; +#else +#if NETSTANDARD16 + return type.GetTypeInfo().Assembly; #else return type.Assembly; +#endif #endif } } diff --git a/src/NEventSocket/Channels/BasicChannel.cs b/src/NEventSocket/Channels/BasicChannel.cs index f24844b..aa5ed33 100644 --- a/src/NEventSocket/Channels/BasicChannel.cs +++ b/src/NEventSocket/Channels/BasicChannel.cs @@ -264,7 +264,7 @@ public async Task PlayUntilCancelled(string file) if (!CanPlayBackAudio) { Log.Warn(() => "Channel [{0}] attempted to play hold music when not answered".Fmt(UUID)); - return Task.FromResult(new DisposableAction()); + return new DisposableAction(); } // essentially, we'll do a playback application call without waiting for the ChannelExecuteComplete event diff --git a/src/NEventSocket/InboundSocket.cs b/src/NEventSocket/InboundSocket.cs index 10247bd..d3d3ff4 100644 --- a/src/NEventSocket/InboundSocket.cs +++ b/src/NEventSocket/InboundSocket.cs @@ -26,9 +26,16 @@ public class InboundSocket : EventSocket { private static readonly ILog Log = LogProvider.GetCurrentClassLogger(); +#if NETSTANDARD16 + private InboundSocket(string host, int port, TimeSpan? timeout = null) : base(new TcpClient(), timeout) + { + this.tcpClient.ConnectAsync(host, port).Wait(); + } +#else private InboundSocket(string host, int port, TimeSpan? timeout = null) : base(new TcpClient(host, port), timeout) { } +#endif /// /// Connects to FreeSwitch and authenticates diff --git a/src/NEventSocket/InboundSocketConnectionFailedException.cs b/src/NEventSocket/InboundSocketConnectionFailedException.cs index f2d1159..3f04a4d 100644 --- a/src/NEventSocket/InboundSocketConnectionFailedException.cs +++ b/src/NEventSocket/InboundSocketConnectionFailedException.cs @@ -39,7 +39,10 @@ public InboundSocketConnectionFailedException(string message, Exception innerExc /// /// The information. /// The context. - protected InboundSocketConnectionFailedException(SerializationInfo info, StreamingContext context) : base(info, context) + protected InboundSocketConnectionFailedException(SerializationInfo info, StreamingContext context) +#if NET451 + : base(info, context) +#endif { } } diff --git a/src/NEventSocket/NEventSocket.csproj b/src/NEventSocket/NEventSocket.csproj index edb115a..df5da3a 100644 --- a/src/NEventSocket/NEventSocket.csproj +++ b/src/NEventSocket/NEventSocket.csproj @@ -1,176 +1,58 @@ - - - - - false - + + - Debug - AnyCPU - {83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E} - Library - Properties - NEventSocket + 3.0.17 + net451;netstandard1.6 NEventSocket - v4.5 - 512 - ..\..\ - - - true - full - false - bin\Debug\ - TRACE;DEBUG;DETECT_LEAKS;TRACE_LEAKS;LIBLOG_PUBLIC - prompt - 4 - bin\Debug\NEventSocket.XML - - - pdbonly - true - bin\Release\ - TRACE;LIBLOG_PUBLIC - prompt - 4 - bin\Release\NEventSocket.XML + NEventSocket + + + + + + + + + + + + + - - - False - ..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - False - ..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - False - ..\..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll - - - False - ..\..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll - - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - - - - + + + $(DefineConstants);LIBLOG_PUBLIC;NET451 + + + + - - - + + + $(DefineConstants);LIBLOG_PUBLIC;NETSTANDARD16 + + + + + + + + + + + + + + + + + + - - - - - - - \ No newline at end of file + diff --git a/src/NEventSocket/NetCore/SerializableAttribute.cs b/src/NEventSocket/NetCore/SerializableAttribute.cs new file mode 100644 index 0000000..276e63f --- /dev/null +++ b/src/NEventSocket/NetCore/SerializableAttribute.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace System +{ + public class SerializableAttribute : Attribute + { + } + + public abstract class SerializationInfo + { + public abstract object GetValue(string name, Type objectType); + + public abstract void AddValue(string name, object value, Type objectType); + } + + public interface ISerializable + { + + } +} diff --git a/src/NEventSocket/Sockets/EventSocket.cs b/src/NEventSocket/Sockets/EventSocket.cs index d170f5a..8c15cb1 100644 --- a/src/NEventSocket/Sockets/EventSocket.cs +++ b/src/NEventSocket/Sockets/EventSocket.cs @@ -72,7 +72,7 @@ protected EventSocket(TcpClient tcpClient, TimeSpan? responseTimeOut = null) : b .ObserveOn(Scheduler.Immediate) .Publish() .RefCount(); - + Log.Trace(() => "EventSocket initialized"); } diff --git a/src/NEventSocket/Sockets/ObservableListener.cs b/src/NEventSocket/Sockets/ObservableListener.cs index 3915113..2bd8001 100644 --- a/src/NEventSocket/Sockets/ObservableListener.cs +++ b/src/NEventSocket/Sockets/ObservableListener.cs @@ -49,8 +49,10 @@ public abstract class ObservableListener : IDisposable where T : ObservableSo static ObservableListener() { +#if NET451 //we need this to work around issues ilmerging rx assemblies PlatformEnlightenmentProvider.Current = new CurrentPlatformEnlightenmentProvider(); +#endif } /// diff --git a/src/NEventSocket/Sockets/ObservableSocket.cs b/src/NEventSocket/Sockets/ObservableSocket.cs index 41d344b..3a6b068 100644 --- a/src/NEventSocket/Sockets/ObservableSocket.cs +++ b/src/NEventSocket/Sockets/ObservableSocket.cs @@ -38,7 +38,7 @@ public abstract class ObservableSocket : IDisposable private readonly InterlockedBoolean isStarted = new InterlockedBoolean(); - private TcpClient tcpClient; + protected TcpClient tcpClient; private Subject subject; @@ -46,8 +46,10 @@ public abstract class ObservableSocket : IDisposable static ObservableSocket() { +#if NET451 //we need this to work around issues ilmerging rx assemblies PlatformEnlightenmentProvider.Current = new CurrentPlatformEnlightenmentProvider(); +#endif } /// @@ -312,7 +314,11 @@ protected virtual void Dispose(bool disposing) { if (tcpClient != null) { +#if NETSTANDARD16 + tcpClient.Dispose(); +#else tcpClient.Close(); +#endif tcpClient = null; SafeLog(LogLevel.Trace, () => "TcpClient closed");