@@ -93,30 +93,30 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
9393 {
9494 string ? messageTemplate = null ;
9595
96- var properties = new List < LogEventProperty > ( ) ;
96+ var properties = new Dictionary < string , LogEventPropertyValue > ( ) ;
9797
9898 if ( state is IEnumerable < KeyValuePair < string , object > > structure )
9999 {
100100 foreach ( var property in structure )
101101 {
102- if ( property . Key == SerilogLoggerProvider . OriginalFormatPropertyName && property . Value is string value )
102+ if ( property is { Key : SerilogLoggerProvider . OriginalFormatPropertyName , Value : string value } )
103103 {
104104 messageTemplate = value ;
105105 }
106106 else if ( property . Key . StartsWith ( "@" ) )
107107 {
108108 if ( _logger . BindProperty ( GetKeyWithoutFirstSymbol ( DestructureDictionary , property . Key ) , property . Value , true , out var destructured ) )
109- properties . Add ( destructured ) ;
109+ properties . Add ( destructured . Name , destructured . Value ) ;
110110 }
111111 else if ( property . Key . StartsWith ( "$" ) )
112112 {
113113 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 ) ;
115115 }
116116 else
117117 {
118118 if ( _logger . BindProperty ( property . Key , property . Value , false , out var bound ) )
119- properties . Add ( bound ) ;
119+ properties . Add ( bound . Name , bound . Value ) ;
120120 }
121121 }
122122
@@ -127,7 +127,7 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
127127 {
128128 messageTemplate = "{" + stateType . Name + ":l}" ;
129129 if ( _logger . BindProperty ( stateType . Name , AsLoggableValue ( state , formatter ) , false , out var stateTypeProperty ) )
130- properties . Add ( stateTypeProperty ) ;
130+ properties . Add ( stateTypeProperty . Name , stateTypeProperty . Value ) ;
131131 }
132132 }
133133
@@ -150,19 +150,19 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
150150 if ( propertyName != null )
151151 {
152152 if ( _logger . BindProperty ( propertyName , AsLoggableValue ( state , formatter ! ) , false , out var property ) )
153- properties . Add ( property ) ;
153+ properties . Add ( property . Name , property . Value ) ;
154154 }
155155 }
156156
157157 if ( eventId . Id != 0 || eventId . Name != null )
158- properties . Add ( CreateEventIdProperty ( eventId ) ) ;
158+ properties . Add ( "EventId" , CreateEventIdPropertyValue ( eventId ) ) ;
159159
160160 var ( traceId , spanId ) = Activity . Current is { } activity ?
161161 ( activity . TraceId , activity . SpanId ) :
162162 ( default ( ActivityTraceId ) , default ( ActivitySpanId ) ) ;
163163
164164 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 ) ;
166166 }
167167
168168 static object ? AsLoggableValue < TState > ( TState state , Func < TState , Exception ? , string > ? formatter )
@@ -173,7 +173,7 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
173173 return stateObj ?? state ;
174174 }
175175
176- internal static LogEventProperty CreateEventIdProperty ( EventId eventId )
176+ internal static StructureValue CreateEventIdPropertyValue ( EventId eventId )
177177 {
178178 var properties = new List < LogEventProperty > ( 2 ) ;
179179
@@ -191,6 +191,6 @@ internal static LogEventProperty CreateEventIdProperty(EventId eventId)
191191 properties . Add ( new LogEventProperty ( "Name" , new ScalarValue ( eventId . Name ) ) ) ;
192192 }
193193
194- return new LogEventProperty ( "EventId" , new StructureValue ( properties ) ) ;
194+ return new StructureValue ( properties ) ;
195195 }
196196}
0 commit comments