Skip to content

Commit 54e3325

Browse files
JusterZhuclaude
andcommitted
fix: insert top-level entry point after using directives
C# requires top-level statements after using directives but before type declarations. Use regex to insert the entry point before the first /// <summary> doc comment, which follows all using statements. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3fcce47 commit 54e3325

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ jobs:
160160
$code = $code -replace '1\.0\.0\.0', '1.0.0.1'
161161
$code = $code -replace 'my-product-001', 'test-001'
162162
163-
# Prepend top-level entry point call so the file compiles as a console app
163+
# Insert top-level entry point after using directives (C# requires
164+
# top-level statements before type declarations, but after usings)
164165
$nl = [Environment]::NewLine
165166
$entryPoint = "// Entry point for build verification$nl" +
166-
'Console.WriteLine("Verifying ' + $templateName + ' compiles...");' + "$nl" +
167-
"await $templateName.RunAsync();$nl$nl"
168-
$code = "$entryPoint$code"
167+
"Console.WriteLine(""Verifying $templateName compiles..."");$nl" +
168+
"await $templateName.RunAsync();$nl"
169+
# Insert before the first /// documentation comment
170+
$code = $code -replace '(?=/// <summary>)', "$entryPoint$nl"
169171
$code | Out-File -FilePath "$testDir\Program.cs" -Encoding UTF8
170172
171173
Write-Host "=== Verifying: $templateName ==="

0 commit comments

Comments
 (0)