File tree Expand file tree Collapse file tree
DesignPatterns.SourceGenerators/Syntax Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,6 +303,22 @@ private static void AppendConstraintGuards(
303303 }
304304 }
305305
306+ if ( ! string . IsNullOrEmpty ( step . Before ) )
307+ {
308+ var before = allSteps . FirstOrDefault ( s =>
309+ string . Equals ( s . MethodName , step . Before , StringComparison . Ordinal )
310+ || string . Equals ( s . BindingName , step . Before , StringComparison . OrdinalIgnoreCase ) ) ;
311+ if ( before . MethodName is not null )
312+ {
313+ sb . Append ( indent ) . AppendLine (
314+ $ " if (state.AppliedOrder.Contains(\" { before . MethodName } \" ))") ;
315+ sb . Append ( indent ) . AppendLine ( " {" ) ;
316+ sb . Append ( indent ) . AppendLine (
317+ $ " throw new InvalidOperationException(\" Step '{ step . MethodName } ' violates an After/Before constraint relative to '{ before . MethodName } '.\" );") ;
318+ sb . Append ( indent ) . AppendLine ( " }" ) ;
319+ }
320+ }
321+
306322 foreach ( var predecessor in allSteps . Where ( s =>
307323 ! string . IsNullOrEmpty ( s . Before )
308324 && ( string . Equals ( s . Before , step . MethodName , StringComparison . Ordinal )
You can’t perform that action at this time.
0 commit comments