Skip to content

pr.yaml: write protected config files as UTF-8 without BOM#339

Merged
Chris-Wolfgang merged 1 commit into
mainfrom
fix/pr-yaml-bom-on-protected-config-fetch
May 9, 2026
Merged

pr.yaml: write protected config files as UTF-8 without BOM#339
Chris-Wolfgang merged 1 commit into
mainfrom
fix/pr-yaml-bom-on-protected-config-fetch

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

The "Fetch trusted configuration files from main branch" step in pr.yaml (in both the v3 gated workflow's main-tests job and the secondary tests job) writes the protected config files back to disk via:

git show "main-branch:$configFile" | Out-File -FilePath $configFile -Encoding UTF8 -NoNewline

In PowerShell, -Encoding UTF8 writes UTF-8 with a BOM. The .NET analyzer engine that reads .editorconfig appears to silently ignore files that begin with a BOM — so the project's severity overrides (e.g. dotnet_diagnostic.MA0002.severity = suggestion) don't apply on CI even though they apply locally. Analyzers fire at their default severity instead, and TreatWarningsAsErrors then escalates them.

This was diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run 24996715587: local Release builds were clean while CI reported MA0002, MA0049, S2365, S1066, MA0158, S1481, S2699 as errors. After repointing the build to the BOM-free version of .editorconfig, the same source compiled clean.

Fix

Switch the four call sites to Out-File -Encoding UTF8NoBOM. PS 6+ supports this encoding token; GitHub-hosted shell: pwsh runners use PowerShell 7+, so it's safe.

Downstream impact

The bug exists in every consumer repo's pr.yaml. They'll pick up the fix on their next template-sync. No retroactive flush needed — once the BOM-free .editorconfig lands on main, subsequent PRs will see the analyzer config applied as intended.

Test plan

  • CI on this PR passes (the same protected-files mechanism runs on this PR)
  • After merge, sync into one consumer repo (e.g. In-memory-Logger) and verify a Release build of an existing PR no longer trips analyzer rules that the project's .editorconfig marks as suggestion

🤖 Generated with Claude Code

The "Fetch trusted configuration files from main branch" step writes
.editorconfig / Directory.Build.props / BannedSymbols.txt / *.globalconfig /
*.ruleset back to disk via `Out-File -Encoding UTF8`. In PowerShell, that
encoding name writes UTF-8 *with* a BOM. The .NET analyzer engine that
reads .editorconfig appears to silently ignore files that begin with a BOM,
which means the project's severity overrides (e.g.
`dotnet_diagnostic.MA0002.severity = suggestion`) don't apply on CI even
though they apply locally — analyzers fire at their default severity instead.

This was diagnosed against In-memory-Logger PR #32 / run 24996715587:
local Release builds were clean while CI reported MA0002, MA0049, S2365,
etc. as errors. After repointing the build to the BOM-free version of
.editorconfig, the same source compiled clean.

Switch to `Out-File -Encoding UTF8NoBOM` (PowerShell 6+; GitHub-hosted
`shell: pwsh` runners use PS 7+ so this is supported). Four sites in the
two "Fetch trusted configuration files" blocks.

Downstream consumers will pick up the fix the next time they run their
template-sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 9, 2026 17:59
@Chris-Wolfgang Chris-Wolfgang merged commit f3c58ee into main May 9, 2026
10 of 11 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the fix/pr-yaml-bom-on-protected-config-fetch branch May 9, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the workflow’s “Fetch trusted configuration files from main branch” step to write protected config files as UTF-8 without a BOM, preventing .NET analyzer configuration files (e.g., .editorconfig) from being ignored on CI due to BOM-prefixed content.

Changes:

  • Replaced Out-File -Encoding UTF8 with Out-File -Encoding UTF8NoBOM at four workflow call sites.
  • Keeps existing -NoNewline behavior while ensuring analyzer configuration files remain BOM-free.

This was referenced May 9, 2026
Chris-Wolfgang added a commit that referenced this pull request May 9, 2026
Each of test-linux-core, test-windows, test-macos-core, and security-scan
ran the "Fetch trusted configuration files from main branch" step twice
back-to-back with identical content (modulo trailing whitespace). Drop
the second occurrence in all four jobs so the protected configs are
restored once per job, not twice.

Net effect: 192 lines deleted, no behavior change — second copy was a
no-op since main's configs are already on disk after the first run.
The single remaining occurrence per job retains the same UTF8NoBOM
encoding behavior introduced in #339.

Flagged by Copilot review on the downstream backport
Chris-Wolfgang/ETL-FixedWidth#90 (which this fixes at the canonical
source so every Wolfgang.* repo picks it up on the next sync).
Chris-Wolfgang added a commit that referenced this pull request May 10, 2026
Each of test-linux-core, test-windows, test-macos-core, and security-scan
ran the "Fetch trusted configuration files from main branch" step twice
back-to-back with identical content (modulo trailing whitespace). Drop
the second occurrence in all four jobs so the protected configs are
restored once per job, not twice.

Net effect: 192 lines deleted, no behavior change — second copy was a
no-op since main's configs are already on disk after the first run.
The single remaining occurrence per job retains the same UTF8NoBOM
encoding behavior introduced in #339.

Flagged by Copilot review on the downstream backport
Chris-Wolfgang/ETL-FixedWidth#90 (which this fixes at the canonical
source so every Wolfgang.* repo picks it up on the next sync).
Chris-Wolfgang added a commit to Chris-Wolfgang/String-Extensions that referenced this pull request May 10, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/DbContextBuilder that referenced this pull request May 10, 2026
Backport of
[repo-template#339](Chris-Wolfgang/repo-template#339).

The 'Fetch trusted configuration files from main branch' step writes the
protected configs back via `Out-File -Encoding UTF8` (BOM-prefixed). The
.NET analyzer engine appears to ignore BOM-prefixed `.editorconfig`
files, so project severity overrides don't apply on CI — analyzers fire
at default severity and `TreatWarningsAsErrors` escalates findings that
pass locally.

This is a 4-line workflow-only change: `UTF8` → `UTF8NoBOM` at the four
call sites. PowerShell 6+ supports the encoding token; `shell: pwsh`
runners use PS 7+, so it's safe.

Diagnosed against [In-memory-Logger PR #32 / run
24996715587](https://github.com/Chris-Wolfgang/In-memory-Logger/actions/runs/24996715587/job/73195928572).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Csv that referenced this pull request May 12, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/D20-Dice that referenced this pull request May 12, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/DateTime-Extensions that referenced this pull request May 12, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Json that referenced this pull request May 14, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Transformers that referenced this pull request May 14, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-FixedWidth that referenced this pull request May 14, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Xml that referenced this pull request May 14, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Test-Kit that referenced this pull request May 14, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/Etl-DbClient that referenced this pull request May 16, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chris-Wolfgang added a commit to Chris-Wolfgang/ETL-Transformers that referenced this pull request Jun 19, 2026
Backport of repo-template PR #339. The 'Fetch trusted configuration files
from main branch' step writes .editorconfig / Directory.Build.props /
BannedSymbols.txt back via 'Out-File -Encoding UTF8' which writes UTF-8
*with* BOM. The .NET analyzer engine appears to ignore .editorconfig
files prefixed by a BOM, so project-level severity overrides don't apply
on CI even though they apply locally — analyzers fire at default severity
and TreatWarningsAsErrors then escalates them to errors.

Switch to 'Out-File -Encoding UTF8NoBOM' (PS 6+; the runner uses pwsh).

Diagnosed against Chris-Wolfgang/In-memory-Logger PR #32 / run
24996715587. See Chris-Wolfgang/repo-template#339 for the full write-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants