@@ -106,20 +106,20 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
106
106
else if ( property . Key . StartsWith ( "@" , StringComparison . Ordinal ) )
107
107
{
108
108
if ( _logger . BindProperty ( GetKeyWithoutFirstSymbol ( DestructureDictionary , property . Key ) , property . Value , true , out var destructured ) )
109
- properties . Add ( destructured . Name , destructured . Value ) ;
109
+ properties [ destructured . Name ] = destructured . Value ;
110
110
}
111
111
else if ( property . Key . StartsWith ( "$" , StringComparison . Ordinal ) )
112
112
{
113
113
if ( _logger . BindProperty ( GetKeyWithoutFirstSymbol ( StringifyDictionary , property . Key ) , property . Value ? . ToString ( ) , true , out var stringified ) )
114
- properties . Add ( stringified . Name , stringified . Value ) ;
114
+ properties [ stringified . Name ] = stringified . Value ;
115
115
}
116
116
else
117
117
{
118
118
// Simple micro-optimization for the most common and reliably scalar values; could go further here.
119
119
if ( property . Value is null or string or int or long && LogEventProperty . IsValidName ( property . Key ) )
120
- properties . Add ( property . Key , new ScalarValue ( property . Value ) ) ;
120
+ properties [ property . Key ] = new ScalarValue ( property . Value ) ;
121
121
else if ( _logger . BindProperty ( property . Key , property . Value , false , out var bound ) )
122
- properties . Add ( bound . Name , bound . Value ) ;
122
+ properties [ bound . Name ] = bound . Value ;
123
123
}
124
124
}
125
125
@@ -130,7 +130,7 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
130
130
{
131
131
messageTemplate = "{" + stateType . Name + ":l}" ;
132
132
if ( _logger . BindProperty ( stateType . Name , AsLoggableValue ( state , formatter ) , false , out var stateTypeProperty ) )
133
- properties . Add ( stateTypeProperty . Name , stateTypeProperty . Value ) ;
133
+ properties [ stateTypeProperty . Name ] = stateTypeProperty . Value ;
134
134
}
135
135
}
136
136
@@ -153,18 +153,18 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
153
153
if ( propertyName != null )
154
154
{
155
155
if ( _logger . BindProperty ( propertyName , AsLoggableValue ( state , formatter ! ) , false , out var property ) )
156
- properties . Add ( property . Name , property . Value ) ;
156
+ properties [ property . Name ] = property . Value ;
157
157
}
158
158
}
159
159
160
160
if ( eventId != default )
161
- properties . Add ( "EventId" , CreateEventIdPropertyValue ( eventId ) ) ;
161
+ properties [ "EventId" ] = CreateEventIdPropertyValue ( eventId ) ;
162
162
163
163
var ( traceId , spanId ) = Activity . Current is { } activity ?
164
164
( activity . TraceId , activity . SpanId ) :
165
165
( default ( ActivityTraceId ) , default ( ActivitySpanId ) ) ;
166
166
167
- var parsedTemplate = MessageTemplateParser . Parse ( messageTemplate ?? "" ) ;
167
+ var parsedTemplate = messageTemplate != null ? MessageTemplateParser . Parse ( messageTemplate ) : MessageTemplate . Empty ;
168
168
return LogEvent . UnstableAssembleFromParts ( DateTimeOffset . Now , level , exception , parsedTemplate , properties , traceId , spanId ) ;
169
169
}
170
170
0 commit comments