This is an automated email from the ASF dual-hosted git repository.

freeandnil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git

commit 13d4e6dce728f13dc1f61e4b22305004ace4132f
Author: Jan Friedrich <[email protected]>
AuthorDate: Wed Sep 18 23:13:31 2024 +0200

    a converter can implement IConvertTo AND IConvertFrom (fixes #183)
---
 scripts/build-preview.ps1                          |  2 +-
 src/log4net.Tests/Appender/FileAppenderTest.cs     |  2 -
 .../Util/TypeConverters/ConverterRegistry.cs       | 55 ++++++----------------
 src/site/xdoc/release/release-notes.xml            |  3 +-
 4 files changed, 17 insertions(+), 45 deletions(-)

diff --git a/scripts/build-preview.ps1 b/scripts/build-preview.ps1
index 3a0d57f5..1637e003 100644
--- a/scripts/build-preview.ps1
+++ b/scripts/build-preview.ps1
@@ -1 +1 @@
-dotnet build -c Release 
'-p:GeneratePackages=true;PackageVersion=3.0.1-preview.1' 
$PSScriptRoot/../src/log4net/log4net.csproj
\ No newline at end of file
+dotnet build -c Release 
'-p:GeneratePackages=true;PackageVersion=3.0.1-preview.2' 
$PSScriptRoot/../src/log4net/log4net.csproj
\ No newline at end of file
diff --git a/src/log4net.Tests/Appender/FileAppenderTest.cs 
b/src/log4net.Tests/Appender/FileAppenderTest.cs
index 709aa5ee..58bcf5c4 100644
--- a/src/log4net.Tests/Appender/FileAppenderTest.cs
+++ b/src/log4net.Tests/Appender/FileAppenderTest.cs
@@ -92,8 +92,6 @@ public sealed class FileAppenderTest
 """);
       ILoggerRepository rep = 
LogManager.CreateRepository(Guid.NewGuid().ToString());
       XmlConfigurator.Configure(rep, log4netConfig["log4net"]!);
-      ILog log = LogManager.GetLogger(rep.Name, "GeneralFileAppender");
-      log.Info("Message");
     }
     finally
     {
diff --git a/src/log4net/Util/TypeConverters/ConverterRegistry.cs 
b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
index fb0b4cad..5837db82 100644
--- a/src/log4net/Util/TypeConverters/ConverterRegistry.cs
+++ b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
@@ -27,8 +27,7 @@ namespace log4net.Util.TypeConverters
   /// </summary>
   /// <remarks>
   /// <para>
-  /// Maintains a registry of type converters used to convert between
-  /// types.
+  /// Maintains a registry of type converters used to convert between types.
   /// </para>
   /// <para>
   /// Use the <see cref="M:AddConverter(Type, object)"/> and 
@@ -44,13 +43,8 @@ namespace log4net.Util.TypeConverters
   public static class ConverterRegistry
   {
     /// <summary>
-    /// Static constructor.
+    /// This class constructor adds the intrinsic type converters
     /// </summary>
-    /// <remarks>
-    /// <para>
-    /// This constructor defines the intrinsic type converters.
-    /// </para>
-    /// </remarks>
     static ConverterRegistry()
     {
       // Add predefined converters here
@@ -67,23 +61,19 @@ namespace log4net.Util.TypeConverters
     /// </summary>
     /// <param name="destinationType">The type being converted to.</param>
     /// <param name="converter">The type converter to use to convert to the 
destination type.</param>
-    /// <remarks>
-    /// <para>
-    /// Adds a converter instance for a specific type.
-    /// </para>
-    /// </remarks>
     public static void AddConverter(Type? destinationType, object? converter)
     {
-      if (destinationType is not null && converter is not null)
+      if (destinationType is null || converter is null)
       {
-        if (converter is IConvertTo convertTo)
-        {
-          s_type2ConvertTo[destinationType] = convertTo;
-        }
-        else if (converter is IConvertFrom convertFrom)
-        {
-          s_type2ConvertFrom[destinationType] = convertFrom;
-        }
+        return;
+      }
+      if (converter is IConvertTo convertTo)
+      {
+        s_type2ConvertTo[destinationType] = convertTo;
+      }
+      if (converter is IConvertFrom convertFrom)
+      {
+        s_type2ConvertFrom[destinationType] = convertFrom;
       }
     }
 
@@ -92,15 +82,8 @@ namespace log4net.Util.TypeConverters
     /// </summary>
     /// <param name="destinationType">The type being converted to.</param>
     /// <param name="converterType">The type of the type converter to use to 
convert to the destination type.</param>
-    /// <remarks>
-    /// <para>
-    /// Adds a converter <see cref="Type"/> for a specific type.
-    /// </para>
-    /// </remarks>
     public static void AddConverter(Type destinationType, Type converterType)
-    {
-      AddConverter(destinationType, CreateConverterInstance(converterType));
-    }
+      => AddConverter(destinationType, CreateConverterInstance(converterType));
 
     /// <summary>
     /// Gets the type converter to use to convert values to the destination 
type.
@@ -111,11 +94,6 @@ namespace log4net.Util.TypeConverters
     /// The type converter instance to use for type conversions or <c>null</c> 
     /// if no type converter is found.
     /// </returns>
-    /// <remarks>
-    /// <para>
-    /// Gets the type converter to use to convert values to the destination 
type.
-    /// </para>
-    /// </remarks>
     public static IConvertTo? GetConvertTo(Type sourceType, Type 
destinationType)
     {
       // TODO: Support inheriting type converters.
@@ -146,11 +124,6 @@ namespace log4net.Util.TypeConverters
     /// The type converter instance to use for type conversions or <c>null</c> 
     /// if no type converter is found.
     /// </returns>
-    /// <remarks>
-    /// <para>
-    /// Gets the type converter to use to convert values to the destination 
type.
-    /// </para>
-    /// </remarks>
     public static IConvertFrom? GetConvertFrom(Type destinationType)
     {
       // TODO: Support inheriting type converters.
@@ -248,4 +221,4 @@ namespace log4net.Util.TypeConverters
     private static readonly ConcurrentDictionary<Type, IConvertTo> 
s_type2ConvertTo = new();
     private static readonly ConcurrentDictionary<Type, IConvertFrom> 
s_type2ConvertFrom = new();
   }
-}
+}
\ No newline at end of file
diff --git a/src/site/xdoc/release/release-notes.xml 
b/src/site/xdoc/release/release-notes.xml
index 180affb4..45237a8b 100644
--- a/src/site/xdoc/release/release-notes.xml
+++ b/src/site/xdoc/release/release-notes.xml
@@ -28,7 +28,8 @@ limitations under the License.
         <section id="a3.0.1-bug" name="Bug fixes">
           <ul>
             <li>
-              <a 
href="https://github.com/apache/logging-log4net/issues/tbd";>tbd</a> (by tbd)
+              <a 
href="https://github.com/apache/logging-log4net/issues/183";>Unable to set 
property [file] on object [log4net.Appender.FileAppender]</a>
+              (reported by @sc-mk fixed by @FreeAndNil in 
https://github.com/apache/logging-log4net/pull/184)
             </li>
           </ul>
         </section><section id="a3.0.1-enhancements" name="Enhancements">

Reply via email to