diff --git a/.gitignore b/.gitignore index 6c925f24..ebfc545a 100644 --- a/.gitignore +++ b/.gitignore @@ -137,7 +137,7 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings +# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj @@ -235,4 +235,4 @@ target # other files to ignore old-log4net.snk src/GeneratedAssemblyInfo.cs - +src/log4net.xml diff --git a/Jenkinsfile b/Jenkinsfile index 43215b5f..0d9386e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -61,21 +61,14 @@ pipeline { // run docker container builder.inside { // compile - sh "nant compile-netstandard" + sh "dotnet build src/log4net.csproj -c Release -f netstandard1.3 -o ../bin/netstandard1.3" + sh "dotnet build src/log4net.csproj -c Release -f netstandard2.0 -o ../bin/netstandard2.0" stash includes: 'bin/**/*.*', name: 'netstandard-assemblies' // test - sh 'cd netstandard/log4net.tests && dotnet test' + sh "dotnet test tests/src/log4net.Tests.csproj" } } - - - // compile - // sh 'nant compile-netstandard' - // stash includes: 'bin/**/*.*', name: 'netstandard-assemblies' - - // test - // sh 'cd netstandard/log4net.tests && dotnet test' } } stage('build net-3.5') { @@ -245,7 +238,7 @@ pipeline { // unstash site unstash 'site' } - + // move site sh 'mv package/target/site/ package/site/' sh 'rmdir -p --ignore-fail-on-non-empty package/target' diff --git a/buildtools/docker/builder-netstandard/Dockerfile b/buildtools/docker/builder-netstandard/Dockerfile index 2dc5f542..48342537 100644 --- a/buildtools/docker/builder-netstandard/Dockerfile +++ b/buildtools/docker/builder-netstandard/Dockerfile @@ -1,5 +1,4 @@ -# Name of container: docker-ubuntu-latest-nant -FROM microsoft/dotnet +FROM microsoft/dotnet:2.0.0-sdk-stretch # define arguments passed in as environment variables ARG JENKINS_UID @@ -17,7 +16,3 @@ RUN mkdir -p /var/workspaces && chmod 0777 /var/workspaces # add jenkins user that maps to the custom workspace RUN groupadd -r -g $JENKINS_GID jenkins-slave RUN useradd --base-dir /var/workspaces --create-home --shell /bin/bash --uid $JENKINS_UID --gid $JENKINS_GID --groups $JENKINS_GID -p -M jenkins - -# install dependencies -RUN apt-get update && apt-get install -y nant git - diff --git a/log4net.build b/log4net.build index 6961d8bf..d491706c 100644 --- a/log4net.build +++ b/log4net.build @@ -1,10 +1,10 @@ - + + - + - + - + - + - - - - - - + - + - + - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/netstandard/log4net.netstandard.sln b/netstandard/log4net.netstandard.sln deleted file mode 100644 index c578a2ef..00000000 --- a/netstandard/log4net.netstandard.sln +++ /dev/null @@ -1,33 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26114.2 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net", "log4net\log4net.csproj", "{00764202-B361-4BC8-A1B9-01D87F9D2D51}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net.tests", "log4net.tests\log4net.tests.csproj", "{6A78D53B-C864-4316-AA00-F2EBFE975223}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4BB38D1C-1862-432B-881C-925714F7F997}" - ProjectSection(SolutionItems) = preProject - nuget.config = nuget.config - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {00764202-B361-4BC8-A1B9-01D87F9D2D51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00764202-B361-4BC8-A1B9-01D87F9D2D51}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00764202-B361-4BC8-A1B9-01D87F9D2D51}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00764202-B361-4BC8-A1B9-01D87F9D2D51}.Release|Any CPU.Build.0 = Release|Any CPU - {6A78D53B-C864-4316-AA00-F2EBFE975223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6A78D53B-C864-4316-AA00-F2EBFE975223}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6A78D53B-C864-4316-AA00-F2EBFE975223}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6A78D53B-C864-4316-AA00-F2EBFE975223}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/netstandard/log4net.tests/log4net.tests.csproj b/netstandard/log4net.tests/log4net.tests.csproj deleted file mode 100755 index 69d5fcbb..00000000 --- a/netstandard/log4net.tests/log4net.tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - 2.0.9 - netcoreapp1.0 - $(DefineConstants);NETSTANDARD1_3 - log4net.tests - log4net.tests - true - $(PackageTargetFallback);portable-net45+win8 - 1.0.4 - false - false - false - false - - - - - - - - - - - - - - - - - diff --git a/netstandard/log4net/log4net.csproj b/netstandard/log4net/log4net.csproj deleted file mode 100755 index 05171e7c..00000000 --- a/netstandard/log4net/log4net.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - Copyright 2004-2017 The Apache Software Foundation. - Apache log4net for .NET Core - 2.0.9 - netstandard1.3 - log4net - log4net - false - false - false - false - false - false - false - false - false - - - - $(DefineConstants);HAS_READERWRITERLOCKSLIM - true - ../../log4net.snk - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Appender/AppenderSkeleton.cs b/src/Appender/AppenderSkeleton.cs index 37a74162..422c458a 100644 --- a/src/Appender/AppenderSkeleton.cs +++ b/src/Appender/AppenderSkeleton.cs @@ -321,7 +321,7 @@ public void DoAppend(LoggingEvent loggingEvent) { ErrorHandler.Error("Failed in DoAppend", ex); } -#if !MONO && !NET_2_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) // 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 @@ -428,7 +428,7 @@ public void DoAppend(LoggingEvent[] loggingEvents) { ErrorHandler.Error("Failed in Bulk DoAppend", ex); } -#if !MONO && !NET_2_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) // 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 diff --git a/src/Appender/ColoredConsoleAppender.cs b/src/Appender/ColoredConsoleAppender.cs index a87ffd9d..7618e5ab 100644 --- a/src/Appender/ColoredConsoleAppender.cs +++ b/src/Appender/ColoredConsoleAppender.cs @@ -163,6 +163,12 @@ public enum Colors : int /// public ColoredConsoleAppender() { +#if NETSTANDARD2_0 + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new PlatformNotSupportedException($"{nameof(ColoredConsoleAppender)} is only available on Windows"); + } +#endif } /// @@ -193,6 +199,12 @@ public ColoredConsoleAppender(ILayout layout) : this(layout, false) [Obsolete("Instead use the default constructor and set the Layout & Target properties")] public ColoredConsoleAppender(ILayout layout, bool writeToErrorStream) { +#if NETSTANDARD2_0 + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new PlatformNotSupportedException($"{nameof(ColoredConsoleAppender)} is only available on Windows"); + } +#endif Layout = layout; m_writeToErrorStream = writeToErrorStream; } @@ -265,7 +277,7 @@ public void AddMapping(LevelColors mapping) /// The format of the output will depend on the appender's layout. /// /// -#if NET_4_0 || MONO_4_0 +#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)] @@ -434,7 +446,7 @@ override protected bool RequiresLayout /// Initialize the level to color mappings set on this appender. /// /// -#if NET_4_0 || MONO_4_0 +#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode=true)] diff --git a/src/Appender/FileAppender.cs b/src/Appender/FileAppender.cs index f6bc151e..482151df 100644 --- a/src/Appender/FileAppender.cs +++ b/src/Appender/FileAppender.cs @@ -24,7 +24,7 @@ using log4net.Util; using log4net.Layout; using log4net.Core; -#if NET_4_5 || NETSTANDARD1_3 +#if NET_4_5 || NETSTANDARD1_3 || NETSTANDARD2_0 using System.Threading.Tasks; #endif @@ -208,7 +208,7 @@ public override void EndWrite(IAsyncResult asyncResult) } #endif -#if NET_4_5 || NETSTANDARD1_3 +#if NET_4_5 || NETSTANDARD1_3 || NETSTANDARD2_0 public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { AssertLocked(); @@ -740,7 +740,7 @@ public class InterProcessLock : LockingModelBase /// - and . /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif public override void OpenFile(string filename, bool append, Encoding encoding) @@ -861,7 +861,7 @@ public override void OnClose() { if (m_mutex != null) { -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 m_mutex.Dispose(); #else m_mutex.Close(); diff --git a/src/Appender/LocalSyslogAppender.cs b/src/Appender/LocalSyslogAppender.cs index 5e7d5e07..9ecabfca 100644 --- a/src/Appender/LocalSyslogAppender.cs +++ b/src/Appender/LocalSyslogAppender.cs @@ -337,7 +337,7 @@ public void AddMapping(LevelSeverity mapping) /// must be called again. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif public override void ActivateOptions() @@ -378,7 +378,7 @@ public override void ActivateOptions() /// The format of the output will depend on the appender's layout. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif #if !NETSTANDARD1_3 @@ -402,7 +402,7 @@ protected override void Append(LoggingEvent loggingEvent) /// Close the syslog when the appender is closed /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif protected override void OnClose() diff --git a/src/Appender/NetSendAppender.cs b/src/Appender/NetSendAppender.cs index 1a9f9c0f..174dc7ef 100644 --- a/src/Appender/NetSendAppender.cs +++ b/src/Appender/NetSendAppender.cs @@ -176,6 +176,12 @@ public class NetSendAppender : AppenderSkeleton /// public NetSendAppender() { +#if NETSTANDARD2_0 + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new PlatformNotSupportedException($"{nameof(NetSendAppender)} is only available on Windows"); + } +#endif } #endregion @@ -304,7 +310,7 @@ public override void ActivateOptions() /// Sends the event using a network message. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif #if !NETSTANDARD1_3 @@ -424,4 +430,4 @@ protected static extern int NetMessageBufferSend( #endif // !CLI_1_0 #endif // !SSCLI #endif // !MONO -#endif // !NETCF \ No newline at end of file +#endif // !NETCF diff --git a/src/Appender/OutputDebugStringAppender.cs b/src/Appender/OutputDebugStringAppender.cs index 5403a49f..f9fec6b3 100644 --- a/src/Appender/OutputDebugStringAppender.cs +++ b/src/Appender/OutputDebugStringAppender.cs @@ -75,7 +75,7 @@ public OutputDebugStringAppender() /// Write the logging event to the output debug string API /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #elif !NETCF [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)] diff --git a/src/Appender/SmtpAppender.cs b/src/Appender/SmtpAppender.cs index 5cb47410..c20470e7 100644 --- a/src/Appender/SmtpAppender.cs +++ b/src/Appender/SmtpAppender.cs @@ -25,7 +25,7 @@ using System.IO; using System.Text; -#if NET_2_0 || MONO_2_0 +#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0 using System.Net.Mail; #else using System.Web.Mail; @@ -324,7 +324,7 @@ public MailPriority Priority set { m_mailPriority = value; } } -#if NET_2_0 || MONO_2_0 +#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0 /// /// Enable or disable use of SSL when sending e-mail message /// @@ -444,7 +444,7 @@ override protected bool RequiresLayout /// the body text to include in the mail virtual protected void SendEmail(string messageBody) { -#if NET_2_0 || MONO_2_0 +#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. @@ -488,7 +488,7 @@ virtual protected void SendEmail(string messageBody) { // .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 +#if !(NET_4_0 || MONO_4_0 || NETSTANDARD2_0) mailMessage.ReplyTo = new MailAddress(m_replyTo); #else mailMessage.ReplyToList.Add(new MailAddress(m_replyTo)); @@ -604,7 +604,7 @@ virtual protected void SendEmail(string messageBody) private MailPriority m_mailPriority = MailPriority.Normal; -#if NET_2_0 || MONO_2_0 +#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0 private bool m_enableSsl = false; private string m_replyTo; #endif diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs index bd1f5608..0ed46897 100644 --- a/src/AssemblyInfo.cs +++ b/src/AssemblyInfo.cs @@ -106,8 +106,11 @@ [assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET")] [assembly: AssemblyTitle("Apache log4net for .NET Framework")] #elif (NETSTANDARD1_3) -[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Core 1.0")] -[assembly: AssemblyTitle("Apache log4net for .NET Core 1.0")] +[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Standard 1.3")] +[assembly: AssemblyTitle("Apache log4net for .NET Standard 1.3")] +#elif (NETSTANDARD2_0) +[assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Standard 2.0")] +[assembly: AssemblyTitle("Apache log4net for .NET Standard 2.0")] #elif (NETCF) [assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NETCF")] [assembly: AssemblyTitle("Apache log4net for .NET Compact Framework")] diff --git a/netstandard/log4net/CompatibilityExtensions.cs b/src/CompatibilityExtensions.cs similarity index 92% rename from netstandard/log4net/CompatibilityExtensions.cs rename to src/CompatibilityExtensions.cs index 48957f2f..2a77b3d2 100644 --- a/netstandard/log4net/CompatibilityExtensions.cs +++ b/src/CompatibilityExtensions.cs @@ -1,10 +1,10 @@ -#region Apache License +#region Apache License // -// Licensed to the Apache Software Foundation (ASF) under one or more +// 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. +// 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 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 @@ -31,6 +31,9 @@ namespace log4net { + /// + /// Extension methods for simple API substitutions for compatibility with .NET Standard 1.3. + /// internal static class CompatibilityExtensions { public static void Close(this Mutex mutex) => mutex.Dispose(); diff --git a/src/Config/XmlConfigurator.cs b/src/Config/XmlConfigurator.cs index 7c81a363..142e18b3 100644 --- a/src/Config/XmlConfigurator.cs +++ b/src/Config/XmlConfigurator.cs @@ -969,7 +969,7 @@ private sealed class ConfigureAndWatchHandler : IDisposable /// Initializes a new instance of the class. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile) @@ -1049,7 +1049,7 @@ private void OnWatchedFileChange(object state) /// /// Release the handles held by the watcher and timer. /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif public void Dispose() diff --git a/src/Core/LoggingEvent.cs b/src/Core/LoggingEvent.cs index dcb2f7c3..e261a2e2 100644 --- a/src/Core/LoggingEvent.cs +++ b/src/Core/LoggingEvent.cs @@ -897,7 +897,7 @@ public string UserName { if (m_data.UserName == null && this.m_cacheUpdatable) { -#if (NETCF || SSCLI || NETSTANDARD1_3) // NETSTANDARD1_3 TODO requires platform-specific code +#if (NETCF || SSCLI || NETSTANDARD1_3 || NETSTANDARD2_0) // NETSTANDARD TODO requires platform-specific code // On compact framework there's no notion of current Windows user m_data.UserName = SystemInfo.NotAvailableText; #else @@ -1091,7 +1091,7 @@ public FixFlags Fix /// is to be used outside that method. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecurityCritical] #else [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter=true)] diff --git a/src/Layout/PatternLayout.cs b/src/Layout/PatternLayout.cs index f4ccfe62..5ffd191e 100644 --- a/src/Layout/PatternLayout.cs +++ b/src/Layout/PatternLayout.cs @@ -864,7 +864,7 @@ static PatternLayout() // .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 && !NETSTANDARD1_3 +#if !(NETCF || SSCLI || CLIENT_PROFILE || NETSTANDARD1_3 || NETSTANDARD2_0) s_globalRulesRegistry.Add("aspnet-cache", typeof(AspNetCachePatternConverter)); s_globalRulesRegistry.Add("aspnet-context", typeof(AspNetContextPatternConverter)); s_globalRulesRegistry.Add("aspnet-request", typeof(AspNetRequestPatternConverter)); diff --git a/src/Log4netAssemblyInfo.cs b/src/Log4netAssemblyInfo.cs index 5c84181f..aceb984c 100644 --- a/src/Log4netAssemblyInfo.cs +++ b/src/Log4netAssemblyInfo.cs @@ -59,8 +59,8 @@ public sealed class AssemblyInfo { public const string TargetFramework = "Mono"; #elif SSCLI public const string TargetFramework = "Shared Source CLI"; -#elif NETSTANDARD1_3 - public const string TargetFramework = ".NET Core"; +#elif NETSTANDARD1_3 || NETSTANDARD2_0 + public const string TargetFramework = ".NET Standard"; #else public const string TargetFramework = "Unknown"; #endif diff --git a/src/Repository/Hierarchy/Logger.cs b/src/Repository/Hierarchy/Logger.cs index d65be9bb..e115da1c 100644 --- a/src/Repository/Hierarchy/Logger.cs +++ b/src/Repository/Hierarchy/Logger.cs @@ -432,7 +432,7 @@ virtual public void Log(Type callerStackBoundaryDeclaringType, Level level, obje { log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex); } -#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { log4net.Util.LogLog.Error(declaringType, "Exception while logging"); @@ -469,7 +469,7 @@ virtual public void Log(LoggingEvent logEvent) { log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex); } -#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { log4net.Util.LogLog.Error(declaringType, "Exception while logging"); @@ -509,7 +509,7 @@ virtual public bool IsEnabledFor(Level level) { log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex); } -#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { log4net.Util.LogLog.Error(declaringType, "Exception while logging"); diff --git a/src/Util/ILogExtensions.cs b/src/Util/ILogExtensions.cs index 5a2ad50d..2930dc18 100644 --- a/src/Util/ILogExtensions.cs +++ b/src/Util/ILogExtensions.cs @@ -17,7 +17,7 @@ // #endregion -#if NET_3_5 || NET_4_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 +#if NET_3_5 || NET_4_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 using System; diff --git a/src/Util/LogicalThreadContextProperties.cs b/src/Util/LogicalThreadContextProperties.cs index 6a756193..f6b4d6ed 100644 --- a/src/Util/LogicalThreadContextProperties.cs +++ b/src/Util/LogicalThreadContextProperties.cs @@ -21,11 +21,11 @@ #if !NETCF using System; -#if !NETSTANDARD1_3 +#if !(NETSTANDARD1_3 || NETSTANDARD2_0) using System.Runtime.Remoting.Messaging; #endif using System.Security; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Threading; #endif @@ -59,7 +59,7 @@ namespace log4net.Util /// Nicko Cadell public sealed class LogicalThreadContextProperties : ContextPropertiesBase { - #if NETSTANDARD1_3 + #if NETSTANDARD1_3 || NETSTANDARD2_0 private static readonly AsyncLocal AsyncLocalDictionary = new AsyncLocal(); #else private const string c_SlotName = "log4net.Util.LogicalThreadContextProperties"; @@ -225,12 +225,12 @@ internal PropertiesDictionary GetProperties(bool create) /// security link demand, therfore we must put the method call in a seperate method /// that we can wrap in an exception handler. /// -#if NET_4_0 || MONO_4_0 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif private static PropertiesDictionary GetLogicalProperties() { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 return AsyncLocalDictionary.Value; #elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary; @@ -248,12 +248,12 @@ private static PropertiesDictionary GetLogicalProperties() /// security link demand, therfore we must put the method call in a seperate method /// that we can wrap in an exception handler. /// -#if NET_4_0 || MONO_4_0 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif private static void SetLogicalProperties(PropertiesDictionary properties) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 AsyncLocalDictionary.Value = properties; #elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 CallContext.LogicalSetData(c_SlotName, properties); diff --git a/src/Util/NativeError.cs b/src/Util/NativeError.cs index 73cc2f75..ab16185d 100644 --- a/src/Util/NativeError.cs +++ b/src/Util/NativeError.cs @@ -114,13 +114,19 @@ public string Message /// native Win32 FormatMessage function. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #elif !NETCF [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode=true)] #endif public static NativeError GetLastError() { +#if NETSTANDARD2_0 + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new PlatformNotSupportedException($"{nameof(NativeError)} is only available on Windows"); + } +#endif int number = Marshal.GetLastWin32Error(); return new NativeError(number, NativeError.GetErrorMessage(number)); } @@ -157,7 +163,7 @@ public static NativeError GetError(int number) /// using the native FormatMessage function. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #elif !NETCF [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)] diff --git a/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs b/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs index 33ec9b4e..dd9a6098 100644 --- a/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs +++ b/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs @@ -46,7 +46,7 @@ internal sealed class ProcessIdPatternConverter : PatternConverter /// Write the current process ID to the output . /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecuritySafeCritical] #endif override protected void Convert(TextWriter writer, object state) diff --git a/src/Util/PatternStringConverters/UserNamePatternConverter.cs b/src/Util/PatternStringConverters/UserNamePatternConverter.cs index b4a15f99..8a2f55ae 100644 --- a/src/Util/PatternStringConverters/UserNamePatternConverter.cs +++ b/src/Util/PatternStringConverters/UserNamePatternConverter.cs @@ -69,6 +69,12 @@ override protected void Convert(TextWriter writer, object state) writer.Write( SystemInfo.NotAvailableText ); } +#if NETSTANDARD2_0 + catch(PlatformNotSupportedException) + { + writer.Write($"{nameof(System.Security.Principal.WindowsIdentity)} is not available on this platform"); + } +#endif #endif } diff --git a/src/Util/ReadOnlyPropertiesDictionary.cs b/src/Util/ReadOnlyPropertiesDictionary.cs index e7e0fe1d..a44598d7 100644 --- a/src/Util/ReadOnlyPropertiesDictionary.cs +++ b/src/Util/ReadOnlyPropertiesDictionary.cs @@ -204,7 +204,7 @@ protected Hashtable InnerHashtable /// Serializes this object into the provided. /// /// -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 [System.Security.SecurityCritical] #else [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter=true)] diff --git a/src/Util/SystemInfo.cs b/src/Util/SystemInfo.cs index 72e84533..a5c3727f 100644 --- a/src/Util/SystemInfo.cs +++ b/src/Util/SystemInfo.cs @@ -174,7 +174,7 @@ public static string ConfigurationFileLocation { get { -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 return SystemInfo.EntryAssemblyLocation+".config"; #else return System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; @@ -233,7 +233,7 @@ public static int CurrentThreadId { #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 || NETSTANDARD1_3 +#elif NET_2_0 || NETCF_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 return System.Threading.Thread.CurrentThread.ManagedThreadId; #else return AppDomain.GetCurrentThreadId(); @@ -484,8 +484,8 @@ public static string AssemblyLocationInfo(Assembly myAssembly) { #if NETCF return "Not supported on Microsoft .NET Compact Framework"; -#elif NETSTANDARD1_3 // TODO Assembly.Location available in netstandard1.5 - return "Not supported on .NET Core"; +#elif NETSTANDARD1_3 + return "Not supported for .NET Standard 1.3"; #else if (myAssembly.GlobalAssemblyCache) { @@ -495,7 +495,7 @@ public static string AssemblyLocationInfo(Assembly myAssembly) { try { -#if NET_4_0 || MONO_4_0 +#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0 if (myAssembly.IsDynamic) { return "Dynamic Assembly"; @@ -613,7 +613,7 @@ public static string AssemblyShortName(Assembly myAssembly) /// public static string AssemblyFileName(Assembly myAssembly) { -#if NETCF || NETSTANDARD1_3 // TODO Assembly.Location is in netstandard1.5 System.Reflection +#if NETCF || NETSTANDARD1_3 // 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. diff --git a/src/Util/SystemStringFormat.cs b/src/Util/SystemStringFormat.cs index 8a50433b..62a0a276 100644 --- a/src/Util/SystemStringFormat.cs +++ b/src/Util/SystemStringFormat.cs @@ -109,7 +109,7 @@ private static string StringFormat(IFormatProvider provider, string format, para 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 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]"); @@ -148,7 +148,7 @@ private static string StringFormatError(Exception formatException, string format log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling", ex); return "Exception during StringFormat. See Internal Log."; } -#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling"); @@ -210,7 +210,7 @@ private static void RenderObject(Object obj, StringBuilder buffer) { buffer.Append(""); } -#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 +#if !(MONO || NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0) catch { buffer.Append(""); diff --git a/src/log4net.csproj b/src/log4net.csproj index 05a7062c..94375a5b 100644 --- a/src/log4net.csproj +++ b/src/log4net.csproj @@ -1,4 +1,3 @@ - - + + - Local - 9.0.30729 - 2.0 - {181FE707-E161-4722-9F38-6AAAB6FAA106} - Debug - AnyCPU - - - - + net20;net35;net35-client;net40;net40-client;net45;netstandard1.3;netstandard2.0 + Copyright 2004-2017 The Apache Software Foundation. + Apache log4net for .NET Core + 2.0.9 + beta log4net - - - JScript - Grid - IE50 - false - Library - log4net - - - - - - - 3.5 - v4.5 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - + log4net + false + true + ../log4net.snk + true + true - - ..\build\bin\net\4.5\debug\ - false - 285212672 - false - - - TRACE;DEBUG;NET;NET_2_0;NET_4_0;NET_4_5 - log4net.xml - true - 4096 - false - false - false - false - 4 - full - prompt - SecurityRules.ruleset + + + + + + + + + + + + STRONG;TRACE;NET_2_0 - - ..\build\bin\net\4.5\release\ - false - 285212672 - false - - - TRACE;STRONG;NET;NET_2_0;NET_4_0;NET_4_5 - log4net.xml - false - 4096 - true - false - false - false - 4 - none - prompt - AllRules.ruleset + + + STRONG;TRACE;NET_2_0;HAS_READERWRITERLOCKSLIM - - - System - - - - System.Data - - - System.Web - - - System.XML - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - + + + .NETFramework + v3.5 + client + STRONG;TRACE;NET_2_0;HAS_READERWRITERLOCKSLIM;CLIENT_PROFILE + + + + STRONG;TRACE;NET_2_0;NET_4_0;HAS_READERWRITERLOCKSLIM + + + + .NETFramework + v4.0 + client + STRONG;TRACE;NET_2_0;NET_4_0;HAS_READERWRITERLOCKSLIM;CLIENT_PROFILE + + + + STRONG;TRACE;NET_2_0;NET_4_0;NET_4_5;HAS_READERWRITERLOCKSLIM + + + + STRONG;TRACE;HAS_READERWRITERLOCKSLIM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - + + + + + + - - - - - - - + diff --git a/src/log4net.sln b/src/log4net.sln index 3d422e36..dcb465a1 100644 --- a/src/log4net.sln +++ b/src/log4net.sln @@ -1,6 +1,6 @@ + Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -# +# Visual Studio 15 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -19,10 +19,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # specific language governing permissions and limitations # under the License. # -# -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net", "log4net.csproj", "{181FE707-E161-4722-9F38-6AAAB6FAA106}" +VisualStudioVersion = 15.0.26801.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "log4net", "log4net.csproj", "{5C1DC5A1-A943-40B5-9270-A65286B4978D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net.Tests", "..\tests\src\log4net.Tests.csproj", "{B0530F10-0238-49A9-93B0-8EF412E90BCF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "log4net.Tests", "..\tests\src\log4net.Tests.csproj", "{DBF648C3-AA35-48C6-9F3C-05669BAABA63}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -30,16 +31,19 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {181FE707-E161-4722-9F38-6AAAB6FAA106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {181FE707-E161-4722-9F38-6AAAB6FAA106}.Debug|Any CPU.Build.0 = Debug|Any CPU - {181FE707-E161-4722-9F38-6AAAB6FAA106}.Release|Any CPU.ActiveCfg = Release|Any CPU - {181FE707-E161-4722-9F38-6AAAB6FAA106}.Release|Any CPU.Build.0 = Release|Any CPU - {B0530F10-0238-49A9-93B0-8EF412E90BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0530F10-0238-49A9-93B0-8EF412E90BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0530F10-0238-49A9-93B0-8EF412E90BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0530F10-0238-49A9-93B0-8EF412E90BCF}.Release|Any CPU.Build.0 = Release|Any CPU + {5C1DC5A1-A943-40B5-9270-A65286B4978D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C1DC5A1-A943-40B5-9270-A65286B4978D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C1DC5A1-A943-40B5-9270-A65286B4978D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C1DC5A1-A943-40B5-9270-A65286B4978D}.Release|Any CPU.Build.0 = Release|Any CPU + {DBF648C3-AA35-48C6-9F3C-05669BAABA63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBF648C3-AA35-48C6-9F3C-05669BAABA63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBF648C3-AA35-48C6-9F3C-05669BAABA63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBF648C3-AA35-48C6-9F3C-05669BAABA63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8655E3DC-898A-49DA-960F-0AD7DB2DFD93} + EndGlobalSection EndGlobal diff --git a/tests/src/Appender/DebugAppenderTest.cs b/tests/src/Appender/DebugAppenderTest.cs index 121c6048..1a4f8bef 100644 --- a/tests/src/Appender/DebugAppenderTest.cs +++ b/tests/src/Appender/DebugAppenderTest.cs @@ -113,7 +113,7 @@ public void DefaultCategoryTest() Debug.Listeners.Remove(categoryTraceListener); } -#if !NETSTANDARD1_3 // "LocationInfo can't get method names on NETSTANDARD1_3 due to unavailable stack frame APIs" +#if !NETCOREAPP1_0 // "LocationInfo can't get method names on NETCOREAPP1_0 due to unavailable stack frame APIs" [Test] public void MethodNameCategoryTest() { diff --git a/tests/src/Appender/MemoryAppenderTest.cs b/tests/src/Appender/MemoryAppenderTest.cs index b97bd623..0f31ff5c 100644 --- a/tests/src/Appender/MemoryAppenderTest.cs +++ b/tests/src/Appender/MemoryAppenderTest.cs @@ -19,7 +19,7 @@ * */ -#if NET_4_0 || MONO_3_5 || MONO_4_0 +#if NET_4_0 || MONO_3_5 || MONO_4_0 || NETCOREAPP1_0 || NETCOREAPP2_0 using System; using System.Linq; diff --git a/tests/src/Appender/RollingFileAppenderTest.cs b/tests/src/Appender/RollingFileAppenderTest.cs index 07ebfec0..c814753d 100644 --- a/tests/src/Appender/RollingFileAppenderTest.cs +++ b/tests/src/Appender/RollingFileAppenderTest.cs @@ -51,7 +51,7 @@ public class RollingFileAppenderTest private int _MaxSizeRollBackups = 3; private CountingAppender _caRoot; private Logger _root; -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 private CultureInfo _currentCulture; private CultureInfo _currentUICulture; #endif @@ -116,7 +116,7 @@ public void SetUp() ResetAndDeleteTestFiles(); InitializeVariables(); -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 // set correct thread culture _currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture; _currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture; @@ -132,7 +132,7 @@ public void TearDown() { ResetAndDeleteTestFiles(); -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 // restore previous culture System.Threading.Thread.CurrentThread.CurrentCulture = _currentCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = _currentUICulture; @@ -1453,7 +1453,7 @@ private static void DestroyLogger() private static void AssertFileEquals(string filename, string contents) { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 StreamReader sr = new StreamReader(File.Open(filename, FileMode.Open)); #else StreamReader sr = new StreamReader(filename); diff --git a/tests/src/Appender/TraceAppenderTest.cs b/tests/src/Appender/TraceAppenderTest.cs index ec5227aa..f3db34b9 100644 --- a/tests/src/Appender/TraceAppenderTest.cs +++ b/tests/src/Appender/TraceAppenderTest.cs @@ -55,7 +55,7 @@ public void DefaultCategoryTest() categoryTraceListener.Category); } -#if !NETSTANDARD1_3 // "LocationInfo can't get method names on NETSTANDARD1_3 due to unavailable stack frame APIs" +#if !NETCOREAPP1_0 // "LocationInfo can't get method names on NETCOREAPP1_0 due to unavailable stack frame APIs" [Test] public void MethodNameCategoryTest() { diff --git a/netstandard/log4net.tests/ApplicationException.cs b/tests/src/ApplicationException.cs similarity index 92% rename from netstandard/log4net.tests/ApplicationException.cs rename to tests/src/ApplicationException.cs index 30bfe37f..67f25900 100644 --- a/netstandard/log4net.tests/ApplicationException.cs +++ b/tests/src/ApplicationException.cs @@ -1,10 +1,11 @@ -#region Apache License +#if NETCOREAPP1_0 +#region Apache License // -// Licensed to the Apache Software Foundation (ASF) under one or more +// 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. +// 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 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 @@ -25,3 +26,4 @@ public class ApplicationException : Exception { } } +#endif diff --git a/netstandard/log4net.tests/CompatibilityExtensions.cs b/tests/src/CompatibilityExtensions.cs similarity index 87% rename from netstandard/log4net.tests/CompatibilityExtensions.cs rename to tests/src/CompatibilityExtensions.cs index a634ed00..1927f814 100644 --- a/netstandard/log4net.tests/CompatibilityExtensions.cs +++ b/tests/src/CompatibilityExtensions.cs @@ -1,10 +1,11 @@ -#region Apache License +#if NETCOREAPP1_0 +#region Apache License // -// Licensed to the Apache Software Foundation (ASF) under one or more +// 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. +// 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 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 @@ -24,6 +25,9 @@ namespace log4net { + /// + /// Extension methods for simple API substitutions for compatibility with .NET Standard 1.3. + /// internal static class CompatibilityExtensions { public static void Close(this Mutex mutex) => mutex.Dispose(); @@ -36,3 +40,4 @@ public static ConstructorInfo GetConstructor(this Type type, BindingFlags bindin } } } +#endif diff --git a/tests/src/Context/LogicalThreadContextTest.cs b/tests/src/Context/LogicalThreadContextTest.cs index 34a7136c..1da998c8 100644 --- a/tests/src/Context/LogicalThreadContextTest.cs +++ b/tests/src/Context/LogicalThreadContextTest.cs @@ -17,7 +17,7 @@ // #endregion -#if NET_4_5 || NETSTANDARD1_3 +#if NET_4_5 || NETCOREAPP1_0 || NETCOREAPP2_0 using System; using System.Threading.Tasks; using System.Linq; diff --git a/tests/src/Core/FixingTest.cs b/tests/src/Core/FixingTest.cs index 34af05de..c1a4d024 100644 --- a/tests/src/Core/FixingTest.cs +++ b/tests/src/Core/FixingTest.cs @@ -33,7 +33,7 @@ public class FixingTest { const string TEST_REPOSITORY = "Test Repository"; -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 [OneTimeSetUp] #else [TestFixtureSetUp] @@ -143,7 +143,7 @@ private static void AssertExpectedLoggingEvent(LoggingEvent loggingEvent, Loggin Assert.AreEqual("System.Exception: This is the exception", loggingEvent.GetExceptionString(), "Exception is incorrect"); Assert.AreEqual(null, loggingEventData.Identity, "Identity is incorrect"); Assert.AreEqual(Level.Warn, loggingEventData.Level, "Level is incorrect"); -#if !NETSTANDARD1_3 // NETSTANDARD1_3: LocationInfo can't get method names +#if !NETCOREAPP1_0 // NETCOREAPP1_0: LocationInfo can't get method names Assert.AreEqual("get_LocationInformation", loggingEvent.LocationInformation.MethodName, "Location Info is incorrect"); #endif Assert.AreEqual("log4net.Tests.Core.FixingTest", loggingEventData.LoggerName, "LoggerName is incorrect"); diff --git a/tests/src/Core/StringFormatTest.cs b/tests/src/Core/StringFormatTest.cs index d0f8473a..1b5b4c37 100644 --- a/tests/src/Core/StringFormatTest.cs +++ b/tests/src/Core/StringFormatTest.cs @@ -40,7 +40,7 @@ namespace log4net.Tests.Core [TestFixture] public class StringFormatTest { -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 private CultureInfo _currentCulture; private CultureInfo _currentUICulture; diff --git a/netstandard/log4net.tests/ExpectedExceptionAttribute.cs b/tests/src/ExpectedExceptionAttribute.cs similarity index 96% rename from netstandard/log4net.tests/ExpectedExceptionAttribute.cs rename to tests/src/ExpectedExceptionAttribute.cs index 771922a0..203cb8fd 100644 --- a/netstandard/log4net.tests/ExpectedExceptionAttribute.cs +++ b/tests/src/ExpectedExceptionAttribute.cs @@ -1,10 +1,11 @@ -#region Apache License +#if NETCOREAPP1_0 || NETCOREAPP2_0 +#region Apache License // -// Licensed to the Apache Software Foundation (ASF) under one or more +// 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. +// 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 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 @@ -83,3 +84,4 @@ public override TestResult Execute(TestExecutionContext context) } } } +#endif diff --git a/tests/src/Hierarchy/Hierarchy.cs b/tests/src/Hierarchy/Hierarchy.cs index 8c832901..b6153073 100644 --- a/tests/src/Hierarchy/Hierarchy.cs +++ b/tests/src/Hierarchy/Hierarchy.cs @@ -86,7 +86,7 @@ public void AddingMultipleAppenders2() CountingAppender alpha = new CountingAppender(); CountingAppender beta = new CountingAppender(); -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 BasicConfigurator.Configure(Utils.GetRepository(), alpha, beta); #else BasicConfigurator.Configure(alpha, beta); diff --git a/tests/src/Hierarchy/Logger.cs b/tests/src/Hierarchy/Logger.cs index 73359202..eb6631ed 100644 --- a/tests/src/Hierarchy/Logger.cs +++ b/tests/src/Hierarchy/Logger.cs @@ -25,7 +25,7 @@ using NUnit.Framework; -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 using System.Reflection; #endif @@ -280,7 +280,7 @@ public void TestExists() object a_b_c = Utils.GetLogger("a.b.c"); object t; -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 Assert.IsNull(LogManager.Exists(GetType().GetTypeInfo().Assembly, "xx")); t = LogManager.Exists(GetType().GetTypeInfo().Assembly, "a"); Assert.AreSame(a, t); diff --git a/tests/src/Hierarchy/XmlHierarchyConfiguratorTest.cs b/tests/src/Hierarchy/XmlHierarchyConfiguratorTest.cs index 60003667..f39d91a1 100644 --- a/tests/src/Hierarchy/XmlHierarchyConfiguratorTest.cs +++ b/tests/src/Hierarchy/XmlHierarchyConfiguratorTest.cs @@ -45,7 +45,7 @@ public string TestProp } } -#if !NETSTANDARD1_3 // TODO write replacement test +#if !(NETCOREAPP1_0 || NETCOREAPP2_0) // TODO write replacement test [Test][Platform(Include="Win")] public void EnvironmentOnWindowsIsCaseInsensitive() { diff --git a/tests/src/Layout/PatternLayoutTest.cs b/tests/src/Layout/PatternLayoutTest.cs index 68e0a1e8..9dfbc6c4 100644 --- a/tests/src/Layout/PatternLayoutTest.cs +++ b/tests/src/Layout/PatternLayoutTest.cs @@ -42,7 +42,7 @@ namespace log4net.Tests.Layout [TestFixture] public class PatternLayoutTest { -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 private CultureInfo _currentCulture; private CultureInfo _currentUICulture; @@ -101,8 +101,8 @@ public void TestThreadPropertiesPattern() stringAppender.Reset(); } -#if NETSTANDARD1_3 - [Test, Ignore("System.Diagnostics.StackTrace isn't fully implemented on NETSTANDARD1_3")] +#if NETCOREAPP1_0 + [Test, Ignore("System.Diagnostics.StackTrace isn't fully implemented on NETCOREAPP1_0")] #else [Test] #endif @@ -356,4 +356,4 @@ protected override string GetFullyQualifiedName(LoggingEvent loggingEvent) } } } -} \ No newline at end of file +} diff --git a/tests/src/Layout/XmlLayoutTest.cs b/tests/src/Layout/XmlLayoutTest.cs index 9918ac76..8035cbbf 100644 --- a/tests/src/Layout/XmlLayoutTest.cs +++ b/tests/src/Layout/XmlLayoutTest.cs @@ -36,7 +36,7 @@ namespace log4net.Tests.Layout [TestFixture] public class XmlLayoutTest { -#if !NETSTANDARD1_3 +#if !NETCOREAPP1_0 private CultureInfo _currentCulture; private CultureInfo _currentUICulture; @@ -83,7 +83,7 @@ private LoggingEventData CreateBaseEvent() private static string CreateEventNode(string message) { return String.Format("{1}" + Environment.NewLine, -#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 +#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETCOREAPP1_0 XmlConvert.ToString(DateTime.Today, XmlDateTimeSerializationMode.Local), #else XmlConvert.ToString(DateTime.Today), @@ -94,7 +94,7 @@ private static string CreateEventNode(string message) private static string CreateEventNode(string key, string value) { return String.Format("Test message" + Environment.NewLine, -#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 +#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETCOREAPP1_0 XmlConvert.ToString(DateTime.Today, XmlDateTimeSerializationMode.Local), #else XmlConvert.ToString(DateTime.Today), @@ -305,7 +305,7 @@ public void TestPropertyIllegalCharacterMaskingInName() Assert.AreEqual(expected, stringAppender.GetString()); } -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETCOREAPP1_0 || NETCOREAPP2_0 [Test] public void BracketsInStackTracesKeepLogWellFormed() { XmlLayout layout = new XmlLayout(); @@ -349,7 +349,7 @@ public void BracketsInStackTracesAreEscapedProperly() { bar(42); var log = stringAppender.GetString(); -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 var startOfExceptionText = log.IndexOf("", StringComparison.Ordinal) + 11; var endOfExceptionText = log.IndexOf("", StringComparison.Ordinal); #else diff --git a/tests/src/Util/SystemInfoTest.cs b/tests/src/Util/SystemInfoTest.cs index e6cc4bf1..32edf875 100644 --- a/tests/src/Util/SystemInfoTest.cs +++ b/tests/src/Util/SystemInfoTest.cs @@ -23,7 +23,7 @@ using NUnit.Framework; -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETCOREAPP1_0 || NETCOREAPP2_0 using System.Linq.Expressions; using System.Reflection; #endif @@ -37,7 +37,7 @@ namespace log4net.Tests.Util public class SystemInfoTest { -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETCOREAPP1_0 || NETCOREAPP2_0 /// /// It's "does not throw not supported exception" NOT /// "returns 'Dynamic Assembly' string for dynamic assemblies" by purpose. @@ -65,7 +65,7 @@ private static Func GetAssemblyLocationInfoMethodCall() public static string TestAssemblyLocationInfoMethod() { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return SystemInfo.AssemblyLocationInfo(typeof(SystemInfoTest).GetTypeInfo().Assembly); #else return SystemInfo.AssemblyLocationInfo(Assembly.GetCallingAssembly()); @@ -88,7 +88,7 @@ public void TestGetTypeFromStringFullyQualified() Assert.AreSame(typeof(SystemInfoTest), t, "Test explicit case in-sensitive type load lower"); } -#if !NETSTANDARD1_3 +#if !(NETCOREAPP1_0 || NETCOREAPP2_0) [Test][Platform(Include="Win")] public void TestGetTypeFromStringCaseInsensitiveOnAssemblyName() { @@ -117,7 +117,7 @@ public void TestGetTypeFromStringRelative() Assert.AreSame(typeof(SystemInfoTest), t, "Test explicit case in-sensitive type load lower"); } -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 [Ignore("This test relies on enumerating loaded assemblies, which is presently impossible in CoreFX (https://github.com/dotnet/corefx/issues/1784).")] #endif [Test] @@ -161,10 +161,10 @@ public void TestGetTypeFromStringFails2() // Wraps SystemInfo.GetTypeFromString because the method relies on GetCallingAssembly, which is // unavailable in CoreFX. As a workaround, only overloads which explicitly take a Type or Assembly - // are exposed for NETSTANDARD1_3. + // are exposed for NETCOREAPP1_0. private Type GetTypeFromString(string typeName, bool throwOnError, bool ignoreCase) { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return SystemInfo.GetTypeFromString(GetType().GetTypeInfo().Assembly, typeName, throwOnError, ignoreCase); #else return SystemInfo.GetTypeFromString(typeName, throwOnError, ignoreCase); diff --git a/tests/src/Utils.cs b/tests/src/Utils.cs index d2ce18bc..7404063b 100644 --- a/tests/src/Utils.cs +++ b/tests/src/Utils.cs @@ -44,7 +44,7 @@ public static object CreateInstance(Type targetType) public static object InvokeMethod(object target, string name, params object[] args) { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return target.GetType().GetTypeInfo().GetDeclaredMethod(name).Invoke(target, args); #else return target.GetType().GetMethod(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, GetTypesArray(args), null).Invoke(target, args); @@ -53,7 +53,7 @@ public static object InvokeMethod(object target, string name, params object[] ar public static object InvokeMethod(Type target, string name, params object[] args) { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return target.GetTypeInfo().GetDeclaredMethod(name).Invoke(null, args); #else return target.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, GetTypesArray(args), null).Invoke(null, args); @@ -122,7 +122,7 @@ internal static void RemovePropertyFromAllContexts() { // Wrappers because repository/logger retrieval APIs require an Assembly argument on NETSTANDARD1_3 internal static ILog GetLogger(string name) { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return LogManager.GetLogger(typeof(Utils).GetTypeInfo().Assembly, name); #else return LogManager.GetLogger(name); @@ -131,7 +131,7 @@ internal static ILog GetLogger(string name) internal static ILoggerRepository GetRepository() { -#if NETSTANDARD1_3 +#if NETCOREAPP1_0 return LogManager.GetRepository(typeof(Utils).GetTypeInfo().Assembly); #else return LogManager.GetRepository(); diff --git a/tests/src/log4net.Tests.csproj b/tests/src/log4net.Tests.csproj index f1768ccd..a29659e3 100644 --- a/tests/src/log4net.Tests.csproj +++ b/tests/src/log4net.Tests.csproj @@ -1,4 +1,3 @@ - - + + - Local - 9.0.30729 - 2.0 - {B0530F10-0238-49A9-93B0-8EF412E90BCF} - Debug - AnyCPU - - - - + + netcoreapp2.0 + false + false log4net.Tests - - - JScript - Grid - IE50 - false - Library - log4net.Tests - - - - - - - 3.5 - v4.5 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - ..\bin\Debug\ - false - 285212672 - false - - - TRACE;DEBUG;NET;NET_2_0;NET_4_0;NET_4_5 - - - true - 4096 - false - false - false - false - 4 - full - prompt - AllRules.ruleset - - - ..\bin\Release\ - false - 285212672 - false - - - TRACE;NET;NET_2_0;NET_4_0;NET_4_5 - - - false - 4096 - true - false - false - false - 4 - none - prompt - AllRules.ruleset + - - ..\..\src\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - System - - - - 3.5 - - - System.Data - - - System.Runtime.Remoting - - - System.XML - - - - - AssemblyVersionInfo.cs - Code - - - - - - - - - - Code - - - Code - - - - Code - - - - Code - - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - - Code - - - Code - - - - - Code - - - Code - - - - - - - Code - - - Code - - - Code - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - - - {181fe707-e161-4722-9f38-6aaab6faa106} - log4net.vs2012 - - - - + + + + + - - - - - - - - \ No newline at end of file + + diff --git a/tests/src/packages.config b/tests/src/packages.config deleted file mode 100644 index e594870a..00000000 --- a/tests/src/packages.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - -