@@ -528,14 +528,14 @@ public void Constructor_WrongArgType_ReportsCGS023()
528528 }
529529
530530 [ Fact ]
531- public void Constructor_NoArgs_NoCGS023 ( )
531+ public void Constructor_NoArgs_ReportsCGS023 ( )
532532 {
533- // new String() — zero args is valid (all params treated as optional)
533+ // new String() — constructor requires a string arg; zero args is a mismatch
534534 var diags = AnalyzeWithObjects (
535535 "string s = new String();" ,
536536 new Dictionary < string , ObjectDefinition > { [ "String" ] = MakeStringDef ( ) } ) ;
537537
538- Assert . DoesNotContain ( diags , d => d . Code == "CGS023" ) ;
538+ Assert . Contains ( diags , d => d . Code == "CGS023" && d . Message . Contains ( "String" ) ) ;
539539 }
540540
541541 [ Fact ]
@@ -569,6 +569,39 @@ public void KnownObjectsFromLoader_InvalidConstructorArgs_ReportsCGS023()
569569 Assert . Contains ( diags , d => d . Code == "CGS023" && d . Message . Contains ( "String" ) ) ;
570570 }
571571
572+ [ Fact ]
573+ public void WorkflowScript_FilenameOverload_NoCGS023 ( )
574+ {
575+ // new WorkflowScript("filename") is a preprocessor special form that the source generator
576+ // replaces with new WorkflowScript(resourceId) on deployment. No CGS023 should be raised.
577+ // WithPreprocessorExtensions() must be called — this overload is NOT in the base definitions.
578+ var result = CgScriptParseService . Parse ( "WorkflowScript script = new WorkflowScript(\" myScript.cgs\" );" ) ;
579+ var diags = SemanticAnalyzer . Analyze ( result . Tree , new CgScriptDefinitions ( ) . WithPreprocessorExtensions ( ) ) ;
580+
581+ Assert . DoesNotContain ( diags , d => d . Code == "CGS023" ) ;
582+ }
583+
584+ [ Fact ]
585+ public void WorkflowScript_FilenameOverload_NotInjectedInBaseDefinitions ( )
586+ {
587+ // Without WithPreprocessorExtensions(), new WorkflowScript("filename") should report CGS023
588+ // because the base definitions only know about the real API constructors.
589+ var result = CgScriptParseService . Parse ( "WorkflowScript script = new WorkflowScript(\" myScript.cgs\" );" ) ;
590+ var diags = SemanticAnalyzer . Analyze ( result . Tree , new CgScriptDefinitions ( ) ) ;
591+
592+ Assert . Contains ( diags , d => d . Code == "CGS023" ) ;
593+ }
594+
595+ [ Fact ]
596+ public void WorkflowScript_TooManyStringArgs_ReportsCGS023 ( )
597+ {
598+ // new WorkflowScript("a", "b", "c") — no constructor accepts three strings even with preprocessor extensions
599+ var result = CgScriptParseService . Parse ( "WorkflowScript script = new WorkflowScript(\" a\" , \" b\" , \" c\" );" ) ;
600+ var diags = SemanticAnalyzer . Analyze ( result . Tree , new CgScriptDefinitions ( ) . WithPreprocessorExtensions ( ) ) ;
601+
602+ Assert . Contains ( diags , d => d . Code == "CGS023" && d . Message . Contains ( "WorkflowScript" ) ) ;
603+ }
604+
572605 // ── CGS024: method call argument mismatch ─────────────────────────────────
573606
574607 private static ObjectDefinition MakeStringWithCompareDef ( )
@@ -873,4 +906,25 @@ public void StringBuilderAppendFormat_WithMultipleArgs_NoCGS024()
873906
874907 Assert . DoesNotContain ( diags , d => d . Code == "CGS024" ) ;
875908 }
909+
910+ [ Fact ]
911+ public void FormatFunction_WithMultipleArgs_NoCGS024 ( )
912+ {
913+ // format("{0} {1}", a, b) — format accepts "Params object" so any number of args is valid.
914+ var result = CgScriptParseService . Parse ( "string s = format(\" {0} {1}\" , 1, 2);" ) ;
915+ var diags = SemanticAnalyzer . Analyze ( result . Tree , new CgScriptDefinitions ( ) ) ;
916+
917+ Assert . DoesNotContain ( diags , d => d . Code == "CGS024" ) ;
918+ }
919+
920+ [ Fact ]
921+ public void WorkflowScriptInvoke_WithArrayArg_NoCGS024 ( )
922+ {
923+ // WorkflowScript.Invoke(array) — exactly one array argument is valid.
924+ // WithPreprocessorExtensions() is needed because new WorkflowScript("filename") is the preprocessor form.
925+ var result = CgScriptParseService . Parse ( "WorkflowScript ws = new WorkflowScript(\" test.cgs\" ); array args = new array(); ws.Invoke(args);" ) ;
926+ var diags = SemanticAnalyzer . Analyze ( result . Tree , new CgScriptDefinitions ( ) . WithPreprocessorExtensions ( ) ) ;
927+
928+ Assert . DoesNotContain ( diags , d => d . Code == "CGS024" ) ;
929+ }
876930}
0 commit comments