@@ -60,7 +60,7 @@ private LogEventInfo CreateLogEventInfo(LogLevel nLogLogLevel, string message, I
6060
6161 private static bool IsNonDigitValue ( string value )
6262 {
63- return ! string . IsNullOrEmpty ( value ) && ( value . Length != 1 || ! char . IsDigit ( value [ 0 ] ) ) ;
63+ return ! String . IsNullOrEmpty ( value ) && ( value . Length != 1 || ! Char . IsDigit ( value [ 0 ] ) ) ;
6464 }
6565
6666#if ! NETSTANDARD1_3
@@ -110,11 +110,7 @@ private LogEventInfo CreateLogEventInfoWithMultipleParameters(LogLevel nLogLogLe
110110 if ( string . IsNullOrEmpty ( parameter . Key ) )
111111 break ; // Skip capture of invalid parameters
112112
113- var parameterName = parameter . Key ;
114- if ( parameterName [ 0 ] == '@' || parameterName [ 0 ] == '$' )
115- {
116- parameterName = parameterName . Substring ( 1 ) ;
117- }
113+ var parameterName = RemoveMarkerFromName ( parameter . Key ) ;
118114 eventInfo . Properties [ parameterName ] = parameter . Value ;
119115 }
120116 return eventInfo ;
@@ -125,11 +121,11 @@ private LogEventInfo CreateLogEventInfoWithMultipleParameters(LogLevel nLogLogLe
125121
126122 private void CaptureEventId ( LogEventInfo eventInfo , EventId eventId )
127123 {
128- if ( ! _options . IgnoreEmptyEventId || eventId . Id != 0 || ! string . IsNullOrEmpty ( eventId . Name ) )
124+ if ( ! _options . IgnoreEmptyEventId || eventId . Id != 0 || ! String . IsNullOrEmpty ( eventId . Name ) )
129125 {
130126 // Attempt to reuse the same string-allocations based on the current <see cref="NLogProviderOptions.EventIdSeparator"/>
131127 var eventIdPropertyNames = _eventIdPropertyNames ?? new Tuple < string , string , string > ( null , null , null ) ;
132- var eventIdSeparator = _options . EventIdSeparator ?? string . Empty ;
128+ var eventIdSeparator = _options . EventIdSeparator ?? String . Empty ;
133129 if ( ! ReferenceEquals ( eventIdPropertyNames . Item1 , eventIdSeparator ) )
134130 {
135131 // Perform atomic cache update of the string-allocations matching the current separator
@@ -147,8 +143,8 @@ private static Tuple<string, string, string> CreateEventIdPropertyNames(string e
147143 {
148144 var eventIdPropertyNames = new Tuple < string , string , string > (
149145 eventIdSeparator ,
150- string . Concat ( "EventId" , eventIdSeparator , "Id" ) ,
151- string . Concat ( "EventId" , eventIdSeparator , "Name" ) ) ;
146+ String . Concat ( "EventId" , eventIdSeparator , "Id" ) ,
147+ String . Concat ( "EventId" , eventIdSeparator , "Name" ) ) ;
152148 return eventIdPropertyNames ;
153149 }
154150
@@ -158,7 +154,7 @@ private void CaptureMessageProperties<TState>(LogEventInfo eventInfo, TState sta
158154 {
159155 foreach ( var property in messageProperties )
160156 {
161- if ( string . IsNullOrEmpty ( property . Key ) )
157+ if ( String . IsNullOrEmpty ( property . Key ) )
162158 continue ;
163159
164160 eventInfo . Properties [ property . Key ] = property . Value ;
@@ -234,7 +230,7 @@ public static IDisposable CreateFromState<TState>(TState state, IEnumerable<KeyV
234230 scope . AddDispose ( NestedDiagnosticsLogicalContext . Push ( state ) ) ;
235231 return scope ;
236232 }
237-
233+
238234 public void AddDispose ( IDisposable disposable )
239235 {
240236 Properties . Add ( disposable ) ;
@@ -302,5 +298,15 @@ public IDisposable BeginScope<TState>(TState state)
302298
303299 return NestedDiagnosticsLogicalContext . Push ( state ) ;
304300 }
301+
302+ internal static string RemoveMarkerFromName ( string parameterName )
303+ {
304+ var firstChar = parameterName [ 0 ] ;
305+ if ( firstChar == '@' || firstChar == '$' )
306+ {
307+ parameterName = parameterName . Substring ( 1 ) ;
308+ }
309+ return parameterName ;
310+ }
305311 }
306312}
0 commit comments