LOG4NET-478 API-based defines rather than version based. Based on patch by NN.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/66bdcb14 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/66bdcb14 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/66bdcb14 Branch: refs/heads/log4net-1.3.x Commit: 66bdcb14261a76d5bf4ba84c670f73306ba4326c Parents: a4427aa Author: Stefan Bodewig <[email protected]> Authored: Sun Oct 25 12:08:36 2015 +0000 Committer: Stefan Bodewig <[email protected]> Committed: Sun Oct 25 12:08:36 2015 +0000 ---------------------------------------------------------------------- src/buildsupport/configure-framework.include | 24 ++++++++++---------- .../Context/LogicalThreadContextTest.cs | 2 +- src/log4net.Tests/log4net.Tests.vs2010.csproj | 2 +- src/log4net.Tests/log4net.Tests.vs2012.csproj | 2 +- src/log4net/Appender/AsyncAppender.cs | 14 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/66bdcb14/src/buildsupport/configure-framework.include ---------------------------------------------------------------------- diff --git a/src/buildsupport/configure-framework.include b/src/buildsupport/configure-framework.include index 90749fa..078d330 100644 --- a/src/buildsupport/configure-framework.include +++ b/src/buildsupport/configure-framework.include @@ -70,9 +70,9 @@ limitations under the License. <target name="set-net-4.0-runtime-configuration"> <property name="nant.settings.currentframework" value="net-4.0" /> <property name="current.build.platform" value="DOTNET"/> - <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE"/> - <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True"/> - <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE"/> + <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,HAS_TPL"/> + <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,HAS_TPL=True"/> + <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D HAS_TPL"/> <property name="current.build.has.systemcore" value="true"/> <property name="current.build.has.systemweb" value="true"/> <property name="current.build.has.systemconfiguration" value="true"/> @@ -85,9 +85,9 @@ limitations under the License. <target name="set-net-4.0-cp-runtime-configuration"> <property name="nant.settings.currentframework" value="net-4.0" /> <property name="current.build.platform" value="DOTNET"/> - <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,CLIENT_PROFILE"/> - <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,CLIENT_PROFILE=True"/> - <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D CLIENT_PROFILE"/> + <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,CLIENT_PROFILE,HAS_TPL"/> + <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,CLIENT_PROFILE=True,HAS_TPL=True"/> + <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D CLIENT_PROFILE /D HAS_TPL"/> <property name="current.build.has.systemcore" value="true"/> <property name="current.build.has.systemweb" value="false"/> <property name="current.build.has.systemconfiguration" value="true"/> @@ -100,9 +100,9 @@ limitations under the License. <target name="set-net-4.5-runtime-configuration"> <property name="nant.settings.currentframework" value="net-4.0" /> <property name="current.build.platform" value="DOTNET"/> - <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,FRAMEWORK_4_5_OR_ABOVE"/> - <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,FRAMEWORK_4_5_OR_ABOVE=True"/> - <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D FRAMEWORK_4_5_OR_ABOVE"/> + <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,FRAMEWORK_4_5_OR_ABOVE,HAS_TPL,HAS_ASYNC_AWAIT"/> + <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,FRAMEWORK_4_5_OR_ABOVE=True,HAS_TPL=True,HAS_ASYNC_AWAIT=True"/> + <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D FRAMEWORK_4_5_OR_ABOVE /D HAS_TPL /D HAS_ASYNC_AWAIT"/> <property name="current.build.has.systemcore" value="true"/> <property name="current.build.has.systemweb" value="true"/> <property name="current.build.has.systemconfiguration" value="true"/> @@ -156,9 +156,9 @@ limitations under the License. <target name="set-mono-4.0-runtime-configuration"> <property name="nant.settings.currentframework" value="mono-4.0" /> <property name="current.build.platform" value="MONO"/> - <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE"/> - <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True"/> - <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE"/> + <property name="current.build.api" value=",FRAMEWORK_3_5_OR_ABOVE,FRAMEWORK_4_0_OR_ABOVE,HAS_TPL"/> + <property name="current.build.api.true" value=",FRAMEWORK_3_5_OR_ABOVE=True,FRAMEWORK_4_0_OR_ABOVE=True,HAS_TPL=True"/> + <property name="current.build.api.slash_d" value=" /D FRAMEWORK_3_5_OR_ABOVE /D FRAMEWORK_4_0_OR_ABOVE /D HAS_TPL"/> <property name="current.build.has.systemcore" value="true"/> <property name="current.build.has.systemweb" value="true"/> <property name="current.build.has.systemconfiguration" value="true"/> http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/66bdcb14/src/log4net.Tests/Context/LogicalThreadContextTest.cs ---------------------------------------------------------------------- diff --git a/src/log4net.Tests/Context/LogicalThreadContextTest.cs b/src/log4net.Tests/Context/LogicalThreadContextTest.cs index 5ac0a24..5549e44 100644 --- a/src/log4net.Tests/Context/LogicalThreadContextTest.cs +++ b/src/log4net.Tests/Context/LogicalThreadContextTest.cs @@ -17,7 +17,7 @@ // #endregion -#if FRAMEWORK_4_5_OR_ABOVE +#if HAS_ASYNC_AWAIT using System; using System.Threading.Tasks; using System.Linq; http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/66bdcb14/src/log4net.Tests/log4net.Tests.vs2010.csproj ---------------------------------------------------------------------- diff --git a/src/log4net.Tests/log4net.Tests.vs2010.csproj b/src/log4net.Tests/log4net.Tests.vs2010.csproj index 392c4f2..bde9715 100644 --- a/src/log4net.Tests/log4net.Tests.vs2010.csproj +++ b/src/log4net.Tests/log4net.Tests.vs2010.csproj @@ -72,7 +72,7 @@ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> <ConfigurationOverrideFile> </ConfigurationOverrideFile> - <DefineConstants>TRACE;DEBUG;DOTNET;FRAMEWORK_3_5_OR_ABOVE;FRAMEWORK_4_0_OR_ABOVE</DefineConstants> + <DefineConstants>TRACE;DEBUG;DOTNET;FRAMEWORK_3_5_OR_ABOVE;FRAMEWORK_4_0_OR_ABOVE;HAS_TPL</DefineConstants> <DocumentationFile> </DocumentationFile> <DebugSymbols>true</DebugSymbols> http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/66bdcb14/src/log4net.Tests/log4net.Tests.vs2012.csproj ---------------------------------------------------------------------- diff --git a/src/log4net.Tests/log4net.Tests.vs2012.csproj b/src/log4net.Tests/log4net.Tests.vs2012.csproj index 4295e27..b4f9b05 100644 --- a/src/log4net.Tests/log4net.Tests.vs2012.csproj +++ b/src/log4net.Tests/log4net.Tests.vs2012.csproj @@ -72,7 +72,7 @@ <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> <ConfigurationOverrideFile> </ConfigurationOverrideFile> - <DefineConstants>TRACE;DEBUG;DOTNET;FRAMEWORK_3_5_OR_ABOVE;FRAMEWORK_4_0_OR_ABOVE;FRAMEWORK_4_5_OR_ABOVE</DefineConstants> + <DefineConstants>TRACE;DEBUG;DOTNET;FRAMEWORK_3_5_OR_ABOVE;FRAMEWORK_4_0_OR_ABOVE;FRAMEWORK_4_5_OR_ABOVE;HAS_TPL;HAS_ASYNC_AWAIT</DefineConstants> <DocumentationFile> </DocumentationFile> <DebugSymbols>true</DebugSymbols> http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/66bdcb14/src/log4net/Appender/AsyncAppender.cs ---------------------------------------------------------------------- diff --git a/src/log4net/Appender/AsyncAppender.cs b/src/log4net/Appender/AsyncAppender.cs index da6932a..eb11c5a 100644 --- a/src/log4net/Appender/AsyncAppender.cs +++ b/src/log4net/Appender/AsyncAppender.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL using System.Threading.Tasks; #else using System.Threading; @@ -46,7 +46,7 @@ namespace log4net.Appender /// </summary> public AsyncAppender() { -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL logTask = new Task(() => { }); logTask.Start(); #endif @@ -92,7 +92,7 @@ namespace log4net.Appender } events.Add(loggingEvent); } -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL logTask.ContinueWith(AsyncAppend); #else ThreadPool.QueueUserWorkItem(AsyncAppend, null); @@ -122,7 +122,7 @@ namespace log4net.Appender } events.AddRange(loggingEvents); } -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL logTask.ContinueWith(AsyncAppend); #else ThreadPool.QueueUserWorkItem(AsyncAppend, null); @@ -145,7 +145,7 @@ namespace log4net.Appender { lock (lockObject) { -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL if (!closed) { logTask.Wait(); @@ -158,7 +158,7 @@ namespace log4net.Appender private void AsyncAppend(object _ignored) { -#if FRAMEWORK_4_0_OR_ABOVE // ContinueWith already ensures there is only one thread executing this method at a time +#if HAS_TPL // ContinueWith already ensures there is only one thread executing this method at a time ForwardEvents(); #else lock (lockObject) @@ -213,7 +213,7 @@ namespace log4net.Appender private readonly object lockObject = new object(); private readonly List<LoggingEvent> events = new List<LoggingEvent>(); private bool closed = false; -#if FRAMEWORK_4_0_OR_ABOVE +#if HAS_TPL private readonly Task logTask; #else private bool inLoggingLoop = false;
