diff --git a/ICD.Common.Utils.Tests/Extensions/JsonExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/JsonExtensionsTest.cs index d174160..c8de33e 100644 --- a/ICD.Common.Utils.Tests/Extensions/JsonExtensionsTest.cs +++ b/ICD.Common.Utils.Tests/Extensions/JsonExtensionsTest.cs @@ -1,10 +1,15 @@ -using System.Collections.Generic; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; -using Newtonsoft.Json; using NUnit.Framework; namespace ICD.Common.Utils.Tests.Extensions diff --git a/ICD.Common.Utils.Tests/ICD.Common.Utils.Tests_NetStandard.csproj b/ICD.Common.Utils.Tests/ICD.Common.Utils.Tests_NetStandard.csproj index eb27fc9..b875bee 100644 --- a/ICD.Common.Utils.Tests/ICD.Common.Utils.Tests_NetStandard.csproj +++ b/ICD.Common.Utils.Tests/ICD.Common.Utils.Tests_NetStandard.csproj @@ -11,12 +11,12 @@ - TRACE;DEBUG;STANDARD + TRACE;DEBUG binNetCoreApp\$(Configuration)\ - TRACE;STANDARD + TRACE @@ -26,6 +26,7 @@ + diff --git a/ICD.Common.Utils.Tests/Json/DateTimeIsoConverterTest.cs b/ICD.Common.Utils.Tests/Json/DateTimeIsoConverterTest.cs index c6d9713..f80b91d 100644 --- a/ICD.Common.Utils.Tests/Json/DateTimeIsoConverterTest.cs +++ b/ICD.Common.Utils.Tests/Json/DateTimeIsoConverterTest.cs @@ -1,6 +1,11 @@ -using System; -using ICD.Common.Utils.Json; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else using Newtonsoft.Json; +#endif +using System; +using ICD.Common.Utils.Json; using NUnit.Framework; namespace ICD.Common.Utils.Tests.Json diff --git a/ICD.Common.Utils.Tests/Json/JsonUtilsTest.cs b/ICD.Common.Utils.Tests/Json/JsonUtilsTest.cs index b257c8d..639dd09 100644 --- a/ICD.Common.Utils.Tests/Json/JsonUtilsTest.cs +++ b/ICD.Common.Utils.Tests/Json/JsonUtilsTest.cs @@ -1,7 +1,12 @@ -using ICD.Common.Utils.Extensions; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; using ICD.Common.Utils.Json; -using Newtonsoft.Json; using NUnit.Framework; namespace ICD.Common.Utils.Tests.Json diff --git a/ICD.Common.Utils/Email/eMailErrorCode.cs b/ICD.Common.Utils/Email/eMailErrorCode.cs index 1aa6628..5ed2d79 100644 --- a/ICD.Common.Utils/Email/eMailErrorCode.cs +++ b/ICD.Common.Utils/Email/eMailErrorCode.cs @@ -1,9 +1,8 @@ using System; -#if STANDARD -using System.Net.Mail; -#endif #if SIMPLSHARP using Crestron.SimplSharp; +#else +using System.Net.Mail; #endif namespace ICD.Common.Utils.Email @@ -126,7 +125,7 @@ namespace ICD.Common.Utils.Email public static class MailErrorCodeUtils { -#if STANDARD +#if !SIMPLSHARP public static eMailErrorCode FromNetStandardMailCode(SmtpStatusCode code) { switch (code) @@ -185,8 +184,7 @@ namespace ICD.Common.Utils.Email throw new ArgumentOutOfRangeException(nameof(code), code, null); } } -#endif -#if SIMPLSHARP +#else public static eMailErrorCode FromSimplMailCode(CrestronMailFunctions.SendMailErrorCodes code) { switch (code) diff --git a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs index cfda1ff..1654b7e 100644 --- a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs +++ b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs @@ -29,7 +29,7 @@ namespace ICD.Common.Utils.Extensions #endif .CodeBase; -#if STANDARD +#if !SIMPLSHARP if (string.IsNullOrEmpty(path)) path = extends.Location; #endif diff --git a/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs b/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs index 82244fa..63b363a 100644 --- a/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonReaderExtensions.cs @@ -1,7 +1,12 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using System.Text.RegularExpressions; using ICD.Common.Properties; -using Newtonsoft.Json; namespace ICD.Common.Utils.Extensions { diff --git a/ICD.Common.Utils/Extensions/JsonSerializerExtensions.cs b/ICD.Common.Utils/Extensions/JsonSerializerExtensions.cs index 7fea6ab..26e2658 100644 --- a/ICD.Common.Utils/Extensions/JsonSerializerExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonSerializerExtensions.cs @@ -1,8 +1,13 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using System.Collections.Generic; using System.Linq; using ICD.Common.Properties; -using Newtonsoft.Json; namespace ICD.Common.Utils.Extensions { diff --git a/ICD.Common.Utils/Extensions/JsonTokenExtensions.cs b/ICD.Common.Utils/Extensions/JsonTokenExtensions.cs index a2ab88f..baff6f2 100644 --- a/ICD.Common.Utils/Extensions/JsonTokenExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonTokenExtensions.cs @@ -1,5 +1,10 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else using Newtonsoft.Json; +#endif +using System; namespace ICD.Common.Utils.Extensions { diff --git a/ICD.Common.Utils/Extensions/JsonWriterExtensions.cs b/ICD.Common.Utils/Extensions/JsonWriterExtensions.cs index f33ab43..52d3ef2 100644 --- a/ICD.Common.Utils/Extensions/JsonWriterExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonWriterExtensions.cs @@ -1,6 +1,11 @@ -using System; -using ICD.Common.Properties; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else using Newtonsoft.Json; +#endif +using System; +using ICD.Common.Properties; namespace ICD.Common.Utils.Extensions { diff --git a/ICD.Common.Utils/ICD.Common.Utils_NetStandard.csproj b/ICD.Common.Utils/ICD.Common.Utils_NetStandard.csproj index 3d00ca3..66d1d29 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_NetStandard.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_NetStandard.csproj @@ -5,24 +5,19 @@ Library netstandard2.0;net472 ICD.Common.Utils - $(AssemblyName) + ICD.Common.Utils false true - Chris Cameron, Jeff Thompson - ICD.Common.Utils - - https://cs-gogs.icdpf.net/Common/Utils - git MSBuild Release 2018.2 - TRACE;DEBUG;STANDARD + TRACE;DEBUG binNetCoreApp\$(Configuration)\ - TRACE;STANDARD + TRACE @@ -39,10 +34,12 @@ + + + - @@ -57,5 +54,4 @@ PreserveNewest - \ No newline at end of file diff --git a/ICD.Common.Utils/IO/IcdDirectory.cs b/ICD.Common.Utils/IO/IcdDirectory.cs index 36a3f05..3c22018 100644 --- a/ICD.Common.Utils/IO/IcdDirectory.cs +++ b/ICD.Common.Utils/IO/IcdDirectory.cs @@ -30,7 +30,7 @@ namespace ICD.Common.Utils.IO #if SIMPLSHARP return Directory.GetApplicationRootDirectory(); #else - return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetPath()); + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetPath()); #endif } diff --git a/ICD.Common.Utils/IO/IcdFile.cs b/ICD.Common.Utils/IO/IcdFile.cs index a188171..e760508 100644 --- a/ICD.Common.Utils/IO/IcdFile.cs +++ b/ICD.Common.Utils/IO/IcdFile.cs @@ -127,7 +127,7 @@ namespace ICD.Common.Utils.IO File.Move(sourceFileName, destFileName); } -#if STANDARD +#if !SIMPLSHARP public static void SetAttributes(string path, FileAttributes attributes, bool recursive) { File.SetAttributes(path, attributes); diff --git a/ICD.Common.Utils/IO/IcdStreamReader.cs b/ICD.Common.Utils/IO/IcdStreamReader.cs index 772d65f..cd6c5f3 100644 --- a/ICD.Common.Utils/IO/IcdStreamReader.cs +++ b/ICD.Common.Utils/IO/IcdStreamReader.cs @@ -1,7 +1,7 @@ using System; #if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; -#elif STANDARD +#else using System.IO; #endif diff --git a/ICD.Common.Utils/IO/IcdStreamWriter.cs b/ICD.Common.Utils/IO/IcdStreamWriter.cs index 78b7eae..b04d256 100644 --- a/ICD.Common.Utils/IO/IcdStreamWriter.cs +++ b/ICD.Common.Utils/IO/IcdStreamWriter.cs @@ -1,6 +1,6 @@ #if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; -#elif STANDARD +#else using System.IO; #endif diff --git a/ICD.Common.Utils/IcdConsole.cs b/ICD.Common.Utils/IcdConsole.cs index 98c05bf..38217f3 100644 --- a/ICD.Common.Utils/IcdConsole.cs +++ b/ICD.Common.Utils/IcdConsole.cs @@ -4,7 +4,7 @@ using System.Text.RegularExpressions; using ICD.Common.Properties; using ICD.Common.Utils.EventArguments; using ICD.Common.Utils.Extensions; -#if SIMPLSHARP +#if !NETSTANDARD using Crestron.SimplSharp; #else using System.Diagnostics; @@ -99,7 +99,7 @@ namespace ICD.Common.Utils message = FixLineEndings(message); -#if SIMPLSHARP +#if !NETSTANDARD if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance) { try @@ -125,7 +125,7 @@ namespace ICD.Common.Utils try { -#if SIMPLSHARP +#if !NETSTANDARD if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) CrestronConsole.PrintLine(fixedMessage); #else @@ -169,7 +169,7 @@ namespace ICD.Common.Utils try { -#if SIMPLSHARP +#if !NETSTANDARD if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) CrestronConsole.Print(fixedMessage); #else @@ -207,7 +207,7 @@ namespace ICD.Common.Utils public static bool SendControlSystemCommand(string command, ref string result) { -#if SIMPLSHARP +#if !NETSTANDARD // No console on VC4 if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) return false; @@ -220,7 +220,7 @@ namespace ICD.Common.Utils public static bool AddNewConsoleCommand(Action callback, string command, string help, eAccessLevel accessLevel) { -#if SIMPLSHARP +#if !NETSTANDARD // Avoid crashing Simpl applications if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Appliance) return false; diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs index 77344f0..7015f6f 100644 --- a/ICD.Common.Utils/IcdEnvironment.Standard.cs +++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs @@ -1,14 +1,17 @@ -#if STANDARD +#if !SIMPLSHARP using System; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Net.NetworkInformation; -using System.Net.Sockets; using System.Text.RegularExpressions; using ICD.Common.Properties; using ICD.Common.Utils.EventArguments; using ICD.Common.Utils.Timers; +using AddressFamily = System.Net.Sockets.AddressFamily; +using Dns = System.Net.Dns; +#if !NETSTANDARD +using Crestron.SimplSharp; +#endif namespace ICD.Common.Utils { @@ -107,8 +110,18 @@ namespace ICD.Common.Utils static IcdEnvironment() { s_Framework = eFramework.Standard; +#if NETFRAMEWORK + s_CrestronSeries = eCrestronSeries.FourSeries; + if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SIMPL) + s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Simpl; + else if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Appliance; + else + s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Server; +#else s_CrestronSeries = eCrestronSeries.Na; s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Na; +#endif } /// @@ -172,6 +185,7 @@ namespace ICD.Common.Utils handler(sessionId, reasonCode); } + /// /// Call this method to raise the device added/removed event for an added device /// Uses a timer to attempt to compress multiple events into a single event /// diff --git a/ICD.Common.Utils/IcdErrorLog.cs b/ICD.Common.Utils/IcdErrorLog.cs index 6ca2607..ca7549a 100644 --- a/ICD.Common.Utils/IcdErrorLog.cs +++ b/ICD.Common.Utils/IcdErrorLog.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using ICD.Common.Properties; -#if SIMPLSHARP +#if !NETSTANDARD using Crestron.SimplSharp; #else using System.Diagnostics; @@ -32,7 +32,7 @@ namespace ICD.Common.Utils private static readonly Dictionary> s_LogMethods = new Dictionary> { -#if SIMPLSHARP +#if !NETSTANDARD {ERROR, (m, e) => ErrorLog.Error(m)}, {WARN, (m, e) => ErrorLog.Warn(m)}, {NOTICE, (m, e) => ErrorLog.Notice(m)}, diff --git a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs index f70a137..834a0af 100644 --- a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs +++ b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs @@ -1,7 +1,12 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; -using Newtonsoft.Json; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/Json/DateTimeIsoConverter.cs b/ICD.Common.Utils/Json/DateTimeIsoConverter.cs index 0d95337..ea018ed 100644 --- a/ICD.Common.Utils/Json/DateTimeIsoConverter.cs +++ b/ICD.Common.Utils/Json/DateTimeIsoConverter.cs @@ -1,6 +1,11 @@ -using System; -using ICD.Common.Utils.Extensions; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else using Newtonsoft.Json; +#endif +using System; +using ICD.Common.Utils.Extensions; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/Json/JsonItemWrapper.cs b/ICD.Common.Utils/Json/JsonItemWrapper.cs index 5dd9944..d087387 100644 --- a/ICD.Common.Utils/Json/JsonItemWrapper.cs +++ b/ICD.Common.Utils/Json/JsonItemWrapper.cs @@ -1,7 +1,12 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; -using Newtonsoft.Json; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/Json/JsonUtils.cs b/ICD.Common.Utils/Json/JsonUtils.cs index e48068b..f69d6fd 100644 --- a/ICD.Common.Utils/Json/JsonUtils.cs +++ b/ICD.Common.Utils/Json/JsonUtils.cs @@ -1,10 +1,15 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using System.Linq; using System.Text; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO; -using Newtonsoft.Json; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/Json/MinimalTypeConverter.cs b/ICD.Common.Utils/Json/MinimalTypeConverter.cs index e11c1b0..f57fc1d 100644 --- a/ICD.Common.Utils/Json/MinimalTypeConverter.cs +++ b/ICD.Common.Utils/Json/MinimalTypeConverter.cs @@ -1,6 +1,11 @@ -using System; -using ICD.Common.Utils.Extensions; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else using Newtonsoft.Json; +#endif +using System; +using ICD.Common.Utils.Extensions; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/Json/ToStringJsonConverter.cs b/ICD.Common.Utils/Json/ToStringJsonConverter.cs index 67f161e..1d489e0 100644 --- a/ICD.Common.Utils/Json/ToStringJsonConverter.cs +++ b/ICD.Common.Utils/Json/ToStringJsonConverter.cs @@ -1,4 +1,10 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +#else +using Newtonsoft.Json; +#endif +using System; using System.Collections.Generic; #if SIMPLSHARP using Crestron.SimplSharp.Reflection; @@ -7,7 +13,6 @@ using System.Reflection; using System.Runtime.ExceptionServices; #endif using ICD.Common.Properties; -using Newtonsoft.Json; namespace ICD.Common.Utils.Json { diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index cae0434..a87d335 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -62,7 +62,7 @@ namespace ICD.Common.Utils { get { -#if SIMPLSHARP +#if !NETSTANDARD switch (IcdEnvironment.CrestronSeries) { case IcdEnvironment.eCrestronSeries.FourSeries: diff --git a/ICD.Common.Utils/Services/Logging/ILoggerService.cs b/ICD.Common.Utils/Services/Logging/ILoggerService.cs index 2bc8554..0c1fac3 100644 --- a/ICD.Common.Utils/Services/Logging/ILoggerService.cs +++ b/ICD.Common.Utils/Services/Logging/ILoggerService.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -#if STANDARD +#if !SIMPLSHARP using System.Text; #endif using ICD.Common.Properties; @@ -106,7 +106,7 @@ namespace ICD.Common.Utils.Services.Logging if (e == null) throw new ArgumentNullException("e"); -#if STANDARD +#if !SIMPLSHARP if (e is AggregateException) { extends.AddEntry(severity, e as AggregateException, message); @@ -117,7 +117,7 @@ namespace ICD.Common.Utils.Services.Logging IcdEnvironment.NewLine, e.Message, e.StackTrace)); } -#if STANDARD +#if !SIMPLSHARP /// /// Logs an aggregate exception as a formatted list of inner exceptions. /// diff --git a/ICD.Common.Utils/Services/Logging/LogItem.cs b/ICD.Common.Utils/Services/Logging/LogItem.cs index c4f9784..9e4dd09 100644 --- a/ICD.Common.Utils/Services/Logging/LogItem.cs +++ b/ICD.Common.Utils/Services/Logging/LogItem.cs @@ -1,6 +1,12 @@ -using System; +#if NETFRAMEWORK +extern alias RealNewtonsoft; +using RealNewtonsoft.Newtonsoft.Json; +using RealNewtonsoft.Newtonsoft.Json.Converters; +#else using Newtonsoft.Json; using Newtonsoft.Json.Converters; +#endif +using System; namespace ICD.Common.Utils.Services.Logging { diff --git a/ICD.Common.Utils/Xml/IcdXmlTextWriter.cs b/ICD.Common.Utils/Xml/IcdXmlTextWriter.cs index deff604..bae875d 100644 --- a/ICD.Common.Utils/Xml/IcdXmlTextWriter.cs +++ b/ICD.Common.Utils/Xml/IcdXmlTextWriter.cs @@ -3,7 +3,6 @@ using System.Text; using ICD.Common.Utils.IO; #if SIMPLSHARP using Crestron.SimplSharp.CrestronXml; - #else using System.Xml; #endif @@ -147,7 +146,7 @@ namespace ICD.Common.Utils.Xml #region Private Methods -#if STANDARD +#if !SIMPLSHARP private static XmlWriterSettings GetSettings(Encoding encoding) { XmlWriterSettings output = GetSettings();