@@ -229,6 +229,8 @@ public Action(string name, ActionType type, IMethodSymbol methodSymbol)
229229 public string ? ReturnDescription ;
230230 public string YarnReturnTypeString => this . MethodSymbol . ReturnType . GetYarnTypeString ( ) ;
231231
232+ public bool ContainsErrors = false ;
233+
232234 public string ToJSON ( )
233235 {
234236 var result = new Dictionary < string , object ? > ( ) ;
@@ -243,6 +245,8 @@ public string ToJSON()
243245 result [ "language" ] = "csharp" ;
244246 result [ "async" ] = this . AsyncType != AsyncType . Sync ;
245247
248+ result [ "containsErrors" ] = this . ContainsErrors ;
249+
246250 if ( this . Declaration != null )
247251 {
248252 var location = this . Declaration . GetLocation ( ) . GetLineSpan ( ) ;
@@ -487,6 +491,8 @@ private IEnumerable<Diagnostic> ValidateFunction(Compilation compilation, ILogge
487491 yield return Diagnostic . Create ( Diagnostics . YS1006YarnFunctionsMustBeStatic , identifierLocation ) ;
488492 }
489493
494+ logger ? . Inc ( ) ;
495+ logger ? . WriteLine ( $ "Validating { identifier } as a function") ;
490496 var paramDiags = ValidateParameters ( compilation , logger ) ;
491497 foreach ( var p in paramDiags )
492498 {
@@ -496,6 +502,7 @@ private IEnumerable<Diagnostic> ValidateFunction(Compilation compilation, ILogge
496502 // Functions must return a number, string, or bool
497503 var returnTypeSymbol = this . MethodSymbol . ReturnType ;
498504
505+ logger ? . Dec ( ) ;
499506 switch ( returnTypeSymbol . SpecialType )
500507 {
501508 case SpecialType . System_Boolean :
@@ -522,33 +529,32 @@ private IEnumerable<Diagnostic> ValidateFunction(Compilation compilation, ILogge
522529 // validates the parameters are correct
523530 private List < Diagnostic > ValidateParameters ( Compilation compilation , ILogger ? logger )
524531 {
532+ logger ? . Inc ( ) ;
525533 List < Diagnostic > diagnostics = new List < Diagnostic > ( ) ;
526534 ParameterListSyntax ? parameterList = null ;
527- Location ? actionLocation = null ;
528535 string ? identifier = null ;
529536
530537 if ( this . MethodDeclarationSyntax is MethodDeclarationSyntax methodDeclaration )
531538 {
532539 identifier = methodDeclaration . Identifier . ToString ( ) ;
533- logger ? . WriteLine ( $ "Validating { identifier } as a method") ;
540+ logger ? . WriteLine ( $ "identified { identifier } as a method") ;
534541 parameterList = methodDeclaration . ParameterList ;
535- actionLocation = methodDeclaration . GetLocation ( ) ;
536542 }
537543 else if ( this . MethodDeclarationSyntax is LocalFunctionStatementSyntax localFunctionStatement )
538544 {
539545 identifier = localFunctionStatement . Identifier . ToString ( ) ;
540- logger ? . WriteLine ( $ "Validating { identifier } as a local function") ;
546+ logger ? . WriteLine ( $ "identified { identifier } as a local function") ;
541547 parameterList = localFunctionStatement . ParameterList ;
542- actionLocation = localFunctionStatement . GetLocation ( ) ;
543548 }
544549 else if ( this . MethodDeclarationSyntax is LambdaExpressionSyntax lambdaExpression )
545550 {
546- logger ? . WriteLine ( "The action is a lambda." ) ;
547- actionLocation = lambdaExpression . GetLocation ( ) ;
551+ logger ? . WriteLine ( "identifed the action as a lambda." ) ;
552+ var actionLocation = lambdaExpression . GetLocation ( ) ;
548553
549554 if ( lambdaExpression is SimpleLambdaExpressionSyntax )
550555 {
551556 logger ? . WriteLine ( "The action is a simple lambda, validations do not apply here, skipping this action." ) ;
557+ logger ? . Dec ( ) ;
552558 diagnostics . Add ( Diagnostic . Create ( Diagnostics . YS1012ActionIsALambda , actionLocation ) ) ;
553559 return diagnostics ;
554560 }
@@ -567,15 +573,18 @@ private List<Diagnostic> ValidateParameters(Compilation compilation, ILogger? lo
567573 if ( parameterList == null || parameterList . Parameters . Count ( ) == 0 )
568574 {
569575 logger ? . WriteLine ( $ "{ identifier } has no parameters, ignoring") ;
576+ logger ? . Dec ( ) ;
570577 return diagnostics ;
571578 }
572579
573580 logger ? . WriteLine ( $ "Will be checking { parameterList . Parameters . Count ( ) } parameters") ;
574581 foreach ( var parameter in parameterList . Parameters )
575582 {
583+ logger ? . Inc ( ) ;
576584 if ( parameter . Type == null )
577585 {
578586 logger ? . WriteLine ( $ "{ parameter . ToFullString ( ) } has no type, ignoring validation?") ;
587+ logger ? . Dec ( ) ;
579588 continue ;
580589 }
581590
@@ -588,13 +597,15 @@ private List<Diagnostic> ValidateParameters(Compilation compilation, ILogger? lo
588597 if ( typeInfo == null )
589598 {
590599 logger ? . WriteLine ( $ "Unable to determine typeinfo of { parameterName } ignoring validation?") ;
600+ logger ? . Dec ( ) ;
591601 continue ;
592602 }
593603
594604 var symbol = model . GetDeclaredSymbol ( parameter ) ;
595605 if ( symbol == null )
596606 {
597607 logger ? . WriteLine ( $ "Unable to determine the declared symbol for { parameterName } , skipping validation") ;
608+ logger ? . Dec ( ) ;
598609 continue ;
599610 }
600611
@@ -603,7 +614,6 @@ private List<Diagnostic> ValidateParameters(Compilation compilation, ILogger? lo
603614 if ( symbol . Type is IArrayTypeSymbol arrayTypeSymbol )
604615 {
605616 var subtype = arrayTypeSymbol . ElementType ;
606- logger ? . WriteLine ( $ "{ parameterName } is a params array made up of { subtype } :_{ subtype . Name } _:-{ subtype . GetYarnTypeString ( ) } -") ;
607617 if ( subtype . GetYarnTypeString ( ) == "any" )
608618 {
609619 logger ? . WriteLine ( $ "{ parameterName } is a parameter array of non Yarn compatible types!") ;
@@ -621,7 +631,6 @@ private List<Diagnostic> ValidateParameters(Compilation compilation, ILogger? lo
621631 }
622632 }
623633
624-
625634 foreach ( var attribute in symbol . GetAttributes ( ) )
626635 {
627636 // this attribute is an enum parameter
@@ -642,15 +651,19 @@ private List<Diagnostic> ValidateParameters(Compilation compilation, ILogger? lo
642651 }
643652 }
644653 }
654+ logger ? . Dec ( ) ;
645655 }
646656
657+ logger ? . Dec ( ) ;
647658 return diagnostics ;
648659 }
649660
650661 private IEnumerable < Diagnostic > ValidateCommand ( Compilation compilation , ILogger ? logger )
651662 {
663+ logger ? . Inc ( ) ;
652664 if ( MethodSymbol == null )
653665 {
666+ logger ? . Dec ( ) ;
654667 throw new NullReferenceException ( "Method symbol is null" ) ;
655668 }
656669
@@ -705,9 +718,12 @@ private IEnumerable<Diagnostic> ValidateCommand(Compilation compilation, ILogger
705718 }
706719 else
707720 {
721+ logger ? . Dec ( ) ;
708722 throw new InvalidOperationException ( $ "Expected decl for { this . Name } ({ this . SourceFileName } ) was of unexpected type { this . MethodDeclarationSyntax ? . GetType ( ) . Name ?? "null" } ") ;
709723 }
710724
725+ logger ? . WriteLine ( $ "Validating { identifier } as a command") ;
726+
711727 var paramDiags = ValidateParameters ( compilation , logger ) ;
712728 foreach ( var p in paramDiags )
713729 {
@@ -719,6 +735,7 @@ private IEnumerable<Diagnostic> ValidateCommand(Compilation compilation, ILogger
719735 var typeIsKnownInvalid = knownInvalidCommandReturnTypes . Contains ( returnTypeSymbol ) ;
720736
721737 var returnTypeIsValid = typeIsKnownValid && ! typeIsKnownInvalid ;
738+ logger ? . Dec ( ) ;
722739
723740 if ( returnTypeIsValid == false )
724741 {
0 commit comments