Skip to content

Commit f615530

Browse files
authored
Avoid boxing ITuple when used for BeginScope (refactor) (#815)
1 parent 84a8349 commit f615530

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public IDisposable ParseBeginScope<T>(T state)
4646
return ScopeContext.PushNestedStateProperties(scopeProperties, scopeProperties);
4747
}
4848
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER || NET471_OR_GREATER
49-
else if (state is System.Runtime.CompilerServices.ITuple && ((System.Runtime.CompilerServices.ITuple)state).Length == 2 && ((System.Runtime.CompilerServices.ITuple)state)[0] is string)
49+
else if (state is System.Runtime.CompilerServices.ITuple && ((System.Runtime.CompilerServices.ITuple)state).Length == 2 && ((System.Runtime.CompilerServices.ITuple)state)[0] is string propertyName)
5050
{
51-
return ScopeContext.PushProperty(((System.Runtime.CompilerServices.ITuple)state)[0]?.ToString() ?? string.Empty, ((System.Runtime.CompilerServices.ITuple)state)[1]);
51+
return ScopeContext.PushProperty(propertyName, ((System.Runtime.CompilerServices.ITuple)state)[1]);
5252
}
5353
#endif
5454

0 commit comments

Comments
 (0)