-
Notifications
You must be signed in to change notification settings - Fork 245
Harden log formatters to handle null formats, null arguments, and null arrays of arguments #480
Conversation
@@ -114,6 +115,8 @@ private static int FindIndexOf(string format, char ch, int startIndex, int endIn | |||
return findIndex == -1 ? endIndex : findIndex; | |||
} | |||
|
|||
private static readonly object[] EmptyArray = new object[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the top of the files with the other fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just Array.Empty<object>()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
low netstandard version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, is the s_
variable name prefix for static/const privates s_varName
a convention we do on this team?
looks good to me. Have someone more familiar with this code sign off on this though. |
|
@@ -20,6 +20,7 @@ public class LogValuesFormatter | |||
|
|||
public string OriginalFormat { get; private set; } | |||
public List<string> ValueNames => _valueNames; | |||
private const string NullValue = "(null)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move to top of class, or below existing private members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, you could move OriginalFormat
and ValueNames
after the ctor
c5e1bdb
to
c6ac6df
Compare
c6ac6df
to
db0ba84
Compare
Resolves #422
cc @muratg @BrennanConroy