Description
Started the Advent of Code 2017 challenge and pasted in the input string into a .ps1 editor windows.
This crashed Editor Services.
Was able to reproduce.
Input string: https://adventofcode.com/2017/day/1/input
Log
04/12/2017 17:33:37 [NORMAL] - Method "StartLogging" at line 144 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
PowerShell Editor Services Host v1.5.1.0 starting (pid 17852)...
Host application details:
Name: Visual Studio Code Host
ProfileId: Microsoft.VSCode
Version: 1.5.1
Arch: 64-bit
Operating system details:
Version: Microsoft Windows NT 10.0.14393.0
Arch: 64-bit
04/12/2017 17:33:37 [NORMAL] - Method "StartLanguageService" at line 180 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
Language service started, listening on port 15230
04/12/2017 17:33:37 [NORMAL] - Method "StartDebugService" at line 254 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
Debug service started, listening on port 27356
04/12/2017 17:33:37 [NORMAL] - Method "Initialize" at line 220 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Session\PowerShellContext.cs
PowerShell runtime version: 5.1.14393.1884, edition: Desktop
04/12/2017 17:33:37 [NORMAL] - Method "FindPSScriptAnalyzerModule" at line 354 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Analysis\AnalysisService.cs
PSScriptAnalyzer found at C:\Users\brettm\.vscode\extensions\ms-vscode.powershell-1.5.1\modules\PSScriptAnalyzer\PSScriptAnalyzer.psd1
04/12/2017 17:33:38 [NORMAL] - Method "Register" at line 36 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.VSCode\ComponentRegistration.cs
PowerShell Editor Services VS Code module loaded.
04/12/2017 17:33:38 [ERROR] - Method "DispatchMessage" at line 147 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs
MessageDispatcher: No handler registered for Event type 'initialized'
04/12/2017 17:33:38 [ERROR] - Method "DispatchMessage" at line 147 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs
MessageDispatcher: No handler registered for Event type '$/setTraceNotification'
04/12/2017 17:33:38 [ERROR] - Method "OnListenTaskCompleted" at line 391 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs
ProtocolEndpoint message loop terminated due to unhandled exception:
System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at Microsoft.PowerShell.EditorServices.ScriptRegion.Create(IScriptExtent scriptExtent)
at Microsoft.PowerShell.EditorServices.ScriptFileMarker.FromParseError(ParseError parseError)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.PowerShell.EditorServices.ScriptFile.ParseFileContents()
at Microsoft.PowerShell.EditorServices.Workspace.GetFileBuffer(String filePath, String initialBuffer)
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidOpenTextDocumentNotification(DidOpenTextDocumentParams openParams, EventContext eventContext)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at Microsoft.PowerShell.EditorServices.ScriptRegion.Create(IScriptExtent scriptExtent)
at Microsoft.PowerShell.EditorServices.ScriptFileMarker.FromParseError(ParseError parseError)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.PowerShell.EditorServices.ScriptFile.ParseFileContents()
at Microsoft.PowerShell.EditorServices.Workspace.GetFileBuffer(String filePath, String initialBuffer)
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidOpenTextDocumentNotification(DidOpenTextDocumentParams openParams, EventContext eventContext)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
at System.Threading.Tasks.Task.Execute()<---
04/12/2017 17:33:38 [ERROR] - Method "ProtocolEndpoint_UnhandledException" at line 418 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\EditorServicesHost.cs
PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.