Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Harden log formatters to handle null formats, null arguments, and null arrays of arguments #480

Merged
merged 1 commit into from
Aug 26, 2016

Conversation

natemcmaster
Copy link
Contributor

@@ -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];
Copy link
Contributor

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.

Copy link
Contributor

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>() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low netstandard version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Copy link
Contributor Author

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?

@pranavkm
Copy link
Contributor

looks good to me. Have someone more familiar with this code sign off on this though.

@muratg
Copy link

muratg commented Aug 26, 2016

cc @victorhurdugaci

@victorhurdugaci
Copy link
Contributor

:shipit:

@@ -20,6 +20,7 @@ public class LogValuesFormatter

public string OriginalFormat { get; private set; }
public List<string> ValueNames => _valueNames;
private const string NullValue = "(null)";
Copy link
Contributor

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.

Copy link
Contributor

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

@natemcmaster natemcmaster force-pushed the namc/null branch 2 times, most recently from c5e1bdb to c6ac6df Compare August 26, 2016 16:24
@natemcmaster natemcmaster merged commit db0ba84 into dev Aug 26, 2016
@natemcmaster natemcmaster deleted the namc/null branch August 26, 2016 16:33
natemcmaster pushed a commit to aspnet/Mvc that referenced this pull request Aug 26, 2016
natemcmaster pushed a commit to aspnet/Identity that referenced this pull request Aug 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants