Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Cannot determine line endings as the text probably contain mixed line endings.

Open
#2,074 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, powershell
Domain
tooling

Research direction

Start by reproducing the failure with Invoke-Formatter and the supplied Get-Content -Raw and Set-Content commands on PowerShell 5.1. Read the EditableText.GetNumNewLineCharacters and GetNewLineCharacters stack frames, then inspect the Formatter.Format path. Done means the reported mixed-line-ending input is handled without the ArgumentException and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Description

Issue - Bug

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

$scriptContent = Get-Content -Path "C:\temp\myscript_posh_v2.ps1" -Raw
Invoke-Formatter -ScriptDefinition $scriptContent | Set-Content -Path "C:\temp\myscript_posh_v2.ps1"
$error[0] | select *

Expected behavior


Actual behavior

PSMessageDetails :
Exception : System.ArgumentException: Cannot determine line endings as the text probably contain mixed line endings.
Parameter name: text
at Microsoft.Windows.PowerShell.ScriptAnalyzer.EditableText.GetNumNewLineCharacters(String text, String[]& lines)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.EditableText.GetNewLineCharacters(String text, String[]& lines)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.EditableText..ctor(String text)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Formatter.Format[TCmdlet](String scriptDefinition, Settings settings, Range range, TCmdlet cmdlet)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeFormatterCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject :
CategoryInfo : NotSpecified: (:) [Invoke-Formatter], ArgumentException
FullyQualifiedErrorId : System.ArgumentException,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeFormatterCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at , : line 2
PipelineIterationInfo : {}

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable

Name                           Value                                                                                                                                                                        
----                           -----                                                                                                                                                                        
PSVersion                      5.1.26100.1882                                                                                                                                                               
PSEdition                      Desktop                                                                                                                                                                      
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                      
BuildVersion                   10.0.26100.1882                                                                                                                                                              
CLRVersion                     4.0.30319.42000                                                                                                                                                              
WSManStackVersion              3.0                                                                                                                                                                          
PSRemotingProtocolVersion      2.3                                                                                                                                                                          
SerializationVersion           1.1.0.1       

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.23.0
Dominant language
C#
Stars
2.2k
Forks
415
Avg merge
13h 1m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSScriptAnalyzer

All issues in PowerShell/PSScriptAnalyzer

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.