| 278 | } |
| 279 | |
| 280 | async function validateCSharp(): Promise<ValidationResult[]> { |
| 281 | const results: ValidationResult[] = []; |
| 282 | const csDir = path.join(VALIDATION_DIR, "csharp"); |
| 283 | const manifest = loadManifest(); |
| 284 | |
| 285 | if (!fs.existsSync(csDir)) { |
| 286 | console.log(" No C# files to validate"); |
| 287 | return results; |
| 288 | } |
| 289 | |
| 290 | // Create a minimal csproj for validation |
| 291 | const csproj = `<Project Sdk="Microsoft.NET.Sdk"> |
| 292 | <PropertyGroup> |
| 293 | <OutputType>Library</OutputType> |
| 294 | <TargetFramework>net8.0</TargetFramework> |
| 295 | <ImplicitUsings>enable</ImplicitUsings> |
| 296 | <Nullable>enable</Nullable> |
| 297 | <NoWarn>CS8019;CS0168;CS0219;GHCP001</NoWarn> |
| 298 | </PropertyGroup> |
| 299 | <ItemGroup> |
| 300 | <ProjectReference Include="${path.join(ROOT_DIR, "dotnet/src/GitHub.Copilot.SDK.csproj")}" /> |
| 301 | </ItemGroup> |
| 302 | </Project>`; |
| 303 | |
| 304 | fs.writeFileSync(path.join(csDir, "DocsValidation.csproj"), csproj); |
| 305 | |
| 306 | const files = await glob("*.cs", { cwd: csDir }); |
| 307 | |
| 308 | // Compile all files together |
| 309 | try { |
| 310 | execFileSync( |
| 311 | "dotnet", |
| 312 | ["build", path.join(csDir, "DocsValidation.csproj")], |
| 313 | { |
| 314 | encoding: "utf-8", |
| 315 | cwd: csDir, |
| 316 | }, |
| 317 | ); |
| 318 | |
| 319 | // All files passed |
| 320 | for (const file of files) { |
| 321 | const block = manifest.blocks.find( |
| 322 | (b) => b.outputFile === `csharp/${file}`, |
| 323 | ); |
| 324 | results.push({ |
| 325 | file: `csharp/${file}`, |
| 326 | sourceFile: block?.sourceFile || "unknown", |
| 327 | sourceLine: block?.sourceLine || 0, |
| 328 | success: true, |
| 329 | errors: [], |
| 330 | }); |
| 331 | } |
| 332 | } catch (err: any) { |
| 333 | const output = err.stdout || err.stderr || err.message || ""; |
| 334 | |
| 335 | // Parse errors by file |
| 336 | const fileErrors = new Map<string, string[]>(); |
| 337 | |