Skip to content

Add UTF-8 BOM to PowerShell files with non-ASCII characters#2195

Open
Copilot wants to merge 1 commit intomainfrom
copilot/fix-psscriptanalyzer-startlinenumber-error
Open

Add UTF-8 BOM to PowerShell files with non-ASCII characters#2195
Copilot wants to merge 1 commit intomainfrom
copilot/fix-psscriptanalyzer-startlinenumber-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

❔What, Why & How

PSScriptAnalyzer CI fails with:

Exception getting "Line": "The property 'StartLineNumber' cannot be found on this object."

Two files contain non-ASCII characters (box-drawing ├│└, em-dash ) without UTF-8 BOM. This triggers PSUseBOMForUnicodeEncodedFile, a file-level rule that emits diagnostic records with no Line property — crashing ConvertTo-SARIF when it accesses $this.Extent.StartLineNumber.

  • Added UTF-8 BOM to Tests/CompileFromWorkspace.Test.ps1 and e2eTests/scenarios/WorkspaceCompilation/runtest.ps1, consistent with all other .ps1/.psm1 files in the repo that contain non-ASCII content.

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

…alyzer CI failure

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/4bad420d-b6e0-4142-9144-8987b7ccbaba

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
@mazhelez mazhelez marked this pull request as ready for review April 1, 2026 14:10
@mazhelez mazhelez requested a review from a team as a code owner April 1, 2026 14:10
Copilot AI review requested due to automatic review settings April 1, 2026 14:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a CI failure in PSScriptAnalyzer/ConvertTo-SARIF by ensuring PowerShell scripts that contain non-ASCII characters are encoded as UTF-8 with BOM, satisfying PSUseBOMForUnicodeEncodedFile.

Changes:

  • Added UTF-8 BOM to Tests/CompileFromWorkspace.Test.ps1 (contains box-drawing characters in help text).
  • Added UTF-8 BOM to e2eTests/scenarios/WorkspaceCompilation/runtest.ps1 (contains em-dash characters in comments).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Tests/CompileFromWorkspace.Test.ps1 Adds UTF-8 BOM so non-ASCII box-drawing characters don’t trigger the analyzer/SARIF crash.
e2eTests/scenarios/WorkspaceCompilation/runtest.ps1 Adds UTF-8 BOM so non-ASCII em-dashes don’t trigger the analyzer/SARIF crash.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mazhelez mazhelez enabled auto-merge (squash) April 1, 2026 15:30
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.

4 participants