remove obsolete #ifdefs #111
diff --git a/src/log4net/Appender/AdoNetAppender.cs b/src/log4net/Appender/AdoNetAppender.cs
index cad90c5..867c8fc 100644
--- a/src/log4net/Appender/AdoNetAppender.cs
+++ b/src/log4net/Appender/AdoNetAppender.cs
@@ -17,19 +17,11 @@
//
#endregion
-// SSCLI 1.0 has no support for ADO.NET
-#if !SSCLI
-
using System;
using System.Collections;
-#if !NETSTANDARD1_3
using System.Configuration;
-#endif
using System.Data;
using System.IO;
-#if NETSTANDARD1_3
-using System.Reflection;
-#endif
using log4net.Util;
using log4net.Layout;
@@ -683,7 +675,6 @@
return ConnectionString;
}
-#if !NETSTANDARD1_3
if (!String.IsNullOrEmpty(ConnectionStringName))
{
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName];
@@ -697,7 +688,6 @@
throw new LogException("Unable to find [" + ConnectionStringName + "] ConfigurationManager.ConnectionStrings item");
}
}
-#endif
if (AppSettingsKey != null && AppSettingsKey.Length > 0)
{
@@ -733,12 +723,7 @@
{
try
{
-#if NETSTANDARD1_3
- // NETSTANDARD1_3 requires comma separated ConnectionType like `System.Data.SqlClient.SqlConnection, System.Data` to work properly.
- return SystemInfo.GetTypeFromString((Assembly)null, ConnectionType, true, false);
-#else
return SystemInfo.GetTypeFromString(ConnectionType, true, false);
-#endif
}
catch (Exception ex)
{
@@ -1179,6 +1164,4 @@
#endregion // Private Instance Fields
}
-}
-
-#endif // !SSCLI
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/AnsiColorTerminalAppender.cs b/src/log4net/Appender/AnsiColorTerminalAppender.cs
index da8cc08..f4613a9 100644
--- a/src/log4net/Appender/AnsiColorTerminalAppender.cs
+++ b/src/log4net/Appender/AnsiColorTerminalAppender.cs
@@ -339,10 +339,6 @@
}
}
-#if NETCF_1_0
- // Write to the output stream
- Console.Write(loggingMessage);
-#else
if (m_writeToErrorStream)
{
// Write to the error stream
@@ -353,7 +349,6 @@
// Write to the output stream
Console.Write(loggingMessage);
}
-#endif
}
diff --git a/src/log4net/Appender/AppenderCollection.cs b/src/log4net/Appender/AppenderCollection.cs
index 768f318..2f89af4 100644
--- a/src/log4net/Appender/AppenderCollection.cs
+++ b/src/log4net/Appender/AppenderCollection.cs
@@ -26,10 +26,7 @@
/// A strongly-typed collection of <see cref="IAppender"/> objects.
/// </summary>
/// <author>Nicko Cadell</author>
- public class AppenderCollection : ICollection, IList, IEnumerable
-#if !NETSTANDARD1_3
- , ICloneable
-#endif
+ public class AppenderCollection : ICollection, IList, IEnumerable, ICloneable
{
#region Interfaces
/// <summary>
diff --git a/src/log4net/Appender/AppenderSkeleton.cs b/src/log4net/Appender/AppenderSkeleton.cs
index 29354c9..0197e3d 100644
--- a/src/log4net/Appender/AppenderSkeleton.cs
+++ b/src/log4net/Appender/AppenderSkeleton.cs
@@ -321,17 +321,6 @@
{
ErrorHandler.Error("Failed in DoAppend", ex);
}
-#if !MONO && !NET_2_0 && !NETSTANDARD
- // on .NET 2.0 (and higher) and Mono (all profiles),
- // exceptions that do not derive from System.Exception will be
- // wrapped in a RuntimeWrappedException by the runtime, and as
- // such will be catched by the catch clause above
- catch
- {
- // Catch handler for non System.Exception types
- ErrorHandler.Error("Failed in DoAppend (unknown exception)");
- }
-#endif
finally
{
m_recursiveGuard = false;
@@ -428,17 +417,6 @@
{
ErrorHandler.Error("Failed in Bulk DoAppend", ex);
}
-#if !MONO && !NET_2_0 && !NETSTANDARD
- // on .NET 2.0 (and higher) and Mono (all profiles),
- // exceptions that do not derive from System.Exception will be
- // wrapped in a RuntimeWrappedException by the runtime, and as
- // such will be catched by the catch clause above
- catch
- {
- // Catch handler for non System.Exception types
- ErrorHandler.Error("Failed in Bulk DoAppend (unknown exception)");
- }
-#endif
finally
{
m_recursiveGuard = false;
diff --git a/src/log4net/Appender/AspNetTraceAppender.cs b/src/log4net/Appender/AspNetTraceAppender.cs
index c478a49..b0cfffe 100644
--- a/src/log4net/Appender/AspNetTraceAppender.cs
+++ b/src/log4net/Appender/AspNetTraceAppender.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.Web;
using log4net.Layout;
@@ -54,7 +50,7 @@
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
/// <author>Ron Grabowski</author>
- public class AspNetTraceAppender : AppenderSkeleton
+ public class AspNetTraceAppender : AppenderSkeleton
{
#region Public Instances Constructors
@@ -85,19 +81,19 @@
/// (<see cref="TraceContext"/>).
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
// check if log4net is running in the context of an ASP.NET application
- if (HttpContext.Current != null)
+ if (HttpContext.Current != null)
{
// check if tracing is enabled for the current context
- if (HttpContext.Current.Trace.IsEnabled)
+ if (HttpContext.Current.Trace.IsEnabled)
{
- if (loggingEvent.Level >= Level.Warn)
+ if (loggingEvent.Level >= Level.Warn)
{
HttpContext.Current.Trace.Warn(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
}
- else
+ else
{
HttpContext.Current.Trace.Write(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
}
@@ -152,6 +148,4 @@
#endregion
}
}
-
-#endif // !NETCF && !SSCLI
-#endif // NET_2_0
+#endif
\ No newline at end of file
diff --git a/src/log4net/Appender/ColoredConsoleAppender.cs b/src/log4net/Appender/ColoredConsoleAppender.cs
index 00a07d2..bd78555 100644
--- a/src/log4net/Appender/ColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ColoredConsoleAppender.cs
@@ -17,18 +17,6 @@
//
#endregion
-// MONO 1.0 Beta mcs does not like #if !A && !B && !C syntax
-
-#if !NETSTANDARD1_3 // netstandard doesn't support System.Security.Permissions
-// .NET Compact Framework 1.0 has no support for Win32 Console API's
-#if !NETCF
-// .Mono 1.0 has no support for Win32 Console API's
-#if !MONO
-// SSCLI 1.0 has no support for Win32 Console API's
-#if !SSCLI
-// We don't want framework or platform specific code in the CLI version of log4net
-#if !CLI_1_0
-
using System;
using System.Globalization;
using System.Runtime.InteropServices;
@@ -266,9 +254,7 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
@@ -435,9 +421,7 @@
/// Initialize the level to color mappings set on this appender.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
public override void ActivateOptions()
{
@@ -659,10 +643,4 @@
#endregion // LevelColors LevelMapping Entry
}
-}
-
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !MONO
-#endif // !NETCF
-#endif // !NETSTANDARD1_3
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/ConsoleAppender.cs b/src/log4net/Appender/ConsoleAppender.cs
index a7299ee..03ff692 100644
--- a/src/log4net/Appender/ConsoleAppender.cs
+++ b/src/log4net/Appender/ConsoleAppender.cs
@@ -151,10 +151,6 @@
/// </remarks>
protected override void Append(LoggingEvent loggingEvent)
{
-#if NETCF_1_0
- // Write to the output stream
- Console.Write(RenderLoggingEvent(loggingEvent));
-#else
if (m_writeToErrorStream)
{
// Write to the error stream
@@ -165,7 +161,6 @@
// Write to the output stream
Console.Write(RenderLoggingEvent(loggingEvent));
}
-#endif
}
/// <summary>
diff --git a/src/log4net/Appender/DebugAppender.cs b/src/log4net/Appender/DebugAppender.cs
index 9aa9e97..b7addd7 100644
--- a/src/log4net/Appender/DebugAppender.cs
+++ b/src/log4net/Appender/DebugAppender.cs
@@ -76,7 +76,6 @@
#region Public Instance Properties
-#if !NETSTANDARD1_3 // System.Diagnostics.Debug has no Flush() in netstandard1.3
/// <summary>
/// Gets or sets a value that indicates whether the appender will
/// flush at the end of each write.
@@ -100,7 +99,6 @@
get { return m_immediateFlush; }
set { m_immediateFlush = value; }
}
-#endif // !NETSTANDARD1_3
/// <summary>
/// Formats the category parameter sent to the Debug method.
@@ -121,7 +119,6 @@
#endregion Public Instance Properties
-#if !NETSTANDARD1_3
/// <summary>
/// Flushes any buffered log data.
/// </summary>
@@ -137,21 +134,9 @@
return true;
}
-#endif
#region Override implementation of AppenderSkeleton
-#if NETSTANDARD1_3
- /// <summary>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// </para>
- /// </remarks>
-#else
/// <summary>
/// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
/// </summary>
@@ -163,7 +148,6 @@
/// is called.
/// </para>
/// </remarks>
-#endif
protected override void Append(LoggingEvent loggingEvent)
{
//
@@ -185,7 +169,6 @@
System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), category);
}
}
-#if !NETSTANDARD1_3
//
// Flush the Debug system if needed
//
@@ -193,7 +176,6 @@
{
System.Diagnostics.Debug.Flush();
}
-#endif
}
/// <summary>
@@ -214,7 +196,6 @@
#region Private Instance Fields
-#if !NETSTANDARD1_3
/// <summary>
/// Immediate flush means that the underlying writer or output stream
/// will be flushed at the end of each append operation.
@@ -231,7 +212,6 @@
/// The default value is <c>true</c>.</para>
/// </remarks>
private bool m_immediateFlush = true;
-#endif
/// <summary>
/// Defaults to a <see cref="Layout.PatternLayout"/> with %logger as the pattern.
@@ -240,4 +220,4 @@
#endregion Private Instance Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/EventLogAppender.cs b/src/log4net/Appender/EventLogAppender.cs
index f87a7bc..4416c02 100644
--- a/src/log4net/Appender/EventLogAppender.cs
+++ b/src/log4net/Appender/EventLogAppender.cs
@@ -17,18 +17,10 @@
//
#endregion
-// MONO 1.0 Beta mcs does not like #if !A && !B && !C syntax
-
// netstandard doesn't support EventLog
-#if NET_2_0
-// .NET Compact Framework 1.0 has no support for EventLog
-#if !NETCF
-// SSCLI 1.0 has no support for EventLog
-#if !SSCLI
-
+#if NET462_OR_GREATER
using System;
using System.Diagnostics;
-using System.Globalization;
using log4net.Util;
using log4net.Layout;
@@ -356,13 +348,9 @@
/// </remarks>
private static void CreateEventSource(string source, string logName, string machineName)
{
-#if NET_2_0
EventSourceCreationData eventSourceCreationData = new EventSourceCreationData(source, logName);
eventSourceCreationData.MachineName = machineName;
EventLog.CreateEventSource(eventSourceCreationData);
-#else
- EventLog.CreateEventSource(source, logName, machineName);
-#endif
}
#region Override implementation of AppenderSkeleton
@@ -689,7 +677,4 @@
#endregion Private Static Fields
}
}
-
-#endif // !SSCLI
-#endif // !NETCF
-#endif // NET_2_0
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Appender/FileAppender.cs b/src/log4net/Appender/FileAppender.cs
index 4179190..4407d56 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -21,21 +21,16 @@
using System;
using System.IO;
-#if !NETCF && !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
using System.Text;
using System.Threading;
using log4net.Util;
using log4net.Layout;
using log4net.Core;
-#if NET_4_5 || NETSTANDARD
using System.Threading.Tasks;
-#endif
namespace log4net.Appender
{
-#if !NETCF
/// <summary>
/// Appends logging events to a file.
/// </summary>
@@ -84,55 +79,6 @@
/// <author>Rodrigo B. de Oliveira</author>
/// <author>Douglas de la Torre</author>
/// <author>Niall Daley</author>
-#else
- /// <summary>
- /// Appends logging events to a file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Logging events are sent to the file specified by
- /// the <see cref="File"/> property.
- /// </para>
- /// <para>
- /// The file can be opened in either append or overwrite mode
- /// by specifying the <see cref="AppendToFile"/> property.
- /// If the file path is relative it is taken as relative from
- /// the application base directory. The file encoding can be
- /// specified by setting the <see cref="Encoding"/> property.
- /// </para>
- /// <para>
- /// The layout's <see cref="ILayout.Header"/> and <see cref="ILayout.Footer"/>
- /// values will be written each time the file is opened and closed
- /// respectively. If the <see cref="AppendToFile"/> property is <see langword="true"/>
- /// then the file may contain multiple copies of the header and footer.
- /// </para>
- /// <para>
- /// This appender will first try to open the file for writing when <see cref="ActivateOptions"/>
- /// is called. This will typically be during configuration.
- /// If the file cannot be opened for writing the appender will attempt
- /// to open the file again each time a message is logged to the appender.
- /// If the file cannot be opened for writing when a message is logged then
- /// the message will be discarded by this appender.
- /// </para>
- /// <para>
- /// The <see cref="FileAppender"/> supports pluggable file locking models via
- /// the <see cref="LockingModel"/> property.
- /// The default behavior, implemented by <see cref="FileAppender.ExclusiveLock"/>
- /// is to obtain an exclusive write lock on the file until this appender is closed.
- /// The alternative model only holds a
- /// write lock while the appender is writing a logging event (<see cref="FileAppender.MinimalLock"/>).
- /// </para>
- /// <para>
- /// All locking strategies have issues and you should seriously consider using a different strategy that
- /// avoids having multiple processes logging to the same file.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Rodrigo B. de Oliveira</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Niall Daley</author>
-#endif
public class FileAppender : TextWriterAppender
{
#region LockingStream Inner Class
@@ -143,9 +89,7 @@
/// </summary>
private sealed class LockingStream : Stream, IDisposable
{
-#if !NETCR
[Serializable]
-#endif
public sealed class LockStateException : LogException
{
public LockStateException(string message)
@@ -161,11 +105,9 @@
{
}
-#if !NETCR && !NETSTANDARD1_3
private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
-#endif
}
private Stream m_realStream = null;
@@ -185,62 +127,12 @@
#region Override Implementation of Stream
-#if NETSTANDARD
protected override void Dispose(bool disposing)
{
m_lockingModel.CloseFile();
base.Dispose(disposing);
}
-#else
- private int m_readTotal = -1;
-
- // Methods
- public override IAsyncResult BeginRead(byte[] buffer,
- int offset,
- int count,
- AsyncCallback callback,
- object state)
- {
- AssertLocked();
- IAsyncResult ret = m_realStream.BeginRead(buffer, offset, count, callback, state);
- m_readTotal = EndRead(ret);
- return ret;
- }
-
- /// <summary>
- /// True asynchronous writes are not supported, the implementation forces a synchronous write.
- /// </summary>
- public override IAsyncResult BeginWrite(byte[] buffer,
- int offset,
- int count,
- AsyncCallback callback,
- object state)
- {
- AssertLocked();
- IAsyncResult ret = m_realStream.BeginWrite(buffer, offset, count, callback, state);
- EndWrite(ret);
- return ret;
- }
-
- public override void Close()
- {
- m_lockingModel.CloseFile();
- }
-
- public override int EndRead(IAsyncResult asyncResult)
- {
- AssertLocked();
- return m_readTotal;
- }
-
- public override void EndWrite(IAsyncResult asyncResult)
- {
- //No-op, it has already been handled
- }
-#endif
-
-#if NET_4_5 || NETSTANDARD
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
AssertLocked();
@@ -249,10 +141,9 @@
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
- AssertLocked();
+ AssertLocked();
return base.WriteAsync(buffer, offset, count, cancellationToken);
}
-#endif
public override void Flush()
{
@@ -284,11 +175,7 @@
void IDisposable.Dispose()
{
-#if NETSTANDARD
Dispose(true);
-#else
- Close();
-#endif
}
public override void Write(byte[] buffer, int offset, int count)
@@ -765,7 +652,6 @@
}
}
-#if !NETCF
/// <summary>
/// Provides cross-process file locking.
/// </summary>
@@ -791,9 +677,7 @@
/// -<see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
public override void OpenFile(string filename, bool append, Encoding encoding)
{
try
@@ -915,11 +799,7 @@
{
if (m_mutex != null)
{
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
m_mutex.Dispose();
-#else
- m_mutex.Close();
-#endif
m_mutex = null;
}
else
@@ -928,7 +808,6 @@
}
}
}
-#endif
/// <summary>
/// Hold no lock on the output file
@@ -1177,28 +1056,6 @@
set { m_securityContext = value; }
}
-#if NETCF
- /// <summary>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </summary>
- /// <value>
- /// The <see cref="FileAppender.LockingModel"/> used to lock the file.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </para>
- /// <para>
- /// There are two built in locking models, <see cref="FileAppender.ExclusiveLock"/> and <see cref="FileAppender.MinimalLock"/>.
- /// The first locks the file from the start of logging to the end, the
- /// second locks only for the minimal amount of time when logging each message
- /// and the last synchronizes processes using a named system wide Mutex.
- /// </para>
- /// <para>
- /// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
- /// </para>
- /// </remarks>
-#else
/// <summary>
/// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
/// </summary>
@@ -1219,7 +1076,6 @@
/// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
/// </para>
/// </remarks>
-#endif
public FileAppender.LockingModelBase LockingModel
{
get { return m_lockingModel; }
diff --git a/src/log4net/Appender/LocalSyslogAppender.cs b/src/log4net/Appender/LocalSyslogAppender.cs
index 549d2ee..0ecfe37 100644
--- a/src/log4net/Appender/LocalSyslogAppender.cs
+++ b/src/log4net/Appender/LocalSyslogAppender.cs
@@ -17,17 +17,13 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for Marshal.StringToHGlobalAnsi
-// SSCLI 1.0 has no support for Marshal.StringToHGlobalAnsi
-#if !NETCF && !SSCLI
-
using System;
using System.Runtime.InteropServices;
using log4net.Core;
using log4net.Util;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// Logs events to a local syslog service.
@@ -62,7 +58,7 @@
/// </remarks>
/// <author>Rob Lyon</author>
/// <author>Nicko Cadell</author>
- public class LocalSyslogAppender : AppenderSkeleton
+ public class LocalSyslogAppender : AppenderSkeleton
{
#region Enumerations
@@ -262,14 +258,14 @@
/// This instance of the <see cref="LocalSyslogAppender" /> class is set up to write
/// to a local syslog service.
/// </remarks>
- public LocalSyslogAppender()
+ public LocalSyslogAppender()
{
}
#endregion // Public Instance Constructors
#region Public Instance Properties
-
+
/// <summary>
/// Message identity
/// </summary>
@@ -300,7 +296,7 @@
get { return m_facility; }
set { m_facility = value; }
}
-
+
#endregion // Public Instance Properties
/// <summary>
@@ -335,13 +331,11 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
public override void ActivateOptions()
{
base.ActivateOptions();
-
+
m_levelMapping.ActivateOptions();
string identString = m_identity;
@@ -376,13 +370,9 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
-#if !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
-#endif
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
string message = RenderLoggingEvent(loggingEvent);
@@ -400,9 +390,7 @@
/// Close the syslog when the appender is closed
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
protected override void OnClose()
{
base.OnClose();
@@ -412,11 +400,11 @@
// close syslog
closelog();
}
- catch (DllNotFoundException)
+ catch(DllNotFoundException)
{
// Ignore dll not found at this point
}
-
+
if (m_handleToIdentity != IntPtr.Zero)
{
// free global ident
@@ -464,30 +452,30 @@
// Fallback to sensible default values
//
- if (level >= Level.Alert)
+ if (level >= Level.Alert)
{
return SyslogSeverity.Alert;
- }
- else if (level >= Level.Critical)
+ }
+ else if (level >= Level.Critical)
{
return SyslogSeverity.Critical;
- }
- else if (level >= Level.Error)
+ }
+ else if (level >= Level.Error)
{
return SyslogSeverity.Error;
- }
- else if (level >= Level.Warn)
+ }
+ else if (level >= Level.Warn)
{
return SyslogSeverity.Warning;
- }
- else if (level >= Level.Notice)
+ }
+ else if (level >= Level.Notice)
{
return SyslogSeverity.Notice;
- }
- else if (level >= Level.Info)
+ }
+ else if (level >= Level.Info)
{
return SyslogSeverity.Informational;
- }
+ }
// Default setting
return SyslogSeverity.Debug;
}
@@ -536,7 +524,7 @@
#endregion // Private Instances Fields
#region External Members
-
+
/// <summary>
/// Open connection to system logger.
/// </summary>
@@ -555,7 +543,7 @@
/// string to <c>"%s"</c>.
/// </para>
/// </remarks>
- [DllImport("libc", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ [DllImport("libc", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
private static extern void syslog(int priority, string format, string message);
/// <summary>
@@ -600,6 +588,4 @@
#endregion // LevelSeverity LevelMapping Entry
}
-}
-
-#endif
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/ManagedColoredConsoleAppender.cs b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
index 263ce17..52474ae 100644
--- a/src/log4net/Appender/ManagedColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
@@ -1,131 +1,123 @@
-#region Apache License
+#region Apache License
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to you under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
#endregion
-// Compatibility:
-// http://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
-// Disable for unsupported targets
-#if !NETCF
-#if !SSCLI
-#if !CLI_1_0
-#if !MONO_1_0
-#if !NET_1_0
-#if !NET_1_1
+// Compatibility:
+// http://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
-// The original ColoredConsoleAppender was written before the .NET framework
-// (and Mono) had built-in support for console colors so it was written using
-// Win32 API calls. The AnsiColorTerminalAppender, while it works, isn't
-// understood by the Windows command prompt.
-// This is a replacement for both that uses the new (.NET 2) Console colors
-// and works on both platforms.
+// The original ColoredConsoleAppender was written before the .NET framework
+// (and Mono) had built-in support for console colors so it was written using
+// Win32 API calls. The AnsiColorTerminalAppender, while it works, isn't
+// understood by the Windows command prompt.
+// This is a replacement for both that uses the new (.NET 2) Console colors
+// and works on both platforms.
-// On Mono/Linux (at least), setting the background color to 'Black' is
-// not the same as the default background color, as it is after
-// Console.Reset(). The difference becomes apparent while running in a
-// terminal application that supports background transparency; the
-// default color is treated as transparent while 'Black' isn't.
-// For this reason, we always reset the colors and only set those
-// explicitly specified in the configuration (Console.BackgroundColor
-// isn't set if ommited).
+// On Mono/Linux (at least), setting the background color to 'Black' is
+// not the same as the default background color, as it is after
+// Console.Reset(). The difference becomes apparent while running in a
+// terminal application that supports background transparency; the
+// default color is treated as transparent while 'Black' isn't.
+// For this reason, we always reset the colors and only set those
+// explicitly specified in the configuration (Console.BackgroundColor
+// isn't set if ommited).
using System;
using log4net.Util;
namespace log4net.Appender
{
- /// <summary>
- /// Appends colorful logging events to the console, using the .NET 2
- /// built-in capabilities.
- /// </summary>
- /// <remarks>
- /// <para>
- /// ManagedColoredConsoleAppender appends log events to the standard output stream
- /// or the error output stream using a layout specified by the
- /// user. It also allows the color of a specific type of message to be set.
- /// </para>
- /// <para>
- /// By default, all output is written to the console's standard output stream.
- /// The <see cref="Target"/> property can be set to direct the output to the
- /// error stream.
- /// </para>
- /// <para>
- /// When configuring the colored console appender, mappings should be
- /// specified to map logging levels to colors. For example:
- /// </para>
- /// <code lang="XML" escaped="true">
+ /// <summary>
+ /// Appends colorful logging events to the console, using the .NET 2
+ /// built-in capabilities.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// ManagedColoredConsoleAppender appends log events to the standard output stream
+ /// or the error output stream using a layout specified by the
+ /// user. It also allows the color of a specific type of message to be set.
+ /// </para>
+ /// <para>
+ /// By default, all output is written to the console's standard output stream.
+ /// The <see cref="Target"/> property can be set to direct the output to the
+ /// error stream.
+ /// </para>
+ /// <para>
+ /// When configuring the colored console appender, mappings should be
+ /// specified to map logging levels to colors. For example:
+ /// </para>
+ /// <code lang="XML" escaped="true">
/// <mapping>
- /// <level value="ERROR" />
- /// <foreColor value="DarkRed" />
- /// <backColor value="White" />
+ /// <level value="ERROR" />
+ /// <foreColor value="DarkRed" />
+ /// <backColor value="White" />
/// </mapping>
/// <mapping>
- /// <level value="WARN" />
- /// <foreColor value="Yellow" />
+ /// <level value="WARN" />
+ /// <foreColor value="Yellow" />
/// </mapping>
/// <mapping>
- /// <level value="INFO" />
- /// <foreColor value="White" />
+ /// <level value="INFO" />
+ /// <foreColor value="White" />
/// </mapping>
/// <mapping>
- /// <level value="DEBUG" />
- /// <foreColor value="Blue" />
+ /// <level value="DEBUG" />
+ /// <foreColor value="Blue" />
/// </mapping>
- /// </code>
- /// <para>
- /// The Level is the standard log4net logging level while
- /// ForeColor and BackColor are the values of <see cref="System.ConsoleColor"/>
- /// enumeration.
- /// </para>
- /// <para>
- /// Based on the ColoredConsoleAppender
- /// </para>
- /// </remarks>
- /// <author>Rick Hobbs</author>
- /// <author>Nicko Cadell</author>
- /// <author>Pavlos Touboulidis</author>
+ /// </code>
+ /// <para>
+ /// The Level is the standard log4net logging level while
+ /// ForeColor and BackColor are the values of <see cref="System.ConsoleColor"/>
+ /// enumeration.
+ /// </para>
+ /// <para>
+ /// Based on the ColoredConsoleAppender
+ /// </para>
+ /// </remarks>
+ /// <author>Rick Hobbs</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Pavlos Touboulidis</author>
public class ManagedColoredConsoleAppender : AppenderSkeleton
{
- /// <summary>
- /// Initializes a new instance of the <see cref="ManagedColoredConsoleAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The instance of the <see cref="ManagedColoredConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ManagedColoredConsoleAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The instance of the <see cref="ManagedColoredConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
public ManagedColoredConsoleAppender()
- {
- }
+ { }
- #region Public Instance Properties
- /// <summary>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </summary>
- /// <value>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </para>
- /// </remarks>
+ #region Public Instance Properties
+ /// <summary>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </summary>
+ /// <value>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </para>
+ /// </remarks>
public virtual string Target
{
get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
@@ -144,36 +136,36 @@
}
}
- /// <summary>
- /// Add a mapping of level to color - done by the config file
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="LevelColors"/> mapping to this appender.
- /// Each mapping defines the foreground and background colors
- /// for a level.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Add a mapping of level to color - done by the config file
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="LevelColors"/> mapping to this appender.
+ /// Each mapping defines the foreground and background colors
+ /// for a level.
+ /// </para>
+ /// </remarks>
public void AddMapping(LevelColors mapping)
{
m_levelMapping.Add(mapping);
}
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to the console.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
+ #region Override implementation of AppenderSkeleton
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to the console.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
System.IO.TextWriter writer;
@@ -183,123 +175,123 @@
else
writer = Console.Out;
- // Reset color
+ // Reset color
Console.ResetColor();
- // see if there is a specified lookup
+ // see if there is a specified lookup
LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
if (levelColors != null)
{
- // if the backColor has been explicitly set
+ // if the backColor has been explicitly set
if (levelColors.HasBackColor)
Console.BackgroundColor = levelColors.BackColor;
- // if the foreColor has been explicitly set
+ // if the foreColor has been explicitly set
if (levelColors.HasForeColor)
Console.ForegroundColor = levelColors.ForeColor;
}
- // Render the event to a string
+ // Render the event to a string
string strLoggingMessage = RenderLoggingEvent(loggingEvent);
- // and write it
+ // and write it
writer.Write(strLoggingMessage);
- // Reset color again
+ // Reset color again
Console.ResetColor();
}
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
protected override bool RequiresLayout
{
get { return true; }
}
- /// <summary>
- /// Initialize the options for this appender
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize the level to color mappings set on this appender.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Initialize the options for this appender
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize the level to color mappings set on this appender.
+ /// </para>
+ /// </remarks>
public override void ActivateOptions()
{
base.ActivateOptions();
m_levelMapping.ActivateOptions();
}
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
- #region Public Static Fields
- /// <summary>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </para>
- /// </remarks>
+ #region Public Static Fields
+ /// <summary>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </para>
+ /// </remarks>
public const string ConsoleOut = "Console.Out";
- /// <summary>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </para>
+ /// </remarks>
public const string ConsoleError = "Console.Error";
- #endregion // Public Static Fields
+ #endregion // Public Static Fields
- #region Private Instances Fields
- /// <summary>
- /// Flag to write output to the error stream rather than the standard output stream
- /// </summary>
+ #region Private Instances Fields
+ /// <summary>
+ /// Flag to write output to the error stream rather than the standard output stream
+ /// </summary>
private bool m_writeToErrorStream = false;
- /// <summary>
- /// Mapping from level object to color value
- /// </summary>
+ /// <summary>
+ /// Mapping from level object to color value
+ /// </summary>
private LevelMapping m_levelMapping = new LevelMapping();
- #endregion // Private Instances Fields
+ #endregion // Private Instances Fields
- #region LevelColors LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the color it should be displayed as.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the mapping between a level and the color it should be displayed in.
- /// </para>
- /// </remarks>
+ #region LevelColors LevelMapping Entry
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the color it should be displayed as.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the mapping between a level and the color it should be displayed in.
+ /// </para>
+ /// </remarks>
public class LevelColors : LevelMappingEntry
{
- /// <summary>
- /// The mapped foreground color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped foreground color for the specified level.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// The mapped foreground color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped foreground color for the specified level.
+ /// </para>
+ /// </remarks>
public ConsoleColor ForeColor
{
get { return (this.foreColor); }
- // Keep a flag that the color has been set
- // and is no longer the default.
+ // Keep a flag that the color has been set
+ // and is no longer the default.
set { this.foreColor = value; this.hasForeColor = true; }
}
private ConsoleColor foreColor;
@@ -312,20 +304,20 @@
}
}
- /// <summary>
- /// The mapped background color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped background color for the specified level.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// The mapped background color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped background color for the specified level.
+ /// </para>
+ /// </remarks>
public ConsoleColor BackColor
{
get { return (this.backColor); }
- // Keep a flag that the color has been set
- // and is no longer the default.
+ // Keep a flag that the color has been set
+ // and is no longer the default.
set { this.backColor = value; this.hasBackColor = true; }
}
private ConsoleColor backColor;
@@ -338,13 +330,6 @@
}
}
}
- #endregion // LevelColors LevelMapping Entry
+ #endregion // LevelColors LevelMapping Entry
}
-}
-
-#endif
-#endif
-#endif // !MONO_1_0
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !NETCF
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/NetSendAppender.cs b/src/log4net/Appender/NetSendAppender.cs
index 1c0d0ae..a21bde3 100644
--- a/src/log4net/Appender/NetSendAppender.cs
+++ b/src/log4net/Appender/NetSendAppender.cs
@@ -17,17 +17,6 @@
//
#endregion
-// MONO 1.0 Beta mcs does not like #if !A && !B && !C syntax
-
-// .NET Compact Framework 1.0 has no support for Win32 NetMessageBufferSend API
-#if !NETCF
-// MONO 1.0 has no support for Win32 NetMessageBufferSend API
-#if !MONO
-// SSCLI 1.0 has no support for Win32 NetMessageBufferSend API
-#if !SSCLI
-// We don't want framework or platform specific code in the CLI version of log4net
-#if !CLI_1_0
-
using System;
using System.Runtime.InteropServices;
@@ -302,12 +291,8 @@
/// Sends the event using a network message.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
-#if !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
-#endif
protected override void Append(LoggingEvent loggingEvent)
{
NativeError nativeError = null;
@@ -417,9 +402,4 @@
#endregion
}
-}
-
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !MONO
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/OutputDebugStringAppender.cs b/src/log4net/Appender/OutputDebugStringAppender.cs
index 5580532..6a12604 100644
--- a/src/log4net/Appender/OutputDebugStringAppender.cs
+++ b/src/log4net/Appender/OutputDebugStringAppender.cs
@@ -17,13 +17,6 @@
//
#endregion
-// MONO 1.0 has no support for Win32 OutputDebugString API
-#if !MONO
-// SSCLI 1.0 has no support for Win32 OutputDebugString API
-#if !SSCLI
-// We don't want framework or platform specific code in the CLI version of log4net
-#if !CLI_1_0
-
using System.Runtime.InteropServices;
using log4net.Core;
@@ -74,15 +67,11 @@
/// Write the logging event to the output debug string API
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
-#endif
protected override void Append(LoggingEvent loggingEvent)
{
-#if NETSTANDARD
+#if NETSTANDARD2_0_OR_GREATER
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new System.PlatformNotSupportedException("OutputDebugString is only available on Windows");
@@ -119,7 +108,7 @@
/// Stub for OutputDebugString native method
/// </para>
/// </remarks>
-#if NETCF || NETSTANDARD
+#if NETSTANDARD2_0_OR_GREATER
[DllImport("CoreDll.dll")]
#else
[DllImport("Kernel32.dll")]
@@ -128,8 +117,4 @@
#endregion // Protected Static Methods
}
-}
-
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !MONO
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/RemoteSyslogAppender.cs b/src/log4net/Appender/RemoteSyslogAppender.cs
index 83e8de0..c113d5a 100644
--- a/src/log4net/Appender/RemoteSyslogAppender.cs
+++ b/src/log4net/Appender/RemoteSyslogAppender.cs
@@ -388,11 +388,7 @@
// Grab as a byte array
buffer = this.Encoding.GetBytes(builder.ToString());
-#if NET_4_5 || NETSTANDARD
Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
-#else
- this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
-#endif
}
}
catch (Exception e)
@@ -603,4 +599,4 @@
#endregion // LevelSeverity LevelMapping Entry
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/RemotingAppender.cs b/src/log4net/Appender/RemotingAppender.cs
index 69a0b6b..3fd32e8 100644
--- a/src/log4net/Appender/RemotingAppender.cs
+++ b/src/log4net/Appender/RemotingAppender.cs
@@ -17,8 +17,8 @@
//
#endregion
-// .NET Compact Framework 1.0 && netstandard has no support for System.Runtime.Remoting
-#if NET_2_0
+// netstandard has no support for System.Runtime.Remoting
+#if NET462_OR_GREATER
using System;
using System.Collections;
@@ -138,9 +138,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
public override void ActivateOptions()
{
base.ActivateOptions();
@@ -336,4 +334,4 @@
}
}
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Appender/RollingFileAppender.cs b/src/log4net/Appender/RollingFileAppender.cs
index aaf0b33..48a30c6 100644
--- a/src/log4net/Appender/RollingFileAppender.cs
+++ b/src/log4net/Appender/RollingFileAppender.cs
@@ -29,7 +29,7 @@
namespace log4net.Appender
{
#if CONFIRM_WIN32_FILE_SHAREMODES
- // The following sounds good, and I though it was the case, but after
+ // The following sounds good, and I thought it was the case, but after
// further testing on Windows I have not been able to confirm it.
/// On the Windows platform if another process has a write lock on the file
@@ -241,24 +241,17 @@
/// </summary>
~RollingFileAppender()
{
-#if !NETCF
if (m_mutexForRolling != null)
{
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
m_mutexForRolling.Dispose();
-#else
- m_mutexForRolling.Close();
-#endif
m_mutexForRolling = null;
}
-#endif
}
#endregion Public Instance Constructors
#region Public Instance Properties
-#if !NET_1_0 && !CLI_1_0 && !NETCF
/// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
/// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
@@ -281,23 +274,6 @@
/// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
/// </para>
/// </remarks>
-#else
- /// <summary>
- /// Gets or sets the strategy for determining the current date and time. The default
- /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
- /// </summary>
- /// <value>
- /// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
- /// </para>
- /// <para>
- /// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
- /// </para>
- /// </remarks>
-#endif
public IDateTime DateTimeStrategy
{
get { return m_dateTime; }
@@ -612,7 +588,6 @@
protected virtual void AdjustFileBeforeAppend()
{
// reuse the file appenders locking model to lock the rolling
-#if !NETCF
try
{
// if rolling should be locked, acquire the lock
@@ -620,7 +595,6 @@
{
m_mutexForRolling.WaitOne();
}
-#endif
if (m_rollDate)
{
var n = m_dateTime.Now;
@@ -640,7 +614,6 @@
RollOverSize();
}
}
-#if !NETCF
}
finally
{
@@ -650,7 +623,6 @@
m_mutexForRolling.ReleaseMutex();
}
}
-#endif
}
/// <summary>
@@ -837,18 +809,14 @@
DateTime last;
using (SecurityContext.Impersonate(this))
{
-#if !NET_1_0 && !CLI_1_0 && !NETCF
if (DateTimeStrategy is UniversalDateTime)
{
last = System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
}
else
{
-#endif
last = System.IO.File.GetLastWriteTime(m_baseFileName);
-#if !NET_1_0 && !CLI_1_0 && !NETCF
}
-#endif
}
LogLog.Debug(declaringType, "[" + last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo) + "] vs. [" + m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo) + "]");
@@ -1157,14 +1125,12 @@
m_baseFileName = base.File;
}
-#if !NETCF
// initialize the mutex that is used to lock rolling
m_mutexForRolling = new Mutex(false, m_baseFileName
.Replace("\\", "_")
.Replace(":", "_")
.Replace("/", "_") + "_rolling"
);
-#endif
if (m_rollDate && File != null && m_scheduledFilename == null)
{
@@ -1705,12 +1671,10 @@
/// </summary>
private string m_baseFileName;
-#if !NETCF
/// <summary>
/// A mutex that is used to lock rolling of files.
/// </summary>
private Mutex m_mutexForRolling;
-#endif
#endregion Private Instance Fields
@@ -1767,7 +1731,6 @@
}
}
-#if !NET_1_0 && !CLI_1_0 && !NETCF
/// <summary>
/// Implementation of <see cref="IDateTime"/> that returns the current time as the coordinated universal time (UTC).
/// </summary>
@@ -1787,7 +1750,6 @@
get { return DateTime.UtcNow; }
}
}
-#endif
#endregion DateTime
}
diff --git a/src/log4net/Appender/SmtpAppender.cs b/src/log4net/Appender/SmtpAppender.cs
index 58f822b..c323415 100644
--- a/src/log4net/Appender/SmtpAppender.cs
+++ b/src/log4net/Appender/SmtpAppender.cs
@@ -1,4 +1,3 @@
-#if NET_2_0 || NETSTANDARD2_0
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,20 +17,11 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for System.Web.Mail
-// SSCLI 1.0 has no support for System.Web.Mail
-#if !NETCF && !SSCLI
-
using System;
using System.IO;
using System.Text;
-#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
using System.Net.Mail;
-#else
-using System.Web.Mail;
-#endif
-
using log4net.Core;
namespace log4net.Appender
@@ -323,7 +313,6 @@
set { m_mailPriority = value; }
}
-#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
/// <summary>
/// Enable or disable use of SSL when sending e-mail message
/// </summary>
@@ -347,7 +336,6 @@
get { return m_replyTo; }
set { m_replyTo = value; }
}
-#endif
/// <summary>
/// Gets or sets the subject encoding to be used.
@@ -443,17 +431,12 @@
/// <param name="messageBody">the body text to include in the mail</param>
protected virtual void SendEmail(string messageBody)
{
-#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
// .NET 2.0 has a new API for SMTP email System.Net.Mail
// This API supports credentials and multiple hosts correctly.
// The old API is deprecated.
// Create and configure the smtp client
-#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0
using SmtpClient smtpClient = new SmtpClient();
-#else
- SmtpClient smtpClient = new SmtpClient();
-#endif
if (!String.IsNullOrEmpty(m_smtpHost))
{
smtpClient.Host = m_smtpHost;
@@ -489,13 +472,7 @@
}
if (!String.IsNullOrEmpty(m_replyTo))
{
- // .NET 4.0 warning CS0618: 'System.Net.Mail.MailMessage.ReplyTo' is obsolete:
- // 'ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses. http://go.microsoft.com/fwlink/?linkid=14202'
-#if !NET_4_0 && !MONO_4_0 && !NETSTANDARD2_0
- mailMessage.ReplyTo = new MailAddress(m_replyTo);
-#else
mailMessage.ReplyToList.Add(new MailAddress(m_replyTo));
-#endif
}
mailMessage.Subject = m_subject;
mailMessage.SubjectEncoding = m_subjectEncoding;
@@ -505,83 +482,6 @@
// behaviour compared to .NET 1.x. We would need a SendCompletedCallback to log errors.
smtpClient.Send(mailMessage);
}
-#else
- // .NET 1.x uses the System.Web.Mail API for sending Mail
-
- MailMessage mailMessage = new MailMessage();
- mailMessage.Body = messageBody;
- mailMessage.BodyEncoding = m_bodyEncoding;
- mailMessage.From = m_from;
- mailMessage.To = m_to;
- if (m_cc != null && m_cc.Length > 0)
- {
- mailMessage.Cc = m_cc;
- }
- if (m_bcc != null && m_bcc.Length > 0)
- {
- mailMessage.Bcc = m_bcc;
- }
- mailMessage.Subject = m_subject;
-#if !MONO && !NET_1_0 && !NET_1_1 && !CLI_1_0
- mailMessage.SubjectEncoding = m_subjectEncoding;
-#endif
- mailMessage.Priority = m_mailPriority;
-
-#if NET_1_1
- // The Fields property on the MailMessage allows the CDO properties to be set directly.
- // This property is only available on .NET Framework 1.1 and the implementation must understand
- // the CDO properties. For details of the fields available in CDO see:
- //
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_configuration_coclass.asp
- //
-
- try
- {
- if (m_authentication == SmtpAuthentication.Basic)
- {
- // Perform basic authentication
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", m_username);
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", m_password);
- }
- else if (m_authentication == SmtpAuthentication.Ntlm)
- {
- // Perform integrated authentication (NTLM)
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 2);
- }
-
- // Set the port if not the default value
- if (m_port != 25)
- {
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", m_port);
- }
- }
- catch(MissingMethodException missingMethodException)
- {
- // If we were compiled against .NET 1.1 but are running against .NET 1.0 then
- // we will get a MissingMethodException when accessing the MailMessage.Fields property.
-
- ErrorHandler.Error("SmtpAppender: Authentication and server Port are only supported when running on the MS .NET 1.1 framework", missingMethodException);
- }
-#else
- if (m_authentication != SmtpAuthentication.None)
- {
- ErrorHandler.Error("SmtpAppender: Authentication is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
- }
-
- if (m_port != 25)
- {
- ErrorHandler.Error("SmtpAppender: Server Port is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
- }
-#endif // if NET_1_1
-
- if (m_smtpHost != null && m_smtpHost.Length > 0)
- {
- SmtpMail.SmtpServer = m_smtpHost;
- }
-
- SmtpMail.Send(mailMessage);
-#endif // if NET_2_0
}
#endregion // Protected Methods
@@ -607,10 +507,8 @@
private MailPriority m_mailPriority = MailPriority.Normal;
-#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
private bool m_enableSsl = false;
private string m_replyTo;
-#endif
#endregion // Private Instance Fields
@@ -657,14 +555,7 @@
/// </summary>
private static string MaybeTrimSeparators(string s)
{
-#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
return string.IsNullOrEmpty(s) ? s : s.Trim(ADDRESS_DELIMITERS);
-#else
- return s != null && s.Length > 0 ? s : s.Trim(ADDRESS_DELIMITERS);
-#endif
}
}
-}
-
-#endif // !NETCF && !SSCLI
-#endif // NET_2_0
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/SmtpPickupDirAppender.cs b/src/log4net/Appender/SmtpPickupDirAppender.cs
index 8a0fab0..471126b 100644
--- a/src/log4net/Appender/SmtpPickupDirAppender.cs
+++ b/src/log4net/Appender/SmtpPickupDirAppender.cs
@@ -157,11 +157,7 @@
m_fileExtension = string.Empty;
}
// Make sure any non empty extension starts with a dot
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
if (!string.IsNullOrEmpty(m_fileExtension) && !m_fileExtension.StartsWith("."))
-#else
- if (m_fileExtension != null && m_fileExtension.Length > 0 && !m_fileExtension.StartsWith("."))
-#endif
{
m_fileExtension = "." + m_fileExtension;
}
diff --git a/src/log4net/Appender/TelnetAppender.cs b/src/log4net/Appender/TelnetAppender.cs
index b0e2130..d637f05 100644
--- a/src/log4net/Appender/TelnetAppender.cs
+++ b/src/log4net/Appender/TelnetAppender.cs
@@ -23,9 +23,7 @@
using System.Net;
using System.Net.Sockets;
using System.IO;
-#if NETSTANDARD
using System.Threading.Tasks;
-#endif
using log4net.Core;
using log4net.Util;
@@ -311,11 +309,7 @@
try
{
-#if NET_4_0 || NETSTANDARD
m_socket.Dispose();
-#else
- m_socket.Close();
-#endif
}
catch { }
@@ -346,11 +340,7 @@
private void AcceptConnection()
{
-#if NETSTANDARD
- m_serverSocket.AcceptAsync().ContinueWith(OnConnect, TaskScheduler.Default);
-#else
m_serverSocket.BeginAccept(new AsyncCallback(OnConnect), null);
-#endif
}
/// <summary>
@@ -433,9 +423,6 @@
}
-#if NETSTANDARD
- private void OnConnect(Task<Socket> acceptTask)
-#else
/// <summary>
/// Callback used to accept a connection on the server socket
/// </summary>
@@ -447,16 +434,11 @@
/// </para>
/// </remarks>
private void OnConnect(IAsyncResult asyncResult)
-#endif
{
try
{
-#if NETSTANDARD
- Socket socket = acceptTask.GetAwaiter().GetResult();
-#else
// Block until a client connects
Socket socket = m_serverSocket.EndAccept(asyncResult);
-#endif
LogLog.Debug(declaringType, "Accepting connection from [" + socket.RemoteEndPoint.ToString() + "]");
SocketClient client = new SocketClient(socket);
@@ -523,11 +505,7 @@
try
{
-#if NET_2_0
- localSocket.Close();
-#else
localSocket.Dispose();
-#endif
}
catch
{
@@ -539,4 +517,4 @@
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/TraceAppender.cs b/src/log4net/Appender/TraceAppender.cs
index e495336..27cdb9f 100644
--- a/src/log4net/Appender/TraceAppender.cs
+++ b/src/log4net/Appender/TraceAppender.cs
@@ -146,22 +146,14 @@
//
// Write the string to the Trace system
//
-#if NETCF
- System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent));
-#else
System.Diagnostics.Trace.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent));
-#endif
//
// Flush the Trace system if needed
//
if (m_immediateFlush)
{
-#if NETCF
- System.Diagnostics.Debug.Flush();
-#else
System.Diagnostics.Trace.Flush();
-#endif
}
}
@@ -218,12 +210,8 @@
if (m_immediateFlush) return true;
// System.Diagnostics.Trace and System.Diagnostics.Debug are thread-safe, so no need for lock(this).
-#if NETCF
- System.Diagnostics.Debug.Flush();
-#else
System.Diagnostics.Trace.Flush();
-#endif
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Appender/UdpAppender.cs b/src/log4net/Appender/UdpAppender.cs
index b0d4f68..216e6b9 100644
--- a/src/log4net/Appender/UdpAppender.cs
+++ b/src/log4net/Appender/UdpAppender.cs
@@ -401,11 +401,7 @@
try
{
Byte[] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray());
-#if NETSTANDARD
- Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
-#else
this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
-#endif
}
catch (Exception ex)
{
@@ -475,19 +471,11 @@
{
if (this.LocalPort == 0)
{
-#if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0
- this.Client = new UdpClient();
-#else
this.Client = new UdpClient(RemoteAddress.AddressFamily);
-#endif
}
else
{
-#if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0
- this.Client = new UdpClient(this.LocalPort);
-#else
this.Client = new UdpClient(this.LocalPort, RemoteAddress.AddressFamily);
-#endif
}
}
catch (Exception ex)
@@ -537,11 +525,7 @@
/// <summary>
/// The encoding to use for the packet.
/// </summary>
-#if NETSTANDARD
- private Encoding m_encoding = Encoding.Unicode;
-#else
private Encoding m_encoding = Encoding.Default;
-#endif
#endregion Private Instance Fields
}
diff --git a/src/log4net/AssemblyInfo.cs b/src/log4net/AssemblyInfo.cs
index 3c55f6b..ed3f5f7 100644
--- a/src/log4net/AssemblyInfo.cs
+++ b/src/log4net/AssemblyInfo.cs
@@ -18,115 +18,40 @@
#endregion
using System.Reflection;
-using System.Runtime.CompilerServices;
-// [assembly:AssemblyKeyFile("log4net.snk")]
-
-#if (!SSCLI)
//
// log4net makes use of static methods which cannot be made com visible
//
[assembly: System.Runtime.InteropServices.ComVisible(false)]
-#endif
//
// log4net is CLS compliant
//
[assembly: System.CLSCompliant(true)]
-#if (!NETCF)
//
// If log4net is strongly named it still allows partially trusted callers
//
[assembly: System.Security.AllowPartiallyTrustedCallers]
-#endif
-#if (NET_4_0 || NETSTANDARD2_0)
//
// Allows partial trust applications (e.g. ASP.NET shared hosting) on .NET 4.0 to work
// given our implementation of ISerializable.
//
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
-#endif
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
-#if (CLI_1_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.CLI 1.0")]
-[assembly: AssemblyTitle("Apache log4net for CLI 1.0 Compatible Frameworks")]
-#elif (NET_1_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 1.0")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 1.0")]
-#elif (NET_1_1)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 1.1")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 1.1")]
-#elif (NET_4_5)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 4.5")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.5")]
-#elif (NET_4_0)
-#if CLIENT_PROFILE
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 4.0 CP")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.0 Client Profile")]
-#else
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 4.0")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.0")]
-#endif // Client Profile
-#elif (NET_3_5)
-#if CLIENT_PROFILE
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 3.5 CP")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 3.5 Client Profile")]
-#else
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 3.5")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 3.5")]
-#endif // Client Profile
-#elif (NET_2_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET 2.0")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework 2.0")]
-#elif (NETCF_1_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NETCF 1.0")]
-[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework 1.0")]
-#elif (NETCF_2_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NETCF 2.0")]
-[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework 2.0")]
-#elif (MONO_1_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-Mono 1.0")]
-[assembly: AssemblyTitle("Apache log4net for Mono 1.0")]
-#elif (MONO_2_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-Mono 2.0")]
-[assembly: AssemblyTitle("Apache log4net for Mono 2.0")]
-#elif (MONO_3_5)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-Mono 3.5")]
-[assembly: AssemblyTitle("Apache log4net for Mono 3.5")]
-#elif (MONO_4_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-Mono 4.0")]
-[assembly: AssemblyTitle("Apache log4net for Mono 4.0")]
-#elif (SSCLI_1_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-SSCLI 1.0")]
-[assembly: AssemblyTitle("Apache log4net for Shared Source CLI 1.0")]
-#elif (NET)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET")]
-[assembly: AssemblyTitle("Apache log4net for .NET Framework")]
-#elif (NETSTANDARD1_3)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET Standard 1.3")]
-[assembly: AssemblyTitle("Apache log4net for .NET Standard 1.3")]
-#elif (NETSTANDARD2_0)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NET Standard 2.0")]
+#if NET462_OR_GREATER
+[assembly: AssemblyInformationalVersion("2.0.16.0-.NET 4.6.2")]
+[assembly: AssemblyTitle("Apache log4net for .NET Framework 4.6.2")]
+#endif
+#if NETSTANDARD2_0_OR_GREATER
+[assembly: AssemblyInformationalVersion("2.0.16.0-.NET Standard 2.0")]
[assembly: AssemblyTitle("Apache log4net for .NET Standard 2.0")]
-#elif (NETCF)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-.NETCF")]
-[assembly: AssemblyTitle("Apache log4net for .NET Compact Framework")]
-#elif (MONO)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-Mono")]
-[assembly: AssemblyTitle("Apache log4net for Mono")]
-#elif (SSCLI)
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0-SSCLI")]
-[assembly: AssemblyTitle("Apache log4net for Shared Source CLI")]
-#else
-[assembly: AssemblyInformationalVersionAttribute("2.0.16.0")]
-[assembly: AssemblyTitle("Apache log4net")]
#endif
#if DEBUG
@@ -137,43 +62,4 @@
[assembly: AssemblyProduct("log4net")]
[assembly: AssemblyDefaultAlias("log4net")]
-[assembly: AssemblyCulture("")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-#if STRONG && (CLI_1_0 || NET_1_0 || NET_1_1 || NETCF_1_0 || SSCLI)
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile(@"..\..\..\log4net.snk")]
-#endif
-// We do not use a CSP key for strong naming
-// [assembly: AssemblyKeyName("")]
-
-[assembly: InternalsVisibleTo("log4net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100297dcac908e286"
- + "89360399027b0ea4cd852fbb74e1ed95e695a5ba55cbd1d075ec20cdb5fa6fc593d3d571527b20"
- + "558d6f39e1f4d5cfe0798428c589c311965244b209c38a02aaa8c9da3b72405b6fedeeb4292c34"
- + "57e9769b74e645c19cb06c2be75fb2d12281a585fbeabf7bd195d6961ba113286fc3e286d7bbd6"
- + "9024ceda")]
-
+[assembly: AssemblyCulture("")]
\ No newline at end of file
diff --git a/src/log4net/AssemblyVersionInfo.cs b/src/log4net/AssemblyVersionInfo.cs
index 14524de..64b2e33 100644
--- a/src/log4net/AssemblyVersionInfo.cs
+++ b/src/log4net/AssemblyVersionInfo.cs
@@ -29,17 +29,12 @@
// by using the '*' as shown below:
[assembly: System.Reflection.AssemblyVersion("2.0.16.0")]
-
-#if !NETCF
-#if !SSCLI
[assembly: System.Reflection.AssemblyFileVersion("2.0.16.0")]
-#endif
-#endif
//
// Shared assembly settings
//
[assembly: System.Reflection.AssemblyCompany("The Apache Software Foundation")]
-[assembly: System.Reflection.AssemblyCopyright("Copyright 2004-2017 The Apache Software Foundation.")]
+[assembly: System.Reflection.AssemblyCopyright("Copyright 2004-2024 The Apache Software Foundation.")]
[assembly: System.Reflection.AssemblyTrademark("Apache and Apache log4net are trademarks of The Apache Software Foundation")]
diff --git a/src/log4net/Config/AliasDomainAttribute.cs b/src/log4net/Config/AliasDomainAttribute.cs
index c1da999..4726d33 100644
--- a/src/log4net/Config/AliasDomainAttribute.cs
+++ b/src/log4net/Config/AliasDomainAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
namespace log4net.Config
@@ -69,6 +66,4 @@
#endregion Public Instance Constructors
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/AliasRepositoryAttribute.cs b/src/log4net/Config/AliasRepositoryAttribute.cs
index 29b4a8f..5d82492 100644
--- a/src/log4net/Config/AliasRepositoryAttribute.cs
+++ b/src/log4net/Config/AliasRepositoryAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
namespace log4net.Config
@@ -98,6 +95,4 @@
#endregion Private Instance Fields
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/BasicConfigurator.cs b/src/log4net/Config/BasicConfigurator.cs
index 53afeae..be31939 100644
--- a/src/log4net/Config/BasicConfigurator.cs
+++ b/src/log4net/Config/BasicConfigurator.cs
@@ -19,9 +19,7 @@
using System;
using System.Collections;
-#if !NETSTANDARD1_3
using System.Reflection;
-#endif
using log4net.Appender;
using log4net.Layout;
@@ -84,7 +82,6 @@
#region Public Static Methods
-#if !NETSTANDARD1_3
/// <summary>
/// Initializes the log4net system with a default configuration.
/// </summary>
@@ -140,7 +137,6 @@
{
return Configure(new IAppender[] { appender });
}
-#endif // !NETSTANDARD1_3
/// <summary>
/// Initializes the <see cref="ILoggerRepository"/> with a default configuration.
@@ -233,4 +229,4 @@
#endregion Public Static Methods
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Config/ConfiguratorAttribute.cs b/src/log4net/Config/ConfiguratorAttribute.cs
index c884736..83d7a39 100644
--- a/src/log4net/Config/ConfiguratorAttribute.cs
+++ b/src/log4net/Config/ConfiguratorAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
using System.Reflection;
@@ -108,6 +105,4 @@
return result;
}
}
-}
-
-#endif //!NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/DOMConfigurator.cs b/src/log4net/Config/DOMConfigurator.cs
index b7c1563..a4de606 100644
--- a/src/log4net/Config/DOMConfigurator.cs
+++ b/src/log4net/Config/DOMConfigurator.cs
@@ -17,16 +17,11 @@
//
#endregion
-#if NET_2_0 // really only because netstandard doesn't understand Assembly.GetCallingAssembly()
using System;
-using System.Xml;
-using System.Collections;
using System.IO;
using System.Reflection;
-using System.Threading;
+using System.Xml;
-using log4net.Appender;
-using log4net.Util;
using log4net.Repository;
namespace log4net.Config
@@ -288,8 +283,6 @@
#region ConfigureAndWatch static methods
-#if (!NETCF && !SSCLI)
-
/// <summary>
/// Configures log4net using the file specified, monitors the file for changes
/// and reloads the configuration if a change is detected.
@@ -351,9 +344,7 @@
{
XmlConfigurator.ConfigureAndWatch(repository, configFile);
}
-#endif
#endregion ConfigureAndWatch static methods
}
-}
-#endif // NET_2_0
+}
\ No newline at end of file
diff --git a/src/log4net/Config/DOMConfiguratorAttribute.cs b/src/log4net/Config/DOMConfiguratorAttribute.cs
index 4a2c2b5..4243bed 100644
--- a/src/log4net/Config/DOMConfiguratorAttribute.cs
+++ b/src/log4net/Config/DOMConfiguratorAttribute.cs
@@ -17,16 +17,7 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
-using System.Reflection;
-using System.IO;
-
-using log4net.Util;
-using log4net.Repository;
-using log4net.Repository.Hierarchy;
namespace log4net.Config
{
@@ -55,6 +46,4 @@
public sealed class DOMConfiguratorAttribute : XmlConfiguratorAttribute
{
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/DomainAttribute.cs b/src/log4net/Config/DomainAttribute.cs
index 1aeab43..7830525 100644
--- a/src/log4net/Config/DomainAttribute.cs
+++ b/src/log4net/Config/DomainAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
namespace log4net.Config
@@ -82,6 +79,4 @@
#endregion Public Instance Constructors
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/Log4NetConfigurationSectionHandler.cs b/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
index be34c8c..25a3d9a 100644
--- a/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
+++ b/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
@@ -1,4 +1,3 @@
-#if NET_2_0 || NETSTANDARD2_0
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for application .config files
-#if !NETCF
-
using System.Configuration;
using System.Xml;
@@ -88,7 +84,4 @@
#endregion Implementation of IConfigurationSectionHandler
}
-}
-
-#endif // !NETCF
-#endif // NET_2_0 || NETSTANDARD2_0
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/PluginAttribute.cs b/src/log4net/Config/PluginAttribute.cs
index 21bbad7..65b9cb7 100644
--- a/src/log4net/Config/PluginAttribute.cs
+++ b/src/log4net/Config/PluginAttribute.cs
@@ -17,15 +17,10 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
using log4net.Core;
-#if !NETSTANDARD1_3
using log4net.Util;
-#endif
using log4net.Plugin;
namespace log4net.Config
@@ -49,7 +44,6 @@
{
#region Public Instance Constructors
-#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
/// <summary>
/// Initializes a new instance of the <see cref="PluginAttribute" /> class
/// with the specified type.
@@ -67,7 +61,6 @@
{
m_typeName = typeName;
}
-#endif
/// <summary>
/// Initializes a new instance of the <see cref="PluginAttribute" /> class
@@ -142,13 +135,11 @@
public IPlugin CreatePlugin()
{
Type pluginType = m_type;
-#if !NETSTANDARD1_3
if (m_type == null)
{
// Get the plugin object type from the string type name
pluginType = SystemInfo.GetTypeFromString(m_typeName, true, true);
}
-#endif
// Check that the type is a plugin
if (!(typeof(IPlugin).IsAssignableFrom(pluginType)))
{
@@ -193,6 +184,4 @@
#endregion Private Instance Fields
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/RepositoryAttribute.cs b/src/log4net/Config/RepositoryAttribute.cs
index 9f3b723..a782863 100644
--- a/src/log4net/Config/RepositoryAttribute.cs
+++ b/src/log4net/Config/RepositoryAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
namespace log4net.Config
@@ -101,7 +98,7 @@
public string Name
{
get { return m_name; }
- set { m_name = value; }
+ set { m_name = value ; }
}
/// <summary>
@@ -127,7 +124,7 @@
public Type RepositoryType
{
get { return m_repositoryType; }
- set { m_repositoryType = value; }
+ set { m_repositoryType = value ; }
}
#endregion Public Instance Properties
@@ -139,6 +136,4 @@
#endregion Private Instance Fields
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/SecurityContextProviderAttribute.cs b/src/log4net/Config/SecurityContextProviderAttribute.cs
index 5e76c1f..c6f1df9 100644
--- a/src/log4net/Config/SecurityContextProviderAttribute.cs
+++ b/src/log4net/Config/SecurityContextProviderAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
using System.Reflection;
@@ -146,6 +143,4 @@
#endregion Private Static Fields
}
-}
-
-#endif // !NETCF
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Config/XmlConfigurator.cs b/src/log4net/Config/XmlConfigurator.cs
index b11cda0..48f22c3 100644
--- a/src/log4net/Config/XmlConfigurator.cs
+++ b/src/log4net/Config/XmlConfigurator.cs
@@ -21,9 +21,7 @@
using System.Xml;
using System.Collections;
using System.IO;
-#if !NETCF && !NETSTANDARD1_3
using System.Reflection;
-#endif
using System.Threading;
using System.Net;
@@ -57,7 +55,6 @@
#region Configure static methods
-#if !NETCF
/// <summary>
/// Automatically configures the <see cref="ILoggerRepository"/> using settings
/// stored in the application's configuration file.
@@ -78,22 +75,6 @@
/// </para>
/// </remarks>
/// <param name="repository">The repository to configure.</param>
-#else
- /// <summary>
- /// Automatically configures the <see cref="ILoggerRepository"/> using settings
- /// stored in the application's configuration file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
-#endif
public static ICollection Configure(ILoggerRepository repository)
{
ArrayList configurationMessages = new ArrayList();
@@ -122,10 +103,6 @@
LogLog.Debug(declaringType, "Application config file location unknown");
}
-#if NETCF || NETSTANDARD1_3
- // No config file reading stuff. Just go straight for the file
- Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation));
-#else
try
{
XmlElement configElement = System.Configuration.ConfigurationManager.GetSection("log4net") as XmlElement;
@@ -154,11 +131,8 @@
LogLog.Error(declaringType, "Failed to parse config file. Is the <configSections> specified as: " + configSectionStr, confEx);
}
}
-#endif
}
-#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
-#if !NETCF
/// <summary>
/// Automatically configures the log4net system based on the
/// application's configuration settings.
@@ -179,21 +153,6 @@
/// </para>
/// </remarks>
/// <seealso cref="Log4NetConfigurationSectionHandler"/>
-#else
- /// <summary>
- /// Automatically configures the log4net system based on the
- /// application's configuration settings.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// </remarks>
-#endif
public static ICollection Configure()
{
return Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
@@ -225,7 +184,6 @@
return configurationMessages;
}
-#if !NETCF
/// <summary>
/// Configures log4net using the specified configuration file.
/// </summary>
@@ -276,42 +234,6 @@
/// </configuration>
/// </code>
/// </remarks>
-#else
- /// <summary>
- /// Configures log4net using the specified configuration file.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
-#endif
public static ICollection Configure(FileInfo configFile)
{
ArrayList configurationMessages = new ArrayList();
@@ -381,7 +303,6 @@
return configurationMessages;
}
-#endif // !NETSTANDARD1_3
/// <summary>
/// Configures the <see cref="ILoggerRepository"/> using the specified XML
@@ -409,7 +330,6 @@
return configurationMessages;
}
-#if !NETCF
/// <summary>
/// Configures the <see cref="ILoggerRepository"/> using the specified configuration
/// file.
@@ -462,44 +382,6 @@
/// </configuration>
/// </code>
/// </remarks>
-#else
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
-#endif
public static ICollection Configure(ILoggerRepository repository, FileInfo configFile)
{
ArrayList configurationMessages = new ArrayList();
@@ -634,7 +516,6 @@
if (configRequest != null)
{
-#if !NETCF_1_0
// authentication may be required, set client to use default credentials
try
{
@@ -644,14 +525,9 @@
{
// ignore security exception
}
-#endif
try
{
-#if NETSTANDARD
- using WebResponse response = configRequest.GetResponseAsync().GetAwaiter().GetResult();
-#else
using WebResponse response = configRequest.GetResponse();
-#endif
if (response != null)
{
using var configStream = response.GetResponseStream();
@@ -708,40 +584,17 @@
else
{
// Load the config file into a document
-#if NETSTANDARD1_3
- XmlDocument doc = new XmlDocument();
-#else
XmlDocument doc = new XmlDocument { XmlResolver = null };
-#endif
try
{
-#if (NETCF)
- // Create a text reader for the file stream
- XmlTextReader xmlReader = new XmlTextReader(configStream);
-#elif NET_2_0 || NETSTANDARD
// Allow the DTD to specify entity includes
XmlReaderSettings settings = new XmlReaderSettings();
// .NET 4.0 warning CS0618: 'System.Xml.XmlReaderSettings.ProhibitDtd'
// is obsolete: 'Use XmlReaderSettings.DtdProcessing property instead.'
-#if NETSTANDARD1_3 // TODO DtdProcessing.Parse not yet available (https://github.com/dotnet/corefx/issues/4376)
settings.DtdProcessing = DtdProcessing.Ignore;
-#elif !NET_4_0 && !MONO_4_0 && !NETSTANDARD2_0
- settings.ProhibitDtd = true;
-#else
- settings.DtdProcessing = DtdProcessing.Ignore;
-#endif
// Create a reader over the input stream
using XmlReader xmlReader = XmlReader.Create(configStream, settings);
-#else
- // Create a validating reader around a text reader for the file stream
- using XmlValidatingReader xmlReader = new XmlValidatingReader(new XmlTextReader(configStream));
-
- // Specify that the reader should not perform validation, but that it should
- // expand entity refs.
- xmlReader.ValidationType = ValidationType.None;
- xmlReader.EntityHandling = EntityHandling.ExpandEntities;
-#endif
// load the data into the document
doc.Load(xmlReader);
@@ -780,8 +633,6 @@
#region ConfigureAndWatch static methods
-#if (!NETCF && !SSCLI)
-#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
/// <summary>
/// Configures log4net using the file specified, monitors the file for changes
/// and reloads the configuration if a change is detected.
@@ -818,7 +669,6 @@
return configurationMessages;
}
-#endif // !NETSTANDARD1_3
/// <summary>
/// Configures the <see cref="ILoggerRepository"/> using the file specified,
@@ -896,13 +746,11 @@
}
}
}
-#endif
#endregion ConfigureAndWatch static methods
#region ConfigureAndWatchHandler
-#if (!NETCF && !SSCLI)
/// <summary>
/// Class used to watch config files.
/// </summary>
@@ -959,9 +807,7 @@
/// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" /> class.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
{
m_repository = repository;
@@ -1039,9 +885,7 @@
/// <summary>
/// Release the handles held by the watcher and timer.
/// </summary>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
-#endif
public void Dispose()
{
m_watcher.EnableRaisingEvents = false;
@@ -1049,7 +893,6 @@
m_timer.Dispose();
}
}
-#endif
#endregion ConfigureAndWatchHandler
@@ -1094,11 +937,7 @@
// Copy the xml data into the root of a new document
// this isolates the xml config data from the rest of
// the document
-#if NETSTANDARD1_3
- XmlDocument newDoc = new XmlDocument();
-#else
XmlDocument newDoc = new XmlDocument { XmlResolver = null };
-#endif
XmlElement newElement = (XmlElement)newDoc.AppendChild(newDoc.ImportNode(element, true));
// Pass the configurator the config element
@@ -1129,5 +968,4 @@
#endregion Private Static Fields
}
-}
-
+}
\ No newline at end of file
diff --git a/src/log4net/Config/XmlConfiguratorAttribute.cs b/src/log4net/Config/XmlConfiguratorAttribute.cs
index bdc79a1..b6d6c24 100644
--- a/src/log4net/Config/XmlConfiguratorAttribute.cs
+++ b/src/log4net/Config/XmlConfiguratorAttribute.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-#if !NETCF
-
using System;
using System.Collections;
using System.Reflection;
@@ -313,13 +310,6 @@
/// <param name="configFile">the FileInfo pointing to the config file</param>
private void ConfigureFromFile(ILoggerRepository targetRepository, FileInfo configFile)
{
-#if (SSCLI)
- if (m_configureAndWatch)
- {
- LogLog.Warn(declaringType, "XmlConfiguratorAttribute: Unable to watch config file not supported on SSCLI");
- }
- XmlConfigurator.Configure(targetRepository, configFile);
-#else
// Do we configure just once or do we configure and then watch?
if (m_configureAndWatch)
{
@@ -329,7 +319,6 @@
{
XmlConfigurator.Configure(targetRepository, configFile);
}
-#endif
}
/// <summary>
@@ -464,6 +453,4 @@
#endregion Private Static Fields
}
-}
-
-#endif // !NETCF
+}
\ No newline at end of file
diff --git a/src/log4net/Core/DefaultRepositorySelector.cs b/src/log4net/Core/DefaultRepositorySelector.cs
index 913bfc8..90699c3 100644
--- a/src/log4net/Core/DefaultRepositorySelector.cs
+++ b/src/log4net/Core/DefaultRepositorySelector.cs
@@ -17,17 +17,10 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for reading assembly attributes
-// and uses the CompactRepositorySelector instead
-#if !NETCF
-
using System;
using System.Collections;
-#if !NETSTANDARD
using System.Configuration;
-#else
using System.Linq;
-#endif
using System.IO;
using System.Reflection;
@@ -587,11 +580,7 @@
try
{
// Look for the RepositoryAttribute on the assembly
-#if NETSTANDARD
- object[] repositoryAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.RepositoryAttribute)).ToArray();
-#else
object[] repositoryAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.RepositoryAttribute), false);
-#endif
if (repositoryAttributes == null || repositoryAttributes.Length == 0)
{
// This is not a problem, but its nice to know what is going on.
@@ -663,11 +652,7 @@
}
// Look for the Configurator attributes (e.g. XmlConfiguratorAttribute) on the assembly
-#if NETSTANDARD
- object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.ConfiguratorAttribute)).ToArray();
-#else
object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.ConfiguratorAttribute), false);
-#endif
if (configAttributes != null && configAttributes.Length > 0)
{
// Sort the ConfiguratorAttributes in priority order
@@ -717,24 +702,7 @@
// Determine whether to watch the file or not based on an app setting value:
bool watchRepositoryConfigFile = false;
-#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile);
-#else
- {
- string watch = SystemInfo.GetAppSetting("log4net.Config.Watch");
- if (watch != null && watch.Length > 0)
- {
- try
- {
- watchRepositoryConfigFile = Boolean.Parse(watch);
- }
- catch (FormatException)
- {
- // simply not a Boolean
- }
- }
- }
-#endif
if (watchRepositoryConfigFile)
{
@@ -815,11 +783,7 @@
}
// Look for the PluginAttribute on the assembly
-#if NETSTANDARD
- object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.PluginAttribute)).ToArray();
-#else
object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.PluginAttribute), false);
-#endif
if (configAttributes != null && configAttributes.Length > 0)
{
foreach (log4net.Plugin.IPluginFactory configAttr in configAttributes)
@@ -859,11 +823,7 @@
}
// Look for the AliasRepositoryAttribute on the assembly
-#if NETSTANDARD
object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.AliasRepositoryAttribute)).ToArray();
-#else
- object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.AliasRepositoryAttribute), false);
-#endif
if (configAttributes != null && configAttributes.Length > 0)
{
foreach (log4net.Config.AliasRepositoryAttribute configAttr in configAttributes)
@@ -908,6 +868,4 @@
#endregion Private Instance Fields
}
-}
-
-#endif // !NETCF
+}
\ No newline at end of file
diff --git a/src/log4net/Core/Level.cs b/src/log4net/Core/Level.cs
index a200e2a..4aab7b7 100644
--- a/src/log4net/Core/Level.cs
+++ b/src/log4net/Core/Level.cs
@@ -80,9 +80,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
public sealed class Level : IComparable
{
#region Public Instance Constructors
@@ -111,11 +109,7 @@
}
m_levelValue = level;
-#if NETSTANDARD1_3
- m_levelName = levelName;
-#else
m_levelName = string.Intern(levelName);
-#endif
m_levelDisplayName = displayName;
}
diff --git a/src/log4net/Core/LevelCollection.cs b/src/log4net/Core/LevelCollection.cs
index 4f35882..6f7ad70 100644
--- a/src/log4net/Core/LevelCollection.cs
+++ b/src/log4net/Core/LevelCollection.cs
@@ -26,10 +26,7 @@
/// A strongly-typed collection of <see cref="Level"/> objects.
/// </summary>
/// <author>Nicko Cadell</author>
- public class LevelCollection : ICollection, IList, IEnumerable
-#if !NETSTANDARD1_3
- , ICloneable
-#endif
+ public class LevelCollection : ICollection, IList, IEnumerable, ICloneable
{
#region Interfaces
@@ -856,5 +853,4 @@
#endregion
}
-
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Core/LocationInfo.cs b/src/log4net/Core/LocationInfo.cs
index a3633fd..5e8295e 100644
--- a/src/log4net/Core/LocationInfo.cs
+++ b/src/log4net/Core/LocationInfo.cs
@@ -18,12 +18,10 @@
#endregion
using System;
-#if !NETCF && !NETSTANDARD1_3
using System.Collections;
using System.Diagnostics;
using log4net.Util;
-#endif
namespace log4net.Core
{
@@ -58,9 +56,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
public class LocationInfo
{
#region Public Instance Constructors
@@ -76,7 +72,7 @@
/// class based on the current thread.
/// </para>
/// </remarks>
- public LocationInfo(Type callerStackBoundaryDeclaringType)
+ public LocationInfo(Type callerStackBoundaryDeclaringType)
{
// Initialize all fields
m_className = NA;
@@ -85,14 +81,13 @@
m_methodName = NA;
m_fullInfo = NA;
-#if !NETCF && !NETSTANDARD1_3 // StackTrace isn't fully implemented for NETSTANDARD1_3 https://github.com/dotnet/corefx/issues/1797
if (callerStackBoundaryDeclaringType != null)
{
try
{
StackTrace st = new StackTrace(true);
int frameIndex = 0;
-
+
// skip frames not from fqnOfCallingClass
while (frameIndex < st.FrameCount)
{
@@ -119,15 +114,15 @@
{
// take into account the frames we skip above
int adjustedFrameCount = st.FrameCount - frameIndex;
- ArrayList stackFramesList = new ArrayList(adjustedFrameCount);
+ ArrayList stackFramesList = new ArrayList(adjustedFrameCount);
m_stackFrames = new StackFrameItem[adjustedFrameCount];
- for (int i = frameIndex; i < st.FrameCount; i++)
+ for (int i=frameIndex; i < st.FrameCount; i++)
{
stackFramesList.Add(new StackFrameItem(st.GetFrame(i)));
}
-
+
stackFramesList.CopyTo(m_stackFrames, 0);
-
+
// now frameIndex is the first 'user' caller frame
StackFrame locationFrame = st.GetFrame(frameIndex);
@@ -137,7 +132,7 @@
if (method != null)
{
- m_methodName = method.Name;
+ m_methodName = method.Name;
if (method.DeclaringType != null)
{
m_className = method.DeclaringType.FullName;
@@ -147,18 +142,17 @@
m_lineNumber = locationFrame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
// Combine all location info
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
}
}
}
- catch (System.Security.SecurityException)
+ catch(System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// some undefined set of SecurityPermission flags.
LogLog.Debug(declaringType, "Security exception while trying to get caller stack frame. Error Ignored. Location Information Not Available.");
}
}
-#endif
}
/// <summary>
@@ -180,7 +174,7 @@
m_fileName = fileName;
m_lineNumber = lineNumber;
m_methodName = methodName;
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
':' + m_lineNumber + ')';
}
@@ -272,8 +266,7 @@
{
get { return m_fullInfo; }
}
-
-#if !NETCF && !NETSTANDARD1_3
+
/// <summary>
/// Gets the stack frames from the stack trace of the caller making the log request
/// </summary>
@@ -281,7 +274,6 @@
{
get { return m_stackFrames; }
}
-#endif
#endregion Public Instance Properties
@@ -292,22 +284,20 @@
private readonly string m_lineNumber;
private readonly string m_methodName;
private readonly string m_fullInfo;
-#if !NETCF && !NETSTANDARD1_3
private readonly StackFrameItem[] m_stackFrames;
-#endif
#endregion Private Instance Fields
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LocationInfo class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LocationInfo);
+ /// <summary>
+ /// The fully qualified type of the LocationInfo class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LocationInfo);
/// <summary>
/// When location information is not available the constant
diff --git a/src/log4net/Core/LogException.cs b/src/log4net/Core/LogException.cs
index f9b8e25..7046442 100644
--- a/src/log4net/Core/LogException.cs
+++ b/src/log4net/Core/LogException.cs
@@ -18,9 +18,7 @@
#endregion
using System;
-#if !NETCF && !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace log4net.Core
{
@@ -36,14 +34,8 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
-#if NETSTANDARD1_3
- public class LogException : Exception
-#else
public class LogException : ApplicationException
-#endif
{
#region Public Instance Constructors
@@ -92,7 +84,6 @@
#region Protected Instance Constructors
-#if !NETCF && !NETSTANDARD1_3
/// <summary>
/// Serialization constructor
/// </summary>
@@ -107,8 +98,7 @@
protected LogException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
-#endif
#endregion Protected Instance Constructors
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Core/LoggerManager.cs b/src/log4net/Core/LoggerManager.cs
index 565cd6a..eeb145f 100644
--- a/src/log4net/Core/LoggerManager.cs
+++ b/src/log4net/Core/LoggerManager.cs
@@ -18,9 +18,7 @@
#endregion
using System;
-#if NETSTANDARD1_3
using System.Runtime.InteropServices;
-#endif
using System.Reflection;
using log4net.Util;
@@ -100,10 +98,6 @@
LogLog.Debug(declaringType, GetVersionInfo());
// Set the default repository selector
-#if NETCF
- s_repositorySelector = new CompactRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy));
- return;
-#elif !NETSTANDARD1_3
// Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector'
string appRepositorySelectorTypeName = SystemInfo.GetAppSetting("log4net.RepositorySelector");
if (appRepositorySelectorTypeName != null && appRepositorySelectorTypeName.Length > 0)
@@ -142,7 +136,6 @@
}
}
}
-#endif
// Create the DefaultRepositorySelector if not configured above
if (s_repositorySelector == null)
{
@@ -164,13 +157,11 @@
/// </remarks>
private static void RegisterAppDomainEvents()
{
-#if !NETCF && !NETSTANDARD1_3
// ProcessExit seems to be fired if we are part of the default domain
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
// Otherwise DomainUnload is fired
AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
-#endif
}
#endregion Static Constructor
@@ -799,25 +790,15 @@
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
-#if NETSTANDARD1_3
- Assembly myAssembly = typeof(LoggerManager).GetTypeInfo().Assembly;
- sb.Append($"log4net assembly [{myAssembly.FullName}]. ");
- //sb.Append($"Loaded from [{myAssembly.Location}]. "); // TODO Assembly.Location available in netstandard1.5
- sb.Append($"(.NET Framework [{RuntimeInformation.FrameworkDescription}] on {RuntimeInformation.OSDescription}");
-#else
Assembly myAssembly = Assembly.GetExecutingAssembly();
sb.Append("log4net assembly [").Append(myAssembly.FullName).Append("]. ");
sb.Append("Loaded from [").Append(SystemInfo.AssemblyLocationInfo(myAssembly)).Append("]. ");
sb.Append("(.NET Runtime [").Append(Environment.Version.ToString()).Append("]");
-#if (!SSCLI)
sb.Append(" on ").Append(Environment.OSVersion.ToString());
-#endif
-#endif // NETSTANDARD1_3
sb.Append(")");
return sb.ToString();
}
-#if (!NETCF)
/// <summary>
/// Called when the <see cref="AppDomain.DomainUnload"/> event fires
/// </summary>
@@ -853,7 +834,6 @@
{
Shutdown();
}
-#endif
#endregion Private Static Methods
@@ -875,4 +855,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Core/LoggingEvent.cs b/src/log4net/Core/LoggingEvent.cs
index b4d2a00..9ebad56 100644
--- a/src/log4net/Core/LoggingEvent.cs
+++ b/src/log4net/Core/LoggingEvent.cs
@@ -24,9 +24,7 @@
using System.IO;
using System.Runtime.Serialization;
using System.Security;
-#if !NETCF && !NETSTANDARD1_3
using System.Security.Principal;
-#endif
using log4net.Util;
using log4net.Repository;
@@ -226,13 +224,8 @@
/// <author>Gert Driesen</author>
/// <author>Douglas de la Torre</author>
/// <author>Daniel Cazzulino</author>
-#if !NETCF
[Serializable]
-#endif
- public class LoggingEvent
-#if !NETCF
- : ISerializable
-#endif
+ public class LoggingEvent : ISerializable
{
private static readonly Type declaringType = typeof(LoggingEvent);
@@ -375,8 +368,6 @@
#region Protected Instance Constructors
-#if !NETCF
-
/// <summary>
/// Serialization constructor
/// </summary>
@@ -414,8 +405,6 @@
m_fixFlags = FixFlags.All;
}
-#endif
-
#endregion Protected Instance Constructors
#region Public Instance Properties
@@ -731,11 +720,6 @@
{
if (m_data.ThreadName == null && this.m_cacheUpdatable)
{
-#if NETCF
- // Get thread ID only
- m_data.ThreadName =
- SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
-#else
// '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
// '.NET TP Worker' is the default thread name in the .NET 8+ thread pool.
// Prefer the numeric thread ID instead.
@@ -767,7 +751,6 @@
.ToString(System.Globalization.CultureInfo.InvariantCulture);
}
}
-#endif
}
return m_data.ThreadName;
@@ -826,10 +809,6 @@
private string TryGetCurrentUserName()
{
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current Windows user
- return SystemInfo.NotAvailableText;
-#else
if (_platformDoesNotSupportWindowsIdentity)
{
// we've already received one PlatformNotSupportedException
@@ -861,23 +840,16 @@
{
return null;
}
-#endif
}
-#if (NETCF || SSCLI || NETSTANDARD1_3)
-#else
private string _cachedWindowsIdentityUserName;
private static string TryReadWindowsIdentityUserName()
{
using var identity = WindowsIdentity.GetCurrent();
return identity?.Name ?? "";
}
-#endif
-#if (NETCF || SSCLI || NETSTANDARD1_3)
-#else
private static bool _platformDoesNotSupportWindowsIdentity;
-#endif
/// <summary>
/// Gets the identity of the current thread principal.
@@ -897,10 +869,6 @@
{
if (m_data.Identity == null && this.m_cacheUpdatable)
{
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current thread principals
- m_data.Identity = SystemInfo.NotAvailableText;
-#else
try
{
if (System.Threading.Thread.CurrentPrincipal != null &&
@@ -933,7 +901,6 @@
m_data.Identity = "";
}
-#endif
}
return m_data.Identity;
@@ -1031,8 +998,6 @@
#region Implementation of ISerializable
-#if !NETCF
-
/// <summary>
/// Serializes this object into the <see cref="SerializationInfo" /> provided.
/// </summary>
@@ -1048,13 +1013,9 @@
/// is to be used outside that method.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecurityCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
+ [System.Security.SecurityCritical]
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
SerializationFormatter = true)]
-#endif
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
// The caller must call FixVolatileData before this object
@@ -1078,8 +1039,6 @@
info.AddValue("Identity", m_data.Identity);
}
-#endif
-
#endregion Implementation of ISerializable
#region Public Instance Methods
@@ -1358,13 +1317,11 @@
{
compositeProperties.Add(m_eventProperties);
}
-#if !NETCF
var logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
if (logicalThreadProperties != null)
{
compositeProperties.Add(logicalThreadProperties);
}
-#endif
var threadProperties = ThreadContext.Properties.GetProperties(false);
if (threadProperties != null)
{
diff --git a/src/log4net/Core/MethodItem.cs b/src/log4net/Core/MethodItem.cs
index 113cd37..93cfa97 100644
--- a/src/log4net/Core/MethodItem.cs
+++ b/src/log4net/Core/MethodItem.cs
@@ -28,9 +28,7 @@
/// as that would require that the containing assembly is loaded.
/// </summary>
///
-#if !NETCF
[Serializable]
-#endif
public class MethodItem
{
#region Public Instance Constructors
diff --git a/src/log4net/Core/StackFrameItem.cs b/src/log4net/Core/StackFrameItem.cs
index abad979..2a26818 100644
--- a/src/log4net/Core/StackFrameItem.cs
+++ b/src/log4net/Core/StackFrameItem.cs
@@ -1,4 +1,3 @@
-#if !NETCF
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -191,5 +190,4 @@
#endregion Private Static Fields
}
-}
-#endif
+}
\ No newline at end of file
diff --git a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
index d510c56..7e19d1a 100644
--- a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
+++ b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
@@ -140,11 +140,6 @@
// Render the string buffer to a string
timeString = s_lastTimeBuf.ToString();
-#if NET_1_1
- // Ensure that the above string is written into the variable NOW on all threads.
- // This is only required on multiprocessor machines with weak memeory models
- System.Threading.Thread.MemoryBarrier();
-#endif
// Store the time as a string (we only have to do this once per second)
s_lastTimeStrings[GetType()] = timeString;
s_lastTimeToTheSecond = currentTimeToTheSecond;
diff --git a/src/log4net/Filter/LoggerMatchFilter.cs b/src/log4net/Filter/LoggerMatchFilter.cs
index 8f57744..6742184 100644
--- a/src/log4net/Filter/LoggerMatchFilter.cs
+++ b/src/log4net/Filter/LoggerMatchFilter.cs
@@ -107,7 +107,7 @@
set { m_loggerToMatch = value; }
}
- #endregion
+ #endregion
#region Override implementation of FilterSkeleton
diff --git a/src/log4net/Filter/StringMatchFilter.cs b/src/log4net/Filter/StringMatchFilter.cs
index 0c4bb7e..f94c89d 100644
--- a/src/log4net/Filter/StringMatchFilter.cs
+++ b/src/log4net/Filter/StringMatchFilter.cs
@@ -91,15 +91,11 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
if (m_stringRegexToMatch != null)
{
-#if NETSTANDARD1_3
- m_regexToMatch = new Regex(m_stringRegexToMatch);
-#else
m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
-#endif
}
}
@@ -186,7 +182,7 @@
/// <see cref="FilterDecision.Deny"/> is returned.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -202,7 +198,7 @@
// to continue processing
return FilterDecision.Neutral;
}
-
+
// Firstly check if we are matching using a regex
if (m_regexToMatch != null)
{
@@ -211,29 +207,29 @@
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
else if (m_stringToMatch != null)
{
// Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
+ if (msg.IndexOf(m_stringToMatch) == -1)
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
return FilterDecision.Neutral;
diff --git a/src/log4net/Layout/DynamicPatternLayout.cs b/src/log4net/Layout/DynamicPatternLayout.cs
index ef6c4bc..8dd206d 100644
--- a/src/log4net/Layout/DynamicPatternLayout.cs
+++ b/src/log4net/Layout/DynamicPatternLayout.cs
@@ -113,7 +113,7 @@
base.Header = value;
m_headerPatternString = new PatternString(value);
}
- } /* property DynamicPatternLayout Header */
+ } /* property DynamicPatternLayout Header */
/// <summary>
/// The footer for the layout format.
@@ -137,7 +137,7 @@
base.Footer = value;
m_footerPatternString = new PatternString(value);
}
- } /* property DynamicPatternLayout Footer */
+ } /* property DynamicPatternLayout Footer */
#endregion
} /* class DynamicPatternLayout */
} /* namespace log4net.Layout */
diff --git a/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs b/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
index 32c8cca..f87020b 100644
--- a/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.IO;
using System.Web;
using log4net.Core;
@@ -75,5 +71,4 @@
}
}
-#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
index 1cd902f..e2253e1 100644
--- a/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.IO;
using System.Web;
using log4net.Core;
@@ -66,5 +62,4 @@
}
}
-#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/AspNetPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
index 17d2ca1..f43dccc 100644
--- a/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.IO;
using System.Web;
using log4net.Core;
@@ -62,6 +58,4 @@
protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext);
}
}
-
-#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
index 01b203e..037ed9d 100644
--- a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.IO;
using System.Web;
using log4net.Core;
@@ -87,5 +83,4 @@
}
}
-#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
index 8cbcae6..14f7997 100644
--- a/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
@@ -1,4 +1,4 @@
-#if NET_2_0
+#if NET462_OR_GREATER
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,10 +18,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE
-
using System.IO;
using System.Web;
using log4net.Core;
@@ -75,5 +71,4 @@
}
}
-#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
index b2262d4..6f3d3e8 100644
--- a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
@@ -99,22 +99,18 @@
case "message":
WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Message);
break;
-#if !NETCF
case "source":
WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Source);
break;
case "stacktrace":
WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.StackTrace);
break;
-#if !NETSTANDARD
case "targetsite":
WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.TargetSite);
break;
-#endif
case "helplink":
WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.HelpLink);
break;
-#endif
default:
// do not output SystemInfo.NotAvailableText
break;
diff --git a/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs b/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
index a97a1b5..862a619 100644
--- a/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
@@ -18,8 +18,6 @@
* under the License.
*
*/
-#if !NETCF && (NET_2_0 || NETSTANDARD2_0)
-
using System;
using System.Text;
@@ -86,5 +84,4 @@
#endregion Private Static Fields
}
-}
-#endif // !NETCF && NET_2_0
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
index df3ccb5..d3be2ff 100644
--- a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
@@ -16,7 +16,7 @@
// limitations under the License.
//
#endregion
-#if !NETCF && (NET_2_0 || NETSTANDARD2_0)
+
using System;
using System.IO;
@@ -146,4 +146,3 @@
#endregion Private Static Fields
}
}
-#endif // !NETCF && NET_2_0
diff --git a/src/log4net/Layout/PatternLayout.cs b/src/log4net/Layout/PatternLayout.cs
index bbf131c..807a44f 100644
--- a/src/log4net/Layout/PatternLayout.cs
+++ b/src/log4net/Layout/PatternLayout.cs
@@ -859,9 +859,8 @@
s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
s_globalRulesRegistry.Add("n", typeof(NewLinePatternConverter));
- // .NET Compact Framework 1.0 has no support for ASP.NET
- // SSCLI 1.0 has no support for ASP.NET
-#if !NETCF && !SSCLI && !CLIENT_PROFILE && !NETSTANDARD
+ // .NET Standard has no support for ASP.NET
+#if NET462_OR_GREATER
s_globalRulesRegistry.Add("aspnet-cache", typeof(AspNetCachePatternConverter));
s_globalRulesRegistry.Add("aspnet-context", typeof(AspNetContextPatternConverter));
s_globalRulesRegistry.Add("aspnet-request", typeof(AspNetRequestPatternConverter));
@@ -905,10 +904,8 @@
s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter));
s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter));
-#if !NETCF && !NETSTANDARD1_3
s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter));
s_globalRulesRegistry.Add("stacktracedetail", typeof(StackTraceDetailPatternConverter));
-#endif
s_globalRulesRegistry.Add("t", typeof(ThreadPatternConverter));
s_globalRulesRegistry.Add("thread", typeof(ThreadPatternConverter));
diff --git a/src/log4net/Log4netAssemblyInfo.cs b/src/log4net/Log4netAssemblyInfo.cs
deleted file mode 100644
index 78f1a01..0000000
--- a/src/log4net/Log4netAssemblyInfo.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-#region Apache License
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to you under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-#endregion
-
-namespace log4net {
-
- /// <summary>
- /// Provides information about the environment the assembly has
- /// been built for.
- /// </summary>
- public sealed class AssemblyInfo {
- /// <summary>Version of the assembly</summary>
- public const string Version = "2.0.9";
-
- /// <summary>Version of the framework targeted</summary>
-#if NET_1_1
- public const decimal TargetFrameworkVersion = 1.1M;
-#elif NET_4_5
- public const decimal TargetFrameworkVersion = 4.5M;
-#elif NET_4_0 || MONO_4_0
- public const decimal TargetFrameworkVersion = 4.5M;
-#elif FRAMEWORK_4_0_OR_ABOVE
- public const decimal TargetFrameworkVersion = 4.0M;
-#elif MONO_3_5
- public const decimal TargetFrameworkVersion = 3.5M;
-#elif NET_2_0 || NETCF_2_0 || MONO_2_0
-#if !CLIENT_PROFILE
- public const decimal TargetFrameworkVersion = 2.0M;
-#else
- public const decimal TargetFrameworkVersion = 3.5M;
-#endif // Client Profile
-#else
- public const decimal TargetFrameworkVersion = 1.0M;
-#endif
-
- /// <summary>Type of framework targeted</summary>
-#if CLI
- public const string TargetFramework = "CLI Compatible Frameworks";
-#elif NET
- public const string TargetFramework = ".NET Framework";
-#elif NETCF
- public const string TargetFramework = ".NET Compact Framework";
-#elif MONO
- public const string TargetFramework = "Mono";
-#elif SSCLI
- public const string TargetFramework = "Shared Source CLI";
-#elif NETSTANDARD1_3
- public const string TargetFramework = ".NET Core";
-#else
- public const string TargetFramework = "Unknown";
-#endif
-
- /// <summary>Does it target a client profile?</summary>
-#if !CLIENT_PROFILE
- public const bool ClientProfile = false;
-#else
- public const bool ClientProfile = true;
-#endif
-
- /// <summary>
- /// Identifies the version and target for this assembly.
- /// </summary>
- public static string Info {
- get {
- return string.Format("Apache log4net version {0} compiled for {1}{2} {3}",
- Version, TargetFramework,
- /* Can't use
- ClientProfile && true ? " Client Profile" :
- or the compiler whines about unreachable expressions
- */
-#if !CLIENT_PROFILE
- string.Empty,
-#else
- " Client Profile",
-#endif
- TargetFrameworkVersion);
- }
- }
- }
-
-}
diff --git a/src/log4net/LogManager.cs b/src/log4net/LogManager.cs
index 0eb25ce..939295e 100644
--- a/src/log4net/LogManager.cs
+++ b/src/log4net/LogManager.cs
@@ -73,7 +73,6 @@
#region Type Specific Manager Methods
-#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
/// <overloads>Returns the named logger if it exists.</overloads>
/// <summary>
/// Returns the named logger if it exists.
@@ -126,7 +125,6 @@
{
return GetLogger(Assembly.GetCallingAssembly(), name);
}
-#endif // !NETSTANDARD1_3
/// <summary>
/// Returns the named logger if it exists.
@@ -254,11 +252,7 @@
/// <returns>The logger with the name specified.</returns>
public static ILog GetLogger(Type type)
{
-#if NETSTANDARD1_3
- return GetLogger(type.GetTypeInfo().Assembly, type.FullName);
-#else
return GetLogger(Assembly.GetCallingAssembly(), type.FullName);
-#endif
}
/// <summary>
@@ -317,7 +311,6 @@
LoggerManager.Shutdown();
}
-#if !NETSTANDARD1_3
/// <overloads>Shutdown a logger repository.</overloads>
/// <summary>
/// Shuts down the default repository.
@@ -341,7 +334,6 @@
{
ShutdownRepository(Assembly.GetCallingAssembly());
}
-#endif
/// <summary>
/// Shuts down the repository for the repository specified.
@@ -395,7 +387,6 @@
LoggerManager.ShutdownRepository(repositoryAssembly);
}
-#if !NETSTANDARD1_3
/// <overloads>Reset the configuration of a repository</overloads>
/// <summary>
/// Resets all values contained in this repository instance to their defaults.
@@ -414,7 +405,6 @@
{
ResetConfiguration(Assembly.GetCallingAssembly());
}
-#endif
/// <summary>
/// Resets all values contained in this repository instance to their defaults.
@@ -454,7 +444,6 @@
LoggerManager.ResetConfiguration(repositoryAssembly);
}
-#if !NETSTANDARD1_3
/// <overloads>Get the logger repository.</overloads>
/// <summary>
/// Returns the default <see cref="ILoggerRepository"/> instance.
@@ -471,7 +460,6 @@
{
return GetRepository(Assembly.GetCallingAssembly());
}
-#endif
/// <summary>
/// Returns the default <see cref="ILoggerRepository"/> instance.
@@ -507,7 +495,6 @@
return GetRepository(repositoryAssembly);
}
-#if !NETSTANDARD1_3
/// <overloads>Get a logger repository.</overloads>
/// <summary>
/// Returns the default <see cref="ILoggerRepository"/> instance.
@@ -523,7 +510,6 @@
{
return GetRepository(Assembly.GetCallingAssembly());
}
-#endif
/// <summary>
/// Returns the default <see cref="ILoggerRepository"/> instance.
@@ -557,7 +543,6 @@
return LoggerManager.GetRepository(repositoryAssembly);
}
-#if !NETSTANDARD1_3
/// <overloads>Create a domain</overloads>
/// <summary>
/// Creates a repository with the specified repository type.
@@ -601,7 +586,6 @@
{
return CreateRepository(Assembly.GetCallingAssembly(), repositoryType);
}
-#endif
/// <summary>
/// Creates a repository with the specified name.
@@ -758,7 +742,6 @@
/// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
public static bool Flush(int millisecondsTimeout)
{
-#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
Appender.IFlushable flushableRepository = LoggerManager.GetRepository(Assembly.GetCallingAssembly()) as Appender.IFlushable;
if (flushableRepository == null)
{
@@ -768,9 +751,6 @@
{
return flushableRepository.Flush(millisecondsTimeout);
}
-#else
- return false;
-#endif
}
#endregion Domain & Repository Manager Methods
@@ -824,4 +804,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/LogicalThreadContext.cs b/src/log4net/LogicalThreadContext.cs
index 79da8fc..ca399f6 100644
--- a/src/log4net/LogicalThreadContext.cs
+++ b/src/log4net/LogicalThreadContext.cs
@@ -17,11 +17,15 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for System.Runtime.Remoting.Messaging.CallContext
-#if !NETCF
-
using log4net.Util;
+#if NET462_OR_GREATER
+using CallContext = System.Runtime.Remoting.Messaging.CallContext;
+#endif
+#if NETSTANDARD2_0_OR_GREATER
+using CallContext = System.Threading.AsyncLocal<log4net.Util.PropertiesDictionary>;
+#endif
+
namespace log4net
{
/// <summary>
@@ -29,15 +33,14 @@
/// </summary>
/// <remarks>
/// <para>
- /// The <c>LogicalThreadContext</c> provides a location for <see cref="System.Runtime.Remoting.Messaging.CallContext"/> specific debugging
+ /// The <c>LogicalThreadContext</c> provides a location for <see cref="CallContext"/> specific debugging
/// information to be stored.
/// The <c>LogicalThreadContext</c> properties override any <see cref="ThreadContext"/> or <see cref="GlobalContext"/>
/// properties with the same name.
/// </para>
/// <para>
/// For .NET Standard 1.3 this class uses
- /// System.Threading.AsyncLocal rather than <see
- /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
+ /// System.Threading.AsyncLocal rather than <see cref="CallContext"/>.
/// </para>
/// <para>
/// The Logical Thread Context has a properties map and a stack.
@@ -52,10 +55,10 @@
/// when a server handles multiple clients near-simultaneously.
/// </para>
/// <para>
- /// The Logical Thread Context is managed on a per <see cref="System.Runtime.Remoting.Messaging.CallContext"/> basis.
+ /// The Logical Thread Context is managed on a per <see cref="CallContext"/> basis.
/// </para>
/// <para>
- /// The <see cref="System.Runtime.Remoting.Messaging.CallContext"/> requires a link time
+ /// The <see cref="CallContext"/> requires a link time
/// <see cref="System.Security.Permissions.SecurityPermission"/> for the
/// <see cref="System.Security.Permissions.SecurityPermissionFlag.Infrastructure"/>.
/// If the calling code does not have this permission then this context will be disabled.
@@ -148,6 +151,4 @@
#endregion Private Static Fields
}
-}
-
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/NDC.cs b/src/log4net/NDC.cs
index c1ded53..9109cc6 100644
--- a/src/log4net/NDC.cs
+++ b/src/log4net/NDC.cs
@@ -20,10 +20,6 @@
using System;
using System.Collections;
-#if NETCF_1_0
-using Stack = log4net.Util.ThreadContextStack.Stack;
-#endif
-
namespace log4net
{
/// <summary>
@@ -346,4 +342,4 @@
#endregion Public Static Methods
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/NetStandardCompatibilityExtensions.cs b/src/log4net/NetStandardCompatibilityExtensions.cs
deleted file mode 100644
index b9bdc60..0000000
--- a/src/log4net/NetStandardCompatibilityExtensions.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-#region Apache License
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to you under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-#endregion
-
-#if NETSTANDARD1_3
-
-using System;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Reflection;
-using System.Threading;
-using System.Xml;
-
-namespace log4net
-{
- internal static class NetStandardCompatibilityExtensions
- {
- public static void Close(this Mutex mutex) => mutex.Dispose();
- public static void Close(this Socket socket) => socket.Dispose();
- public static void Close(this Stream stream) => stream.Dispose();
- public static void Close(this StreamWriter streamWriter) => streamWriter.Dispose();
- public static void Close(this StreamReader streamReader) => streamReader.Dispose();
- public static void Close(this UdpClient client) => client.Dispose();
- public static void Close(this WebResponse response) => response.Dispose();
- public static void Close(this XmlWriter xmlWriter) => xmlWriter.Dispose();
- public static void Close(this TextWriter textWriter) => textWriter.Dispose();
-
- public static Attribute[] GetCustomAttributes(this Type type, Type other, bool inherit) => type.GetTypeInfo().GetCustomAttributes(other, inherit).Cast<Attribute>().ToArray();
- public static bool IsAssignableFrom(this Type type, Type other) => type.GetTypeInfo().IsAssignableFrom(other.GetTypeInfo());
- public static bool IsSubclassOf(this Type type, Type t) => type.GetTypeInfo().IsSubclassOf(t);
-
- public static string ToLower(this string s, CultureInfo cultureInfo) => cultureInfo.TextInfo.ToLower(s);
- public static string ToUpper(this string s, CultureInfo cultureInfo) => cultureInfo.TextInfo.ToUpper(s);
- }
-}
-
-#endif
diff --git a/src/log4net/ObjectRenderer/RendererMap.cs b/src/log4net/ObjectRenderer/RendererMap.cs
index 0e4284d..7306f0c 100644
--- a/src/log4net/ObjectRenderer/RendererMap.cs
+++ b/src/log4net/ObjectRenderer/RendererMap.cs
@@ -19,9 +19,6 @@
using System;
using System.IO;
-#if NETSTANDARD1_3
-using System.Reflection;
-#endif
using System.Collections;
using log4net.Util;
@@ -203,11 +200,7 @@
if (result == null)
{
-#if NETSTANDARD1_3
- for (Type cur = type; cur != null; cur = cur.GetTypeInfo().BaseType)
-#else
for (Type cur = type; cur != null; cur = cur.BaseType)
-#endif
{
// Search the type's interfaces
result = SearchTypeAndInterfaces(cur);
diff --git a/src/log4net/Plugin/PluginCollection.cs b/src/log4net/Plugin/PluginCollection.cs
index 4019d67..db18338 100644
--- a/src/log4net/Plugin/PluginCollection.cs
+++ b/src/log4net/Plugin/PluginCollection.cs
@@ -23,13 +23,10 @@
namespace log4net.Plugin
{
/// <summary>
- /// A strongly-typed collection of <see cref="IPlugin"/> objects.
+ /// A strongly-typed collection of <see cref="IPlugin"/> objects.
/// </summary>
/// <author>Nicko Cadell</author>
- public class PluginCollection : ICollection, IList, IEnumerable
-#if !NETSTANDARD1_3
- , ICloneable
-#endif
+ public class PluginCollection : ICollection, IList, IEnumerable, ICloneable
{
#region Interfaces
@@ -873,4 +870,4 @@
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
index bee95b4..5b7dab4 100644
--- a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
+++ b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
@@ -18,8 +18,8 @@
//
#endregion
-// .NET Compact Framework 1.0 && netstandard has no support for System.Runtime.Remoting
-#if NET_2_0
+// netstandard has no support for System.Runtime.Remoting
+#if NET462_OR_GREATER
using System;
using System.Runtime.Remoting;
@@ -120,9 +120,7 @@
/// This method is called when the plugin is attached to the repository.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
-#endif
public override void Attach(ILoggerRepository repository)
{
base.Attach(repository);
@@ -149,9 +147,7 @@
/// sink is disconnected.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
public override void Shutdown()
{
// Stops the sink from receiving messages
@@ -254,9 +250,7 @@
/// therefore this implementation returns <c>null</c>.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0
- [System.Security.SecurityCritical]
-#endif
+ [System.Security.SecurityCritical]
public override object InitializeLifetimeService()
{
return null;
@@ -277,4 +271,4 @@
}
}
-#endif // NET_2_0
\ No newline at end of file
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/Repository/Hierarchy/Logger.cs b/src/log4net/Repository/Hierarchy/Logger.cs
index 0ec41db..d83cf06 100644
--- a/src/log4net/Repository/Hierarchy/Logger.cs
+++ b/src/log4net/Repository/Hierarchy/Logger.cs
@@ -70,14 +70,9 @@
/// logger creator.
/// </para>
/// </remarks>
- protected Logger(string name)
+ protected Logger(string name)
{
-#if NETCF || NETSTANDARD1_3
- // NETCF: String.Intern causes Native Exception
- m_name = name;
-#else
m_name = string.Intern(name);
-#endif
}
#endregion Protected Instance Constructors
@@ -140,14 +135,14 @@
/// </remarks>
public virtual Level EffectiveLevel
{
- get
+ get
{
- for (Logger c = this; c != null; c = c.m_parent)
+ for(Logger c = this; c != null; c = c.m_parent)
{
Level level = c.m_level;
// Casting level to Object for performance, otherwise the overloaded operator is called
- if ((object)level != null)
+ if ((object)level != null)
{
return level;
}
@@ -208,7 +203,7 @@
/// appenders, then it won't be added again.
/// </para>
/// </remarks>
- public virtual void AddAppender(IAppender newAppender)
+ public virtual void AddAppender(IAppender newAppender)
{
if (newAppender == null)
{
@@ -218,7 +213,7 @@
m_appenderLock.AcquireWriterLock();
try
{
- if (m_appenderAttachedImpl == null)
+ if (m_appenderAttachedImpl == null)
{
m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
}
@@ -242,7 +237,7 @@
/// can be found, then a <see cref="EmptyCollection"/> is returned.
/// </para>
/// </remarks>
- public virtual AppenderCollection Appenders
+ public virtual AppenderCollection Appenders
{
get
{
@@ -253,7 +248,7 @@
{
return AppenderCollection.EmptyCollection;
}
- else
+ else
{
return m_appenderAttachedImpl.Appenders;
}
@@ -275,7 +270,7 @@
/// Returns the named appender, or null if the appender is not found.
/// </para>
/// </remarks>
- public virtual IAppender GetAppender(string name)
+ public virtual IAppender GetAppender(string name)
{
m_appenderLock.AcquireReaderLock();
try
@@ -304,12 +299,12 @@
/// This is useful when re-reading configuration information.
/// </para>
/// </remarks>
- public virtual void RemoveAllAppenders()
+ public virtual void RemoveAllAppenders()
{
m_appenderLock.AcquireWriterLock();
try
{
- if (m_appenderAttachedImpl != null)
+ if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.RemoveAllAppenders();
m_appenderAttachedImpl = null;
@@ -334,12 +329,12 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
+ public virtual IAppender RemoveAppender(IAppender appender)
{
m_appenderLock.AcquireWriterLock();
try
{
- if (appender != null && m_appenderAttachedImpl != null)
+ if (appender != null && m_appenderAttachedImpl != null)
{
return m_appenderAttachedImpl.RemoveAppender(appender);
}
@@ -364,7 +359,7 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public virtual IAppender RemoveAppender(string name)
+ public virtual IAppender RemoveAppender(string name)
{
m_appenderLock.AcquireWriterLock();
try
@@ -380,7 +375,7 @@
}
return null;
}
-
+
#endregion
#region Implementation of ILogger
@@ -418,25 +413,19 @@
/// This method must not throw any exception to the caller.
/// </para>
/// </remarks>
- public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
{
try
{
if (IsEnabledFor(level))
{
- ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
+ ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
}
}
catch (Exception ex)
{
log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
-#endif
}
/// <summary>
@@ -468,12 +457,6 @@
{
log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
-#endif
}
/// <summary>
@@ -508,12 +491,6 @@
{
log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
-#endif
return false;
}
@@ -531,11 +508,11 @@
/// </para>
/// </remarks>
public ILoggerRepository Repository
- {
+ {
get { return m_hierarchy; }
}
- #endregion Implementation of ILogger
+ #endregion Implementation of ILogger
/// <summary>
/// Deliver the <see cref="LoggingEvent"/> to the attached appenders.
@@ -553,7 +530,7 @@
/// to log the particular log request.
/// </para>
/// </remarks>
- protected virtual void CallAppenders(LoggingEvent loggingEvent)
+ protected virtual void CallAppenders(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -562,15 +539,15 @@
int writes = 0;
- for (Logger c = this; c != null; c = c.m_parent)
+ for(Logger c=this; c != null; c=c.m_parent)
{
- if (c.m_appenderAttachedImpl != null)
+ if (c.m_appenderAttachedImpl != null)
{
// Protected against simultaneous call to addAppender, removeAppender,...
c.m_appenderLock.AcquireReaderLock();
try
{
- if (c.m_appenderAttachedImpl != null)
+ if (c.m_appenderAttachedImpl != null)
{
writes += c.m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
}
@@ -581,12 +558,12 @@
}
}
- if (!c.m_additive)
+ if (!c.m_additive)
{
break;
}
}
-
+
// No appenders in hierarchy, warn user only once.
//
// Note that by including the AppDomain values for the currently running
@@ -596,7 +573,7 @@
// or impossible to determine which .config file is missing appender
// definitions.
//
- if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
+ if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
{
m_hierarchy.EmittedNoAppenderWarning = true;
LogLog.Debug(declaringType, "No appenders could be found for logger [" + Name + "] repository [" + Repository.Name + "]");
@@ -605,12 +582,10 @@
{
LogLog.Debug(declaringType, " Current AppDomain context information: ");
LogLog.Debug(declaringType, " BaseDirectory : " + SystemInfo.ApplicationBaseDirectory);
-#if !NETCF && !NETSTANDARD1_3
LogLog.Debug(declaringType, " FriendlyName : " + AppDomain.CurrentDomain.FriendlyName);
LogLog.Debug(declaringType, " DynamicDirectory: " + AppDomain.CurrentDomain.DynamicDirectory);
-#endif
}
- catch (System.Security.SecurityException)
+ catch(System.Security.SecurityException)
{
// Insufficient permissions to display info from the AppDomain
}
@@ -625,7 +600,7 @@
/// Used to ensure that the appenders are correctly shutdown.
/// </para>
/// </remarks>
- public virtual void CloseNestedAppenders()
+ public virtual void CloseNestedAppenders()
{
m_appenderLock.AcquireWriterLock();
try
@@ -633,7 +608,7 @@
if (m_appenderAttachedImpl != null)
{
AppenderCollection appenders = m_appenderAttachedImpl.Appenders;
- foreach (IAppender appender in appenders)
+ foreach(IAppender appender in appenders)
{
if (appender is IAppenderAttachable)
{
@@ -660,11 +635,11 @@
/// the <paramref name="message"/>.
/// </para>
/// </remarks>
- public virtual void Log(Level level, object message, Exception exception)
+ public virtual void Log(Level level, object message, Exception exception)
{
if (IsEnabledFor(level))
{
- ForcedLog(declaringType, level, message, exception);
+ ForcedLog(declaringType, level, message, exception);
}
}
@@ -682,7 +657,7 @@
/// appenders.
/// </para>
/// </remarks>
- protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
{
CallAppenders(new LoggingEvent(callerStackBoundaryDeclaringType, this.Hierarchy, this.Name, level, message, exception));
}
@@ -696,7 +671,7 @@
/// Delivers the logging event to the attached appenders.
/// </para>
/// </remarks>
- protected virtual void ForcedLog(LoggingEvent logEvent)
+ protected virtual void ForcedLog(LoggingEvent logEvent)
{
// The logging event may not have been created by this logger
// the Repository may not be correctly set on the event. This
@@ -708,10 +683,10 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the Logger class.
- /// </summary>
- private static readonly Type declaringType = typeof(Logger);
+ /// <summary>
+ /// The fully qualified type of the Logger class.
+ /// </summary>
+ private static readonly Type declaringType = typeof(Logger);
#endregion Private Static Fields
@@ -720,7 +695,7 @@
/// <summary>
/// The name of this logger.
/// </summary>
- private readonly string m_name;
+ private readonly string m_name;
/// <summary>
/// The assigned level of this logger.
@@ -782,7 +757,7 @@
/// Lock to protect AppenderAttachedImpl variable m_appenderAttachedImpl
/// </summary>
private readonly ReaderWriterLock m_appenderLock = new ReaderWriterLock();
-
+
#endregion
}
}
diff --git a/src/log4net/Repository/Hierarchy/LoggerKey.cs b/src/log4net/Repository/Hierarchy/LoggerKey.cs
index 7d74ad8..ee72165 100644
--- a/src/log4net/Repository/Hierarchy/LoggerKey.cs
+++ b/src/log4net/Repository/Hierarchy/LoggerKey.cs
@@ -64,12 +64,7 @@
/// <param name="name">The name of the logger.</param>
internal LoggerKey(string name)
{
-#if NETCF || NETSTANDARD1_3
- // NETCF: String.Intern causes Native Exception
- m_name = name;
-#else
m_name = string.Intern(name);
-#endif
m_hashCache = name.GetHashCode();
}
@@ -115,12 +110,8 @@
LoggerKey objKey = obj as LoggerKey;
if (objKey != null)
{
-#if NETCF || NETSTANDARD1_3
- return ( m_name == objKey.m_name );
-#else
// Compare reference types rather than string's overloaded ==
return (((object)m_name) == ((object)objKey.m_name));
-#endif
}
return false;
}
@@ -134,5 +125,4 @@
#endregion Private Instance Fields
}
-}
-
+}
\ No newline at end of file
diff --git a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
index 164933f..7f149ac 100644
--- a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
+++ b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
@@ -300,11 +300,7 @@
LogLog.Debug(declaringType, "Loading Appender [" + appenderName + "] type: [" + typeName + "]");
try
{
-#if NETSTANDARD1_3
- IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, typeName, true, true));
-#else
IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(typeName, true, true));
-#endif
appender.Name = appenderName;
foreach (XmlNode currentNode in appenderElement.ChildNodes)
@@ -490,11 +486,7 @@
{
try
{
-#if NETSTANDARD1_3
- m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, renderedClassName, true, true), renderer);
-#else
m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(renderedClassName, true, true), renderer);
-#endif
}
catch (Exception e)
{
@@ -638,7 +630,6 @@
if (propertyValue != null)
{
-#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
try
{
// Expand environment variables in the string.
@@ -656,7 +647,6 @@
// will be skipped with the following warning message.
LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.");
}
-#endif
Type parsedObjectConversionTargetType = null;
@@ -667,11 +657,7 @@
// Read the explicit subtype
try
{
-#if NETSTANDARD1_3
- Type subType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, subTypeString, true, true);
-#else
Type subType = SystemInfo.GetTypeFromString(subTypeString, true, true);
-#endif
LogLog.Debug(declaringType, "Parameter [" + name + "] specified subtype [" + subType.FullName + "]");
@@ -726,11 +712,7 @@
try
{
// Pass to the property
-#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- propInfo.SetValue(target, convertedValue, null);
-#else
propInfo.SetValue(target, convertedValue, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
-#endif
}
catch (TargetInvocationException targetInvocationEx)
{
@@ -745,11 +727,7 @@
try
{
// Pass to the property
-#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- methInfo.Invoke(target, new[] { convertedValue });
-#else
methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] { convertedValue }, CultureInfo.InvariantCulture);
-#endif
}
catch (TargetInvocationException targetInvocationEx)
{
@@ -801,11 +779,7 @@
try
{
// Pass to the property
-#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- propInfo.SetValue(target, createdObject, null);
-#else
propInfo.SetValue(target, createdObject, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
-#endif
}
catch (TargetInvocationException targetInvocationEx)
{
@@ -820,11 +794,7 @@
try
{
// Pass to the property
-#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- methInfo.Invoke(target, new[] { createdObject });
-#else
methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] { createdObject }, CultureInfo.InvariantCulture);
-#endif
}
catch (TargetInvocationException targetInvocationEx)
{
@@ -860,12 +830,7 @@
/// <returns><c>true</c> if the type is creatable using a default constructor, <c>false</c> otherwise</returns>
private static bool IsTypeConstructible(Type type)
{
-#if NETSTANDARD1_3
- TypeInfo typeInfo = type.GetTypeInfo();
- if (typeInfo.IsClass && !typeInfo.IsAbstract)
-#else
if (type.IsClass && !type.IsAbstract)
-#endif
{
ConstructorInfo defaultConstructor = type.GetConstructor(new Type[0]);
if (defaultConstructor != null && !defaultConstructor.IsAbstract && !defaultConstructor.IsPrivate)
@@ -991,11 +956,7 @@
// Read the explicit object type
try
{
-#if NETSTANDARD1_3
- objectType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, objectTypeString, true, true);
-#else
objectType = SystemInfo.GetTypeFromString(objectTypeString, true, true);
-#endif
}
catch (Exception ex)
{
@@ -1067,21 +1028,12 @@
#endregion Protected Instance Methods
-#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
private bool HasCaseInsensitiveEnvironment
{
get
{
-#if NET_1_0 || NET_1_1 || CLI_1_0
- // actually there is no guarantee, but we don't know better
- return true;
-#elif MONO_1_0
- // see above
- return false;
-#else
PlatformID platform = Environment.OSVersion.Platform;
return platform != PlatformID.Unix && platform != PlatformID.MacOSX;
-#endif
}
}
@@ -1098,7 +1050,6 @@
}
return hash;
}
-#endif
#region Private Constants
diff --git a/src/log4net/Util/EmptyCollection.cs b/src/log4net/Util/EmptyCollection.cs
index ab36d94..7dd9fad 100644
--- a/src/log4net/Util/EmptyCollection.cs
+++ b/src/log4net/Util/EmptyCollection.cs
@@ -33,9 +33,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
public sealed class EmptyCollection : ICollection
{
#region Private Instance Constructors
diff --git a/src/log4net/Util/EmptyDictionary.cs b/src/log4net/Util/EmptyDictionary.cs
index a35d3f9..dbdce4d 100644
--- a/src/log4net/Util/EmptyDictionary.cs
+++ b/src/log4net/Util/EmptyDictionary.cs
@@ -33,9 +33,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
public sealed class EmptyDictionary : IDictionary
{
#region Private Instance Constructors
@@ -336,4 +334,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/GlobalContextProperties.cs b/src/log4net/Util/GlobalContextProperties.cs
index cfebd22..d516804 100644
--- a/src/log4net/Util/GlobalContextProperties.cs
+++ b/src/log4net/Util/GlobalContextProperties.cs
@@ -49,11 +49,7 @@
/// reordering reads and writes of this thread performed on different threads.
/// </para>
/// </remarks>
-#if NETCF
- private ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
-#else
private volatile ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
-#endif
/// <summary>
/// Lock object used to synchronize updates within this instance
diff --git a/src/log4net/Util/ILogExtensions.cs b/src/log4net/Util/ILogExtensions.cs
index 0d13e04..3cfbb96 100644
--- a/src/log4net/Util/ILogExtensions.cs
+++ b/src/log4net/Util/ILogExtensions.cs
@@ -17,8 +17,6 @@
//
#endregion
-#if NET_3_5 || NET_4_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
-
using System;
using log4net.Core;
@@ -1737,5 +1735,4 @@
#endregion
}
-}
-#endif
+}
\ No newline at end of file
diff --git a/src/log4net/Util/LogLog.cs b/src/log4net/Util/LogLog.cs
index a54f010..6a1d79e 100644
--- a/src/log4net/Util/LogLog.cs
+++ b/src/log4net/Util/LogLog.cs
@@ -168,7 +168,6 @@
/// </remarks>
static LogLog()
{
-#if !NETCF
try
{
InternalDebugging = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Debug"), false);
@@ -183,7 +182,6 @@
// We will leave debug OFF and print an Error message
Error(typeof(LogLog), "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
}
-#endif
}
#endregion Static Constructor
@@ -535,13 +533,8 @@
{
try
{
-#if NETCF
- Console.WriteLine(message);
- //System.Diagnostics.Debug.WriteLine(message);
-#else
Console.Out.WriteLine(message);
Trace.WriteLine(message);
-#endif
}
catch
{
@@ -569,13 +562,8 @@
{
try
{
-#if NETCF
- Console.WriteLine(message);
- //System.Diagnostics.Debug.WriteLine(message);
-#else
Console.Error.WriteLine(message);
Trace.WriteLine(message);
-#endif
}
catch
{
diff --git a/src/log4net/Util/LogicalThreadContextProperties.cs b/src/log4net/Util/LogicalThreadContextProperties.cs
index 2104220..28020c5 100644
--- a/src/log4net/Util/LogicalThreadContextProperties.cs
+++ b/src/log4net/Util/LogicalThreadContextProperties.cs
@@ -17,16 +17,13 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for System.Runtime.Remoting.Messaging.CallContext
-#if !NETCF
-
using System;
-#if !NETSTANDARD
-using System.Runtime.Remoting.Messaging;
-#endif
using System.Security;
-#if NETSTANDARD
-using System.Threading;
+#if NET462_OR_GREATER
+using CallContext = System.Runtime.Remoting.Messaging.CallContext;
+#endif
+#if NETSTANDARD2_0_OR_GREATER
+using CallContext = System.Threading.AsyncLocal<log4net.Util.PropertiesDictionary>;
#endif
namespace log4net.Util
@@ -45,8 +42,7 @@
/// </para>
/// <para>
/// For .NET Standard 1.3 this class uses
- /// System.Threading.AsyncLocal rather than <see
- /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
+ /// System.Threading.AsyncLocal rather than <see cref="CallContext"/>.
/// </para>
/// <para>
/// The <see cref="CallContext"/> requires a link time
@@ -59,8 +55,8 @@
/// <author>Nicko Cadell</author>
public sealed class LogicalThreadContextProperties : ContextPropertiesBase
{
-#if NETSTANDARD
- private static readonly AsyncLocal<PropertiesDictionary> AsyncLocalDictionary = new AsyncLocal<PropertiesDictionary>();
+#if NETSTANDARD2_0_OR_GREATER
+ private static readonly CallContext AsyncLocalDictionary = new CallContext();
#else
private const string c_SlotName = "log4net.Util.LogicalThreadContextProperties";
#endif
@@ -221,21 +217,16 @@
/// </summary>
/// <returns>The peroperties dictionary stored in the call context</returns>
/// <remarks>
- /// The <see cref="CallContext"/> method <see cref="CallContext.GetData"/> has a
- /// security link demand, therfore we must put the method call in a seperate method
- /// that we can wrap in an exception handler.
+ /// The <see cref="CallContext"/> method GetData security link demand, therefore we must
+ /// put the method call in a seperate method that we can wrap in an exception handler.
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
private static PropertiesDictionary GetLogicalProperties()
{
-#if NETSTANDARD
- return AsyncLocalDictionary.Value;
-#elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
- return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary;
+#if NETSTANDARD2_0_OR_GREATER
+ return AsyncLocalDictionary.Value;
#else
- return CallContext.GetData(c_SlotName) as PropertiesDictionary;
+ return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary;
#endif
}
@@ -244,21 +235,16 @@
/// </summary>
/// <param name="properties">The properties.</param>
/// <remarks>
- /// The <see cref="CallContext"/> method <see cref="CallContext.SetData"/> has a
- /// security link demand, therfore we must put the method call in a seperate method
- /// that we can wrap in an exception handler.
+ /// The <see cref="CallContext"/> method SetData has a security link demand, therefore we must
+ /// put the method call in a seperate method that we can wrap in an exception handler.
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
private static void SetLogicalProperties(PropertiesDictionary properties)
{
-#if NETSTANDARD
+#if NETSTANDARD2_0_OR_GREATER
AsyncLocalDictionary.Value = properties;
-#elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
- CallContext.LogicalSetData(c_SlotName, properties);
#else
- CallContext.SetData(c_SlotName, properties);
+ CallContext.LogicalSetData(c_SlotName, properties);
#endif
}
@@ -277,6 +263,4 @@
#endregion Private Static Fields
}
-}
-
-#endif
+}
\ No newline at end of file
diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs
index bd7b0ab..6a92248 100644
--- a/src/log4net/Util/LogicalThreadContextStack.cs
+++ b/src/log4net/Util/LogicalThreadContextStack.cs
@@ -17,7 +17,6 @@
//
#endregion
-#if !NETCF
using System;
using System.Collections;
@@ -29,11 +28,7 @@
/// <summary>
/// Delegate type used for LogicalThreadContextStack's callbacks.
/// </summary>
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
public delegate void TwoArgAction<T1, T2>(T1 t1, T2 t2);
-#else
- public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2);
-#endif
/// <summary>
/// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
@@ -63,11 +58,7 @@
/// The callback used to let the <see cref="log4net.Util.LogicalThreadContextStacks"/> register a
/// new instance of a <see cref="log4net.Util.LogicalThreadContextStack"/>.
/// </summary>
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
private TwoArgAction<string, LogicalThreadContextStack> m_registerNew;
-#else
- private TwoArgAction m_registerNew;
-#endif
#endregion Private Instance Fields
@@ -81,11 +72,7 @@
/// Initializes a new instance of the <see cref="LogicalThreadContextStack" /> class.
/// </para>
/// </remarks>
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
internal LogicalThreadContextStack(string propertyKey, TwoArgAction<string, LogicalThreadContextStack> registerNew)
-#else
- internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew)
-#endif
{
m_propertyKey = propertyKey;
m_registerNew = registerNew;
@@ -445,5 +432,4 @@
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Util/LogicalThreadContextStacks.cs b/src/log4net/Util/LogicalThreadContextStacks.cs
index 6ea5901..0d32d80 100644
--- a/src/log4net/Util/LogicalThreadContextStacks.cs
+++ b/src/log4net/Util/LogicalThreadContextStacks.cs
@@ -17,7 +17,6 @@
//
#endregion
-#if !NETCF
using System;
namespace log4net.Util
@@ -75,11 +74,7 @@
if (propertyValue == null)
{
// Stack does not exist, create
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
stack = new LogicalThreadContextStack(key, registerNew);
-#else
- stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
-#endif
m_properties[key] = stack;
}
else
@@ -101,11 +96,7 @@
LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named [" + key + "] failed because a property with the same name exists which is a [" + propertyValue.GetType().Name + "] with value [" + propertyValueString + "]");
-#if NET_2_0 || MONO_2_0 || NETSTANDARD
stack = new LogicalThreadContextStack(key, registerNew);
-#else
- stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
-#endif
}
}
@@ -137,6 +128,4 @@
#endregion Private Static Fields
}
-}
-
-#endif
+}
\ No newline at end of file
diff --git a/src/log4net/Util/NativeError.cs b/src/log4net/Util/NativeError.cs
index e93cef1..f7d3632 100644
--- a/src/log4net/Util/NativeError.cs
+++ b/src/log4net/Util/NativeError.cs
@@ -17,13 +17,6 @@
//
#endregion
-// MONO 1.0 has no support for Win32 Error APIs
-#if !MONO
-// SSCLI 1.0 has no support for Win32 Error APIs
-#if !SSCLI
-// We don't want framework or platform specific code in the CLI version of log4net
-#if !CLI_1_0
-
using System;
using System.Globalization;
using System.Runtime.InteropServices;
@@ -114,12 +107,8 @@
/// native Win32 <c>FormatMessage</c> function.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
+ [System.Security.SecuritySafeCritical]
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
-#endif
public static NativeError GetLastError()
{
int number = Marshal.GetLastWin32Error();
@@ -158,12 +147,8 @@
/// using the native <c>FormatMessage</c> function.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
+ [System.Security.SecuritySafeCritical]
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
-#endif
public static string GetErrorMessage(int messageId)
{
// Win32 constants
@@ -262,11 +247,7 @@
/// call <see cref="M:Marshal.GetLastWin32Error()" />.
/// </para>
/// </returns>
-#if NETCF || NETSTANDARD
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
-#else
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
-#endif
private static extern int FormatMessage(
int dwFlags,
ref IntPtr lpSource,
@@ -285,8 +266,4 @@
#endregion
}
-}
-
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !MONO
+}
\ No newline at end of file
diff --git a/src/log4net/Util/OptionConverter.cs b/src/log4net/Util/OptionConverter.cs
index 8f4bcc7..8171213 100644
--- a/src/log4net/Util/OptionConverter.cs
+++ b/src/log4net/Util/OptionConverter.cs
@@ -183,11 +183,7 @@
}
else
{
-#if NETSTANDARD1_3
- if (target.GetTypeInfo().IsEnum)
-#else
if (target.IsEnum)
-#endif
{
// Target type is an enum.
@@ -204,11 +200,7 @@
if (meth != null)
{
// Call the Parse method
-#if NETSTANDARD1_3
- return meth.Invoke(target, new[] { txt });
-#else
return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] { txt }, CultureInfo.InvariantCulture);
-#endif
}
else
{
@@ -219,21 +211,6 @@
return null;
}
- // /// <summary>
- // /// Looks up the <see cref="IConvertFrom"/> for the target type.
- // /// </summary>
- // /// <param name="target">The type to lookup the converter for.</param>
- // /// <returns>The converter for the specified type.</returns>
- // public static IConvertFrom GetTypeConverter(Type target)
- // {
- // IConvertFrom converter = ConverterRegistry.GetConverter(target);
- // if (converter == null)
- // {
- // throw new InvalidOperationException("No type converter defined for [" + target + "]");
- // }
- // return converter;
- // }
-
/// <summary>
/// Checks if there is an appropriate type conversion from the source type to the target type.
/// </summary>
@@ -380,11 +357,7 @@
{
try
{
-#if NETSTANDARD1_3
- Type classObj = SystemInfo.GetTypeFromString(superClass.GetTypeInfo().Assembly, className, true, true);
-#else
Type classObj = SystemInfo.GetTypeFromString(className, true, true);
-#endif
if (!superClass.IsAssignableFrom(classObj))
{
LogLog.Error(declaringType, "OptionConverter: A [" + className + "] object is not assignable to a [" + superClass.FullName + "] variable.");
@@ -504,45 +477,7 @@
/// <returns>An object of type <paramref name="enumType" /> whose value is represented by <paramref name="value" />.</returns>
private static object ParseEnum(System.Type enumType, string value, bool ignoreCase)
{
-#if !NETCF
return Enum.Parse(enumType, value, ignoreCase);
-#else
- FieldInfo[] fields = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);
-
- string[] names = value.Split(new char[] {','});
- for (int i = 0; i < names.Length; ++i)
- {
- names[i] = names [i].Trim();
- }
-
- long retVal = 0;
-
- try
- {
- // Attempt to convert to numeric type
- return Enum.ToObject(enumType, Convert.ChangeType(value, typeof(long), CultureInfo.InvariantCulture));
- }
- catch {}
-
- foreach (string name in names)
- {
- bool found = false;
- foreach(FieldInfo field in fields)
- {
- if (String.Compare(name, field.Name, ignoreCase) == 0)
- {
- retVal |= ((IConvertible) field.GetValue(null)).ToInt64(CultureInfo.InvariantCulture);
- found = true;
- break;
- }
- }
- if (!found)
- {
- throw new ArgumentException("Failed to lookup member [" + name + "] from Enum type [" + enumType.Name + "]");
- }
- }
- return Enum.ToObject(enumType, retVal);
-#endif
}
#endregion Private Static Methods
@@ -565,4 +500,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternConverter.cs b/src/log4net/Util/PatternConverter.cs
index 8403ddd..7d7c0f7 100644
--- a/src/log4net/Util/PatternConverter.cs
+++ b/src/log4net/Util/PatternConverter.cs
@@ -217,7 +217,7 @@
private static readonly string[] SPACES = { " ", " ", " ", " ", // 1,2,4,8 spaces
" ", // 16 spaces
- " " }; // 32 spaces
+ " " }; // 32 spaces
/// <summary>
/// Fast space padding method.
diff --git a/src/log4net/Util/PatternString.cs b/src/log4net/Util/PatternString.cs
index d844b63..b256a54 100644
--- a/src/log4net/Util/PatternString.cs
+++ b/src/log4net/Util/PatternString.cs
@@ -294,12 +294,8 @@
s_globalRulesRegistry.Add("appdomain", typeof(AppDomainPatternConverter));
s_globalRulesRegistry.Add("date", typeof(DatePatternConverter));
-#if !NETCF
s_globalRulesRegistry.Add("env", typeof(EnvironmentPatternConverter));
-#if !NETSTANDARD1_3 // EnvironmentFolderPathPatternConverter not yet supported
s_globalRulesRegistry.Add("envFolderPath", typeof(EnvironmentFolderPathPatternConverter));
-#endif
-#endif
s_globalRulesRegistry.Add("identity", typeof(IdentityPatternConverter));
s_globalRulesRegistry.Add("literal", typeof(LiteralPatternConverter));
s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
@@ -311,13 +307,11 @@
s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
-#if !NETCF && !NETSTANDARD1_3
// TODO - have added common variants of casing like utcdate above.
// Wouldn't it be better to use a case-insensitive Hashtable?
s_globalRulesRegistry.Add("appsetting", typeof(AppSettingPatternConverter));
s_globalRulesRegistry.Add("appSetting", typeof(AppSettingPatternConverter));
s_globalRulesRegistry.Add("AppSetting", typeof(AppSettingPatternConverter));
-#endif
}
#endregion Static Constructor
diff --git a/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs b/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
index b3487ff..201f3a2 100644
--- a/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for application .config files
-#if !NETCF && (NET_2_0 || NETSTANDARD2_0)
-
using System.IO;
using System.Collections;
using System.Configuration;
@@ -104,5 +101,4 @@
}
}
}
-}
-#endif // !NETCF && NET_2_0
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs b/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
index a66cdce..f51de82 100644
--- a/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
@@ -17,8 +17,6 @@
//
#endregion
-#if !NETCF && (NET_2_0 || NETSTANDARD2_0)
-
using System;
using System.IO;
@@ -93,6 +91,4 @@
#endregion Private Static Fields
}
-}
-
-#endif // !NETCF && NET_2_0
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
index 7efb2a2..c9767f5 100644
--- a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
@@ -17,9 +17,6 @@
//
#endregion
-// .NET Compact Framework 1.0 has no support for Environment.GetEnvironmentVariable()
-#if !NETCF
-
using System;
using System.IO;
@@ -60,7 +57,6 @@
// Lookup the environment variable
string envValue = Environment.GetEnvironmentVariable(this.Option);
-#if NET_2_0 || NETSTANDARD2_0
// If we didn't see it for the process, try a user level variable.
if (envValue == null)
{
@@ -72,7 +68,6 @@
{
envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.Machine);
}
-#endif
if (envValue != null && envValue.Length > 0)
{
@@ -106,6 +101,4 @@
#endregion Private Static Fields
}
-}
-
-#endif // !NETCF
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
index 8f6b926..c1d0368 100644
--- a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
@@ -48,10 +48,6 @@
/// </remarks>
protected override void Convert(TextWriter writer, object state)
{
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current thread principals
- writer.Write( SystemInfo.NotAvailableText );
-#else
try
{
if (System.Threading.Thread.CurrentPrincipal != null &&
@@ -69,7 +65,6 @@
writer.Write(SystemInfo.NotAvailableText);
}
-#endif
}
#region Private Static Fields
@@ -85,4 +80,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
index 55dbeeb..c9edd67 100644
--- a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
@@ -43,15 +43,9 @@
/// Write the current process ID to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
protected override void Convert(TextWriter writer, object state)
{
-#if (NETCF || SSCLI)
- // On compact framework there is no System.Diagnostics.Process class
- writer.Write( SystemInfo.NotAvailableText );
-#else
try
{
writer.Write(System.Diagnostics.Process.GetCurrentProcess().Id);
@@ -64,7 +58,6 @@
writer.Write(SystemInfo.NotAvailableText);
}
-#endif
}
#region Private Static Fields
@@ -80,4 +73,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
index 9955116..a4c1388 100644
--- a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
@@ -61,13 +61,12 @@
{
CompositeProperties compositeProperties = new CompositeProperties();
-#if !NETCF
PropertiesDictionary logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
if (logicalThreadProperties != null)
{
compositeProperties.Add(logicalThreadProperties);
}
-#endif
+
PropertiesDictionary threadProperties = ThreadContext.Properties.GetProperties(false);
if (threadProperties != null)
{
diff --git a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
index a0f4789..2b6f95b 100644
--- a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
@@ -45,10 +45,6 @@
/// </remarks>
protected override void Convert(TextWriter writer, object state)
{
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current Windows user
- writer.Write( SystemInfo.NotAvailableText );
-#else
try
{
System.Security.Principal.WindowsIdentity windowsIdentity = null;
@@ -66,7 +62,6 @@
writer.Write(SystemInfo.NotAvailableText);
}
-#endif
}
#region Private Static Fields
@@ -82,4 +77,4 @@
#endregion Private Static Fields
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/PropertiesDictionary.cs b/src/log4net/Util/PropertiesDictionary.cs
index 6a37b60..0bd500f 100644
--- a/src/log4net/Util/PropertiesDictionary.cs
+++ b/src/log4net/Util/PropertiesDictionary.cs
@@ -35,12 +35,8 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if NETCF
- public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, IDictionary
-#else
[Serializable]
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
-#endif
{
#region Public Instance Constructors
@@ -73,7 +69,6 @@
#region Private Instance Constructors
-#if !NETCF
/// <summary>
/// Initializes a new instance of the <see cref="PropertiesDictionary" /> class
/// with serialized data.
@@ -88,7 +83,6 @@
private PropertiesDictionary(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
-#endif
#endregion Protected Instance Constructors
diff --git a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
index c59be90..10d77b5 100644
--- a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
+++ b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
@@ -19,9 +19,6 @@
using System;
using System.Collections;
-#if NETSTANDARD1_3
-using System.Reflection;
-#endif
using System.Runtime.Serialization;
using System.Xml;
@@ -42,12 +39,8 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if NETCF
- public class ReadOnlyPropertiesDictionary : IDictionary
-#else
[Serializable]
public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary
-#endif
{
#region Private Instance Fields
@@ -93,7 +86,6 @@
#region Private Instance Constructors
-#if !NETCF
/// <summary>
/// Deserialization constructor
/// </summary>
@@ -113,7 +105,6 @@
InnerHashtable[XmlConvert.DecodeName(entry.Name)] = entry.Value;
}
}
-#endif
#endregion Protected Instance Constructors
@@ -194,7 +185,6 @@
#region Implementation of ISerializable
-#if !NETCF
/// <summary>
/// Serializes this object into the <see cref="SerializationInfo" /> provided.
/// </summary>
@@ -205,12 +195,8 @@
/// Serializes this object into the <see cref="SerializationInfo" /> provided.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecurityCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
+ [System.Security.SecurityCritical]
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)]
-#endif
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
foreach (DictionaryEntry entry in InnerHashtable.Clone() as IDictionary)
@@ -224,11 +210,7 @@
var entryValue = entry.Value;
// If value is serializable then we add it to the list
-#if NETSTANDARD1_3
- var isSerializable = entryValue?.GetType().GetTypeInfo().IsSerializable ?? false;
-#else
var isSerializable = entryValue?.GetType().IsSerializable ?? false;
-#endif
if (!isSerializable)
{
continue;
@@ -245,7 +227,6 @@
}
}
}
-#endif
#endregion Implementation of ISerializable
diff --git a/src/log4net/Util/ReaderWriterLock.cs b/src/log4net/Util/ReaderWriterLock.cs
index abac458..47ba22e 100644
--- a/src/log4net/Util/ReaderWriterLock.cs
+++ b/src/log4net/Util/ReaderWriterLock.cs
@@ -17,13 +17,6 @@
//
#endregion
-#if (!NETCF) && !NETSTANDARD1_3
-#define HAS_READERWRITERLOCK
-#endif
-#if NET_4_0 || MONO_4_0
-#define HAS_READERWRITERLOCKSLIM
-#endif
-
using System;
namespace log4net.Util
@@ -61,14 +54,7 @@
/// </remarks>
public ReaderWriterLock()
{
-
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
m_lock = new System.Threading.ReaderWriterLockSlim(System.Threading.LockRecursionPolicy.SupportsRecursion);
-#else
- m_lock = new System.Threading.ReaderWriterLock();
-#endif
-#endif
}
#endregion Private Instance Constructors
@@ -86,20 +72,12 @@
/// </remarks>
public void AcquireReaderLock()
{
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
- // prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
- try { }
- finally
- {
- m_lock.EnterReadLock();
- }
-#else
- m_lock.AcquireReaderLock(-1);
-#endif
-#else
- System.Threading.Monitor.Enter(this);
-#endif
+ // prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
+ try { }
+ finally
+ {
+ m_lock.EnterReadLock();
+ }
}
/// <summary>
@@ -113,16 +91,7 @@
/// </remarks>
public void ReleaseReaderLock()
{
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
m_lock.ExitReadLock();
-#else
- m_lock.ReleaseReaderLock();
-
-#endif
-#else
- System.Threading.Monitor.Exit(this);
-#endif
}
/// <summary>
@@ -135,20 +104,12 @@
/// </remarks>
public void AcquireWriterLock()
{
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
- // prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
- try { }
- finally
- {
- m_lock.EnterWriteLock();
- }
-#else
- m_lock.AcquireWriterLock(-1);
-#endif
-#else
- System.Threading.Monitor.Enter(this);
-#endif
+ // prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
+ try { }
+ finally
+ {
+ m_lock.EnterWriteLock();
+ }
}
/// <summary>
@@ -162,29 +123,14 @@
/// </remarks>
public void ReleaseWriterLock()
{
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
m_lock.ExitWriteLock();
-#else
- m_lock.ReleaseWriterLock();
-#endif
-#else
- System.Threading.Monitor.Exit(this);
-#endif
}
#endregion Public Methods
#region Private Members
-#if HAS_READERWRITERLOCK
-#if HAS_READERWRITERLOCKSLIM
private System.Threading.ReaderWriterLockSlim m_lock;
-#else
- private System.Threading.ReaderWriterLock m_lock;
-#endif
-
-#endif
#endregion
}
diff --git a/src/log4net/Util/SystemInfo.cs b/src/log4net/Util/SystemInfo.cs
index 5cf7980..2500cd8 100644
--- a/src/log4net/Util/SystemInfo.cs
+++ b/src/log4net/Util/SystemInfo.cs
@@ -18,11 +18,7 @@
#endregion
using System;
-#if NETSTANDARD1_3
-using System.Globalization;
-#else
using System.Configuration;
-#endif
using System.Reflection;
using System.IO;
using System.Collections;
@@ -80,7 +76,6 @@
string nullText = DEFAULT_NULL_TEXT;
string notAvailableText = DEFAULT_NOT_AVAILABLE_TEXT;
-#if !NETCF
// Look for log4net.NullText in AppSettings
string nullTextAppSettingsKey = SystemInfo.GetAppSetting("log4net.NullText");
if (nullTextAppSettingsKey != null && nullTextAppSettingsKey.Length > 0)
@@ -96,7 +91,6 @@
LogLog.Debug(declaringType, "Initializing NotAvailableText value to [" + notAvailableTextAppSettingsKey + "].");
notAvailableText = notAvailableTextAppSettingsKey;
}
-#endif
s_notAvailableText = notAvailableText;
s_nullText = nullText;
}
@@ -120,11 +114,7 @@
{
get
{
-#if NETCF
- return "\r\n";
-#else
return System.Environment.NewLine;
-#endif
}
}
@@ -144,13 +134,7 @@
{
get
{
-#if NETCF
-- return System.IO.Path.GetDirectoryName(SystemInfo.EntryAssemblyLocation) + System.IO.Path.DirectorySeparatorChar;
-#elif NETSTANDARD1_3
- return Directory.GetCurrentDirectory();
-#else
return AppDomain.CurrentDomain.BaseDirectory;
-#endif
}
}
@@ -172,8 +156,8 @@
{
get
{
-#if NETCF || NETSTANDARD
- return SystemInfo.EntryAssemblyLocation+".config";
+#if NETSTANDARD2_0_OR_GREATER
+ return SystemInfo.EntryAssemblyLocation + ".config";
#else
return System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
@@ -197,14 +181,8 @@
{
if (entryAssemblyLocation != null)
return entryAssemblyLocation;
-#if NETCF
- return entryAssemblyLocation = SystemInfo.NativeEntryAssemblyLocation;
-#elif NETSTANDARD1_3 // TODO GetEntryAssembly is available for netstandard1.5
- return entryAssemblyLocation = AppContext.BaseDirectory;
-#else
return entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location
?? throw new InvalidOperationException($"Unable to determine EntryAssembly location: EntryAssembly is null. Try explicitly setting {nameof(SystemInfo)}.{nameof(EntryAssemblyLocation)}");
-#endif
}
set => entryAssemblyLocation = value;
}
@@ -235,13 +213,7 @@
{
get
{
-#if NETCF_1_0
- return System.Threading.Thread.CurrentThread.GetHashCode();
-#elif NET_2_0 || NETCF_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
return System.Threading.Thread.CurrentThread.ManagedThreadId;
-#else
- return AppDomain.GetCurrentThreadId();
-#endif
}
}
@@ -295,11 +267,7 @@
{
try
{
-#if NETSTANDARD1_3
- s_hostName = Environment.GetEnvironmentVariable("COMPUTERNAME");
-#elif (!SSCLI && !NETCF)
s_hostName = Environment.MachineName;
-#endif
}
catch (InvalidOperationException)
{
@@ -345,9 +313,7 @@
{
try
{
-#if !NETCF && !NETSTANDARD1_3
s_appFriendlyName = AppDomain.CurrentDomain.FriendlyName;
-#endif
}
catch (System.Security.SecurityException)
{
@@ -486,11 +452,6 @@
/// </remarks>
public static string AssemblyLocationInfo(Assembly myAssembly)
{
-#if NETCF
- return "Not supported on Microsoft .NET Compact Framework";
-#elif NETSTANDARD1_3
- return "Not supported on .NET Core";
-#else
if (myAssembly.GlobalAssemblyCache)
{
return "Global Assembly Cache";
@@ -499,24 +460,15 @@
{
try
{
-#if NET_4_0 || MONO_4_0
if (myAssembly.IsDynamic)
{
return "Dynamic Assembly";
}
-#else
-#if !NETSTANDARD2_0
- if (myAssembly is System.Reflection.Emit.AssemblyBuilder)
- {
- return "Dynamic Assembly";
- }
-#endif
if (myAssembly.GetType().FullName == "System.Reflection.Emit.InternalAssemblyBuilder")
{
return "Dynamic Assembly";
}
-#endif
else
{
// This call requires FileIOPermission for access to the path
@@ -544,7 +496,6 @@
return "Location Permission Denied";
}
}
-#endif
}
/// <summary>
@@ -563,12 +514,7 @@
/// </remarks>
public static string AssemblyQualifiedName(Type type)
{
- return type.FullName + ", "
-#if NETSTANDARD1_3
- + type.GetTypeInfo().Assembly.FullName;
-#else
- + type.Assembly.FullName;
-#endif
+ return type.FullName + ", " + type.Assembly.FullName;
}
/// <summary>
@@ -620,27 +566,7 @@
/// </remarks>
public static string AssemblyFileName(Assembly myAssembly)
{
-#if NETCF || NETSTANDARD1_3 // TODO Assembly.Location is in netstandard1.5 System.Reflection
- // This is not very good because it assumes that only
- // the entry assembly can be an EXE. In fact multiple
- // EXEs can be loaded in to a process.
-
- string assemblyShortName = SystemInfo.AssemblyShortName(myAssembly);
- string entryAssemblyShortName = System.IO.Path.GetFileNameWithoutExtension(SystemInfo.EntryAssemblyLocation);
-
- if (string.Compare(assemblyShortName, entryAssemblyShortName, true) == 0)
- {
- // assembly is entry assembly
- return assemblyShortName + ".exe";
- }
- else
- {
- // assembly is not entry assembly
- return assemblyShortName + ".dll";
- }
-#else
return System.IO.Path.GetFileName(myAssembly.Location);
-#endif
}
/// <summary>
@@ -665,14 +591,9 @@
/// </remarks>
public static Type GetTypeFromString(Type relativeType, string typeName, bool throwOnError, bool ignoreCase)
{
-#if NETSTANDARD1_3
- return GetTypeFromString(relativeType.GetTypeInfo().Assembly, typeName, throwOnError, ignoreCase);
-#else
return GetTypeFromString(relativeType.Assembly, typeName, throwOnError, ignoreCase);
-#endif
}
-#if !NETSTANDARD1_3
/// <summary>
/// Loads the type specified in the type string.
/// </summary>
@@ -696,7 +617,6 @@
{
return GetTypeFromString(Assembly.GetCallingAssembly(), typeName, throwOnError, ignoreCase);
}
-#endif
/// <summary>
/// Loads the type specified in the type string.
@@ -724,11 +644,6 @@
if (typeName.IndexOf(',') == -1)
{
//LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
-#if NETSTANDARD1_3
- return relativeAssembly.GetType(typeName, throwOnError, ignoreCase);
-#elif NETCF
- return relativeAssembly.GetType(typeName, throwOnError);
-#else
// Attempt to lookup the type from the relativeAssembly
Type type = relativeAssembly.GetType(typeName, false, ignoreCase);
if (type != null)
@@ -781,20 +696,13 @@
throw new TypeLoadException("Could not load type [" + typeName + "]. Tried assembly [" + relativeAssembly.FullName + "] and all loaded assemblies");
}
return null;
-#endif
}
else
{
// Includes explicit assembly name
//LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from global Type");
-#if NETCF
- // In NETCF 2 and 3 arg versions seem to behave differently
- // https://issues.apache.org/jira/browse/LOG4NET-113
- return Type.GetType(typeName, throwOnError);
-#else
return Type.GetType(typeName, throwOnError, ignoreCase);
-#endif
}
}
@@ -810,11 +718,7 @@
/// </remarks>
public static Guid NewGuid()
{
-#if NETCF_1_0
- return PocketGuid.NewGuid();
-#else
return Guid.NewGuid();
-#endif
}
/// <summary>
@@ -838,13 +742,7 @@
/// </remarks>
public static ArgumentOutOfRangeException CreateArgumentOutOfRangeException(string parameterName, object actualValue, string message)
{
-#if NETCF_1_0
- return new ArgumentOutOfRangeException(message + " [param=" + parameterName + "] [value=" + actualValue + "]");
-#elif NETCF_2_0
- return new ArgumentOutOfRangeException(parameterName, message + " [value=" + actualValue + "]");
-#else
return new ArgumentOutOfRangeException(parameterName, actualValue, message);
-#endif
}
@@ -862,19 +760,6 @@
/// </remarks>
public static bool TryParse(string s, out int val)
{
-#if NETCF
- val = 0;
- try
- {
- val = int.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
-
- return false;
-#else
// Initialise out param
val = 0;
@@ -893,7 +778,6 @@
}
return false;
-#endif
}
/// <summary>
@@ -910,19 +794,6 @@
/// </remarks>
public static bool TryParse(string s, out long val)
{
-#if NETCF
- val = 0;
- try
- {
- val = long.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
-
- return false;
-#else
// Initialise out param
val = 0;
@@ -941,7 +812,6 @@
}
return false;
-#endif
}
/// <summary>
@@ -958,19 +828,6 @@
/// </remarks>
public static bool TryParse(string s, out short val)
{
-#if NETCF
- val = 0;
- try
- {
- val = short.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
-
- return false;
-#else
// Initialise out param
val = 0;
@@ -989,7 +846,6 @@
}
return false;
-#endif
}
/// <summary>
@@ -1006,13 +862,7 @@
{
try
{
-#if NETCF || NETSTANDARD1_3
- // Configuration APIs are not suported under the Compact Framework
-#elif NET_2_0 || NETSTANDARD2_0
return ConfigurationManager.AppSettings[key];
-#else
- return ConfigurationSettings.AppSettings[key];
-#endif
}
catch (Exception ex)
{
@@ -1083,13 +933,7 @@
/// </remarks>
public static Hashtable CreateCaseInsensitiveHashtable()
{
-#if NETCF_1_0
- return new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
-#elif NETCF_2_0 || NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
return new Hashtable(StringComparer.OrdinalIgnoreCase);
-#else
- return System.Collections.Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable();
-#endif
}
/// <summary>
@@ -1106,56 +950,13 @@
/// <returns><c>true</c> if the strings are equal, <c>false</c> otherwise.</returns>
public static Boolean EqualsIgnoringCase(String a, String b)
{
-#if NET_1_0 || NET_1_1 || NETCF_1_0
- return string.Compare(a, b, true, System.Globalization.CultureInfo.InvariantCulture) == 0
-#elif NETSTANDARD1_3
- return CultureInfo.InvariantCulture.CompareInfo.Compare(a, b, CompareOptions.IgnoreCase) == 0;
-#else // >= .NET-2.0
return String.Equals(a, b, StringComparison.OrdinalIgnoreCase);
-#endif
}
#endregion Public Static Methods
#region Private Static Methods
-#if NETCF
- private static string NativeEntryAssemblyLocation
- {
- get
- {
- StringBuilder moduleName = null;
-
- IntPtr moduleHandle = GetModuleHandle(IntPtr.Zero);
-
- if (moduleHandle != IntPtr.Zero)
- {
- moduleName = new StringBuilder(255);
- if (GetModuleFileName(moduleHandle, moduleName, moduleName.Capacity) == 0)
- {
- throw new NotSupportedException(NativeError.GetLastError().ToString());
- }
- }
- else
- {
- throw new NotSupportedException(NativeError.GetLastError().ToString());
- }
-
- return moduleName.ToString();
- }
- }
-
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
- private static extern IntPtr GetModuleHandle(IntPtr ModuleName);
-
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
- private static extern Int32 GetModuleFileName(
- IntPtr hModule,
- StringBuilder ModuleName,
- Int32 cch);
-
-#endif
-
#endregion Private Static Methods
#region Public Static Fields
@@ -1210,126 +1011,5 @@
private static DateTime s_processStartTimeUtc = DateTime.UtcNow;
#endregion
-
- #region Compact Framework Helper Classes
-#if NETCF_1_0
- /// <summary>
- /// Generate GUIDs on the .NET Compact Framework.
- /// </summary>
- public class PocketGuid
- {
- // guid variant types
- private enum GuidVariant
- {
- ReservedNCS = 0x00,
- Standard = 0x02,
- ReservedMicrosoft = 0x06,
- ReservedFuture = 0x07
- }
-
- // guid version types
- private enum GuidVersion
- {
- TimeBased = 0x01,
- Reserved = 0x02,
- NameBased = 0x03,
- Random = 0x04
- }
-
- // constants that are used in the class
- private class Const
- {
- // number of bytes in guid
- public const int ByteArraySize = 16;
-
- // multiplex variant info
- public const int VariantByte = 8;
- public const int VariantByteMask = 0x3f;
- public const int VariantByteShift = 6;
-
- // multiplex version info
- public const int VersionByte = 7;
- public const int VersionByteMask = 0x0f;
- public const int VersionByteShift = 4;
- }
-
- // imports for the crypto api functions
- private class WinApi
- {
- public const uint PROV_RSA_FULL = 1;
- public const uint CRYPT_VERIFYCONTEXT = 0xf0000000;
-
- [DllImport("CoreDll.dll")]
- public static extern bool CryptAcquireContext(
- ref IntPtr phProv, string pszContainer, string pszProvider,
- uint dwProvType, uint dwFlags);
-
- [DllImport("CoreDll.dll")]
- public static extern bool CryptReleaseContext(
- IntPtr hProv, uint dwFlags);
-
- [DllImport("CoreDll.dll")]
- public static extern bool CryptGenRandom(
- IntPtr hProv, int dwLen, byte[] pbBuffer);
- }
-
- // all static methods
- private PocketGuid()
- {
- }
-
- /// <summary>
- /// Return a new System.Guid object.
- /// </summary>
- public static Guid NewGuid()
- {
- IntPtr hCryptProv = IntPtr.Zero;
- Guid guid = Guid.Empty;
-
- try
- {
- // holds random bits for guid
- byte[] bits = new byte[Const.ByteArraySize];
-
- // get crypto provider handle
- if (!WinApi.CryptAcquireContext(ref hCryptProv, null, null,
- WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT))
- {
- throw new SystemException(
- "Failed to acquire cryptography handle.");
- }
-
- // generate a 128 bit (16 byte) cryptographically random number
- if (!WinApi.CryptGenRandom(hCryptProv, bits.Length, bits))
- {
- throw new SystemException(
- "Failed to generate cryptography random bytes.");
- }
-
- // set the variant
- bits[Const.VariantByte] &= Const.VariantByteMask;
- bits[Const.VariantByte] |=
- ((int)GuidVariant.Standard << Const.VariantByteShift);
-
- // set the version
- bits[Const.VersionByte] &= Const.VersionByteMask;
- bits[Const.VersionByte] |=
- ((int)GuidVersion.Random << Const.VersionByteShift);
-
- // create the new System.Guid object
- guid = new Guid(bits);
- }
- finally
- {
- // release the crypto provider handle
- if (hCryptProv != IntPtr.Zero)
- WinApi.CryptReleaseContext(hCryptProv, 0);
- }
-
- return guid;
- }
- }
-#endif
- #endregion Compact Framework Helper Classes
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/SystemStringFormat.cs b/src/log4net/Util/SystemStringFormat.cs
index 0d75e89..2a94531 100644
--- a/src/log4net/Util/SystemStringFormat.cs
+++ b/src/log4net/Util/SystemStringFormat.cs
@@ -117,13 +117,6 @@
log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format [" + format + "]", ex);
return StringFormatError(ex, format, args);
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]");
- return StringFormatError(null, format, args);
- }
-#endif
}
/// <summary>
@@ -156,13 +149,6 @@
log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling", ex);
return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling");
- return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
- }
-#endif
}
/// <summary>
@@ -218,12 +204,6 @@
{
buffer.Append("<Exception: ").Append(ex.Message).Append(">");
}
-#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- buffer.Append("<Exception>");
- }
-#endif
}
}
diff --git a/src/log4net/Util/TextWriterAdapter.cs b/src/log4net/Util/TextWriterAdapter.cs
index 24304f0..393fdf8 100644
--- a/src/log4net/Util/TextWriterAdapter.cs
+++ b/src/log4net/Util/TextWriterAdapter.cs
@@ -149,12 +149,7 @@
/// <para>
/// </para>
/// </remarks>
-#if !NETSTANDARD1_3
- override
-#else
- virtual
-#endif
- public void Close()
+ override public void Close()
{
m_writer.Close();
}
diff --git a/src/log4net/Util/ThreadContextProperties.cs b/src/log4net/Util/ThreadContextProperties.cs
index 0fbeef6..39040a6 100644
--- a/src/log4net/Util/ThreadContextProperties.cs
+++ b/src/log4net/Util/ThreadContextProperties.cs
@@ -18,9 +18,6 @@
#endregion
using System;
-#if NETCF
-using System.Collections;
-#endif
namespace log4net.Util
{
@@ -38,18 +35,11 @@
{
#region Private Instance Fields
-#if NETCF
- /// <summary>
- /// The thread local data slot to use to store a PropertiesDictionary.
- /// </summary>
- private readonly static LocalDataStoreSlot s_threadLocalSlot = System.Threading.Thread.AllocateDataSlot();
-#else
/// <summary>
/// Each thread will automatically have its instance.
/// </summary>
[ThreadStatic]
private static PropertiesDictionary _dictionary;
-#endif
#endregion Private Instance Fields
@@ -86,9 +76,6 @@
{
get
{
-#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
-#endif
if (_dictionary != null)
{
return _dictionary[key];
@@ -116,9 +103,6 @@
/// </remarks>
public void Remove(string key)
{
-#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
-#endif
if (_dictionary != null)
{
_dictionary.Remove(key);
@@ -134,9 +118,6 @@
/// <returns>a set of the defined keys</returns>
public string[] GetKeys()
{
-#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
-#endif
if (_dictionary != null)
{
return _dictionary.GetKeys();
@@ -154,9 +135,6 @@
/// </remarks>
public void Clear()
{
-#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
-#endif
if (_dictionary != null)
{
_dictionary.Clear();
@@ -181,20 +159,13 @@
/// </remarks>
internal PropertiesDictionary GetProperties(bool create)
{
-#if NETCF
- PropertiesDictionary _dictionary = (PropertiesDictionary)System.Threading.Thread.GetData(s_threadLocalSlot);
-#endif
if (_dictionary == null && create)
{
_dictionary = new PropertiesDictionary();
-#if NETCF
- System.Threading.Thread.SetData(s_threadLocalSlot, _dictionary);
-#endif
}
return _dictionary;
}
#endregion Internal Instance Methods
}
-}
-
+}
\ No newline at end of file
diff --git a/src/log4net/Util/ThreadContextStack.cs b/src/log4net/Util/ThreadContextStack.cs
index 37ed907..5beb1dd 100644
--- a/src/log4net/Util/ThreadContextStack.cs
+++ b/src/log4net/Util/ThreadContextStack.cs
@@ -19,9 +19,7 @@
using System;
-#if !NETCF_1_0
using System.Collections;
-#endif
using log4net.Core;
@@ -399,57 +397,5 @@
#endregion Implementation of IDisposable
}
-
-#if NETCF_1_0
- /// <summary>
- /// Subclass of <see cref="System.Collections.Stack"/> to
- /// provide missing methods.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The Compact Framework version of the <see cref="System.Collections.Stack"/>
- /// class is missing the <c>Clear</c> and <c>Clone</c> methods.
- /// This subclass adds implementations of those missing methods.
- /// </para>
- /// </remarks>
- public class Stack : System.Collections.Stack
- {
- /// <summary>
- /// Clears the stack of all elements.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears the stack of all elements.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- while(Count > 0)
- {
- Pop();
- }
- }
-
- /// <summary>
- /// Makes a shallow copy of the stack's elements.
- /// </summary>
- /// <returns>A new stack that has a shallow copy of the stack's elements.</returns>
- /// <remarks>
- /// <para>
- /// Makes a shallow copy of the stack's elements.
- /// </para>
- /// </remarks>
- public Stack Clone()
- {
- Stack res = new Stack();
- object[] items = ToArray();
- foreach(object item in items)
- {
- res.Push(item);
- }
- return res;
- }
- }
-#endif
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/ThreadContextStacks.cs b/src/log4net/Util/ThreadContextStacks.cs
index 6997636..3938b7b 100644
--- a/src/log4net/Util/ThreadContextStacks.cs
+++ b/src/log4net/Util/ThreadContextStacks.cs
@@ -18,7 +18,6 @@
#endregion
using System;
-using System.Collections;
namespace log4net.Util
{
@@ -120,5 +119,4 @@
#endregion Private Static Fields
}
-}
-
+}
\ No newline at end of file
diff --git a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
index 61bd750..d7c3782 100644
--- a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
+++ b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
@@ -18,9 +18,7 @@
#endregion
using System;
-#if !NETCF && !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace log4net.Util.TypeConverters
{
@@ -36,14 +34,8 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if !NETCF
[Serializable]
-#endif
-#if NETSTANDARD1_3
- public class ConversionNotSupportedException : Exception
-#else
public class ConversionNotSupportedException : ApplicationException
-#endif
{
#region Public Instance Constructors
@@ -92,7 +84,6 @@
#region Protected Instance Constructors
-#if !NETCF && !NETSTANDARD1_3
/// <summary>
/// Serialization constructor
/// </summary>
@@ -107,7 +98,6 @@
protected ConversionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
-#endif
#endregion Protected Instance Constructors
@@ -155,4 +145,4 @@
#endregion Public Static Methods
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/TypeConverters/ConverterRegistry.cs b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
index ec3e59b..eaf29ad 100644
--- a/src/log4net/Util/TypeConverters/ConverterRegistry.cs
+++ b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
@@ -19,9 +19,6 @@
using System;
using System.Collections;
-#if NETSTANDARD1_3
-using System.Reflection;
-#endif
namespace log4net.Util.TypeConverters
{
@@ -215,9 +212,6 @@
{
// Look for an attribute on the destination type
var attributes = destinationType
-#if NETSTANDARD1_3
- .GetTypeInfo()
-#endif
.GetCustomAttributes(typeof(TypeConverterAttribute), true);
if (attributes is null)
{
diff --git a/src/log4net/Util/TypeConverters/IPAddressConverter.cs b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
index 60c7bf6..f954468 100644
--- a/src/log4net/Util/TypeConverters/IPAddressConverter.cs
+++ b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
@@ -77,16 +77,12 @@
{
try
{
-#if NET_2_0 || NETCF_2_0
-
-#if !NETCF_2_0
// Try an explicit parse of string representation of an IPAddress (v4 or v6)
IPAddress result;
if (IPAddress.TryParse(str, out result))
{
return result;
}
-#endif
// Try to resolve via DNS. This is a blocking call.
// GetHostEntry works with either an IPAddress string or a host name
@@ -98,37 +94,6 @@
{
return host.AddressList[0];
}
-#else
- // Before .NET 2 we need to try to parse the IPAddress from the string first
-
- // Check if the string only contains IP address valid chars
- if (str.Trim(validIpAddressChars).Length == 0)
- {
- try
- {
- // try to parse the string as an IP address
- return IPAddress.Parse(str);
- }
- catch(FormatException)
- {
- // Ignore a FormatException, try to resolve via DNS
- }
- }
-
- // Try to resolve via DNS. This is a blocking call.
-#if NETSTANDARD
- IPHostEntry host = Dns.GetHostEntryAsync(str).GetAwaiter().GetResult();
-#else
- IPHostEntry host = Dns.GetHostByName(str);
-#endif
- if (host != null &&
- host.AddressList != null &&
- host.AddressList.Length > 0 &&
- host.AddressList[0] != null)
- {
- return host.AddressList[0];
- }
-#endif
}
catch (Exception ex)
{
@@ -145,4 +110,4 @@
/// </summary>
private static readonly char[] validIpAddressChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', 'x', 'X', '.', ':', '%' };
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/TypeConverters/TypeConverter.cs b/src/log4net/Util/TypeConverters/TypeConverter.cs
index c5136e4..d48a923 100644
--- a/src/log4net/Util/TypeConverters/TypeConverter.cs
+++ b/src/log4net/Util/TypeConverters/TypeConverter.cs
@@ -18,9 +18,6 @@
#endregion
using System;
-#if NETSTANDARD1_3
-using System.Reflection;
-#endif
namespace log4net.Util.TypeConverters
{
@@ -79,15 +76,11 @@
string str = source as string;
if (str != null)
{
-#if NETSTANDARD1_3 // TODO can we use ComponentModel here?
- return SystemInfo.GetTypeFromString(GetType().GetTypeInfo().Assembly, str, true, true);
-#else
return SystemInfo.GetTypeFromString(str, true, true);
-#endif
}
throw ConversionNotSupportedException.Create(typeof(Type), source);
}
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/log4net/Util/WindowsSecurityContext.cs b/src/log4net/Util/WindowsSecurityContext.cs
index bed14bc..21cadfc 100644
--- a/src/log4net/Util/WindowsSecurityContext.cs
+++ b/src/log4net/Util/WindowsSecurityContext.cs
@@ -17,16 +17,7 @@
//
#endregion
-#if NET_2_0
-// .NET Compact Framework 1.0 has no support for WindowsIdentity
-#if !NETCF
-// MONO 1.0 has no support for Win32 Logon APIs
-#if !MONO
-// SSCLI 1.0 has no support for Win32 Logon APIs
-#if !SSCLI
-// We don't want framework or platform specific code in the CLI version of log4net
-#if !CLI_1_0
-
+#if NET462_OR_GREATER
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
@@ -276,9 +267,7 @@
/// token is used to initialize the WindowsIdentity.
/// </para>
/// </remarks>
-#if NET_4_0 || MONO_4_0
- [System.Security.SecuritySafeCritical]
-#endif
+ [System.Security.SecuritySafeCritical]
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
private static WindowsIdentity LogonUser(string userName, string domainName, string password)
{
@@ -380,10 +369,4 @@
#endregion
}
}
-
-#endif // !CLI_1_0
-#endif // !SSCLI
-#endif // !MONO
-#endif // !NETCF
-#endif // NET_2_0
-
+#endif // NET462_OR_GREATER
\ No newline at end of file
diff --git a/src/log4net/log4net.csproj b/src/log4net/log4net.csproj
index b641bcc..67e1875 100644
--- a/src/log4net/log4net.csproj
+++ b/src/log4net/log4net.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>log4net</PackageId>
<Version>3.0.0</Version>
@@ -73,13 +73,6 @@
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<Deterministic>true</Deterministic>
</PropertyGroup>
- <PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
- <DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_0</DefineConstants>
- <NoWarn>1574</NoWarn>
- </PropertyGroup>
- <PropertyGroup Condition="'$(TargetFramework)'=='net462'">
- <DefineConstants>$(DefineConstants);NET_2_0;NET_4_0;NET_4_5</DefineConstants>
- </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DefineConstants>TRACE;DEBUG;$(DefineConstants)</DefineConstants>
</PropertyGroup>
@@ -88,17 +81,18 @@
<DebugType>none</DebugType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
- <ItemGroup>
+ <PropertyGroup />
+ <ItemGroup Condition="'$(TargetFramework)'=='net462'">
<Reference Update="System">
<Name>System</Name>
</Reference>
- <Reference Include="System.Configuration" Condition="$(DefineConstants.Contains(NET_2_0))" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Web">
+ <Name>System.Web</Name>
+ </Reference>
<Reference Update="System.Data">
<Name>System.Data</Name>
</Reference>
- <Reference Include="System.Web" Condition="$(DefineConstants.Contains(NET_2_0)) and !$(DefineConstants.Contains(CLIENT_PROFILE))">
- <Name>System.Web</Name>
- </Reference>
<Reference Update="System.Xml">
<Name>System.XML</Name>
</Reference>
@@ -129,19 +123,14 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
- <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net35" Version="1.0.3">
- <PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- </PackageReference>
</ItemGroup>
- <PropertyGroup />
<Import Project="../MonoForFramework.targets" />
<Target Name="_ResolveCopyLocalNuGetPackagePdbsAndXml" Condition="$(CopyLocalLockFileAssemblies) == true" AfterTargets="ResolveReferences">
<!-- "Workaround" for missing '.pdb'-Files from NuGet Packages -->
<!-- https://github.com/dotnet/sdk/issues/1458#issuecomment-420456386 -->
<ItemGroup>
- <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).pdb')"/>
- <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).xml')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).xml')"/>
+ <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).pdb')" />
+ <ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).xml')" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and Exists('%(RootDir)%(Directory)%(Filename).xml')" />
</ItemGroup>
</Target>
</Project>
diff --git a/src/site/xdoc/release/framework-support.xml b/src/site/xdoc/release/framework-support.xml
index ba3c102..eb2d010 100644
--- a/src/site/xdoc/release/framework-support.xml
+++ b/src/site/xdoc/release/framework-support.xml
@@ -60,84 +60,134 @@
<section id="appenders" name="Appenders">
<p>
- Currently all appenders are available in each supported framework:
+ The following appenders are supported as specified:
</p>
<div class="table">
<table>
<colgroup>
<col style="text-align: left;" />
+ <col style="text-align: center;" />
+ <col style="text-align: center;" />
</colgroup>
<tr>
<th>Appender</th>
+ <th>.NET Framework 4.6.2</th>
+ <th>.NET Standard 2.0</th>
</tr>
<tr>
<td>AdoNetAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>AnsiColorTerminalAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>AspNetTraceAppender</td>
+ <td>x</td>
+ <td></td>
</tr>
<tr>
<td>BufferingForwardingAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>ColoredConsoleAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>ConsoleAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>DebugAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>EventLogAppender</td>
+ <td>x</td>
+ <td></td>
</tr>
<tr>
<td>FileAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>ForwardingAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>LocalSyslogAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>ManagedColoredConsoleAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>MemoryAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>NetSendAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>OutputDebugStringAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>RemoteSyslogAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>RemotingAppender</td>
+ <td>x</td>
+ <td></td>
</tr>
<tr>
<td>RollingFileAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>SmtpAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>SmtpPickupDirAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>TelnetAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>TraceAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
<tr>
<td>UdpAppender</td>
+ <td>x</td>
+ <td>x</td>
</tr>
</table>
</div>