◐ Shell
clean mode source ↗

Replace custom method with File.ReadAllText() in ScriptAnalysis.cs by amritanand-py · Pull Request #26060 · PowerShell/PowerShell

…ine\Modules\ScriptAnalysis.cs

The ReadScript method was retrieving a SafeFileHandle from the FileStream but never using it.
This line was unnecessary since proper disposal is already handled by the using blocks.

Changes

Removed redundant SafeFileHandle assignment.

@iSazonov added the CL-CodeCleanup

Indicates that a PR should be marked as a Code Cleanup change in the Change Log

label

Sep 16, 2025
The ReadScript helper method has been removed, and all call sites have been updated to use File.ReadAllText(path, Encoding.Default) directly.
Changes

Deleted the ReadScript method from ScriptAnalysis.cs.

Replaced all usages of ReadScript with:
File.ReadAllText(path, Encoding.Default)

iSazonov

@iSazonov

@amritanand-py

iSazonov

@iSazonov iSazonov changed the title Remove unused SafeFileHandle in PowerShell/src/System.Management.Automation/engine/Modules/ScriptAnalysis.cs Replace custom method with File.ReadAllText() ScriptAnalysis.cs

Oct 8, 2025

@iSazonov iSazonov changed the title Replace custom method with File.ReadAllText() ScriptAnalysis.cs Replace custom method with File.ReadAllText() in ScriptAnalysis.cs

Oct 8, 2025

@iSazonov iSazonov added CL-CodeCleanup

Indicates that a PR should be marked as a Code Cleanup change in the Change Log

and removed CL-CodeCleanup

Indicates that a PR should be marked as a Code Cleanup change in the Change Log

labels

Oct 15, 2025

SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request

Dec 12, 2025

kilasuit pushed a commit to kilasuit/PowerShell that referenced this pull request

Jan 2, 2026

JustinGrote pushed a commit to JustinGrote/PowerShell that referenced this pull request

Jun 2, 2026