Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLogLogger - Reduce complexity of CreateLogEventInfo #559

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/NLog.Extensions.Logging/Logging/NLogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, EventId

private LogEventInfo CreateLogEventInfo<TState>(LogLevel nLogLogLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
if ((_options.CaptureMessageTemplates || _options.CaptureMessageProperties) && state is IReadOnlyList<KeyValuePair<string, object>> messagePropertyList)
if (_options.CaptureMessageProperties && state is IReadOnlyList<KeyValuePair<string, object>> messagePropertyList)
{
if (_options.CaptureMessageTemplates)
{
Expand Down Expand Up @@ -181,7 +181,7 @@ private static bool AllParameterCorrectlyPositionalMapped(NLogMessageParameterLi

for (int i = 0; i < messageTemplateParameters.Count; ++i)
{
if (!messageParameters[i].Name.Equals(messageTemplateParameters[i].Name))
if (!messageParameters[i].Name.Equals(messageTemplateParameters[i].Name, StringComparison.Ordinal))
{
return false;
}
Expand All @@ -204,7 +204,7 @@ private static object[] CreateStructuredLogEventInfoParameters(NLogMessageParame
bool extraProperty = true;
for (int j = startPos; j < messageTemplateParameters.Count; ++j)
{
if (propertyName.Equals(messageTemplateParameters[j].Name))
if (propertyName.Equals(messageTemplateParameters[j].Name, StringComparison.Ordinal))
{
extraProperty = false;
paramsArray[j] = messageParameters[i].Value;
Expand Down