Skip to content

Commit 37d2ee2

Browse files
authored
NLogBeginScopeParser - Reduce complexity of ParseScopeProperties (#657)
1 parent 32c9e8f commit 37d2ee2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ private IReadOnlyList<KeyValuePair<string, object>> ParseScopeProperties(IReadOn
5858

5959
if (!NLogLogger.OriginalFormatPropertyName.Equals(scopePropertyList[scopePropertyCount - 1].Key))
6060
return IncludeActivityIdsProperties(scopePropertyList);
61+
else if (scopePropertyCount == 1)
62+
return Array.Empty<KeyValuePair<string, object>>();
6163
else
6264
scopePropertyCount -= 1; // Handle BeginScope("Hello {World}", "Earth")
6365

@@ -66,10 +68,6 @@ private IReadOnlyList<KeyValuePair<string, object>> ParseScopeProperties(IReadOn
6668
{
6769
return new[] { firstProperty };
6870
}
69-
else if (scopePropertyCount == 0)
70-
{
71-
return Array.Empty<KeyValuePair<string, object>>();
72-
}
7371
else
7472
{
7573
var propertyList = new List<KeyValuePair<string, object>>(scopePropertyCount);

0 commit comments

Comments
 (0)