erikmav commented on code in PR #131:
URL: https://github.com/apache/logging-log4net/pull/131#discussion_r1541720526


##########
src/log4net/Core/LogImpl.cs:
##########
@@ -326,7 +329,7 @@ public virtual void DebugFormat(string format, object arg0, 
object arg1, object
     /// methods instead.
     /// </para>
     /// </remarks>
-    public virtual void DebugFormat(IFormatProvider provider, string format, 
params object[] args)
+    public virtual void DebugFormat(IFormatProvider? provider, string format, 
params object[] args)

Review Comment:
   Added unit tests for these cases, and ended up with a specific hack for 
`XxxFormat(message, object? arg0)` not being matched when called with 
`XxxFormat("{0}", null)` and resulting in LogLog warnings on exceptions trying 
to render (see below). The overload with `XxxFormat(message, object?[]?)` is 
matched instead. To ensure `XxxFormat("{0}", null)` results in an expected 
empty string, the `object?[]?` overload converts a null array to an array of 
one null, `object?[] { null }`.
   
   log4net:WARN Exception while rendering format
   System.FormatException: Index (zero based) must be greater than or equal to 
zero and less than the size of the argument list.
      at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, 
String format, ParamsArray args)
      at System.String.FormatHelper(IFormatProvider provider, String format, 
ParamsArray args)
      at System.String.Format(IFormatProvider provider, String format, Object[] 
args)
      at log4net.Util.SystemStringFormat.StringFormat(IFormatProvider provider, 
String format, Object[] args) in 
C:\log4net2\src\log4net\Util\SystemStringFormat.cs:line 100



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to