Repository: dotnet/runtime
File: eng/breakingChanges/breaking-change-doc.ps1 (PowerShell)

Code before:
    # Single PR mode - fetch only the specified PR
    Write-Host "   Mode: Single PR #$PrNumber"
    $prs = @(@{ number = $PrNumber })
} else {
    # Query mode - fetch all PRs matching criteria
    Write-Host "   Mode: Query - $Query"

    try {
        $prsJson = gh pr list --repo $Config.SourceRepo --search $Query --limit $Config.MaxPRs --json number
        $prs = $prsJson | ConvertFrom-Json
    } catch {
        Write-Error "Failed to fetch PRs: $($_.Exception.Message)"
        exit 1
    }

    Write-Host "   Found $($prs.Count) PRs to collect data for"
}

# Collect detailed data for each PR
$analysisData = @()
foreach ($pr in $prs) {
    Write-Host "   Collecting data for PR #$($pr.number): $($pr.title)" -ForegroundColor Gray

    # Get comprehensive PR details including comments, reviews, and commits
    try {
        $prDetails = gh pr view $pr.number --repo $Config.SourceRepo --json number,title,url,baseRefName,closedAt,mergeCommit,labels,files,state,body,comments,reviews,closingIssuesReferences,commits
        $prDetailData = $prDetails | ConvertFrom-Json
    } catch {
        Write-Warning "Could not fetch detailed PR data for #$($pr.number)"
        continue
    }

    # Extract commits from the PR details
    $commits = @()
    if ($prDetailData.commits) {
        foreach ($commit in $prDetailData.commits) {
            $commitMessage = $commit.messageHeadline
            if ($commit.messageBody -and $commit.messageBody.Trim() -ne "") {
                $commitMessage += "`n`n" + $commit.messageBody
            }
            $commits += $commitMessage
        }
    }

    # Get closing issues with full details and comments
    $closingIssues = @()
    foreach ($issueRef in $prDetailData.closingIssuesReferences) {
        if ($issueRef.number) {
            try {
                Write-Host "     Fetching issue #$($issueRef.number)..." -ForegroundColor DarkGray
                $issueDetails = gh issue view $issueRef.number --repo $Config.SourceRepo --json number,title,body,comments,labels,state,createdAt,closedAt,url

Review comment (security):
The `author` field is missing from the JSON query but is required on line 879 where `$prDetailData.author.login` is accessed. Add `author` to the list of fields: `--json number,title,url,baseRefName,closedAt,mergeCommit,labels,files,state,body,comments,reviews,closingIssuesReferences,commits,author`
```suggestion
        $prDetails = gh pr view $pr.number --repo $Config.SourceRepo --json number,title,url,baseRefName,closedAt,mergeCommit,labels,files,state,body,comments,reviews,closingIssuesReferences,commits,author
```

Code after:
    # Single PR mode - fetch only the specified PR
    Write-Host "   Mode: Single PR #$PrNumber"
    $prs = @(@{ number = $PrNumber })
} else {
    # Query mode - fetch all PRs matching criteria
    Write-Host "   Mode: Query - $Query"

    try {
        $prsJson = gh pr list --repo $Config.SourceRepo --search $Query --limit $Config.MaxPRs --json number
        $prs = $prsJson | ConvertFrom-Json
    } catch {
        Write-Error "Failed to fetch PRs: $($_.Exception.Message)"
        exit 1
    }

    Write-Host "   Found $($prs.Count) PRs to collect data for"
}

# Collect detailed data for each PR
$analysisData = @()
foreach ($pr in $prs) {
    Write-Host "   Collecting data for PR #$($pr.number): $($pr.title)" -ForegroundColor Gray

    # Get comprehensive PR details including comments, reviews, and commits
    try {
        $prDetails = gh pr view $pr.number --repo $Config.SourceRepo --json number,title,author,url,baseRefName,closedAt,mergedAt,mergeCommit,labels,files,state,body,comments,reviews,closingIssuesReferences,commits
        $prDetailData = $prDetails | ConvertFrom-Json
    } catch {
        Write-Warning "Could not fetch detailed PR data for #$($pr.number)"
        continue
    }

    # Extract commits from the PR details
    $commits = @()
    if ($prDetailData.commits) {
        foreach ($commit in $prDetailData.commits) {
            $commitMessage = $commit.messageHeadline
            if ($commit.messageBody -and $commit.messageBody.Trim() -ne "") {
                $commitMessage += "`n`n" + $commit.messageBody
            }
            $commits += $commitMessage
        }
    }

    # Get closing issues with full details and comments
    $closingIssues = @()
    foreach ($issueRef in $prDetailData.closingIssuesReferences) {
        if ($issueRef.number) {
            try {
                Write-Host "     Fetching issue #$($issueRef.number)..." -ForegroundColor DarkGray
                $issueDetails = gh issue view $issueRef.number --repo $Config.SourceRepo --json number,title,body,comments,labels,state,createdAt,closedAt,url