diff --git a/src/Exceptionless.Portable/Exceptionless.Portable.csproj b/src/Exceptionless.Portable/Exceptionless.Portable.csproj deleted file mode 100644 index 573973f1..00000000 --- a/src/Exceptionless.Portable/Exceptionless.Portable.csproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - - netstandard2.0 - - - netstandard2.0;portable46-net451+win81+wpa81;net45 - - - - Exceptionless.Portable - Exceptionless.Portable - [DEPRECATED] Exceptionless Portable Class Library - [DEPRECATED] Please install the Exceptionless package instead. - Exceptionless;Error;Report;Reporting;Exception;Logging;Log;ELMAH;pcl - - - - - - - - - - - - .NETPortable - v4.6 - Profile151 - $(DefineConstants);PORTABLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Exceptionless.Portable/readme.txt b/src/Exceptionless.Portable/readme.txt deleted file mode 100644 index de88f48a..00000000 --- a/src/Exceptionless.Portable/readme.txt +++ /dev/null @@ -1 +0,0 @@ -The Exceptionless.Portable package has been deprecated. Please install the Exceptionless package. \ No newline at end of file diff --git a/src/Exceptionless/Configuration/CertificateData.cs b/src/Exceptionless/Configuration/CertificateData.cs index 0b15333f..593c8c95 100644 --- a/src/Exceptionless/Configuration/CertificateData.cs +++ b/src/Exceptionless/Configuration/CertificateData.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System.Net.Http; +using System.Net.Http; using System.Net.Security; using System.Security.Cryptography.X509Certificates; @@ -45,12 +44,11 @@ private CertificateData(X509Chain chain, SslPolicyErrors sslPolicyErrors) { public object Sender { get; } #endif -#if !NET45 && !PORTABLE && !NETSTANDARD1_2 +#if !NET45 /// /// The request which was sent to the remore party /// public HttpRequestMessage Request { get; } #endif } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Configuration/ExceptionlessConfiguration.cs b/src/Exceptionless/Configuration/ExceptionlessConfiguration.cs index d38402f7..f8ee163e 100644 --- a/src/Exceptionless/Configuration/ExceptionlessConfiguration.cs +++ b/src/Exceptionless/Configuration/ExceptionlessConfiguration.cs @@ -1,7 +1,5 @@ using System; -#if !PORTABLE using System.Collections.Concurrent; -#endif using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -20,14 +18,9 @@ public class ExceptionlessConfiguration { private const string DEFAULT_HEARTBEAT_SERVER_URL = "https://heartbeat.exceptionless.io"; private const string DEFAULT_USER_AGENT = "exceptionless/"; private static readonly Lazy _version = new Lazy(() => { - #if !PORTABLE var assembly = Assembly.GetExecutingAssembly(); var attribute = assembly.GetCustomAttribute(); return attribute.Version; - #else - // NOTE: This is hard coded for a single release. The next release will deprecate portable. - return "4.4.0.0"; - #endif }); private const int DEFAULT_SUBMISSION_BATCH_SIZE = 50; @@ -167,7 +160,7 @@ public string ApiKey { /// Whether the client is currently enabled or not. If it is disabled, submitted errors will be discarded and no data will be sent to the server. /// public bool Enabled { get; set; } - + /// /// Maximum time (provided in days) that the queue will persist events /// @@ -194,7 +187,7 @@ public string ApiKey { public SettingsDictionary Settings { get; private set; } /// - /// How often the client should check for updated server settings when idle. The default is every 2 minutes. + /// How often the client should check for updated server settings when idle. The default is every 2 minutes. /// public TimeSpan? UpdateSettingsWhenIdleInterval { get { return _updateSettingsWhenIdleInterval; } @@ -287,12 +280,10 @@ public int SubmissionBatchSize { } } -#if !PORTABLE && !NETSTANDARD1_2 /// /// Callback which is invoked to validate the exceptionless server certificate. /// public Func ServerCertificateValidationCallback { get; set; } -#endif /// /// A list of exclusion patterns that will automatically remove any data that matches them from any data submitted to the server. @@ -372,11 +363,7 @@ public void AddEventExclusion(Func eventExclusionCallback) { #region Plugins -#if !PORTABLE private readonly ConcurrentDictionary _plugins = new ConcurrentDictionary(); -#else - private readonly Dictionary _plugins = new Dictionary(); -#endif /// /// The list of plugins that will be used in this configuration. @@ -394,12 +381,8 @@ public void AddPlugin(T plugin) where T : IEventPlugin { string key = typeof(T).FullName; RemovePlugin(key); -#if !PORTABLE if (!_plugins.TryAdd(key, new PluginRegistration(key, GetPriority(typeof(T)), new Lazy(() => plugin)))) Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key)); -#else - _plugins[key] = new PluginRegistration(key, GetPriority(typeof(T)), new Lazy(() => plugin)); -#endif } /// @@ -419,12 +402,8 @@ public void AddPlugin(string key, Type pluginType) { RemovePlugin(key); var plugin = new PluginRegistration(key, GetPriority(pluginType), new Lazy(() => Resolver.Resolve(pluginType) as IEventPlugin)); -#if !PORTABLE if (!_plugins.TryAdd(key, plugin)) Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key)); -#else - _plugins[key] = plugin; -#endif } /// @@ -446,12 +425,8 @@ public void AddPlugin(string key, int priority, Func(() => factory(this))); -#if !PORTABLE if (!_plugins.TryAdd(key, plugin)) Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key)); -#else - _plugins[key] = plugin; -#endif } /// @@ -479,14 +454,10 @@ public void AddPlugin(string key, Action pluginAction) { /// The plugin action to run. public void AddPlugin(string key, int priority, Action pluginAction) { RemovePlugin(key); - + var plugin = new PluginRegistration(key, priority, new Lazy(() => new ActionPlugin(pluginAction))); -#if !PORTABLE if (!_plugins.TryAdd(key, plugin)) Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key)); -#else - _plugins[key] = plugin; -#endif } /// @@ -502,16 +473,9 @@ public void RemovePlugin() where T : IEventPlugin { /// /// The key for the plugin to be removed. public void RemovePlugin(string key) { -#if !PORTABLE PluginRegistration plugin; if (_plugins.TryRemove(key, out plugin)) plugin.Dispose(); -#else - if (_plugins.ContainsKey(key)) { - _plugins[key].Dispose(); - _plugins.Remove(key); - } -#endif } private int GetPriority(Type type) { diff --git a/src/Exceptionless/Configuration/ExceptionlessSection.cs b/src/Exceptionless/Configuration/ExceptionlessSection.cs index ea138a9f..9209a1ff 100644 --- a/src/Exceptionless/Configuration/ExceptionlessSection.cs +++ b/src/Exceptionless/Configuration/ExceptionlessSection.cs @@ -1,4 +1,4 @@ -#if !PORTABLE && !NETSTANDARD +#if !NETSTANDARD using System; using System.ComponentModel; using System.Configuration; @@ -10,7 +10,7 @@ internal class ExceptionlessSection : ConfigurationSection { [ConfigurationProperty("apiKey", IsRequired = true)] public string ApiKey { get { return base["apiKey"] as string; } set { base["apiKey"] = value; } } - + [ConfigurationProperty("serverUrl")] public string ServerUrl { get { return base["serverUrl"] as string; } set { base["serverUrl"] = value; } } diff --git a/src/Exceptionless/Exceptionless.csproj b/src/Exceptionless/Exceptionless.csproj index 30a340f2..9cd1aa1b 100644 --- a/src/Exceptionless/Exceptionless.csproj +++ b/src/Exceptionless/Exceptionless.csproj @@ -5,15 +5,14 @@ netstandard2.0 - netstandard2.0;portable46-net451+win81+wpa81;net45 + netstandard2.0;net45 Exceptionless Exceptionless Exceptionless client for non visual (ie. Console and Services) applications. - Exceptionless client for portable applications. $(Description) - Exceptionless;Error;Report;Reporting;Exception;Logging;Log;ELMAH;pcl;NETSTANDARD;Core + Exceptionless;Error;Report;Reporting;Exception;Logging;Log;ELMAH;NETSTANDARD;Core @@ -39,48 +38,6 @@ - - .NETPortable - v4.6 - Profile151 - $(DefineConstants);PORTABLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);NET45 diff --git a/src/Exceptionless/Extensions/EventBuilderExtensions.cs b/src/Exceptionless/Extensions/EventBuilderExtensions.cs index dcb841d1..72e62fb9 100644 --- a/src/Exceptionless/Extensions/EventBuilderExtensions.cs +++ b/src/Exceptionless/Extensions/EventBuilderExtensions.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using Exceptionless.Models.Data; - -#if !PORTABLE && !NETSTANDARD1_2 using Exceptionless.Plugins.Default; -#endif namespace Exceptionless { public static class EventBuilderExtensions { @@ -102,7 +99,6 @@ public static EventBuilder SetManualStackingKey(this EventBuilder builder, strin return builder; } -#if !PORTABLE && !NETSTANDARD1_2 /// /// Adds the recent trace log entries to the event. /// @@ -113,6 +109,5 @@ public static EventBuilder AddRecentTraceLogEntries(this EventBuilder builder, D TraceLogPlugin.AddRecentTraceLogEntries(builder.Target, listener, maxEntriesToInclude); return builder; } -#endif } } \ No newline at end of file diff --git a/src/Exceptionless/Extensions/ExceptionlessClientExtensions.cs b/src/Exceptionless/Extensions/ExceptionlessClientExtensions.cs index e7466663..0710073c 100644 --- a/src/Exceptionless/Extensions/ExceptionlessClientExtensions.cs +++ b/src/Exceptionless/Extensions/ExceptionlessClientExtensions.cs @@ -23,20 +23,15 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null client.Configuration.ApiKey = apiKey; client.Configuration.ReadAllConfig(); - -#if !PORTABLE && !NETSTANDARD1_2 client.Configuration.UseTraceLogEntriesPlugin(); -#endif if (client.Configuration.UpdateSettingsWhenIdleInterval == null) client.Configuration.UpdateSettingsWhenIdleInterval = TimeSpan.FromMinutes(2); -#if !PORTABLE && !NETSTANDARD1_2 client.RegisterAppDomainUnhandledExceptionHandler(); // make sure that queued events are sent when the app exits client.RegisterOnProcessExitHandler(); -#endif client.RegisterTaskSchedulerUnobservedTaskExceptionHandler(); if (client.Configuration.SessionsEnabled) @@ -51,10 +46,8 @@ public static void Shutdown(this ExceptionlessClient client) { if (client == null) throw new ArgumentNullException(nameof(client)); -#if !PORTABLE && !NETSTANDARD1_2 client.UnregisterAppDomainUnhandledExceptionHandler(); client.UnregisterOnProcessExitHandler(); -#endif client.UnregisterTaskSchedulerUnobservedTaskExceptionHandler(); client.ProcessQueue(); @@ -349,7 +342,6 @@ public static void SubmitSessionHeartbeat(this ExceptionlessClient client, strin namespace Exceptionless.Extensions { public static class ExceptionlessClientExtensions { -#if !PORTABLE && !NETSTANDARD1_2 private static UnhandledExceptionEventHandler _onAppDomainUnhandledException; public static void RegisterAppDomainUnhandledExceptionHandler(this ExceptionlessClient client) { if (client == null) @@ -426,7 +418,6 @@ public static void UnregisterOnProcessExitHandler(this ExceptionlessClient clien AppDomain.CurrentDomain.ProcessExit -= _onProcessExit; _onProcessExit = null; } -#endif private static EventHandler _onTaskSchedulerOnUnobservedTaskException; public static void RegisterTaskSchedulerUnobservedTaskExceptionHandler(this ExceptionlessClient client) { diff --git a/src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs b/src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs index 49d52559..558e52ab 100644 --- a/src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs +++ b/src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Net.Security; using System.Reflection; using Exceptionless.Configuration; using Exceptionless.Dependency; @@ -12,11 +13,7 @@ using Exceptionless.Models.Data; using Exceptionless.Serializer; using Exceptionless.Storage; - -#if !PORTABLE && !NETSTANDARD1_2 using Exceptionless.Diagnostics; -using System.Net.Security; -#endif #if NET45 using System.Configuration; @@ -155,11 +152,10 @@ public static void ReadFromAttributes(this ExceptionlessConfiguration config, IC if (assemblies == null) { Assembly callingAssembly = null; -#if NET45 || NETSTANDARD2_0 try { callingAssembly = Assembly.GetCallingAssembly(); } catch (PlatformNotSupportedException) { } -#endif + assemblies = new List { callingAssembly }; } @@ -213,7 +209,6 @@ public static void UseInMemoryStorage(this ExceptionlessConfiguration config) { config.Resolver.Register(); } -#if !PORTABLE && !NETSTANDARD1_2 public static void UseTraceLogger(this ExceptionlessConfiguration config, LogLevel minLogLevel = null) { config.Resolver.Register(new TraceExceptionlessLog { MinimumLogLevel = minLogLevel ?? LogLevel.Info }); } @@ -242,7 +237,6 @@ public static void UseTraceLogEntriesPlugin(this ExceptionlessConfiguration conf config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), ex, String.Concat("Error adding ExceptionlessTraceListener: ", ex.Message)); } } -#endif #if NET45 public static void UseIsolatedStorageLogger(this ExceptionlessConfiguration config, LogLevel minLogLevel = null) { @@ -257,28 +251,22 @@ public static void UseIsolatedStorage(this ExceptionlessConfiguration config) { public static void ReadAllConfig(this ExceptionlessConfiguration config, params Assembly[] configAttributesAssemblies) { if (configAttributesAssemblies == null || configAttributesAssemblies.Length == 0) { -#if NETSTANDARD1_5 - config.ReadFromAttributes(Assembly.GetEntryAssembly()); -#elif NET45 || NETSTANDARD2_0 Assembly callingAssembly = null; try { callingAssembly = Assembly.GetCallingAssembly(); } catch (PlatformNotSupportedException) { } config.ReadFromAttributes(Assembly.GetEntryAssembly(), callingAssembly); -#endif } else { config.ReadFromAttributes(configAttributesAssemblies); } -#if !PORTABLE && !NETSTANDARD +#if !NETSTANDARD config.ReadFromConfigSection(); config.ReadFromAppSettings(); #endif -#if !PORTABLE && !NETSTANDARD1_2 config.ReadFromEnvironmentalVariables(); -#endif config.ApplySavedServerSettings(); } @@ -402,7 +390,6 @@ public static void ReadFromAppSettings(this ExceptionlessConfiguration config) { } #endif -#if !PORTABLE && !NETSTANDARD1_2 /// /// Reads the Exceptionless configuration from Environment Variables. /// @@ -441,9 +428,7 @@ private static string GetEnvironmentalVariable(string name) { return _environmentVariables[name]; } -#endif -#if !PORTABLE && !NETSTANDARD1_2 /// /// Add a custom server certificate validation against the thumbprint of the server certificate. /// @@ -481,7 +466,6 @@ public static void TrustCAThumbprint(this ExceptionlessConfiguration config, str public static void SkipCertificateValidation(this ExceptionlessConfiguration config) { config.ServerCertificateValidationCallback = x => true; } -#endif private static bool IsValidApiKey(string apiKey) { return !String.IsNullOrEmpty(apiKey) && apiKey != "API_KEY_HERE"; diff --git a/src/Exceptionless/Extensions/ReflectionExtensions.cs b/src/Exceptionless/Extensions/ReflectionExtensions.cs index a93284f7..bd3715ae 100644 --- a/src/Exceptionless/Extensions/ReflectionExtensions.cs +++ b/src/Exceptionless/Extensions/ReflectionExtensions.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.IO; using System.Reflection; @@ -14,21 +13,17 @@ public static AssemblyName GetAssemblyName(this Assembly assembly) { } public static DateTime? GetCreationTime(this Assembly assembly) { -#if NET45 || NETSTANDARD1_5 || NETSTANDARD2_0 try { return File.GetCreationTimeUtc(assembly.Location); } catch {} -#endif return null; } public static DateTime? GetLastWriteTime(this Assembly assembly) { -#if NET45 || NETSTANDARD1_5 || NETSTANDARD2_0 try { return File.GetLastWriteTimeUtc(assembly.Location); } catch {} -#endif return null; } @@ -50,11 +45,10 @@ public static string GetInformationalVersion(this Assembly assembly) { var attr = assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; return attr != null ? attr.InformationalVersion : null; } - + public static string GetCompany(this Assembly assembly) { var attr = assembly.GetCustomAttribute(typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute; return attr != null ? attr.Company : null; } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Extensions/ToErrorModelExtensions.cs b/src/Exceptionless/Extensions/ToErrorModelExtensions.cs index b1f7c4be..56f5ca16 100644 --- a/src/Exceptionless/Extensions/ToErrorModelExtensions.cs +++ b/src/Exceptionless/Extensions/ToErrorModelExtensions.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; @@ -20,7 +19,7 @@ internal static class ToErrorModelExtensions { private static readonly ConcurrentDictionary _moduleCache = new ConcurrentDictionary(); private static readonly string[] _exceptionExclusions = { "@exceptionless", "Data", "HelpLink", "ExceptionContext", "InnerExceptions", "InnerException", "Errors", "Types", - "Message", "Source", "StackTrace", "TargetSite", "HResult", + "Message", "Source", "StackTrace", "TargetSite", "HResult", "Entries", "StateEntries", "PersistedState", "Results" }; @@ -58,7 +57,7 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie if (info != null) error.Code = info.GetValue(exception, null).ToString(); } catch (Exception) { } - + #if NET45 try { if (exception.TargetSite != null) { @@ -141,14 +140,12 @@ private static string GetMessage(this Exception exception) { private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false) { var modules = new ModuleCollection(); -#if !PORTABLE && !NETSTANDARD1_2 try { int id = 1; foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (!includeDynamic && assembly.IsDynamic) continue; -#if !NETSTANDARD1_3 && !NETSTANDARD1_4 try { if (!includeDynamic && String.IsNullOrEmpty(assembly.Location)) continue; @@ -156,7 +153,6 @@ private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool inc const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust."; log.Error(typeof(ExceptionlessClient), ex, message); } -#endif if (!includeSystem) { try { @@ -179,7 +175,7 @@ private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool inc } catch (Exception ex) { log.Error(typeof(ExceptionlessClient), ex, "Error loading modules: " + ex.Message); } -#endif + return modules; } @@ -226,11 +222,9 @@ private static void PopulateMethod(this Method method, Error root, MethodBase me method.Name = methodBase.Name; if (methodBase.DeclaringType != null) { method.DeclaringNamespace = methodBase.DeclaringType.Namespace; -#if NET45 || NETSTANDARD1_5 || NETSTANDARD2_0 if (methodBase.DeclaringType.GetTypeInfo().MemberType == MemberTypes.NestedType && methodBase.DeclaringType.DeclaringType != null) method.DeclaringType = methodBase.DeclaringType.DeclaringType.Name + "+" + methodBase.DeclaringType.Name; else -#endif method.DeclaringType = methodBase.DeclaringType.Name; } @@ -306,13 +300,11 @@ public static Module ToModuleInfo(this Assembly assembly) { if (lastWriteTime.HasValue) mod.ModifiedDate = lastWriteTime.Value; -#if NET45 || NETSTANDARD1_5 || NETSTANDARD2_0 if (assembly == Assembly.GetEntryAssembly()) mod.IsEntry = true; -#endif + return mod; }); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Extensions/TypeExtensions.cs b/src/Exceptionless/Extensions/TypeExtensions.cs index 9dc27861..ad9ea27b 100644 --- a/src/Exceptionless/Extensions/TypeExtensions.cs +++ b/src/Exceptionless/Extensions/TypeExtensions.cs @@ -5,89 +5,6 @@ namespace Exceptionless.Extensions { internal static class TypeExtensions { -#if PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 - [Flags] - internal enum BindingFlags { - Default = 0, - IgnoreCase = 1, - DeclaredOnly = 2, - Instance = 4, - Static = 8, - Public = 16, - NonPublic = 32, - FlattenHierarchy = 64, - InvokeMethod = 256, - CreateInstance = 512, - GetField = 1024, - SetField = 2048, - GetProperty = 4096, - SetProperty = 8192, - PutDispProperty = 16384, - ExactBinding = 65536, - PutRefDispProperty = 32768, - SuppressChangeType = 131072, - OptionalParamBinding = 262144, - IgnoreReturn = 16777216 - } - - public static Type[] GetGenericArguments(this Type type) { - return type.GetTypeInfo().GenericTypeArguments; - } - - public static IEnumerable GetInterfaces(this Type type) { - return type.GetTypeInfo().ImplementedInterfaces; - } - - public static PropertyInfo GetProperty(this Type type, string name) { - return type.GetTypeInfo().GetDeclaredProperty(name); - } - - public static IEnumerable GetProperties(this Type type, BindingFlags bindingFlags) { - IList properties = (bindingFlags.HasFlag(BindingFlags.DeclaredOnly)) - ? type.GetTypeInfo().DeclaredProperties.ToList() - : type.GetTypeInfo().GetPropertiesRecursive(); - - return properties.Where(p => TestAccessibility(p, bindingFlags)); - } - - private static IList GetPropertiesRecursive(this TypeInfo type) { - TypeInfo t = type; - IList properties = new List(); - while (t != null) { - foreach (PropertyInfo member in t.DeclaredProperties) { - if (!properties.Any(p => p.Name == member.Name)) { - properties.Add(member); - } - } - t = (t.BaseType != null) ? t.BaseType.GetTypeInfo() : null; - } - - return properties; - } - - private static bool TestAccessibility(PropertyInfo member, BindingFlags bindingFlags) { - if (member.GetMethod != null && TestAccessibility(member.GetMethod, bindingFlags)) { - return true; - } - - if (member.SetMethod != null && TestAccessibility(member.SetMethod, bindingFlags)) { - return true; - } - - return false; - } - - private static bool TestAccessibility(MethodBase member, BindingFlags bindingFlags) { - bool visibility = (member.IsPublic && bindingFlags.HasFlag(BindingFlags.Public)) || - (!member.IsPublic && bindingFlags.HasFlag(BindingFlags.NonPublic)); - - bool instance = (member.IsStatic && bindingFlags.HasFlag(BindingFlags.Static)) || - (!member.IsStatic && bindingFlags.HasFlag(BindingFlags.Instance)); - - return visibility && instance; - } -#endif - public static PropertyInfo[] GetPublicProperties(this Type type) { if (type.GetTypeInfo().IsInterface) { var propertyInfos = new List(); @@ -118,7 +35,7 @@ public static PropertyInfo[] GetPublicProperties(this Type type) { return type.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance).ToArray(); } - + public static object GetDefaultValue(this Type type) { if (type == null || type.IsNullable()) return null; @@ -184,12 +101,12 @@ public static bool IsPrimitiveType(this Type type) { return false; } - + public static bool IsNumeric(this Type type) { if (type.IsArray) return false; - return type == typeof(sbyte) + return type == typeof(sbyte) || type == typeof(short) || type == typeof(ushort) || type == typeof(int) diff --git a/src/Exceptionless/Logging/FileExceptionlessLog.cs b/src/Exceptionless/Logging/FileExceptionlessLog.cs index 7c941a44..d6efd217 100644 --- a/src/Exceptionless/Logging/FileExceptionlessLog.cs +++ b/src/Exceptionless/Logging/FileExceptionlessLog.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Concurrent; using System.IO; using System.Text; @@ -126,7 +125,7 @@ public void Flush() { if (_isFlushing || _buffer.IsEmpty) return; - + try { _isFlushing = true; @@ -239,7 +238,7 @@ internal void CheckFileSize() { } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exceptionless: Error rewriting the log file after trimming it: {0}", ex.Message); } - + _isCheckingFileSize = false; } @@ -302,5 +301,4 @@ public LogEntry(LogLevel level, string message) { public string Message { get; set; } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Logging/TraceExceptionlessLog.cs b/src/Exceptionless/Logging/TraceExceptionlessLog.cs index 852ac2a4..a222aec9 100644 --- a/src/Exceptionless/Logging/TraceExceptionlessLog.cs +++ b/src/Exceptionless/Logging/TraceExceptionlessLog.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; namespace Exceptionless.Logging { public class TraceExceptionlessLog : IExceptionlessLog { @@ -32,5 +31,4 @@ public void Trace(string message, string source = null) { public void Flush() { } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Models/Client/Data/Method.cs b/src/Exceptionless/Models/Client/Data/Method.cs index 787591df..c338b788 100644 --- a/src/Exceptionless/Models/Client/Data/Method.cs +++ b/src/Exceptionless/Models/Client/Data/Method.cs @@ -34,11 +34,7 @@ public override bool Equals(object obj) { return Equals((Method)obj); } -#if PORTABLE - private static readonly ISet _exclusions = new HashSet(StringComparer.OrdinalIgnoreCase) { "ILOffset", "NativeOffset" }; -#else private static readonly ISet _exclusions = new HashSet(StringComparer.InvariantCultureIgnoreCase) { "ILOffset", "NativeOffset" }; -#endif public override int GetHashCode() { unchecked { diff --git a/src/Exceptionless/Models/Client/Data/RequestInfo.cs b/src/Exceptionless/Models/Client/Data/RequestInfo.cs index 423f608d..b79f8494 100644 --- a/src/Exceptionless/Models/Client/Data/RequestInfo.cs +++ b/src/Exceptionless/Models/Client/Data/RequestInfo.cs @@ -83,11 +83,7 @@ public override bool Equals(object obj) { return Equals((RequestInfo)obj); } -#if PORTABLE - private static readonly ISet _cookieHashCodeExclusions = new HashSet(StringComparer.OrdinalIgnoreCase) { "__LastReferenceId" }; -#else private static readonly ISet _cookieHashCodeExclusions = new HashSet(StringComparer.InvariantCultureIgnoreCase) { "__LastReferenceId" }; -#endif public override int GetHashCode() { unchecked { diff --git a/src/Exceptionless/Models/Client/Event.cs b/src/Exceptionless/Models/Client/Event.cs index 3a809719..7e6e02ad 100644 --- a/src/Exceptionless/Models/Client/Event.cs +++ b/src/Exceptionless/Models/Client/Event.cs @@ -72,11 +72,7 @@ public override bool Equals(object obj) { return Equals((Event)obj); } -#if PORTABLE - private static readonly ISet _exclusions = new HashSet(StringComparer.OrdinalIgnoreCase) { KnownDataKeys.TraceLog }; -#else private static readonly ISet _exclusions = new HashSet(StringComparer.InvariantCultureIgnoreCase) { KnownDataKeys.TraceLog }; -#endif public override int GetHashCode() { unchecked { diff --git a/src/Exceptionless/Models/Collections/ObservableDictionary.cs b/src/Exceptionless/Models/Collections/ObservableDictionary.cs index 31d03ac5..64b39441 100644 --- a/src/Exceptionless/Models/Collections/ObservableDictionary.cs +++ b/src/Exceptionless/Models/Collections/ObservableDictionary.cs @@ -1,77 +1,41 @@ using System; using System.Collections; -#if !PORTABLE using System.Collections.Concurrent; -#endif using System.Collections.Generic; namespace Exceptionless.Models.Collections { public class ObservableDictionary : IDictionary { -#if !PORTABLE private readonly ConcurrentDictionary _dictionary; -#else - private readonly IDictionary _dictionary; -#endif public ObservableDictionary() { -#if !PORTABLE _dictionary = new ConcurrentDictionary(); -#else - _dictionary = new Dictionary(); -#endif } public ObservableDictionary(IDictionary dictionary) { -#if !PORTABLE _dictionary = new ConcurrentDictionary(dictionary); -#else - _dictionary = new Dictionary(dictionary); -#endif } public ObservableDictionary(IEqualityComparer comparer) { -#if !PORTABLE _dictionary = new ConcurrentDictionary(comparer); -#else - _dictionary = new Dictionary(comparer); -#endif } public ObservableDictionary(IDictionary dictionary, IEqualityComparer comparer) { -#if !PORTABLE _dictionary = new ConcurrentDictionary(dictionary, comparer); -#else - _dictionary = new Dictionary(dictionary, comparer); -#endif } public void Add(TKey key, TValue value) { -#if !PORTABLE if (_dictionary.TryAdd(key, value)) OnChanged(new ChangedEventArgs>(new KeyValuePair(key, value), ChangedAction.Add)); -#else - _dictionary.Add(key, value); - OnChanged(new ChangedEventArgs>(new KeyValuePair(key, value), ChangedAction.Add)); -#endif } public void Add(KeyValuePair item) { -#if !PORTABLE if (_dictionary.TryAdd(item.Key, item.Value)) OnChanged(new ChangedEventArgs>(item, ChangedAction.Add)); -#else - _dictionary.Add(item); - OnChanged(new ChangedEventArgs>(item, ChangedAction.Add)); -#endif } public bool Remove(TKey key) { TValue value = default(TValue); -#if !PORTABLE bool success = _dictionary.TryRemove(key, out value); -#else - bool success = _dictionary.Remove(key); -#endif if (success) OnChanged(new ChangedEventArgs>(new KeyValuePair(key, value), ChangedAction.Remove)); @@ -79,12 +43,8 @@ public bool Remove(TKey key) { } public bool Remove(KeyValuePair item) { -#if !PORTABLE TValue value; bool success = _dictionary.TryRemove(item.Key, out value); -#else - bool success = _dictionary.Remove(item); -#endif if (success) OnChanged(new ChangedEventArgs>(item, ChangedAction.Remove)); @@ -101,11 +61,7 @@ public bool ContainsKey(TKey key) { } public bool Contains(KeyValuePair item) { -#if !PORTABLE return _dictionary.ContainsKey(item.Key); -#else - return _dictionary.Contains(item); -#endif } public bool TryGetValue(TKey key, out TValue value) { diff --git a/src/Exceptionless/Models/Collections/SettingsDictionary.cs b/src/Exceptionless/Models/Collections/SettingsDictionary.cs index b943bda2..3d1fc847 100644 --- a/src/Exceptionless/Models/Collections/SettingsDictionary.cs +++ b/src/Exceptionless/Models/Collections/SettingsDictionary.cs @@ -1,7 +1,5 @@ using System; -#if !PORTABLE using System.Collections.Concurrent; -#endif using System.Collections.Generic; using System.Linq; using Exceptionless.Extensions; @@ -38,10 +36,10 @@ public bool GetBoolean(string name, bool @default) { string temp = null; if (String.IsNullOrWhiteSpace(name) || !TryGetValue(name, out temp)) return @default; - + if (String.IsNullOrEmpty(temp)) return @default; - + return temp.ToBoolean(@default); } @@ -165,21 +163,13 @@ protected override void OnChanged(ChangedEventArgs> } foreach (var logger in logLevelKeysToRemove) { -#if !PORTABLE LogLevel value; _minLogLevels.TryRemove(logger, out value); -#else - _minLogLevels.Remove(logger); -#endif } } foreach (var eventType in _eventTypes) { -#if !PORTABLE ConcurrentDictionary sourceDictionary; -#else - Dictionary sourceDictionary; -#endif if (eventType.Key == null || !_typeSourceEnabled.TryGetValue(eventType.Key, out sourceDictionary)) continue; @@ -193,23 +183,16 @@ protected override void OnChanged(ChangedEventArgs> } foreach (var logger in sourceKeysToRemove) { -#if !PORTABLE bool value; sourceDictionary.TryRemove(logger, out value); -#else - sourceDictionary.Remove(logger); -#endif } } base.OnChanged(args); } -#if !PORTABLE private readonly ConcurrentDictionary _minLogLevels = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); -#else - private readonly Dictionary _minLogLevels = new Dictionary(StringComparer.OrdinalIgnoreCase); -#endif + public LogLevel GetMinLogLevel(string loggerName) { if (String.IsNullOrEmpty(loggerName)) loggerName = "*"; @@ -220,37 +203,22 @@ public LogLevel GetMinLogLevel(string loggerName) { string setting = GetTypeAndSourceSetting("log", loggerName, "Trace"); if (setting == null) { -#if !PORTABLE _minLogLevels.AddOrUpdate(loggerName, LogLevel.Trace, (logName, level) => LogLevel.Trace); -#else - _minLogLevels[loggerName] = LogLevel.Trace; -#endif return LogLevel.Trace; } minLogLevel = LogLevel.FromString(setting); -#if !PORTABLE _minLogLevels.AddOrUpdate(loggerName, minLogLevel, (logName, level) => minLogLevel); -#else - _minLogLevels[loggerName] = minLogLevel; -#endif return minLogLevel; } -#if !PORTABLE private readonly ConcurrentDictionary> _typeSourceEnabled = new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase); -#else - private readonly Dictionary> _typeSourceEnabled = new Dictionary>(StringComparer.OrdinalIgnoreCase); -#endif + public bool GetTypeAndSourceEnabled(string type, string source) { if (type == null) return true; -#if !PORTABLE ConcurrentDictionary sourceDictionary; -#else - Dictionary sourceDictionary; -#endif if (source != null && _typeSourceEnabled.TryGetValue(type, out sourceDictionary)) { bool sourceEnabled; if (sourceDictionary.TryGetValue(source, out sourceEnabled)) @@ -260,36 +228,21 @@ public bool GetTypeAndSourceEnabled(string type, string source) { return GetTypeAndSourceSetting(type, source, "true").ToBoolean(true); } -#if !PORTABLE private readonly ConcurrentDictionary _eventTypes = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); -#else - private readonly Dictionary _eventTypes = new Dictionary(StringComparer.OrdinalIgnoreCase); -#endif + private string GetTypeAndSourceSetting(string type, string source, string defaultValue) { if (type == null) return defaultValue; -#if !PORTABLE ConcurrentDictionary sourceDictionary; -#else - Dictionary sourceDictionary; -#endif string sourcePrefix; if (!_typeSourceEnabled.TryGetValue(type, out sourceDictionary)) { -#if !PORTABLE + sourceDictionary = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); _typeSourceEnabled.TryAdd(type, sourceDictionary); -#else - sourceDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); - _typeSourceEnabled.Add(type, sourceDictionary); -#endif sourcePrefix = "@@" + type + ":"; -#if !PORTABLE + _eventTypes.TryAdd(type, sourcePrefix); -#else - if (!_eventTypes.ContainsKey(type)) - _eventTypes.Add(type, sourcePrefix); -#endif } else { sourcePrefix = _eventTypes[type]; } @@ -298,7 +251,7 @@ private string GetTypeAndSourceSetting(string type, string source, string defaul string settingValue; if (TryGetValue(sourcePrefix + source, out settingValue)) return settingValue; - + // check for wildcard match var sourceSettings = this .Where(kvp => kvp.Key.StartsWith(sourcePrefix)) diff --git a/src/Exceptionless/Plugins/Default/015_PrivateInformationPlugin.cs b/src/Exceptionless/Plugins/Default/015_PrivateInformationPlugin.cs index c82acc7e..a0419f50 100644 --- a/src/Exceptionless/Plugins/Default/015_PrivateInformationPlugin.cs +++ b/src/Exceptionless/Plugins/Default/015_PrivateInformationPlugin.cs @@ -1,5 +1,4 @@ -#if NET45 || NETSTANDARD2_0 -using System; +using System; using Exceptionless.Dependency; namespace Exceptionless.Plugins.Default { @@ -14,5 +13,4 @@ public void Run(EventPluginContext context) { context.Event.SetUserIdentity(Environment.UserName); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Plugins/Default/020_ErrorPlugin.cs b/src/Exceptionless/Plugins/Default/020_ErrorPlugin.cs index 06850274..b0456b64 100644 --- a/src/Exceptionless/Plugins/Default/020_ErrorPlugin.cs +++ b/src/Exceptionless/Plugins/Default/020_ErrorPlugin.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using Exceptionless.Extensions; using Exceptionless.Models; @@ -23,5 +22,4 @@ public void Run(EventPluginContext context) { exception.MarkProcessed(); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Plugins/Default/070_TraceLogPlugin.cs b/src/Exceptionless/Plugins/Default/070_TraceLogPlugin.cs index 7712c5a5..e1d5d658 100644 --- a/src/Exceptionless/Plugins/Default/070_TraceLogPlugin.cs +++ b/src/Exceptionless/Plugins/Default/070_TraceLogPlugin.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -15,7 +14,7 @@ public class TraceLogPlugin : IEventPlugin, IDisposable { public const int DefaultMaxEntriesToInclude = 25; private readonly ExceptionlessConfiguration _configuration; - private readonly ExceptionlessTraceListener _listener; + private readonly ExceptionlessTraceListener _listener; public TraceLogPlugin(ExceptionlessConfiguration config, ExceptionlessTraceListener listener = null) { _configuration = config; @@ -54,7 +53,7 @@ public static void AddRecentTraceLogEntries(Event ev, ExceptionlessTraceListener public void Dispose() { if (_configuration != null && _configuration.Settings != null) - _configuration.Settings.Changed -= OnSettingsChanged; + _configuration.Settings.Changed -= OnSettingsChanged; } private void OnSettingsChanged(object sender, ChangedEventArgs> e) { @@ -64,5 +63,4 @@ private void OnSettingsChanged(object sender, ChangedEventArgs !a.IsDynamic && a != typeof(ExceptionlessClient).GetTypeInfo().Assembly && a != GetType().GetTypeInfo().Assembly && a != typeof(object).GetTypeInfo().Assembly)) { @@ -59,10 +56,8 @@ private string GetVersionFromLoadedAssemblies(IExceptionlessLog log) { if (!String.IsNullOrEmpty(company) && (String.Equals(company, "Exceptionless", StringComparison.OrdinalIgnoreCase) || String.Equals(company, "Microsoft Corporation", StringComparison.OrdinalIgnoreCase))) continue; -#if !NETSTANDARD1_3 && !NETSTANDARD1_4 if (!assembly.GetReferencedAssemblies().Any(an => String.Equals(an.FullName, typeof(ExceptionlessClient).GetTypeInfo().Assembly.FullName))) continue; -#endif string version = GetVersionFromAssembly(assembly); if (!String.IsNullOrEmpty(version)) @@ -93,7 +88,5 @@ private string GetVersionFromAssembly(Assembly assembly) { return !String.IsNullOrEmpty(version) && !String.Equals(version, "0.0.0.0") ? version : null; } -#endif - } - } -#endif \ No newline at end of file + } +} diff --git a/src/Exceptionless/Plugins/EventPluginManager.cs b/src/Exceptionless/Plugins/EventPluginManager.cs index 6dcb43ae..3f9dfd1b 100644 --- a/src/Exceptionless/Plugins/EventPluginManager.cs +++ b/src/Exceptionless/Plugins/EventPluginManager.cs @@ -27,16 +27,10 @@ public static void AddDefaultPlugins(ExceptionlessConfiguration config) { config.AddPlugin(); config.AddPlugin(); config.AddPlugin(); -#if !PORTABLE && !NETSTANDARD1_2 config.AddPlugin(); -#else - config.AddPlugin(); -#endif config.AddPlugin(); config.AddPlugin(); -#if !PORTABLE && !NETSTANDARD1_2 config.AddPlugin(); -#endif config.AddPlugin(); config.AddPlugin(); } diff --git a/src/Exceptionless/Polyfill/ConcurrentQueue.cs b/src/Exceptionless/Polyfill/ConcurrentQueue.cs deleted file mode 100644 index a24dd587..00000000 --- a/src/Exceptionless/Polyfill/ConcurrentQueue.cs +++ /dev/null @@ -1,214 +0,0 @@ -#if PFX_LEGACY_3_5 || PORTABLE40 - -using System; -using System.Threading; -using System.Collections.Generic; - -namespace System.Collections.Concurrent -{ - internal interface IProducerConsumerCollection : IEnumerable, ICollection, IEnumerable - { - bool TryAdd(T item); - bool TryTake(out T item); - T[] ToArray(); - void CopyTo(T[] array, int index); - } - - [System.Diagnostics.DebuggerDisplay ("Count={Count}")] - internal class ConcurrentQueue : IProducerConsumerCollection, IEnumerable, ICollection, IEnumerable - { - class Node - { - public T Value; - public Node Next; - } - - Node head = new Node (); - Node tail; - int count; - - class NodeObjectPool : ObjectPool { - protected override Node Creator () - { - return new Node (); - } - } - static readonly NodeObjectPool pool = new NodeObjectPool (); - - static Node ZeroOut (Node node) - { - node.Value = default(T); - node.Next = null; - return node; - } - - public ConcurrentQueue () - { - tail = head; - } - - public ConcurrentQueue (IEnumerable collection): this() - { - foreach (T item in collection) - Enqueue (item); - } - - public void Enqueue (T item) - { - Node node = pool.Take (); - node.Value = item; - - Node oldTail = null; - Node oldNext = null; - - bool update = false; - while (!update) { - oldTail = tail; - oldNext = oldTail.Next; - - // Did tail was already updated ? - if (tail == oldTail) { - if (oldNext == null) { - // The place is for us - update = Interlocked.CompareExchange (ref tail.Next, node, null) == null; - } else { - // another Thread already used the place so give him a hand by putting tail where it should be - Interlocked.CompareExchange (ref tail, oldNext, oldTail); - } - } - } - // At this point we added correctly our node, now we have to update tail. If it fails then it will be done by another thread - Interlocked.CompareExchange (ref tail, node, oldTail); - - Interlocked.Increment (ref count); - } - - bool IProducerConsumerCollection.TryAdd (T item) - { - Enqueue (item); - return true; - } - - public bool TryDequeue (out T result) - { - result = default (T); - bool advanced = false; - - while (!advanced) { - Node oldHead = head; - Node oldTail = tail; - Node oldNext = oldHead.Next; - - if (oldHead == head) { - // Empty case ? - if (oldHead == oldTail) { - // This should be false then - if (oldNext != null) { - // If not then the linked list is mal formed, update tail - Interlocked.CompareExchange (ref tail, oldNext, oldTail); - } - result = default (T); - return false; - } else { - result = oldNext.Value; - advanced = Interlocked.CompareExchange (ref head, oldNext, oldHead) == oldHead; - if (advanced) - pool.Release (ZeroOut (oldHead)); - } - } - } - - Interlocked.Decrement (ref count); - - return true; - } - - public bool TryPeek (out T result) - { - if (IsEmpty) { - result = default (T); - return false; - } - - Node first = head.Next; - result = first.Value; - return true; - } - - internal void Clear () - { - count = 0; - tail = head = new Node (); - } - - IEnumerator IEnumerable.GetEnumerator () - { - return (IEnumerator)InternalGetEnumerator (); - } - - public IEnumerator GetEnumerator () - { - return InternalGetEnumerator (); - } - - IEnumerator InternalGetEnumerator () - { - Node my_head = head; - while ((my_head = my_head.Next) != null) { - yield return my_head.Value; - } - } - - void ICollection.CopyTo (Array array, int index) - { - T[] dest = array as T[]; - if (dest == null) - return; - CopyTo (dest, index); - } - - public void CopyTo (T[] array, int index) - { - IEnumerator e = InternalGetEnumerator (); - int i = index; - while (e.MoveNext ()) { - array [i++] = e.Current; - } - } - - public T[] ToArray () - { - T[] dest = new T [count]; - CopyTo (dest, 0); - return dest; - } - - bool ICollection.IsSynchronized { - get { return true; } - } - - bool IProducerConsumerCollection.TryTake (out T item) - { - return TryDequeue (out item); - } - - object syncRoot = new object(); - object ICollection.SyncRoot { - get { return syncRoot; } - } - - public int Count { - get { - return count; - } - } - - public bool IsEmpty { - get { - return count == 0; - } - } - } -} - -#endif \ No newline at end of file diff --git a/src/Exceptionless/Polyfill/ObjectPool.cs b/src/Exceptionless/Polyfill/ObjectPool.cs deleted file mode 100644 index 5f67f8ec..00000000 --- a/src/Exceptionless/Polyfill/ObjectPool.cs +++ /dev/null @@ -1,70 +0,0 @@ -#if PFX_LEGACY_3_5 || PORTABLE40 - -using System; -using System.Threading; -using System.Collections; -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace System.Collections.Concurrent -{ - internal abstract class ObjectPool where T : class - { - const int capacity = 20; - const int bit = 0x8000000; - - readonly T[] buffer; - int addIndex; - int removeIndex; - - public ObjectPool () - { - buffer = new T[capacity]; - for (int i = 0; i < capacity; i++) - buffer[i] = Creator (); - addIndex = capacity - 1; - } - - protected abstract T Creator (); - - public T Take () - { - if ((addIndex & ~bit) - 1 == removeIndex) - return Creator (); - - int i; - T result; - int tries = 3; - - do { - i = removeIndex; - if ((addIndex & ~bit) - 1 == i || tries == 0) - return Creator (); - result = buffer[i % capacity]; - } while (Interlocked.CompareExchange (ref removeIndex, i + 1, i) != i && --tries > -1); - - return result; - } - - public void Release (T obj) - { - if (obj == null || addIndex - removeIndex >= capacity - 1) - return; - - int i; - int tries = 3; - do { - do { - i = addIndex; - } while ((i & bit) > 0); - if (i - removeIndex >= capacity - 1) - return; - } while (Interlocked.CompareExchange (ref addIndex, i + 1 + bit, i) != i && --tries > 0); - - buffer[i % capacity] = obj; - addIndex = addIndex - bit; - } - } -} - -#endif \ No newline at end of file diff --git a/src/Exceptionless/Properties/AssemblyInfo.cs b/src/Exceptionless/Properties/AssemblyInfo.cs index 04b2cb6f..a230202c 100644 --- a/src/Exceptionless/Properties/AssemblyInfo.cs +++ b/src/Exceptionless/Properties/AssemblyInfo.cs @@ -8,9 +8,7 @@ [assembly: AssemblyTitle("Exceptionless")] [assembly: AssemblyDescription("Exceptionless")] [assembly: Exceptionless.Linking.Preserve] -#if !PORTABLE && !NETSTANDARD1_2 [assembly: Guid("2d458cc4-3bb3-4852-b6a2-11d5ac8672df")] -#endif [assembly: InternalsVisibleTo("Exceptionless.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9357232b9bcad78fd310297fdb41bf42816ee2ca9ccdace999889de2badb6f06df2de1d9f2c8cb17b21f5311f11d6bb328d55e0dd9fe8adc5e2dc4610028c1bdacb3355d2e239b81d0bb0ac83e615fc641f8a3ec49e4fad8e305994953d448ef7b38e8c256601e54af19c035b562e3e5e5461c2a93b8dd11936e451b05034a2")] [assembly: InternalsVisibleTo("Exceptionless.TestHarness, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9357232b9bcad78fd310297fdb41bf42816ee2ca9ccdace999889de2badb6f06df2de1d9f2c8cb17b21f5311f11d6bb328d55e0dd9fe8adc5e2dc4610028c1bdacb3355d2e239b81d0bb0ac83e615fc641f8a3ec49e4fad8e305994953d448ef7b38e8c256601e54af19c035b562e3e5e5461c2a93b8dd11936e451b05034a2")] \ No newline at end of file diff --git a/src/Exceptionless/Services/DefaultEnvironmentInfoCollector.cs b/src/Exceptionless/Services/DefaultEnvironmentInfoCollector.cs index 7c7d6409..e37ddcbf 100644 --- a/src/Exceptionless/Services/DefaultEnvironmentInfoCollector.cs +++ b/src/Exceptionless/Services/DefaultEnvironmentInfoCollector.cs @@ -3,9 +3,7 @@ using System.Globalization; using System.Linq; using System.Net; -#if !PORTABLE && !NETSTANDARD1_2 using System.Net.Sockets; -#endif using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -41,15 +39,12 @@ public EnvironmentInfo GetEnvironmentInfo() { } private void PopulateApplicationInfo(EnvironmentInfo info) { -#if !PORTABLE && !NETSTANDARD1_2 try { info.Data.Add("AppDomainName", AppDomain.CurrentDomain.FriendlyName); } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get AppDomain friendly name. Error message: {0}", ex.Message); } -#endif -#if !PORTABLE && !NETSTANDARD1_2 if (_config.IncludeIpAddress) { try { IPHostEntry hostEntry = Dns.GetHostEntryAsync(Dns.GetHostName()).ConfigureAwait(false).GetAwaiter().GetResult(); @@ -59,7 +54,6 @@ private void PopulateApplicationInfo(EnvironmentInfo info) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get ip address. Error message: {0}", ex.Message); } } -#endif } private void PopulateProcessInfo(EnvironmentInfo info) { @@ -69,7 +63,6 @@ private void PopulateProcessInfo(EnvironmentInfo info) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get processor count. Error message: {0}", ex.Message); } -#if !PORTABLE && !NETSTANDARD1_2 try { Process process = Process.GetCurrentProcess(); info.ProcessName = process.ProcessName; @@ -79,19 +72,13 @@ private void PopulateProcessInfo(EnvironmentInfo info) { } try { -#if NETSTANDARD1_5 - info.CommandLine = String.Join(" ", Environment.GetCommandLineArgs()); -#elif NET45 || NETSTANDARD2_0 info.CommandLine = Environment.CommandLine; -#endif } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get command line. Error message: {0}", ex.Message); } -#endif } private void PopulateThreadInfo(EnvironmentInfo info) { -#if !PORTABLE && !NETSTANDARD1_2 try { info.ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(NumberFormatInfo.InvariantInfo); } catch (Exception ex) { @@ -103,18 +90,15 @@ private void PopulateThreadInfo(EnvironmentInfo info) { } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get current thread name. Error message: {0}", ex.Message); } -#endif } private void PopulateMemoryInfo(EnvironmentInfo info) { -#if !PORTABLE && !NETSTANDARD1_2 try { Process process = Process.GetCurrentProcess(); info.ProcessMemorySize = process.PrivateMemorySize64; } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get process memory size. Error message: {0}", ex.Message); } -#endif #if NET45 try { @@ -160,20 +144,14 @@ private void PopulateRuntimeInfo(EnvironmentInfo info) { if (_config.IncludeMachineName) { try { -#if NET45 || NETSTANDARD1_5 || NETSTANDARD2_0 info.MachineName = Environment.MachineName; -#elif !PORTABLE && !NETSTANDARD1_2 - Process process = Process.GetCurrentProcess(); - info.MachineName = process.MachineName; -#else - info.MachineName = Guid.NewGuid().ToString("N"); -#endif + Process process = Process.GetCurrentProcess(); + info.MachineName = process.MachineName; } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get machine name. Error message: {0}", ex.Message); } } -#if !PORTABLE && !NETSTANDARD1_2 #if NETSTANDARD Microsoft.Extensions.PlatformAbstractions.PlatformServices computerInfo = null; #elif NET45 @@ -190,10 +168,8 @@ private void PopulateRuntimeInfo(EnvironmentInfo info) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get computer info. Error message: {0}", ex.Message); } -#if NETSTANDARD || NET45 if (computerInfo == null) return; -#endif try { #if NETSTANDARD @@ -210,7 +186,6 @@ private void PopulateRuntimeInfo(EnvironmentInfo info) { } catch (Exception ex) { _log.FormattedWarn(typeof(DefaultEnvironmentInfoCollector), "Unable to get populate runtime info. Error message: {0}", ex.Message); } -#endif } #if NETSTANDARD diff --git a/src/Exceptionless/Storage/FolderObjectStorage.cs b/src/Exceptionless/Storage/FolderObjectStorage.cs index 223306a1..e015eca0 100644 --- a/src/Exceptionless/Storage/FolderObjectStorage.cs +++ b/src/Exceptionless/Storage/FolderObjectStorage.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Generic; using System.IO; using Exceptionless.Dependency; @@ -146,5 +145,4 @@ public IEnumerable GetObjectList(string searchPattern = null, int? l public void Dispose() {} } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Storage/LockFile.cs b/src/Exceptionless/Storage/LockFile.cs index 860ccb32..0a3dd419 100644 --- a/src/Exceptionless/Storage/LockFile.cs +++ b/src/Exceptionless/Storage/LockFile.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Concurrent; using System.Diagnostics; using System.IO; @@ -72,7 +71,7 @@ private void CreateLock(string path, TimeSpan timeout) { } } - // create file + // create file try { using (var fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write, FileShare.None)) fs.Dispose(); @@ -142,7 +141,7 @@ private bool IsLockExpired(string path) { if (String.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path)); - return (!_lockStatus.ContainsKey(path) || !_lockStatus[path]) + return (!_lockStatus.ContainsKey(path) || !_lockStatus[path]) && GetCreationTimeUtc(path) < DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(DefaultTimeOutInSeconds * 10)); } @@ -163,5 +162,4 @@ public void Dispose() { ReleaseLock(); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Submission/DefaultSubmissionClient.cs b/src/Exceptionless/Submission/DefaultSubmissionClient.cs index 5901edcd..3d190d40 100644 --- a/src/Exceptionless/Submission/DefaultSubmissionClient.cs +++ b/src/Exceptionless/Submission/DefaultSubmissionClient.cs @@ -4,10 +4,8 @@ using System.Net; using System.Net.Http; using System.Net.Http.Headers; -#if NET45 || (!PORTABLE && !NETSTANDARD1_2) using System.Net.Security; using System.Security.Cryptography.X509Certificates; -#endif using System.Text; using Exceptionless.Configuration; using Exceptionless.Dependency; @@ -45,7 +43,7 @@ public SubmissionResponse PostEvents(IEnumerable events, ExceptionlessCon } catch (Exception ex) { return new SubmissionResponse(500, exception: ex); } - + int settingsVersion; if (Int32.TryParse(GetSettingsVersionHeader(response.Headers), out settingsVersion)) SettingsManager.CheckVersion(settingsVersion, config); @@ -130,16 +128,16 @@ protected virtual HttpClient CreateHttpClient(ExceptionlessConfiguration config) #else var handler = new HttpClientHandler { UseDefaultCredentials = true }; #endif -#if !PORTABLE && !NETSTANDARD1_2 + var callback = config.ServerCertificateValidationCallback; if (callback != null) { #if NET45 - handler.ServerCertificateValidationCallback = (s,c,ch,p)=>Validate(s,c,ch,p,callback); + handler.ServerCertificateValidationCallback = (s,c,ch,p) => Validate(s,c,ch,p,callback); #else - handler.ServerCertificateCustomValidationCallback = (m,c,ch,p)=>Validate(m,c,ch,p,callback); + handler.ServerCertificateCustomValidationCallback = (m,c,ch,p) => Validate(m,c,ch,p,callback); #endif } -#endif + if (handler.SupportsAutomaticDecompression) handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip | DecompressionMethods.None; @@ -158,7 +156,6 @@ protected virtual HttpClient CreateHttpClient(ExceptionlessConfiguration config) return client; } -#if !PORTABLE && !NETSTANDARD1_2 #if NET45 private bool Validate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors, Func callback) { var certData = new CertificateData(sender, certificate, chain, sslPolicyErrors); @@ -169,7 +166,6 @@ private bool Validate(HttpRequestMessage httpRequestMessage, X509Certificate2 ce var certData = new CertificateData(httpRequestMessage, certificate, chain, sslPolicyErrors); return callback(certData); } -#endif #endif private string GetResponseMessage(HttpResponseMessage response) { @@ -202,7 +198,7 @@ private string GetResponseText(HttpResponseMessage response) { return null; } - + private string GetSettingsVersionHeader(HttpResponseHeaders headers) { IEnumerable values; if (headers != null && headers.TryGetValues(ExceptionlessHeaders.ConfigurationVersion, out values)) @@ -210,7 +206,7 @@ private string GetSettingsVersionHeader(HttpResponseHeaders headers) { return null; } - + private Uri GetServiceEndPoint(ExceptionlessConfiguration config) { var builder = new UriBuilder(config.ServerUrl); builder.Path += builder.Path.EndsWith("/") ? "api/v2" : "/api/v2"; diff --git a/src/Exceptionless/Utility/AssemblyHelper.cs b/src/Exceptionless/Utility/AssemblyHelper.cs index c6a340f1..7ef9fa40 100644 --- a/src/Exceptionless/Utility/AssemblyHelper.cs +++ b/src/Exceptionless/Utility/AssemblyHelper.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -8,11 +7,7 @@ namespace Exceptionless.Utility { public class AssemblyHelper { public static Assembly GetRootAssembly() { -#if NET45 || NETSTANDARD2_0 ||NETSTANDARD1_5 return Assembly.GetEntryAssembly(); -#else - return null; -#endif } public static string GetAssemblyTitle() { @@ -29,11 +24,10 @@ public static string GetAssemblyTitle() { // If there is an attribute, return its value return ((AssemblyTitleAttribute)attributes[0]).Title; } - + public static List GetTypes(IExceptionlessLog log) { var types = new List(); -#if !PORTABLE && !NETSTANDARD1_2 var assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { try { @@ -45,10 +39,8 @@ public static List GetTypes(IExceptionlessLog log) { log.Error(typeof(AssemblyHelper), ex, String.Format("An error occurred while getting types for assembly \"{0}\".", assembly)); } } -#endif return types; } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Utility/ExceptionlessTraceListener.cs b/src/Exceptionless/Utility/ExceptionlessTraceListener.cs index 5bfea8d7..9aaf6bc2 100644 --- a/src/Exceptionless/Utility/ExceptionlessTraceListener.cs +++ b/src/Exceptionless/Utility/ExceptionlessTraceListener.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -32,7 +31,7 @@ public int MaxEntriesToStore { get { return _maxEntriesToStore; } set { _maxEntriesToStore = value; - + if (_maxEntriesToStore <= 0) InnerList.Clear(); } @@ -67,5 +66,4 @@ public List GetLogEntries(int entryCount = TraceLogPlugin.DefaultMaxEntr return new List(InnerList.Take(entryCount).ToArray()); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Utility/PathHelper.cs b/src/Exceptionless/Utility/PathHelper.cs index 5b00e923..dca1a353 100644 --- a/src/Exceptionless/Utility/PathHelper.cs +++ b/src/Exceptionless/Utility/PathHelper.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.IO; namespace Exceptionless.Utility { @@ -21,7 +20,6 @@ public static string ExpandPath(string sourceFile) { if (!sourceFile.StartsWith(DATA_DIRECTORY, StringComparison.OrdinalIgnoreCase)) return Path.GetFullPath(sourceFile); -#if !(PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4) string dataDirectory = GetDataDirectory(); int length = DATA_DIRECTORY.Length; @@ -38,12 +36,8 @@ public static string ExpandPath(string sourceFile) { fullPath = Path.GetFullPath(fullPath); return fullPath; -#else - return sourceFile; -#endif } -#if !(PORTABLE || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2) /// /// Gets the data directory for the |DataDirectory| macro. /// @@ -55,7 +49,5 @@ public static string GetDataDirectory() { return Path.GetFullPath(dataDirectory); } -#endif } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/Utility/Run.cs b/src/Exceptionless/Utility/Run.cs index 1f99c86b..8a427e1d 100644 --- a/src/Exceptionless/Utility/Run.cs +++ b/src/Exceptionless/Utility/Run.cs @@ -1,5 +1,4 @@ -#if !PORTABLE && !NETSTANDARD1_2 -using System; +using System; using System.Threading; namespace Exceptionless.Utility { @@ -32,5 +31,4 @@ public static T WithRetries(Func action, int attempts = 3, TimeSpan? retry throw new Exception("Should not get here."); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Exceptionless/readme.txt b/src/Exceptionless/readme.txt index 8765cc75..b871213c 100644 --- a/src/Exceptionless/readme.txt +++ b/src/Exceptionless/readme.txt @@ -1,8 +1,8 @@ ------------------------------------- Exceptionless Readme ------------------------------------- -Exceptionless provides real-time error reporting for your apps. It organizes the -gathered information into simple actionable data that will help your app become +Exceptionless provides real-time error reporting for your apps. It organizes the +gathered information into simple actionable data that will help your app become exceptionless! Learn more at http://exceptionless.io. @@ -10,8 +10,8 @@ Learn more at http://exceptionless.io. ------------------------------------- How to get an api key ------------------------------------- -The Exceptionless client requires an api key to use the Exceptionless service. -You can get your Exceptionless api key by logging into http://exceptionless.io +The Exceptionless client requires an api key to use the Exceptionless service. +You can get your Exceptionless api key by logging into http://exceptionless.io and viewing your project configuration page. ------------------------------------- @@ -24,13 +24,13 @@ Please visit the wiki https://github.com/exceptionless/Exceptionless.Net/wiki/Co for detailed information on how to configure the client to meet your requirements. ------------------------------------- - .NET Core && Portable Class Library (PCL) Integration + .NET Core Integration ------------------------------------- -This library is platform agnostic and is compiled against different runtimes. Depending on the +This library is platform agnostic and is compiled against different runtimes. Depending on the referenced runtime, Exceptionless will attempt to wire up to available error handlers and attempt to -discover configuration settings available to that runtime. For these reasons if you are on a known -platform then use the platform specific package to save you time configuring while giving you more -contextual information. For more information and configuration examples please read the Exceptionless +discover configuration settings available to that runtime. For these reasons if you are on a known +platform then use the platform specific package to save you time configuring while giving you more +contextual information. For more information and configuration examples please read the Exceptionless Configuration documentation on https://github.com/exceptionless/Exceptionless.Net/wiki/Configuration On app startup, import the Exceptionless namespace and call the client.Startup() extension method @@ -44,14 +44,14 @@ for examples on sending events to Exceptionless. ------------------------------------- .NET Framework (Legacy) Integration ------------------------------------- -If your project has an app.config file, the Exceptionless NuGet package +If your project has an app.config file, the Exceptionless NuGet package will automatically configure your app.config with the required config sections. -All you need to do is open the app.config and add your Exceptionless api key to +All you need to do is open the app.config and add your Exceptionless api key to the app.config Exceptionless section. -If your project does not have an app.config file, then please add the following +If your project does not have an app.config file, then please add the following assembly attribute and your own Exceptionless api key to your project (E.G., AssemblyInfo class). [assembly: Exceptionless.Configuration.Exceptionless("API_KEY_HERE")] @@ -67,8 +67,8 @@ for examples on sending events to Exceptionless. ------------------------------------- Manually reporting an exception ------------------------------------- -By default the Exceptionless Client will report all unhandled exceptions. You can -also manually send an exception by importing the Exceptionless namespace and calling +By default the Exceptionless Client will report all unhandled exceptions. You can +also manually send an exception by importing the Exceptionless namespace and calling the following method. exception.ToExceptionless().Submit() diff --git a/src/Platforms/Exceptionless.NLog/LogBuilderExtensions.cs b/src/Platforms/Exceptionless.NLog/LogBuilderExtensions.cs index 8a2fa7ad..fffd5bf9 100644 --- a/src/Platforms/Exceptionless.NLog/LogBuilderExtensions.cs +++ b/src/Platforms/Exceptionless.NLog/LogBuilderExtensions.cs @@ -76,11 +76,8 @@ private static void AddTags(this LogEventInfo ev, params string[] tags) { if (tags == null || tags.Length == 0) return; -#if PORTABLE - var list = ev.GetTags() ?? new HashSet(StringComparer.OrdinalIgnoreCase); -#else var list = ev.GetTags() ?? new HashSet(StringComparer.InvariantCultureIgnoreCase); -#endif + foreach (string tag in tags) list.Add(tag); @@ -89,7 +86,7 @@ private static void AddTags(this LogEventInfo ev, params string[] tags) { internal static IDictionary GetContextData(this LogEventInfo ev) { if (ev.Properties.ContainsKey(ContextData) && ev.Properties[ContextData] is IDictionary) - return (IDictionary)ev.Properties[ContextData]; + return (IDictionary)ev.Properties[ContextData]; return null; }