Skip to content

Commit

Permalink
removed legacy #ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeAndNil committed Mar 5, 2024
1 parent 488fdc5 commit 8cb606e
Show file tree
Hide file tree
Showing 103 changed files with 2,299 additions and 4,354 deletions.
19 changes: 1 addition & 18 deletions src/log4net/Appender/AdoNetAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -683,7 +675,6 @@ protected virtual string ResolveConnectionString(out string connectionStringCont
return ConnectionString;
}

#if !NETSTANDARD1_3
if (!String.IsNullOrEmpty(ConnectionStringName))
{
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName];
Expand All @@ -697,7 +688,6 @@ protected virtual string ResolveConnectionString(out string connectionStringCont
throw new LogException("Unable to find [" + ConnectionStringName + "] ConfigurationManager.ConnectionStrings item");
}
}
#endif

if (AppSettingsKey != null && AppSettingsKey.Length > 0)
{
Expand Down Expand Up @@ -733,12 +723,7 @@ protected virtual Type ResolveConnectionType()
{
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)
{
Expand Down Expand Up @@ -1179,6 +1164,4 @@ public virtual void FormatValue(IDbCommand command, LoggingEvent loggingEvent)

#endregion // Private Instance Fields
}
}

#endif // !SSCLI
}
5 changes: 0 additions & 5 deletions src/log4net/Appender/AnsiColorTerminalAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,6 @@ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
}
}

#if NETCF_1_0
// Write to the output stream
Console.Write(loggingMessage);
#else
if (m_writeToErrorStream)
{
// Write to the error stream
Expand All @@ -353,7 +349,6 @@ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
// Write to the output stream
Console.Write(loggingMessage);
}
#endif

}

Expand Down
5 changes: 1 addition & 4 deletions src/log4net/Appender/AppenderCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ namespace log4net.Appender
/// 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>
Expand Down
120 changes: 49 additions & 71 deletions src/log4net/Appender/AppenderSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,23 @@ public void Close()
/// </para>
/// <para>
/// <list type="bullet">
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvent"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvent"/>.
/// </description>
/// </item>
/// <item>
/// <description>
/// Calls <see cref="M:PreAppendCheck()"/> and checks that
/// it returns <c>true</c>.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvent"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvent"/>.
/// </description>
/// </item>
/// <item>
/// <description>
/// Calls <see cref="M:PreAppendCheck()"/> and checks that
/// it returns <c>true</c>.</description>
/// </item>
/// </list>
/// </para>
/// <para>
Expand Down Expand Up @@ -321,17 +321,6 @@ public void DoAppend(LoggingEvent loggingEvent)
{
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;
Expand Down Expand Up @@ -360,23 +349,23 @@ public void DoAppend(LoggingEvent loggingEvent)
/// </para>
/// <para>
/// <list type="bullet">
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvents"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvents"/>.
/// </description>
/// </item>
/// <item>
/// <description>
/// Calls <see cref="M:PreAppendCheck()"/> and checks that
/// it returns <c>true</c>.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvents"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvents"/>.
/// </description>
/// </item>
/// <item>
/// <description>
/// Calls <see cref="M:PreAppendCheck()"/> and checks that
/// it returns <c>true</c>.</description>
/// </item>
/// </list>
/// </para>
/// <para>
Expand Down Expand Up @@ -428,17 +417,6 @@ public void DoAppend(LoggingEvent[] loggingEvents)
{
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;
Expand All @@ -464,18 +442,18 @@ public void DoAppend(LoggingEvent[] loggingEvents)
/// </para>
/// <para>
/// <list type="bullet">
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvent"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvent"/>.
/// </description>
/// </item>
/// <item>
/// <description>
/// Checks that the severity of the <paramref name="loggingEvent"/>
/// is greater than or equal to the <see cref="Threshold"/> of this
/// appender.</description>
/// </item>
/// <item>
/// <description>
/// Checks that the <see cref="IFilter"/> chain accepts the
/// <paramref name="loggingEvent"/>.
/// </description>
/// </item>
/// </list>
/// </para>
/// </remarks>
Expand All @@ -493,14 +471,14 @@ protected virtual bool FilterEvent(LoggingEvent loggingEvent)
switch (f.Decide(loggingEvent))
{
case FilterDecision.Deny:
return false; // Return without appending
return false; // Return without appending

case FilterDecision.Accept:
f = null; // Break out of the loop
f = null; // Break out of the loop
break;

case FilterDecision.Neutral:
f = f.Next; // Move to next filter
f = f.Next; // Move to next filter
break;
}
}
Expand Down
24 changes: 9 additions & 15 deletions src/log4net/Appender/AspNetTraceAppender.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -54,7 +50,7 @@ namespace log4net.Appender
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
/// <author>Ron Grabowski</author>
public class AspNetTraceAppender : AppenderSkeleton
public class AspNetTraceAppender : AppenderSkeleton
{
#region Public Instances Constructors

Expand All @@ -66,7 +62,7 @@ public class AspNetTraceAppender : AppenderSkeleton
/// Default constructor.
/// </para>
/// </remarks>
public AspNetTraceAppender()
public AspNetTraceAppender()
{
}

Expand All @@ -85,19 +81,19 @@ public AspNetTraceAppender()
/// (<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));
}
Expand Down Expand Up @@ -152,6 +148,4 @@ public PatternLayout Category
#endregion
}
}

#endif // !NETCF && !SSCLI
#endif // NET_2_0
#endif
Loading

0 comments on commit 8cb606e

Please sign in to comment.