@@ -568,10 +568,12 @@ static void EmitConsoleAppRun(SourceProductionContext sourceProductionContext, R
568568
569569 var wellKnownTypes = new WellKnownTypes ( model . Compilation ) ;
570570
571- var parser = new Parser ( sourceProductionContext , node , model , wellKnownTypes , DelegateBuildType . MakeDelegateWhenHasDefaultValue , [ ] ) ;
571+ var reporter = new DiagnosticReporter ( ) ;
572+ var parser = new Parser ( reporter , node , model , wellKnownTypes , DelegateBuildType . MakeDelegateWhenHasDefaultValue , [ ] ) ;
572573 var command = parser . ParseAndValidateForRun ( ) ;
573574 if ( command == null )
574575 {
576+ reporter . ReportToContext ( sourceProductionContext ) ;
575577 return ;
576578 }
577579 if ( command . HasFilter )
@@ -657,12 +659,13 @@ static void EmitConsoleAppBuilder(SourceProductionContext sourceProductionContex
657659 return ;
658660 }
659661
662+ var reporter = new DiagnosticReporter ( ) ;
660663 var names = new HashSet < string > ( ) ;
661664 var commands1 = methodGroup [ "Add" ]
662665 . Select ( x =>
663666 {
664667 var wellKnownTypes = new WellKnownTypes ( x . Model . Compilation ) ;
665- var parser = new Parser ( sourceProductionContext , x . Node , x . Model , wellKnownTypes , DelegateBuildType . OnlyActionFunc , globalFilters ) ;
668+ var parser = new Parser ( reporter , x . Node , x . Model , wellKnownTypes , DelegateBuildType . OnlyActionFunc , globalFilters ) ;
666669 var command = parser . ParseAndValidateForBuilderDelegateRegistration ( ) ;
667670
668671 // validation command name duplicate
@@ -681,7 +684,7 @@ static void EmitConsoleAppBuilder(SourceProductionContext sourceProductionContex
681684 . SelectMany ( x =>
682685 {
683686 var wellKnownTypes = new WellKnownTypes ( x . Model . Compilation ) ;
684- var parser = new Parser ( sourceProductionContext , x . Node , x . Model , wellKnownTypes , DelegateBuildType . None , globalFilters ) ;
687+ var parser = new Parser ( reporter , x . Node , x . Model , wellKnownTypes , DelegateBuildType . None , globalFilters ) ;
685688 var commands = parser . ParseAndValidateForBuilderClassRegistration ( ) ;
686689
687690 // validation command name duplicate
@@ -699,6 +702,12 @@ static void EmitConsoleAppBuilder(SourceProductionContext sourceProductionContex
699702
700703 var commands = commands1 . Concat ( commands2 ) . ToArray ( ) ;
701704
705+ if ( reporter . HasDiagnostics )
706+ {
707+ reporter . ReportToContext ( sourceProductionContext ) ;
708+ return ;
709+ }
710+
702711 // don't emit if exists failure(already reported error)
703712 if ( commands . Any ( x => x == null ) )
704713 {
0 commit comments