Skip to content

Commit 6c9e4ff

Browse files
committed
make neventsocket compile on netcore
1 parent 7cc5df7 commit 6c9e4ff

12 files changed

Lines changed: 161 additions & 220 deletions

NEventSocket.sln

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,22 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25123.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket", "src\NEventSocket\NEventSocket.csproj", "{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}"
7-
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{E15B83EF-2CE1-4479-A457-D340DCA80869}"
9-
ProjectSection(SolutionItems) = preProject
10-
BREAKING CHANGES.md = BREAKING CHANGES.md
11-
default.ps1 = default.ps1
12-
src\NEventSocket\NEventSocket.nuspec = src\NEventSocket\NEventSocket.nuspec
13-
Settings.StyleCop = Settings.StyleCop
14-
SharedAssemblyInfo.cs = SharedAssemblyInfo.cs
15-
EndProjectSection
16-
EndProject
17-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8A973BD1-83E8-4794-A81A-538CC7069BDC}"
18-
ProjectSection(SolutionItems) = preProject
19-
test\Settings.StyleCop = test\Settings.StyleCop
20-
EndProjectSection
21-
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket.Tests", "test\NEventSocket.Tests\NEventSocket.Tests.csproj", "{731A678B-6827-468A-BFA1-AB2533947D61}"
23-
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEventSocket.Examples", "src\NEventSocket.Examples\NEventSocket.Examples.csproj", "{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}"
6+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NEventSocket", "src\NEventSocket\NEventSocket.xproj", "{2197E806-F41A-40F0-A720-D45FE5C9ED77}"
257
EndProject
268
Global
279
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2810
Debug|Any CPU = Debug|Any CPU
2911
Release|Any CPU = Release|Any CPU
3012
EndGlobalSection
3113
GlobalSection(ProjectConfigurationPlatforms) = postSolution
32-
{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{83DCA19D-3FF7-4E60-A066-BAE1C5A7B65E}.Release|Any CPU.Build.0 = Release|Any CPU
36-
{731A678B-6827-468A-BFA1-AB2533947D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37-
{731A678B-6827-468A-BFA1-AB2533947D61}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{731A678B-6827-468A-BFA1-AB2533947D61}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{731A678B-6827-468A-BFA1-AB2533947D61}.Release|Any CPU.Build.0 = Release|Any CPU
40-
{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41-
{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Debug|Any CPU.Build.0 = Debug|Any CPU
42-
{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Release|Any CPU.ActiveCfg = Release|Any CPU
43-
{D64BAE1E-EB6C-4149-91DC-8EB7A06C8374}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{2197E806-F41A-40F0-A720-D45FE5C9ED77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2197E806-F41A-40F0-A720-D45FE5C9ED77}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2197E806-F41A-40F0-A720-D45FE5C9ED77}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2197E806-F41A-40F0-A720-D45FE5C9ED77}.Release|Any CPU.Build.0 = Release|Any CPU
4418
EndGlobalSection
4519
GlobalSection(SolutionProperties) = preSolution
4620
HideSolutionNode = FALSE
4721
EndGlobalSection
48-
GlobalSection(NestedProjects) = preSolution
49-
{731A678B-6827-468A-BFA1-AB2533947D61} = {8A973BD1-83E8-4794-A81A-538CC7069BDC}
50-
EndGlobalSection
5122
EndGlobal

src/NEventSocket/App_Packages/LibLog.4.2/LibLog.cs

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#pragma warning disable 1591
4040

4141
using System.Diagnostics.CodeAnalysis;
42+
using System.Linq;
4243

4344
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NEventSocket.Logging")]
4445
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "NEventSocket.Logging.Logger.#Invoke(NEventSocket.Logging.LogLevel,System.Func`1<System.String>,System.Exception,System.Object[])")]
@@ -508,16 +509,21 @@ static ILog For<T>()
508509
#endif
509510
static ILog GetCurrentClassLogger()
510511
{
512+
#if NETSTANDARD16
513+
var trace = new StackTrace(null, false);
514+
var stackFrame = trace.GetFrames().Skip(1).First();
515+
#else
511516
var stackFrame = new StackFrame(1, false);
517+
#endif
512518
return GetLogger(stackFrame.GetMethod().DeclaringType);
513519
}
514520
#endif
515521

516-
/// <summary>
517-
/// Gets a logger for the specified type.
518-
/// </summary>
519-
/// <param name="type">The type whose name will be used for the logger.</param>
520-
/// <returns>An instance of <see cref="ILog"/></returns>
522+
/// <summary>
523+
/// Gets a logger for the specified type.
524+
/// </summary>
525+
/// <param name="type">The type whose name will be used for the logger.</param>
526+
/// <returns>An instance of <see cref="ILog"/></returns>
521527
#if LIBLOG_PUBLIC
522528
public
523529
#else
@@ -690,6 +696,7 @@ public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception
690696
return false;
691697
}
692698
#if !LIBLOG_PORTABLE
699+
693700
var envVar = Environment.GetEnvironmentVariable(LogProvider.DisableLoggingEnvironmentVariable);
694701

695702
if (envVar != null && envVar.Equals("true", StringComparison.OrdinalIgnoreCase))
@@ -1205,9 +1212,24 @@ public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception
12051212
lock (CallerStackBoundaryTypeSync)
12061213
{
12071214
#if !LIBLOG_PORTABLE
1215+
#if NETSTANDARD16
1216+
StackTrace stack = new StackTrace(exception, true);
1217+
#else
12081218
StackTrace stack = new StackTrace();
1219+
#endif
12091220
Type thisType = GetType();
12101221
s_callerStackBoundaryType = Type.GetType("LoggerExecutionWrapper");
1222+
#if NETSTANDARD16
1223+
var frames = stack.GetFrames();
1224+
for (var i = 1; i < frames.Length; i++)
1225+
{
1226+
if (!IsInTypeHierarchy(thisType, frames[i].GetMethod().DeclaringType))
1227+
{
1228+
s_callerStackBoundaryType = frames[i - 1].GetMethod().DeclaringType;
1229+
break;
1230+
}
1231+
}
1232+
#else
12111233
for (var i = 1; i < stack.FrameCount; i++)
12121234
{
12131235
if (!IsInTypeHierarchy(thisType, stack.GetFrame(i).GetMethod().DeclaringType))
@@ -1216,6 +1238,7 @@ public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception
12161238
break;
12171239
}
12181240
}
1241+
#endif
12191242
#else
12201243
s_callerStackBoundaryType = typeof (LoggerExecutionWrapper);
12211244
#endif
@@ -1996,8 +2019,12 @@ internal static Type GetBaseTypePortable(this Type type)
19962019
{
19972020
#if LIBLOG_PORTABLE
19982021
return type.GetTypeInfo().BaseType;
2022+
#else
2023+
#if NETSTANDARD16
2024+
return type.GetTypeInfo().BaseType;
19992025
#else
20002026
return type.BaseType;
2027+
#endif
20012028
#endif
20022029
}
20032030

@@ -2016,16 +2043,24 @@ internal static MethodInfo GetSetMethod(this PropertyInfo propertyInfo)
20162043
#if !LIBLOG_PORTABLE
20172044
internal static object CreateDelegate(this MethodInfo methodInfo, Type delegateType)
20182045
{
2046+
#if NETSTANDARD16
2047+
return null;
2048+
#else
20192049
return Delegate.CreateDelegate(delegateType, methodInfo);
2050+
#endif
20202051
}
20212052
#endif
20222053

20232054
internal static Assembly GetAssemblyPortable(this Type type)
20242055
{
20252056
#if LIBLOG_PORTABLE
20262057
return type.GetTypeInfo().Assembly;
2058+
#else
2059+
#if NETSTANDARD16
2060+
return type.GetTypeInfo().Assembly;
20272061
#else
20282062
return type.Assembly;
2063+
#endif
20292064
#endif
20302065
}
20312066
}

src/NEventSocket/Channels/BasicChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public async Task<IDisposable> PlayUntilCancelled(string file)
264264
if (!CanPlayBackAudio)
265265
{
266266
Log.Warn(() => "Channel [{0}] attempted to play hold music when not answered".Fmt(UUID));
267-
return Task.FromResult(new DisposableAction());
267+
return new DisposableAction();
268268
}
269269

270270
// essentially, we'll do a playback application call without waiting for the ChannelExecuteComplete event

src/NEventSocket/InboundSocket.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ public class InboundSocket : EventSocket
2626
{
2727
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
2828

29+
#if NETSTANDARD16
30+
private InboundSocket(string host, int port, TimeSpan? timeout = null) : base(new TcpClient(), timeout)
31+
{
32+
this.tcpClient.ConnectAsync(host, port).Wait();
33+
}
34+
#else
2935
private InboundSocket(string host, int port, TimeSpan? timeout = null) : base(new TcpClient(host, port), timeout)
3036
{
3137
}
38+
#endif
3239

3340
/// <summary>
3441
/// Connects to FreeSwitch and authenticates

src/NEventSocket/InboundSocketConnectionFailedException.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public InboundSocketConnectionFailedException(string message, Exception innerExc
3939
/// </summary>
4040
/// <param name="info">The information.</param>
4141
/// <param name="context">The context.</param>
42-
protected InboundSocketConnectionFailedException(SerializationInfo info, StreamingContext context) : base(info, context)
42+
protected InboundSocketConnectionFailedException(SerializationInfo info, StreamingContext context)
43+
#if NET451
44+
: base(info, context)
45+
#endif
4346
{
4447
}
4548
}

src/NEventSocket/NEventSocket.csproj

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)