@@ -93,30 +93,30 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
93
93
{
94
94
string ? messageTemplate = null ;
95
95
96
- var properties = new List < LogEventProperty > ( ) ;
96
+ var properties = new Dictionary < string , LogEventPropertyValue > ( ) ;
97
97
98
98
if ( state is IEnumerable < KeyValuePair < string , object > > structure )
99
99
{
100
100
foreach ( var property in structure )
101
101
{
102
- if ( property . Key == SerilogLoggerProvider . OriginalFormatPropertyName && property . Value is string value )
102
+ if ( property is { Key : SerilogLoggerProvider . OriginalFormatPropertyName , Value : string value } )
103
103
{
104
104
messageTemplate = value ;
105
105
}
106
106
else if ( property . Key . StartsWith ( "@" ) )
107
107
{
108
108
if ( _logger . BindProperty ( GetKeyWithoutFirstSymbol ( DestructureDictionary , property . Key ) , property . Value , true , out var destructured ) )
109
- properties . Add ( destructured ) ;
109
+ properties . Add ( destructured . Name , destructured . Value ) ;
110
110
}
111
111
else if ( property . Key . StartsWith ( "$" ) )
112
112
{
113
113
if ( _logger . BindProperty ( GetKeyWithoutFirstSymbol ( StringifyDictionary , property . Key ) , property . Value ? . ToString ( ) , true , out var stringified ) )
114
- properties . Add ( stringified ) ;
114
+ properties . Add ( stringified . Name , stringified . Value ) ;
115
115
}
116
116
else
117
117
{
118
118
if ( _logger . BindProperty ( property . Key , property . Value , false , out var bound ) )
119
- properties . Add ( bound ) ;
119
+ properties . Add ( bound . Name , bound . Value ) ;
120
120
}
121
121
}
122
122
@@ -127,7 +127,7 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
127
127
{
128
128
messageTemplate = "{" + stateType . Name + ":l}" ;
129
129
if ( _logger . BindProperty ( stateType . Name , AsLoggableValue ( state , formatter ) , false , out var stateTypeProperty ) )
130
- properties . Add ( stateTypeProperty ) ;
130
+ properties . Add ( stateTypeProperty . Name , stateTypeProperty . Value ) ;
131
131
}
132
132
}
133
133
@@ -150,19 +150,19 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
150
150
if ( propertyName != null )
151
151
{
152
152
if ( _logger . BindProperty ( propertyName , AsLoggableValue ( state , formatter ! ) , false , out var property ) )
153
- properties . Add ( property ) ;
153
+ properties . Add ( property . Name , property . Value ) ;
154
154
}
155
155
}
156
156
157
157
if ( eventId . Id != 0 || eventId . Name != null )
158
- properties . Add ( CreateEventIdProperty ( eventId ) ) ;
158
+ properties . Add ( "EventId" , CreateEventIdPropertyValue ( eventId ) ) ;
159
159
160
160
var ( traceId , spanId ) = Activity . Current is { } activity ?
161
161
( activity . TraceId , activity . SpanId ) :
162
162
( default ( ActivityTraceId ) , default ( ActivitySpanId ) ) ;
163
163
164
164
var parsedTemplate = MessageTemplateParser . Parse ( messageTemplate ?? "" ) ;
165
- return new LogEvent ( DateTimeOffset . Now , level , exception , parsedTemplate , properties , traceId , spanId ) ;
165
+ return LogEvent . UnstableAssembleFromParts ( DateTimeOffset . Now , level , exception , parsedTemplate , properties , traceId , spanId ) ;
166
166
}
167
167
168
168
static object ? AsLoggableValue < TState > ( TState state , Func < TState , Exception ? , string > ? formatter )
@@ -173,7 +173,7 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
173
173
return stateObj ?? state ;
174
174
}
175
175
176
- internal static LogEventProperty CreateEventIdProperty ( EventId eventId )
176
+ internal static StructureValue CreateEventIdPropertyValue ( EventId eventId )
177
177
{
178
178
var properties = new List < LogEventProperty > ( 2 ) ;
179
179
@@ -191,6 +191,6 @@ internal static LogEventProperty CreateEventIdProperty(EventId eventId)
191
191
properties . Add ( new LogEventProperty ( "Name" , new ScalarValue ( eventId . Name ) ) ) ;
192
192
}
193
193
194
- return new LogEventProperty ( "EventId" , new StructureValue ( properties ) ) ;
194
+ return new StructureValue ( properties ) ;
195
195
}
196
196
}
0 commit comments