diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..f69ee50f --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,41 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- master + +workspace: + clean: all + +pool: + vmImage: 'windows-latest' + +steps: +- task: UseDotNet@2 + displayName: "Use .net core sdk 2.2" + inputs: + packageType: 'sdk' + version: '2.2.x' +- task: DotNetCoreCLI@2 + displayName: "Build solution" + inputs: + command: 'build' + arguments: '-c Release' + projects: '.\netstandard\log4net.netstandard.sln' + feedsToUse: 'select' + vstsFeed: 'cc499f7c-f140-4e59-aa34-508c25f2cac1' +- task: CopyFiles@2 + displayName: 'Copy package' + inputs: + SourceFolder: '$(Build.SourcesDirectory)\netstandard\log4net\bin\Release' + Contents: '**' + TargetFolder: '$(Build.ArtifactStagingDirectory)' + CleanTargetFolder: true +- task: PublishBuildArtifacts@1 + displayName: 'Publish package' + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'drop' + publishLocation: 'Container' \ No newline at end of file diff --git a/log4net.build b/log4net.build index 230d6a80..21e6472d 100644 --- a/log4net.build +++ b/log4net.build @@ -1913,14 +1913,21 @@ limitations under the License. + + + + + + + diff --git a/netstandard/log4net.netstandard.sln b/netstandard/log4net.netstandard.sln index d436d060..bc2b4214 100644 --- a/netstandard/log4net.netstandard.sln +++ b/netstandard/log4net.netstandard.sln @@ -1,37 +1,21 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -# -# -# 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. -# -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29403.142 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "log4net", "log4net\log4net.xproj", "{00764202-B361-4BC8-A1B9-01D87F9D2D51}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "log4net.tests", "log4net.tests\log4net.tests.xproj", "{6A78D53B-C864-4316-AA00-F2EBFE975223}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4BB38D1C-1862-432B-881C-925714F7F997}" ProjectSection(SolutionItems) = preProject global.json = global.json nuget.config = nuget.config EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "log4net", "log4net\log4net.csproj", "{00764202-B361-4BC8-A1B9-01D87F9D2D51}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "log4net.tests", "log4net.tests\log4net.tests.csproj", "{6A78D53B-C864-4316-AA00-F2EBFE975223}" + ProjectSection(ProjectDependencies) = postProject + {00764202-B361-4BC8-A1B9-01D87F9D2D51} = {00764202-B361-4BC8-A1B9-01D87F9D2D51} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,4 +34,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {316D5265-B6A6-4270-9E1C-41BED3BF5E05} + EndGlobalSection EndGlobal diff --git a/netstandard/log4net.tests/log4net.tests.csproj b/netstandard/log4net.tests/log4net.tests.csproj new file mode 100644 index 00000000..170336db --- /dev/null +++ b/netstandard/log4net.tests/log4net.tests.csproj @@ -0,0 +1,32 @@ + + + + 2.0.9 + netcoreapp2.2 + $(DefineConstants);NETSTANDARD1_3 + log4net.tests + log4net.tests + true + 2.2.0 + false + false + false + false + false + + + + + + + + + + + + + + + + + diff --git a/netstandard/log4net.tests/log4net.tests.xproj b/netstandard/log4net.tests/log4net.tests.xproj deleted file mode 100644 index 92eecae3..00000000 --- a/netstandard/log4net.tests/log4net.tests.xproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 6a78d53b-c864-4316-aa00-f2ebfe975223 - log4net.tests - ..\artifacts\obj\$(MSBuildProjectName) - ..\..\build\netstandard\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2.0 - - - True - - - diff --git a/netstandard/log4net.tests/project.json b/netstandard/log4net.tests/project.json deleted file mode 100644 index e5a37726..00000000 --- a/netstandard/log4net.tests/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "version": "2.0.9", - "buildOptions": { - "compile": [ - "../../tests/src/*.cs", - "../../tests/src/Appender/AppenderCollectionTest.cs", - "../../tests/src/Appender/BufferingAppenderTest.cs", - "../../tests/src/Appender/CountingAppender.cs", - "../../tests/src/Appender/MemoryAppenderTest.cs", - "../../tests/src/Appender/RollingFileAppenderTest.cs", - "../../tests/src/Appender/SmtpPickupDirAppenderTest.cs", - "../../tests/src/Appender/StringAppender.cs", - "../../tests/src/Appender/TraceAppenderTest.cs", - "../../tests/src/Context/LogicalThreadContextTest.cs", - "../../tests/src/Context/ThreadContextTest.cs", - "../../tests/src/Core/**/*.cs", - "../../tests/src/DateFormatter/**/*.cs", - "../../tests/src/Hierarchy/**/*.cs", - "../../tests/src/Layout/**/*.cs", - "../../tests/src/LoggerRepository/**/*.cs", - "../../tests/src/Util/CyclicBufferTest.cs", - "../../tests/src/Util/LogLogTest.cs", - "../../tests/src/Util/PatternConverterTest.cs", - "../../tests/src/Util/RandomStringPatternConverterTest.cs", - "../../tests/src/Util/SystemInfoTest.cs", - "../../tests/src/Util/TransformTest.cs" - ], - "define": [ "NETSTANDARD1_3" ] - }, - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - "dotnet-test-nunit": "3.4.0-beta-2", - "log4net": { "target": "project" }, - "NUnit": "3.4.1" - }, - "imports": [ "portable-net45+win8" ] - } - }, - "testRunner": "nunit" -} diff --git a/netstandard/log4net/CompatibilityExtensions.cs b/netstandard/log4net/CompatibilityExtensions.cs index c0a9076b..e31fc01e 100644 --- a/netstandard/log4net/CompatibilityExtensions.cs +++ b/netstandard/log4net/CompatibilityExtensions.cs @@ -17,7 +17,7 @@ // #endregion -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System; using System.Globalization; @@ -41,7 +41,7 @@ internal static class CompatibilityExtensions public static void Close(this WebResponse response) => response.Dispose(); public static void Close(this XmlWriter xmlWriter) => xmlWriter.Dispose(); - public static Attribute[] GetCustomAttributes(this Type type, Type other, bool inherit) => type.GetTypeInfo().GetCustomAttributes(other, inherit).ToArray(); + public static object[] GetCustomAttributes(this Type type, Type other, bool inherit) => type.GetTypeInfo().GetCustomAttributes(other, inherit).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); diff --git a/netstandard/log4net/log4net.csproj b/netstandard/log4net/log4net.csproj new file mode 100644 index 00000000..ca53e361 --- /dev/null +++ b/netstandard/log4net/log4net.csproj @@ -0,0 +1,67 @@ + + + + Copyright 2004-2017 The Apache Software Foundation. + Apache log4net for .NET Core + 2.0.9 + netstandard1.3;netstandard2.0 + log4net + log4net + false + false + false + false + false + false + false + false + + + + $(DefineConstants);HAS_READERWRITERLOCKSLIM + true + ../../log4net.snk + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/netstandard/log4net/log4net.xproj b/netstandard/log4net/log4net.xproj deleted file mode 100644 index 083a7a45..00000000 --- a/netstandard/log4net/log4net.xproj +++ /dev/null @@ -1,260 +0,0 @@ - - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 00764202-b361-4bc8-a1b9-01d87f9d2d51 - log4net - ..\artifacts\obj\$(MSBuildProjectName) - ..\..\build\netstandard\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2.0 - - - diff --git a/netstandard/log4net/project.json b/netstandard/log4net/project.json deleted file mode 100644 index e5fc4e3b..00000000 --- a/netstandard/log4net/project.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "log4net", - "version": "2.0.9", - "title": "Apache log4net for .NET Core", - "copyright": "Copyright 2004-2017 The Apache Software Foundation.", - "frameworks": { - "netstandard1.3": { - "buildOptions": { - "compile": { - "include": [ "*.cs", "../../src/**/*.cs" ], - "exclude": [ - "../../src/Appender/AdoNetAppender.cs", - "../../src/Appender/AspNetTraceAppender.cs", - "../../src/Appender/ColoredConsoleAppender.cs", - "../../src/Appender/EventLogAppender.cs", - "../../src/Appender/NetSendAppender.cs", - "../../src/Appender/RemotingAppender.cs", - "../../src/Appender/SmtpAppender.cs", - "../../src/Config/DOMConfigurator.cs", - "../../src/Config/DOMConfiguratorAttribute.cs", - "../../src/Config/Log4NetConfigurationSectionHandler.cs", - "../../src/Layout/Pattern/AspNetCachePatternConverter.cs", - "../../src/Layout/Pattern/AspNetContextPatternConverter.cs", - "../../src/Layout/Pattern/AspNetPatternConverter.cs", - "../../src/Layout/Pattern/AspNetRequestPatternConverter.cs", - "../../src/Layout/Pattern/AspNetSessionPatternConverter.cs", - "../../src/Layout/Pattern/StackTraceDetailPatternConverter.cs", - "../../src/Layout/Pattern/StackTracePatternConverter.cs", - "../../src/Plugin/RemoteLoggingServerPlugin.cs", - "../../src/Util/PatternStringConverters/AppSettingPatternConverter.cs", - "../../src/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs", - "../../src/Util/NativeError.cs", - "../../src/Util/WindowsSecurityContext.cs" - ] - }, - "define": [ "HAS_READERWRITERLOCKSLIM" ], - "publicSign": true, - "keyFile": "../../log4net.snk" - }, - "dependencies": { - "System.AppContext": "4.1.0", - "System.Collections.NonGeneric": "4.0.1", - "System.Console": "4.0.0", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Process": "4.1.0", - "System.Diagnostics.StackTrace": "4.0.1", - "System.Diagnostics.TraceSource": "4.0.0", - "System.IO.FileSystem": "4.0.1", - "System.IO.FileSystem.Watcher": "4.0.0", - "System.Linq": "4.1.0", - "System.Net.NameResolution": "4.0.0", - "System.Net.Requests": "4.0.11", - "System.Net.Sockets": "4.1.0", - "System.Reflection": "4.3.0", - "System.Reflection.Extensions": "4.0.1", - "System.Reflection.TypeExtensions": "4.1.0", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.InteropServices.RuntimeInformation": "4.0.0", - "System.Runtime.Serialization.Formatters": "4.3.0", - "System.Text.RegularExpressions": "4.1.0", - "System.Threading": "4.0.11", - "System.Threading.Thread": "4.0.0", - "System.Threading.Timer": "4.0.1", - "System.Xml.ReaderWriter": "4.0.11", - "System.Xml.XmlDocument": "4.0.1" - } - } - } -} diff --git a/netstandard/nuget.config b/netstandard/nuget.config new file mode 100644 index 00000000..1b997731 --- /dev/null +++ b/netstandard/nuget.config @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Appender/AppenderCollection.cs b/src/Appender/AppenderCollection.cs index 21987b84..1b9f4cac 100644 --- a/src/Appender/AppenderCollection.cs +++ b/src/Appender/AppenderCollection.cs @@ -27,7 +27,7 @@ namespace log4net.Appender /// /// Nicko Cadell public class AppenderCollection : ICollection, IList, IEnumerable -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 , ICloneable #endif { diff --git a/src/Appender/AppenderSkeleton.cs b/src/Appender/AppenderSkeleton.cs index 6f99eda8..6edd99f7 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 && !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 && !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/DebugAppender.cs b/src/Appender/DebugAppender.cs index df6a618c..095b6f66 100644 --- a/src/Appender/DebugAppender.cs +++ b/src/Appender/DebugAppender.cs @@ -119,7 +119,7 @@ public PatternLayout Category #endregion Public Instance Properties -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 /// /// Flushes any buffered log data. /// @@ -171,7 +171,7 @@ override protected void Append(LoggingEvent loggingEvent) System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), category); } } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 // // Flush the Debug system if needed // diff --git a/src/Appender/FileAppender.cs b/src/Appender/FileAppender.cs index 41616b97..7906ad4d 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 @@ -162,7 +162,7 @@ public LockingStream(LockingModelBase locking) #region Override Implementation of Stream -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 protected override void Dispose(bool disposing) { m_lockingModel.CloseFile(); @@ -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(); @@ -247,7 +247,7 @@ public override void SetLength(long value) } void IDisposable.Dispose() { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 Dispose(true); #else Close(); @@ -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 a21d7ed8..de1158a8 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,10 +378,10 @@ 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 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)] #endif protected override void Append(LoggingEvent loggingEvent) @@ -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/OutputDebugStringAppender.cs b/src/Appender/OutputDebugStringAppender.cs index cd48689f..50cd563a 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/RemoteSyslogAppender.cs b/src/Appender/RemoteSyslogAppender.cs index b7a8c66d..9f22906f 100644 --- a/src/Appender/RemoteSyslogAppender.cs +++ b/src/Appender/RemoteSyslogAppender.cs @@ -409,7 +409,7 @@ protected override void Append(LoggingEvent loggingEvent) // Grab as a byte array buffer = this.Encoding.GetBytes(builder.ToString()); -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait(); #else this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint); diff --git a/src/Appender/RollingFileAppender.cs b/src/Appender/RollingFileAppender.cs index 7554bf43..da3d3bab 100644 --- a/src/Appender/RollingFileAppender.cs +++ b/src/Appender/RollingFileAppender.cs @@ -244,7 +244,7 @@ public RollingFileAppender() #if !NETCF if (m_mutexForRolling != null) { -#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 +#if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 m_mutexForRolling.Dispose(); #else m_mutexForRolling.Close(); diff --git a/src/Appender/TelnetAppender.cs b/src/Appender/TelnetAppender.cs index 4d768a2b..52c4ab34 100644 --- a/src/Appender/TelnetAppender.cs +++ b/src/Appender/TelnetAppender.cs @@ -22,417 +22,414 @@ using System.Globalization; using System.Net; using System.Net.Sockets; -using System.Text; using System.IO; -using System.Threading; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Threading.Tasks; #endif -using log4net.Layout; using log4net.Core; using log4net.Util; -namespace log4net.Appender +namespace log4net.Appender { - /// - /// Appender that allows clients to connect via Telnet to receive log messages - /// - /// - /// - /// The TelnetAppender accepts socket connections and streams logging messages - /// back to the client. - /// The output is provided in a telnet-friendly way so that a log can be monitored - /// over a TCP/IP socket. - /// This allows simple remote monitoring of application logging. - /// - /// - /// The default is 23 (the telnet port). - /// - /// - /// Keith Long - /// Nicko Cadell - public class TelnetAppender : AppenderSkeleton - { - private SocketHandler m_handler; - private int m_listeningPort = 23; - - #region Constructor - - /// - /// Default constructor - /// - /// - /// - /// Default constructor - /// - /// - public TelnetAppender() - { - } - - #endregion - - #region Private Static Fields - - /// - /// The fully qualified type of the TelnetAppender class. - /// - /// - /// Used by the internal logger to record the Type of the - /// log message. - /// - private readonly static Type declaringType = typeof(TelnetAppender); - - #endregion Private Static Fields - - /// - /// Gets or sets the TCP port number on which this will listen for connections. - /// - /// - /// An integer value in the range to - /// indicating the TCP port number on which this will listen for connections. - /// - /// - /// - /// The default value is 23 (the telnet port). - /// - /// - /// The value specified is less than - /// or greater than . - public int Port - { - get - { - return m_listeningPort; - } - set - { - if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort) - { - throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value, - "The value specified for Port is less than " + - IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) + - " or greater than " + - IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + "."); - } - else - { - m_listeningPort = value; - } - } - } - - #region Override implementation of AppenderSkeleton - - /// - /// Overrides the parent method to close the socket handler - /// - /// - /// - /// Closes all the outstanding connections. - /// - /// - protected override void OnClose() - { - base.OnClose(); - - if (m_handler != null) - { - m_handler.Dispose(); - m_handler = null; - } - } - - /// - /// This appender requires a to be set. - /// - /// true - /// - /// - /// This appender requires a to be set. - /// - /// - protected override bool RequiresLayout - { - get { return true; } - } - - /// - /// Initialize the appender based on the options set. - /// - /// - /// - /// This is part of the delayed object - /// activation scheme. The method must - /// be called on this object after the configuration properties have - /// been set. Until is called this - /// object is in an undefined state and must not be used. - /// - /// - /// If any of the configuration properties are modified then - /// must be called again. - /// - /// - /// Create the socket handler and wait for connections - /// - /// - public override void ActivateOptions() - { - base.ActivateOptions(); - try - { - LogLog.Debug(declaringType, "Creating SocketHandler to listen on port ["+m_listeningPort+"]"); - m_handler = new SocketHandler(m_listeningPort); - } - catch(Exception ex) - { - LogLog.Error(declaringType, "Failed to create SocketHandler", ex); - throw; - } - } - - /// - /// Writes the logging event to each connected client. - /// - /// The event to log. - /// - /// - /// Writes the logging event to each connected client. - /// - /// - protected override void Append(LoggingEvent loggingEvent) - { - if (m_handler != null && m_handler.HasConnections) - { - m_handler.Send(RenderLoggingEvent(loggingEvent)); - } - } - - #endregion - - #region SocketHandler helper class - - /// - /// Helper class to manage connected clients - /// - /// - /// - /// The SocketHandler class is used to accept connections from - /// clients. It is threaded so that clients can connect/disconnect - /// asynchronously. - /// - /// - protected class SocketHandler : IDisposable - { - private const int MAX_CONNECTIONS = 20; - - private Socket m_serverSocket; - private ArrayList m_clients = new ArrayList(); - - /// - /// Class that represents a client connected to this handler - /// - /// - /// - /// Class that represents a client connected to this handler - /// - /// - protected class SocketClient : IDisposable - { - private Socket m_socket; - private StreamWriter m_writer; - - /// - /// Create this for the specified - /// - /// the client's socket - /// - /// - /// Opens a stream writer on the socket. - /// - /// - public SocketClient(Socket socket) - { - m_socket = socket; - - try - { - m_writer = new StreamWriter(new NetworkStream(socket)); - } - catch - { - Dispose(); - throw; - } - } - - /// - /// Write a string to the client - /// - /// string to send - /// - /// - /// Write a string to the client - /// - /// - public void Send(String message) - { - m_writer.Write(message); - m_writer.Flush(); - } - - #region IDisposable Members - - /// - /// Cleanup the clients connection - /// - /// - /// - /// Close the socket connection. - /// - /// - public void Dispose() - { - try - { - if (m_writer != null) - { + /// + /// Appender that allows clients to connect via Telnet to receive log messages + /// + /// + /// + /// The TelnetAppender accepts socket connections and streams logging messages + /// back to the client. + /// The output is provided in a telnet-friendly way so that a log can be monitored + /// over a TCP/IP socket. + /// This allows simple remote monitoring of application logging. + /// + /// + /// The default is 23 (the telnet port). + /// + /// + /// Keith Long + /// Nicko Cadell + public class TelnetAppender : AppenderSkeleton + { + private SocketHandler m_handler; + private int m_listeningPort = 23; + + #region Constructor + + /// + /// Default constructor + /// + /// + /// + /// Default constructor + /// + /// + public TelnetAppender() + { + } + + #endregion + + #region Private Static Fields + + /// + /// The fully qualified type of the TelnetAppender class. + /// + /// + /// Used by the internal logger to record the Type of the + /// log message. + /// + private static readonly Type declaringType = typeof(TelnetAppender); + + #endregion Private Static Fields + + /// + /// Gets or sets the TCP port number on which this will listen for connections. + /// + /// + /// An integer value in the range to + /// indicating the TCP port number on which this will listen for connections. + /// + /// + /// + /// The default value is 23 (the telnet port). + /// + /// + /// The value specified is less than + /// or greater than . + public int Port + { + get + { + return m_listeningPort; + } + set + { + if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort) + { + throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value, + "The value specified for Port is less than " + + IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) + + " or greater than " + + IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + "."); + } + else + { + m_listeningPort = value; + } + } + } + + #region Override implementation of AppenderSkeleton + + /// + /// Overrides the parent method to close the socket handler + /// + /// + /// + /// Closes all the outstanding connections. + /// + /// + protected override void OnClose() + { + base.OnClose(); + + if (m_handler != null) + { + m_handler.Dispose(); + m_handler = null; + } + } + + /// + /// This appender requires a to be set. + /// + /// true + /// + /// + /// This appender requires a to be set. + /// + /// + protected override bool RequiresLayout + { + get { return true; } + } + + /// + /// Initialize the appender based on the options set. + /// + /// + /// + /// This is part of the delayed object + /// activation scheme. The method must + /// be called on this object after the configuration properties have + /// been set. Until is called this + /// object is in an undefined state and must not be used. + /// + /// + /// If any of the configuration properties are modified then + /// must be called again. + /// + /// + /// Create the socket handler and wait for connections + /// + /// + public override void ActivateOptions() + { + base.ActivateOptions(); + try + { + LogLog.Debug(declaringType, "Creating SocketHandler to listen on port [" + m_listeningPort + "]"); + m_handler = new SocketHandler(m_listeningPort); + } + catch (Exception ex) + { + LogLog.Error(declaringType, "Failed to create SocketHandler", ex); + throw; + } + } + + /// + /// Writes the logging event to each connected client. + /// + /// The event to log. + /// + /// + /// Writes the logging event to each connected client. + /// + /// + protected override void Append(LoggingEvent loggingEvent) + { + if (m_handler != null && m_handler.HasConnections) + { + m_handler.Send(RenderLoggingEvent(loggingEvent)); + } + } + + #endregion + + #region SocketHandler helper class + + /// + /// Helper class to manage connected clients + /// + /// + /// + /// The SocketHandler class is used to accept connections from + /// clients. It is threaded so that clients can connect/disconnect + /// asynchronously. + /// + /// + protected class SocketHandler : IDisposable + { + private const int MAX_CONNECTIONS = 20; + + private Socket m_serverSocket; + private ArrayList m_clients = new ArrayList(); + + /// + /// Class that represents a client connected to this handler + /// + /// + /// + /// Class that represents a client connected to this handler + /// + /// + protected class SocketClient : IDisposable + { + private Socket m_socket; + private StreamWriter m_writer; + + /// + /// Create this for the specified + /// + /// the client's socket + /// + /// + /// Opens a stream writer on the socket. + /// + /// + public SocketClient(Socket socket) + { + m_socket = socket; + + try + { + m_writer = new StreamWriter(new NetworkStream(socket)); + } + catch + { + Dispose(); + throw; + } + } + + /// + /// Write a string to the client + /// + /// string to send + /// + /// + /// Write a string to the client + /// + /// + public void Send(String message) + { + m_writer.Write(message); + m_writer.Flush(); + } + + #region IDisposable Members + + /// + /// Cleanup the clients connection + /// + /// + /// + /// Close the socket connection. + /// + /// + public void Dispose() + { + try + { + if (m_writer != null) + { m_writer.Close(); - m_writer = null; - } - } - catch { } - - if (m_socket != null) - { - try - { - m_socket.Shutdown(SocketShutdown.Both); - } - catch { } - - try - { + m_writer = null; + } + } + catch { } + + if (m_socket != null) + { + try + { + m_socket.Shutdown(SocketShutdown.Both); + } + catch { } + + try + { m_socket.Close(); - } - catch { } - - m_socket = null; - } - } - - #endregion - } - - /// - /// Opens a new server port on - /// - /// the local port to listen on for connections - /// - /// - /// Creates a socket handler on the specified local server port. - /// - /// - public SocketHandler(int port) - { - m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - - m_serverSocket.Bind(new IPEndPoint(IPAddress.Any, port)); - m_serverSocket.Listen(5); - AcceptConnection(); - } - - private void AcceptConnection() - { -#if NETSTANDARD1_3 - m_serverSocket.AcceptAsync().ContinueWith(OnConnect, TaskScheduler.Default); + } + catch { } + + m_socket = null; + } + } + + #endregion + } + + /// + /// Opens a new server port on + /// + /// the local port to listen on for connections + /// + /// + /// Creates a socket handler on the specified local server port. + /// + /// + public SocketHandler(int port) + { + m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + + m_serverSocket.Bind(new IPEndPoint(IPAddress.Any, port)); + m_serverSocket.Listen(5); + AcceptConnection(); + } + + private void AcceptConnection() + { +#if NETSTANDARD1_3 || NETSTANDARD2_0 + m_serverSocket.AcceptAsync().ContinueWith(OnConnect, TaskScheduler.Default); #else m_serverSocket.BeginAccept(new AsyncCallback(OnConnect), null); #endif - } - - /// - /// Sends a string message to each of the connected clients - /// - /// the text to send - /// - /// - /// Sends a string message to each of the connected clients - /// - /// - public void Send(String message) - { - ArrayList localClients = m_clients; - - foreach (SocketClient client in localClients) - { - try - { - client.Send(message); - } - catch (Exception) - { - // The client has closed the connection, remove it from our list - client.Dispose(); - RemoveClient(client); - } - } - } - - /// - /// Add a client to the internal clients list - /// - /// client to add - private void AddClient(SocketClient client) - { - lock(this) - { - ArrayList clientsCopy = (ArrayList)m_clients.Clone(); - clientsCopy.Add(client); - m_clients = clientsCopy; - } - } - - /// - /// Remove a client from the internal clients list - /// - /// client to remove - private void RemoveClient(SocketClient client) - { - lock(this) - { - ArrayList clientsCopy = (ArrayList)m_clients.Clone(); - clientsCopy.Remove(client); - m_clients = clientsCopy; - } - } - - /// - /// Test if this handler has active connections - /// - /// - /// true if this handler has active connections - /// - /// - /// - /// This property will be true while this handler has - /// active connections, that is at least one connection that - /// the handler will attempt to send a message to. - /// - /// - public bool HasConnections - { - get - { - ArrayList localClients = m_clients; - - return (localClients != null && localClients.Count > 0); - } - } - - -#if NETSTANDARD1_3 - private void OnConnect(Task acceptTask) + } + + /// + /// Sends a string message to each of the connected clients + /// + /// the text to send + /// + /// + /// Sends a string message to each of the connected clients + /// + /// + public void Send(String message) + { + ArrayList localClients = m_clients; + + foreach (SocketClient client in localClients) + { + try + { + client.Send(message); + } + catch (Exception) + { + // The client has closed the connection, remove it from our list + client.Dispose(); + RemoveClient(client); + } + } + } + + /// + /// Add a client to the internal clients list + /// + /// client to add + private void AddClient(SocketClient client) + { + lock (this) + { + ArrayList clientsCopy = (ArrayList)m_clients.Clone(); + clientsCopy.Add(client); + m_clients = clientsCopy; + } + } + + /// + /// Remove a client from the internal clients list + /// + /// client to remove + private void RemoveClient(SocketClient client) + { + lock (this) + { + ArrayList clientsCopy = (ArrayList)m_clients.Clone(); + clientsCopy.Remove(client); + m_clients = clientsCopy; + } + } + + /// + /// Test if this handler has active connections + /// + /// + /// true if this handler has active connections + /// + /// + /// + /// This property will be true while this handler has + /// active connections, that is at least one connection that + /// the handler will attempt to send a message to. + /// + /// + public bool HasConnections + { + get + { + ArrayList localClients = m_clients; + + return (localClients != null && localClients.Count > 0); + } + } + + +#if NETSTANDARD1_3 || NETSTANDARD2_0 + private void OnConnect(Task acceptTask) #else /// /// Callback used to accept a connection on the server socket @@ -446,91 +443,91 @@ private void OnConnect(Task acceptTask) /// private void OnConnect(IAsyncResult asyncResult) #endif - { - try - { -#if NETSTANDARD1_3 - Socket socket = acceptTask.GetAwaiter().GetResult(); + { + try + { +#if NETSTANDARD1_3 || NETSTANDARD2_0 + 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); - - int currentActiveConnectionsCount = m_clients.Count; - if (currentActiveConnectionsCount < MAX_CONNECTIONS) - { - try - { - client.Send("TelnetAppender v1.0 (" + (currentActiveConnectionsCount + 1) + " active connections)\r\n\r\n"); - AddClient(client); - } - catch - { - client.Dispose(); - } - } - else - { - client.Send("Sorry - Too many connections.\r\n"); - client.Dispose(); - } - } - catch - { - } - finally - { - if (m_serverSocket != null) - { - AcceptConnection(); - } - } - } - - #region IDisposable Members - - /// - /// Close all network connections - /// - /// - /// - /// Make sure we close all network connections - /// - /// - public void Dispose() - { - ArrayList localClients = m_clients; - - foreach (SocketClient client in localClients) - { - client.Dispose(); - } - m_clients.Clear(); - - Socket localSocket = m_serverSocket; - m_serverSocket = null; - try - { - localSocket.Shutdown(SocketShutdown.Both); - } - catch - { - } - - try - { - localSocket.Close(); - } - catch - { - } - } - - #endregion - } - - #endregion - } + LogLog.Debug(declaringType, "Accepting connection from [" + socket.RemoteEndPoint.ToString() + "]"); + SocketClient client = new SocketClient(socket); + + int currentActiveConnectionsCount = m_clients.Count; + if (currentActiveConnectionsCount < MAX_CONNECTIONS) + { + try + { + client.Send("TelnetAppender v1.0 (" + (currentActiveConnectionsCount + 1) + " active connections)\r\n\r\n"); + AddClient(client); + } + catch + { + client.Dispose(); + } + } + else + { + client.Send("Sorry - Too many connections.\r\n"); + client.Dispose(); + } + } + catch + { + } + finally + { + if (m_serverSocket != null) + { + AcceptConnection(); + } + } + } + + #region IDisposable Members + + /// + /// Close all network connections + /// + /// + /// + /// Make sure we close all network connections + /// + /// + public void Dispose() + { + ArrayList localClients = m_clients; + + foreach (SocketClient client in localClients) + { + client.Dispose(); + } + m_clients.Clear(); + + Socket localSocket = m_serverSocket; + m_serverSocket = null; + try + { + localSocket.Shutdown(SocketShutdown.Both); + } + catch + { + } + + try + { + localSocket.Close(); + } + catch + { + } + } + + #endregion + } + + #endregion + } } diff --git a/src/Appender/UdpAppender.cs b/src/Appender/UdpAppender.cs index 55770ff1..3db08feb 100644 --- a/src/Appender/UdpAppender.cs +++ b/src/Appender/UdpAppender.cs @@ -403,7 +403,7 @@ protected override void Append(LoggingEvent loggingEvent) try { Byte [] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray()); -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait(); #else this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint); @@ -540,7 +540,7 @@ protected virtual void InitializeClientConnection() /// /// The encoding to use for the packet. /// -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 private Encoding m_encoding = Encoding.Unicode; #else private Encoding m_encoding = Encoding.Default; diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs index 4f470093..d136e6bd 100644 --- a/src/AssemblyInfo.cs +++ b/src/AssemblyInfo.cs @@ -105,7 +105,7 @@ #elif (NET) [assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET")] [assembly: AssemblyTitle("Apache log4net for .NET Framework")] -#elif (NETSTANDARD1_3) +#elif (NETSTANDARD1_3 || NETSTANDARD2_0) [assembly: AssemblyInformationalVersionAttribute("2.0.9.0-.NET Core 1.0")] [assembly: AssemblyTitle("Apache log4net for .NET Core 1.0")] #elif (NETCF) diff --git a/src/Config/BasicConfigurator.cs b/src/Config/BasicConfigurator.cs index 1f89ad2d..419c9dad 100644 --- a/src/Config/BasicConfigurator.cs +++ b/src/Config/BasicConfigurator.cs @@ -82,7 +82,7 @@ private BasicConfigurator() #region Public Static Methods -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 /// /// Initializes the log4net system with a default configuration. /// @@ -138,7 +138,7 @@ static public ICollection Configure(IAppender appender) { return Configure(new IAppender[] { appender }); } -#endif // !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 /// /// Initializes the with a default configuration. diff --git a/src/Config/PluginAttribute.cs b/src/Config/PluginAttribute.cs index eb919068..2f48bc83 100644 --- a/src/Config/PluginAttribute.cs +++ b/src/Config/PluginAttribute.cs @@ -49,7 +49,7 @@ public sealed class PluginAttribute : Attribute, IPluginFactory { #region Public Instance Constructors -#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). /// /// Initializes a new instance of the class /// with the specified type. @@ -142,7 +142,7 @@ public string TypeName public IPlugin CreatePlugin() { Type pluginType = m_type; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 if (m_type == null) { // Get the plugin object type from the string type name diff --git a/src/Config/XmlConfigurator.cs b/src/Config/XmlConfigurator.cs index 5b11d98d..4443929d 100644 --- a/src/Config/XmlConfigurator.cs +++ b/src/Config/XmlConfigurator.cs @@ -121,7 +121,7 @@ static private void InternalConfigure(ILoggerRepository repository) LogLog.Debug(declaringType, "Application config file location unknown"); } -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 // No config file reading stuff. Just go straight for the file Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation)); #else @@ -161,7 +161,7 @@ static private void InternalConfigure(ILoggerRepository repository) #endif } -#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). #if !NETCF /// /// Automatically configures the log4net system based on the @@ -385,7 +385,7 @@ static public ICollection Configure(Stream configStream) return configurationMessages; } -#endif // !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0 /// /// Configures the using the specified XML @@ -567,7 +567,8 @@ static private void InternalConfigure(ILoggerRepository repository, FileInfo con { // Force the file closed whatever happens fs.Close(); - } + fs = null; + } } } else @@ -651,7 +652,7 @@ static private void InternalConfigure(ILoggerRepository repository, Uri configUr #endif try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 WebResponse response = configRequest.GetResponseAsync().GetAwaiter().GetResult(); #else WebResponse response = configRequest.GetResponse(); @@ -728,12 +729,12 @@ static private void InternalConfigure(ILoggerRepository repository, Stream confi #if (NETCF) // Create a text reader for the file stream XmlTextReader xmlReader = new XmlTextReader(configStream); -#elif NET_2_0 || NETSTANDARD1_3 +#elif NET_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0 // 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) +#if NETSTANDARD1_3 || NETSTANDARD2_0// TODO DtdProcessing.Parse not yet available (https://github.com/dotnet/corefx/issues/4376) settings.DtdProcessing = DtdProcessing.Ignore; #elif !NET_4_0 && !MONO_4_0 settings.ProhibitDtd = false; @@ -791,7 +792,7 @@ static private void InternalConfigure(ILoggerRepository repository, Stream confi #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). +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 && !NETSTANDARD2_0// Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). /// /// Configures log4net using the file specified, monitors the file for changes /// and reloads the configuration if a change is detected. @@ -828,7 +829,7 @@ static public ICollection ConfigureAndWatch(FileInfo configFile) return configurationMessages; } -#endif // !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 && !NETSTANDARD2_0 /// /// Configures the using the file specified, @@ -969,7 +970,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 +1050,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/DefaultRepositorySelector.cs b/src/Core/DefaultRepositorySelector.cs index 970f296e..2998239d 100644 --- a/src/Core/DefaultRepositorySelector.cs +++ b/src/Core/DefaultRepositorySelector.cs @@ -23,7 +23,7 @@ using System; using System.Collections; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System.Configuration; #else using System.Linq; @@ -587,7 +587,7 @@ private void GetInfoForAssembly(Assembly assembly, ref string repositoryName, re try { // Look for the RepositoryAttribute on the assembly -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 object[] repositoryAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.RepositoryAttribute)).ToArray(); #else object[] repositoryAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.RepositoryAttribute), false); @@ -663,7 +663,7 @@ private void ConfigureRepository(Assembly assembly, ILoggerRepository repository } // Look for the Configurator attributes (e.g. XmlConfiguratorAttribute) on the assembly -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.ConfiguratorAttribute)).ToArray(); #else object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.ConfiguratorAttribute), false); @@ -717,7 +717,7 @@ private void ConfigureRepository(Assembly assembly, ILoggerRepository repository // 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 || NETSTANDARD1_3 +#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 || NETSTANDARD2_0 Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile); #else { @@ -815,7 +815,7 @@ private void LoadPlugins(Assembly assembly, ILoggerRepository repository) } // Look for the PluginAttribute on the assembly -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.PluginAttribute)).ToArray(); #else object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.PluginAttribute), false); @@ -859,7 +859,7 @@ private void LoadAliases(Assembly assembly, ILoggerRepository repository) } // Look for the AliasRepositoryAttribute on the assembly -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.AliasRepositoryAttribute)).ToArray(); #else object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.AliasRepositoryAttribute), false); diff --git a/src/Core/ExceptionEvaluator.cs b/src/Core/ExceptionEvaluator.cs index 967c37e5..36ba307b 100644 --- a/src/Core/ExceptionEvaluator.cs +++ b/src/Core/ExceptionEvaluator.cs @@ -18,7 +18,7 @@ #endregion using System; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif diff --git a/src/Core/Level.cs b/src/Core/Level.cs index 713918dd..4918f7a1 100644 --- a/src/Core/Level.cs +++ b/src/Core/Level.cs @@ -111,7 +111,7 @@ public Level(int level, string levelName, string displayName) } m_levelValue = level; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 m_levelName = levelName; #else m_levelName = string.Intern(levelName); diff --git a/src/Core/LevelCollection.cs b/src/Core/LevelCollection.cs index d51bd0d9..6a396925 100644 --- a/src/Core/LevelCollection.cs +++ b/src/Core/LevelCollection.cs @@ -27,7 +27,7 @@ namespace log4net.Core /// /// Nicko Cadell public class LevelCollection : ICollection, IList, IEnumerable -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 , ICloneable #endif { diff --git a/src/Core/LogException.cs b/src/Core/LogException.cs index e7f243df..0189cb79 100644 --- a/src/Core/LogException.cs +++ b/src/Core/LogException.cs @@ -39,7 +39,7 @@ namespace log4net.Core #if !NETCF [Serializable] #endif -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 public class LogException : Exception #else public class LogException : ApplicationException @@ -92,7 +92,7 @@ public LogException(String message, Exception innerException) : base(message, in #region Protected Instance Constructors -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) /// /// Serialization constructor /// diff --git a/src/Core/LoggerManager.cs b/src/Core/LoggerManager.cs index 8ffaad2f..e02c2d18 100644 --- a/src/Core/LoggerManager.cs +++ b/src/Core/LoggerManager.cs @@ -18,7 +18,7 @@ #endregion using System; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Runtime.InteropServices; #else using System.Configuration; @@ -105,7 +105,7 @@ static LoggerManager() #if NETCF s_repositorySelector = new CompactRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy)); return; -#elif !NETSTANDARD1_3 +#elif !NETSTANDARD1_3 && !NETSTANDARD2_0 // Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector' string appRepositorySelectorTypeName = SystemInfo.GetAppSetting("log4net.RepositorySelector"); if (appRepositorySelectorTypeName != null && appRepositorySelectorTypeName.Length > 0) @@ -166,7 +166,7 @@ static LoggerManager() /// private static void RegisterAppDomainEvents() { -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) // ProcessExit seems to be fired if we are part of the default domain AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); @@ -801,7 +801,7 @@ private static string GetVersionInfo() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 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 @@ -814,7 +814,7 @@ private static string GetVersionInfo() #if (!SSCLI) sb.Append(" on ").Append(Environment.OSVersion.ToString()); #endif -#endif // NETSTANDARD1_3 +#endif // NETSTANDARD1_3 || NETSTANDARD2_0 sb.Append(")"); return sb.ToString(); } diff --git a/src/Core/LoggingEvent.cs b/src/Core/LoggingEvent.cs index eb54a609..4c942001 100644 --- a/src/Core/LoggingEvent.cs +++ b/src/Core/LoggingEvent.cs @@ -22,7 +22,7 @@ using System.IO; #if (!NETCF) using System.Runtime.Serialization; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System.Security.Principal; #endif #endif @@ -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) // NETSTANDARD1_3 TODO requires platform-specific code // On compact framework there's no notion of current Windows user m_data.UserName = SystemInfo.NotAvailableText; #else @@ -945,7 +945,7 @@ public string Identity { if (m_data.Identity == null && this.m_cacheUpdatable) { -#if (NETCF || SSCLI || NETSTANDARD1_3) +#if (NETCF || SSCLI || NETSTANDARD1_3 || NETSTANDARD2_0) // On compact framework there's no notion of current thread principals m_data.Identity = 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/Filter/StringMatchFilter.cs b/src/Filter/StringMatchFilter.cs index 38fa49d4..4175f3c5 100644 --- a/src/Filter/StringMatchFilter.cs +++ b/src/Filter/StringMatchFilter.cs @@ -95,7 +95,7 @@ override public void ActivateOptions() { if (m_stringRegexToMatch != null) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 m_regexToMatch = new Regex(m_stringRegexToMatch); #else m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled); diff --git a/src/Layout/Pattern/ExceptionPatternConverter.cs b/src/Layout/Pattern/ExceptionPatternConverter.cs index 06d3928f..a5f9d1e4 100644 --- a/src/Layout/Pattern/ExceptionPatternConverter.cs +++ b/src/Layout/Pattern/ExceptionPatternConverter.cs @@ -106,7 +106,7 @@ override protected void Convert(TextWriter writer, LoggingEvent loggingEvent) case "stacktrace": WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.StackTrace); break; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 case "targetsite": WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.TargetSite); break; diff --git a/src/Layout/PatternLayout.cs b/src/Layout/PatternLayout.cs index 31a56443..bd0e9dbc 100644 --- a/src/Layout/PatternLayout.cs +++ b/src/Layout/PatternLayout.cs @@ -20,7 +20,7 @@ using System; using System.Collections; using System.IO; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif @@ -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)); @@ -908,7 +908,7 @@ static PatternLayout() s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter)); s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter)); -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter)); s_globalRulesRegistry.Add("stacktracedetail", typeof(StackTraceDetailPatternConverter)); #endif diff --git a/src/Layout/RawLayoutConverter.cs b/src/Layout/RawLayoutConverter.cs index 7ccfe77a..947365ca 100644 --- a/src/Layout/RawLayoutConverter.cs +++ b/src/Layout/RawLayoutConverter.cs @@ -18,7 +18,7 @@ #endregion using System; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif diff --git a/src/Layout/XmlLayout.cs b/src/Layout/XmlLayout.cs index 34f9750a..f4c4e97c 100644 --- a/src/Layout/XmlLayout.cs +++ b/src/Layout/XmlLayout.cs @@ -220,7 +220,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent) writer.WriteStartElement(m_elmEvent); writer.WriteAttributeString(ATTR_LOGGER, loggingEvent.LoggerName); -#if NET_2_0 || NETCF_2_0 || MONO_2_0 || NETSTANDARD1_3 +#if NET_2_0 || NETCF_2_0 || MONO_2_0 || NETSTANDARD1_3 || NETSTANDARD2_0 writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp, XmlDateTimeSerializationMode.Local)); #else writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp)); diff --git a/src/Layout/XmlLayoutBase.cs b/src/Layout/XmlLayoutBase.cs index 9b51653d..44be025e 100644 --- a/src/Layout/XmlLayoutBase.cs +++ b/src/Layout/XmlLayoutBase.cs @@ -196,7 +196,7 @@ override public void Format(TextWriter writer, LoggingEvent loggingEvent) { throw new ArgumentNullException("loggingEvent"); } -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 var settings = new XmlWriterSettings { Indent = false, diff --git a/src/Log4netAssemblyInfo.cs b/src/Log4netAssemblyInfo.cs index 78f1a012..8c476161 100644 --- a/src/Log4netAssemblyInfo.cs +++ b/src/Log4netAssemblyInfo.cs @@ -59,7 +59,7 @@ public sealed class AssemblyInfo { public const string TargetFramework = "Mono"; #elif SSCLI public const string TargetFramework = "Shared Source CLI"; -#elif NETSTANDARD1_3 +#elif NETSTANDARD1_3 || NETSTANDARD2_0 public const string TargetFramework = ".NET Core"; #else public const string TargetFramework = "Unknown"; diff --git a/src/LogManager.cs b/src/LogManager.cs index 59f6b533..4dc3738d 100644 --- a/src/LogManager.cs +++ b/src/LogManager.cs @@ -73,7 +73,7 @@ private LogManager() #region Type Specific Manager Methods -#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). /// Returns the named logger if it exists. /// /// Returns the named logger if it exists. @@ -126,7 +126,7 @@ public static ILog GetLogger(string name) { return GetLogger(Assembly.GetCallingAssembly(), name); } -#endif // !NETSTANDARD1_3 +#endif // !NETSTANDARD1_3 && !NETSTANDARD2_0 /// /// Returns the named logger if it exists. @@ -254,7 +254,7 @@ public static ILog GetLogger(Assembly repositoryAssembly, string name) /// The logger with the name specified. public static ILog GetLogger(Type type) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 return GetLogger(type.GetTypeInfo().Assembly, type.FullName); #else return GetLogger(Assembly.GetCallingAssembly(), type.FullName); @@ -317,7 +317,7 @@ public static void Shutdown() LoggerManager.Shutdown(); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// Shutdown a logger repository. /// /// Shuts down the default repository. @@ -395,7 +395,7 @@ public static void ShutdownRepository(Assembly repositoryAssembly) LoggerManager.ShutdownRepository(repositoryAssembly); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// Reset the configuration of a repository /// /// Resets all values contained in this repository instance to their defaults. @@ -454,7 +454,7 @@ public static void ResetConfiguration(Assembly repositoryAssembly) LoggerManager.ResetConfiguration(repositoryAssembly); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// Get the logger repository. /// /// Returns the default instance. @@ -507,7 +507,7 @@ public static ILoggerRepository GetLoggerRepository(Assembly repositoryAssembly) return GetRepository(repositoryAssembly); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// Get a logger repository. /// /// Returns the default instance. @@ -557,7 +557,7 @@ public static ILoggerRepository GetRepository(Assembly repositoryAssembly) return LoggerManager.GetRepository(repositoryAssembly); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// Create a domain /// /// Creates a repository with the specified repository type. @@ -758,7 +758,7 @@ public static ILoggerRepository[] GetAllRepositories() /// True if all logging events were flushed successfully, else false. public static bool Flush(int millisecondsTimeout) { -#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221). +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 // 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) { diff --git a/src/ObjectRenderer/RendererMap.cs b/src/ObjectRenderer/RendererMap.cs index 7f4db96c..5a4f405e 100644 --- a/src/ObjectRenderer/RendererMap.cs +++ b/src/ObjectRenderer/RendererMap.cs @@ -19,7 +19,7 @@ using System; using System.IO; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif @@ -220,7 +220,7 @@ public IObjectRenderer Get(Type type) if (result == null) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 for (Type cur = type; cur != null; cur = cur.GetTypeInfo().BaseType) #else for(Type cur = type; cur != null; cur = cur.BaseType) diff --git a/src/Plugin/PluginCollection.cs b/src/Plugin/PluginCollection.cs index 7e7d4e24..936ddd9b 100644 --- a/src/Plugin/PluginCollection.cs +++ b/src/Plugin/PluginCollection.cs @@ -27,7 +27,7 @@ namespace log4net.Plugin /// /// Nicko Cadell public class PluginCollection : ICollection, IList, IEnumerable -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 , ICloneable #endif { diff --git a/src/Repository/Hierarchy/Logger.cs b/src/Repository/Hierarchy/Logger.cs index 34735a73..e00e67b0 100644 --- a/src/Repository/Hierarchy/Logger.cs +++ b/src/Repository/Hierarchy/Logger.cs @@ -73,7 +73,7 @@ public abstract class Logger : IAppenderAttachable, ILogger /// protected Logger(string name) { -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 // NETCF: String.Intern causes Native Exception m_name = name; #else @@ -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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 catch { log4net.Util.LogLog.Error(declaringType, "Exception while logging"); @@ -606,7 +606,7 @@ virtual protected void CallAppenders(LoggingEvent loggingEvent) { LogLog.Debug(declaringType, " Current AppDomain context information: "); LogLog.Debug(declaringType, " BaseDirectory : " + SystemInfo.ApplicationBaseDirectory); -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) LogLog.Debug(declaringType, " FriendlyName : " + AppDomain.CurrentDomain.FriendlyName); LogLog.Debug(declaringType, " DynamicDirectory: " + AppDomain.CurrentDomain.DynamicDirectory); #endif diff --git a/src/Repository/Hierarchy/LoggerKey.cs b/src/Repository/Hierarchy/LoggerKey.cs index ccc566b1..6f3cbb7f 100644 --- a/src/Repository/Hierarchy/LoggerKey.cs +++ b/src/Repository/Hierarchy/LoggerKey.cs @@ -64,7 +64,7 @@ internal sealed class LoggerKey /// The name of the logger. internal LoggerKey(string name) { -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 // NETCF: String.Intern causes Native Exception m_name = name; #else @@ -115,7 +115,7 @@ override public bool Equals(object obj) LoggerKey objKey = obj as LoggerKey; if (objKey != null) { -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 return ( m_name == objKey.m_name ); #else // Compare reference types rather than string's overloaded == diff --git a/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs b/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs index f5021c10..f688ba69 100644 --- a/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs +++ b/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs @@ -300,7 +300,7 @@ protected IAppender ParseAppender(XmlElement appenderElement) LogLog.Debug(declaringType, "Loading Appender [" + appenderName + "] type: [" + typeName + "]"); try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 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)); @@ -490,7 +490,7 @@ protected void ParseRenderer(XmlElement element) { try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 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); @@ -638,7 +638,7 @@ protected void SetParameter(XmlElement element, object target) if(propertyValue != null) { -#if !(NETCF || NETSTANDARD1_3) // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6 +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6 try { // Expand environment variables in the string. @@ -666,7 +666,7 @@ protected void SetParameter(XmlElement element, object target) // Read the explicit subtype try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 Type subType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, subTypeString, true, true); #else Type subType = SystemInfo.GetTypeFromString(subTypeString, true, true); @@ -725,7 +725,7 @@ protected void SetParameter(XmlElement element, object target) try { // Pass to the property -#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5 +#if NETSTANDARD1_3 || NETSTANDARD2_0 // TODO BindingFlags is available for netstandard1.5 propInfo.SetValue(target, convertedValue, null); #else propInfo.SetValue(target, convertedValue, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture); @@ -744,7 +744,7 @@ protected void SetParameter(XmlElement element, object target) try { // Pass to the property -#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5 +#if NETSTANDARD1_3 || NETSTANDARD2_0 // TODO BindingFlags is available for netstandard1.5 methInfo.Invoke(target, new[] { convertedValue }); #else methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {convertedValue}, CultureInfo.InvariantCulture); @@ -800,7 +800,7 @@ protected void SetParameter(XmlElement element, object target) try { // Pass to the property -#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5 +#if NETSTANDARD1_3 || NETSTANDARD2_0 // TODO BindingFlags is available for netstandard1.5 propInfo.SetValue(target, createdObject, null); #else propInfo.SetValue(target, createdObject, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture); @@ -819,7 +819,7 @@ protected void SetParameter(XmlElement element, object target) try { // Pass to the property -#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5 +#if NETSTANDARD1_3 || NETSTANDARD2_0 // TODO BindingFlags is available for netstandard1.5 methInfo.Invoke(target, new[] { createdObject }); #else methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {createdObject}, CultureInfo.InvariantCulture); @@ -859,7 +859,7 @@ private bool HasAttributesOrElements(XmlElement element) /// true if the type is creatable using a default constructor, false otherwise private static bool IsTypeConstructible(Type type) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 TypeInfo typeInfo = type.GetTypeInfo(); if (typeInfo.IsClass && !typeInfo.IsAbstract) #else @@ -990,7 +990,7 @@ protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, // Read the explicit object type try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 objectType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, objectTypeString, true, true); #else objectType = SystemInfo.GetTypeFromString(objectTypeString, true, true); @@ -1066,7 +1066,7 @@ protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, #endregion Protected Instance Methods -#if !(NETCF || NETSTANDARD1_3) // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6 +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6 private bool HasCaseInsensitiveEnvironment { get diff --git a/src/Util/ILogExtensions.cs b/src/Util/ILogExtensions.cs index 608d05d3..13e11f59 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/LogLog.cs b/src/Util/LogLog.cs index 9a9b4dad..23d7ab1d 100644 --- a/src/Util/LogLog.cs +++ b/src/Util/LogLog.cs @@ -19,7 +19,7 @@ using System; using System.Collections; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System.Configuration; #endif using System.Diagnostics; diff --git a/src/Util/LogicalThreadContextProperties.cs b/src/Util/LogicalThreadContextProperties.cs index c5879fc4..960de3e7 100644 --- a/src/Util/LogicalThreadContextProperties.cs +++ b/src/Util/LogicalThreadContextProperties.cs @@ -18,14 +18,15 @@ #endregion // .NET Compact Framework 1.0 has no support for System.Runtime.Remoting.Messaging.CallContext -#if !NETCF + +#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 +60,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"; @@ -230,7 +231,7 @@ internal PropertiesDictionary GetProperties(bool create) #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; @@ -253,7 +254,7 @@ private static PropertiesDictionary GetLogicalProperties() #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/OptionConverter.cs b/src/Util/OptionConverter.cs index cc791dc8..823a5369 100644 --- a/src/Util/OptionConverter.cs +++ b/src/Util/OptionConverter.cs @@ -212,7 +212,7 @@ public static long ToFileSize(string argValue, long defaultValue) return defaultValue; } - string s = argValue.Trim().ToUpper(CultureInfo.InvariantCulture); + string s = argValue.Trim().ToUpper(CultureInfo.InvariantCulture); long multiplier = 1; int index; @@ -286,7 +286,7 @@ public static object ConvertStringTo(Type target, string txt) } else { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 if (target.GetTypeInfo().IsEnum) #else if (target.IsEnum) @@ -307,7 +307,7 @@ public static object ConvertStringTo(Type target, string txt) if (meth != null) { // Call the Parse method -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 return meth.Invoke(target, new[] { txt }); #else return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] {txt}, CultureInfo.InvariantCulture); @@ -483,7 +483,7 @@ public static object InstantiateByClassName(string className, Type superClass, o { try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 Type classObj = SystemInfo.GetTypeFromString(superClass.GetTypeInfo().Assembly, className, true, true); #else Type classObj = SystemInfo.GetTypeFromString(className, true, true); diff --git a/src/Util/PatternString.cs b/src/Util/PatternString.cs index a8f14ce3..948e39ae 100644 --- a/src/Util/PatternString.cs +++ b/src/Util/PatternString.cs @@ -20,7 +20,7 @@ using System; using System.Collections; using System.IO; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif @@ -300,7 +300,7 @@ static PatternString() s_globalRulesRegistry.Add("date", typeof(DatePatternConverter)); #if !NETCF s_globalRulesRegistry.Add("env", typeof(EnvironmentPatternConverter)); -#if !NETSTANDARD1_3 // EnvironmentFolderPathPatternConverter not yet supported +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 // EnvironmentFolderPathPatternConverter not yet supported s_globalRulesRegistry.Add("envFolderPath", typeof(EnvironmentFolderPathPatternConverter)); #endif #endif @@ -315,7 +315,7 @@ static PatternString() s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter)); s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter)); s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter)); -#if !NETCF && !NETSTANDARD1_3 +#if !NETCF && !NETSTANDARD1_3 && !NETSTANDARD2_0 // 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)); diff --git a/src/Util/PatternStringConverters/IdentityPatternConverter.cs b/src/Util/PatternStringConverters/IdentityPatternConverter.cs index d92a292b..27f89ac4 100644 --- a/src/Util/PatternStringConverters/IdentityPatternConverter.cs +++ b/src/Util/PatternStringConverters/IdentityPatternConverter.cs @@ -48,7 +48,7 @@ internal sealed class IdentityPatternConverter : PatternConverter /// override protected void Convert(TextWriter writer, object state) { -#if (NETCF || SSCLI || NETSTANDARD1_3) +#if (NETCF || SSCLI || NETSTANDARD1_3 || NETSTANDARD2_0) // On compact framework there's no notion of current thread principals writer.Write( SystemInfo.NotAvailableText ); #else diff --git a/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs b/src/Util/PatternStringConverters/ProcessIdPatternConverter.cs index 2d6a5a1e..57cffa5f 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 0f8dffb3..437c71c9 100644 --- a/src/Util/PatternStringConverters/UserNamePatternConverter.cs +++ b/src/Util/PatternStringConverters/UserNamePatternConverter.cs @@ -48,7 +48,7 @@ internal sealed class UserNamePatternConverter : PatternConverter /// override protected void Convert(TextWriter writer, object state) { -#if (NETCF || SSCLI || NETSTANDARD1_3) +#if (NETCF || SSCLI || NETSTANDARD1_3 || NETSTANDARD2_0) // On compact framework there's no notion of current Windows user writer.Write( SystemInfo.NotAvailableText ); #else diff --git a/src/Util/PropertiesDictionary.cs b/src/Util/PropertiesDictionary.cs index d2e48d5c..c5131204 100644 --- a/src/Util/PropertiesDictionary.cs +++ b/src/Util/PropertiesDictionary.cs @@ -75,7 +75,7 @@ public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : #region Private Instance Constructors -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) /// /// Initializes a new instance of the class /// with serialized data. diff --git a/src/Util/ReadOnlyPropertiesDictionary.cs b/src/Util/ReadOnlyPropertiesDictionary.cs index fba6c1ac..2dc0366e 100644 --- a/src/Util/ReadOnlyPropertiesDictionary.cs +++ b/src/Util/ReadOnlyPropertiesDictionary.cs @@ -92,7 +92,7 @@ public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDicti #region Private Instance Constructors -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) /// /// Deserialization constructor /// @@ -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)] @@ -217,7 +217,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte object entryValue = entry.Value; // If value is serializable then we add it to the list -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 bool isSerializable = entryValue.GetType().GetTypeInfo().IsSerializable; #else bool isSerializable = entryValue.GetType().IsSerializable; diff --git a/src/Util/SystemInfo.cs b/src/Util/SystemInfo.cs index c0b04f62..3819f817 100644 --- a/src/Util/SystemInfo.cs +++ b/src/Util/SystemInfo.cs @@ -18,7 +18,7 @@ #endregion using System; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Globalization; #else using System.Configuration; @@ -148,7 +148,7 @@ public static string ApplicationBaseDirectory { #if NETCF - return System.IO.Path.GetDirectoryName(SystemInfo.EntryAssemblyLocation) + System.IO.Path.DirectorySeparatorChar; -#elif NETSTANDARD1_3 +#elif NETSTANDARD1_3 || NETSTANDARD2_0 return Directory.GetCurrentDirectory(); #else return AppDomain.CurrentDomain.BaseDirectory; @@ -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; @@ -197,7 +197,7 @@ public static string EntryAssemblyLocation { #if NETCF return SystemInfo.NativeEntryAssemblyLocation; -#elif NETSTANDARD1_3 // TODO GetEntryAssembly is available for netstandard1.5 +#elif NETSTANDARD1_3 || NETSTANDARD2_0 // TODO GetEntryAssembly is available for netstandard1.5 return AppContext.BaseDirectory; #else return System.Reflection.Assembly.GetEntryAssembly().Location; @@ -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(); @@ -291,7 +291,7 @@ public static string HostName { try { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 s_hostName = Environment.GetEnvironmentVariable("COMPUTERNAME"); #elif (!SSCLI && !NETCF) s_hostName = Environment.MachineName; @@ -341,7 +341,7 @@ public static string ApplicationFriendlyName { try { -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) s_appFriendlyName = AppDomain.CurrentDomain.FriendlyName; #endif } @@ -484,7 +484,7 @@ 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 +#elif NETSTANDARD1_3 || NETSTANDARD2_0 // TODO Assembly.Location available in netstandard1.5 return "Not supported on .NET Core"; #else if (myAssembly.GlobalAssemblyCache) @@ -557,7 +557,7 @@ public static string AssemblyLocationInfo(Assembly myAssembly) public static string AssemblyQualifiedName(Type type) { return type.FullName + ", " -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 + type.GetTypeInfo().Assembly.FullName; #else + type.Assembly.FullName; @@ -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 || NETSTANDARD2_0 // 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. @@ -658,14 +658,14 @@ public static string AssemblyFileName(Assembly myAssembly) /// public static Type GetTypeFromString(Type relativeType, string typeName, bool throwOnError, bool ignoreCase) { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 return GetTypeFromString(relativeType.GetTypeInfo().Assembly, typeName, throwOnError, ignoreCase); #else return GetTypeFromString(relativeType.Assembly, typeName, throwOnError, ignoreCase); #endif } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// /// Loads the type specified in the type string. /// @@ -717,7 +717,7 @@ public static Type GetTypeFromString(Assembly relativeAssembly, string typeName, if(typeName.IndexOf(',') == -1) { //LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]"); -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 return relativeAssembly.GetType(typeName, throwOnError, ignoreCase); #elif NETCF return relativeAssembly.GetType(typeName, throwOnError); @@ -999,7 +999,7 @@ public static string GetAppSetting(string key) { try { -#if NETCF || NETSTANDARD1_3 +#if NETCF || NETSTANDARD1_3 || NETSTANDARD2_0 // Configuration APIs are not suported under the Compact Framework #elif NET_2_0 return ConfigurationManager.AppSettings[key]; @@ -1101,7 +1101,7 @@ 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 +#elif NETSTANDARD1_3 || NETSTANDARD2_0 return CultureInfo.InvariantCulture.CompareInfo.Compare(a, b, CompareOptions.IgnoreCase) == 0; #else // >= .NET-2.0 return String.Equals(a, b, StringComparison.OrdinalIgnoreCase); diff --git a/src/Util/SystemStringFormat.cs b/src/Util/SystemStringFormat.cs index a852f399..97302652 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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_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 !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD1_3 && !NETSTANDARD2_0 catch { buffer.Append(""); diff --git a/src/Util/TypeConverters/ConversionNotSupportedException.cs b/src/Util/TypeConverters/ConversionNotSupportedException.cs index 86ae9fc2..948bdcca 100644 --- a/src/Util/TypeConverters/ConversionNotSupportedException.cs +++ b/src/Util/TypeConverters/ConversionNotSupportedException.cs @@ -18,7 +18,7 @@ #endregion using System; -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) using System.Runtime.Serialization; #endif @@ -39,7 +39,7 @@ namespace log4net.Util.TypeConverters #if !NETCF [Serializable] #endif -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 public class ConversionNotSupportedException : Exception #else public class ConversionNotSupportedException : ApplicationException @@ -92,7 +92,7 @@ public ConversionNotSupportedException(String message, Exception innerException) #region Protected Instance Constructors -#if !(NETCF || NETSTANDARD1_3) +#if !(NETCF || NETSTANDARD1_3 || NETSTANDARD2_0) /// /// Serialization constructor /// diff --git a/src/Util/TypeConverters/ConverterRegistry.cs b/src/Util/TypeConverters/ConverterRegistry.cs index 0ddfb12f..869c9923 100644 --- a/src/Util/TypeConverters/ConverterRegistry.cs +++ b/src/Util/TypeConverters/ConverterRegistry.cs @@ -19,7 +19,7 @@ using System; using System.Globalization; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Linq; #endif using System.Reflection; diff --git a/src/Util/TypeConverters/IPAddressConverter.cs b/src/Util/TypeConverters/IPAddressConverter.cs index d9cbf327..f014606e 100644 --- a/src/Util/TypeConverters/IPAddressConverter.cs +++ b/src/Util/TypeConverters/IPAddressConverter.cs @@ -116,7 +116,7 @@ public object ConvertFrom(object source) } // Try to resolve via DNS. This is a blocking call. -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 IPHostEntry host = Dns.GetHostEntryAsync(str).GetAwaiter().GetResult(); #else IPHostEntry host = Dns.GetHostByName(str); diff --git a/src/Util/TypeConverters/PatternStringConverter.cs b/src/Util/TypeConverters/PatternStringConverter.cs index 723cc254..5e35ee07 100644 --- a/src/Util/TypeConverters/PatternStringConverter.cs +++ b/src/Util/TypeConverters/PatternStringConverter.cs @@ -18,7 +18,7 @@ #endregion using System; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif using System.Text; diff --git a/src/Util/TypeConverters/TypeConverter.cs b/src/Util/TypeConverters/TypeConverter.cs index 3a6d6a90..540f0d1a 100644 --- a/src/Util/TypeConverters/TypeConverter.cs +++ b/src/Util/TypeConverters/TypeConverter.cs @@ -19,7 +19,7 @@ using System; using System.Text; -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 using System.Reflection; #endif @@ -80,7 +80,7 @@ public object ConvertFrom(object source) string str = source as string; if (str != null) { -#if NETSTANDARD1_3 // TODO can we use ComponentModel here? +#if NETSTANDARD1_3 || NETSTANDARD2_0 // TODO can we use ComponentModel here? return SystemInfo.GetTypeFromString(GetType().GetTypeInfo().Assembly, str, true, true); #else return SystemInfo.GetTypeFromString(str, true, true);