@@ -121,21 +121,21 @@ public WorkflowInstance(WorkflowInstanceDetails details)
121121 mutableQueries = new ( ( ) => new ( Definition . Queries , OnQueryDefinitionAdded ) , false ) ;
122122 mutableSignals = new ( ( ) => new ( Definition . Signals , OnSignalDefinitionAdded ) , false ) ;
123123 mutableUpdates = new ( ( ) => new ( Definition . Updates , OnUpdateDefinitionAdded ) , false ) ;
124- var initialMemo = details . Start . Memo ;
124+ var initialMemo = details . Init . Memo ;
125125 memo = new (
126126 ( ) => initialMemo == null ? new Dictionary < string , IRawValue > ( 0 ) :
127127 initialMemo . Fields . ToDictionary (
128128 kvp => kvp . Key ,
129129 kvp => ( IRawValue ) new RawValue ( kvp . Value ) ) ,
130130 false ) ;
131- var initialSearchAttributes = details . Start . SearchAttributes ;
131+ var initialSearchAttributes = details . Init . SearchAttributes ;
132132 typedSearchAttributes = new (
133133 ( ) => initialSearchAttributes == null ? new ( new ( ) ) :
134134 SearchAttributeCollection . FromProto ( initialSearchAttributes ) ,
135135 false ) ;
136136 var act = details . InitialActivation ;
137137 CurrentBuildId = act . BuildIdForCurrentTask ;
138- var start = details . Start ;
138+ var start = details . Init ;
139139 startArgs = new (
140140 ( ) => DecodeArgs (
141141 method : Definition . RunMethod ,
@@ -151,7 +151,7 @@ public WorkflowInstance(WorkflowInstanceDetails details)
151151 { "task_queue" , details . TaskQueue } ,
152152 { "workflow_type" , start . WorkflowType } ,
153153 } ) ) ) ;
154- initialSearchAttributes = details . Start . SearchAttributes ;
154+ initialSearchAttributes = details . Init . SearchAttributes ;
155155 WorkflowInfo . ParentInfo ? parent = null ;
156156 if ( start . ParentWorkflowInfo != null )
157157 {
@@ -188,7 +188,7 @@ public WorkflowInstance(WorkflowInstanceDetails details)
188188 replaySafeLogger = new ( logger ) ;
189189 onTaskStarting = details . OnTaskStarting ;
190190 onTaskCompleted = details . OnTaskCompleted ;
191- Random = new ( details . Start . RandomnessSeed ) ;
191+ Random = new ( details . Init . RandomnessSeed ) ;
192192 TracingEventsEnabled = ! details . DisableTracingEvents ;
193193 workerLevelFailureExceptionTypes = details . WorkerLevelFailureExceptionTypes ;
194194 disableEagerActivityExecution = details . DisableEagerActivityExecution ;
@@ -538,8 +538,25 @@ public WorkflowActivationCompletion Activate(WorkflowActivation act)
538538 {
539539 // We must set the sync context to null so work isn't posted there
540540 SynchronizationContext . SetSynchronizationContext ( null ) ;
541+ // TODO: Temporary workaround in lieu of https://github.com/temporalio/sdk-dotnet/issues/375
542+ var sortedJobs = act . Jobs . OrderBy ( j =>
543+ {
544+ switch ( j . VariantCase )
545+ {
546+ case WorkflowActivationJob . VariantOneofCase . NotifyHasPatch :
547+ case WorkflowActivationJob . VariantOneofCase . UpdateRandomSeed :
548+ return 1 ;
549+ case WorkflowActivationJob . VariantOneofCase . SignalWorkflow :
550+ case WorkflowActivationJob . VariantOneofCase . DoUpdate :
551+ return 2 ;
552+ case WorkflowActivationJob . VariantOneofCase . InitializeWorkflow :
553+ return 3 ;
554+ default :
555+ return 4 ;
556+ }
557+ } ) . ToList ( ) ;
541558 // We can trust jobs are deterministically ordered by core
542- foreach ( var job in act . Jobs )
559+ foreach ( var job in sortedJobs )
543560 {
544561 Apply ( job ) ;
545562 // Run scheduler once. Do not check conditions when patching or querying.
@@ -880,8 +897,8 @@ private void Apply(WorkflowActivationJob job)
880897 case WorkflowActivationJob . VariantOneofCase . SignalWorkflow :
881898 ApplySignalWorkflow ( job . SignalWorkflow ) ;
882899 break ;
883- case WorkflowActivationJob . VariantOneofCase . StartWorkflow :
884- ApplyStartWorkflow ( job . StartWorkflow ) ;
900+ case WorkflowActivationJob . VariantOneofCase . InitializeWorkflow :
901+ ApplyStartWorkflow ( job . InitializeWorkflow ) ;
885902 break ;
886903 case WorkflowActivationJob . VariantOneofCase . UpdateRandomSeed :
887904 ApplyUpdateRandomSeed ( job . UpdateRandomSeed ) ;
@@ -1292,7 +1309,7 @@ await inbound.Value.HandleSignalAsync(new(
12921309 } ) ) ;
12931310 }
12941311
1295- private void ApplyStartWorkflow ( StartWorkflow start )
1312+ private void ApplyStartWorkflow ( InitializeWorkflow init )
12961313 {
12971314 _ = QueueNewTaskAsync ( ( ) => RunTopLevelAsync ( async ( ) =>
12981315 {
0 commit comments