Skip to content

Exception when typing something at the top of a new script file in .NET Core project #4115

@cartermp

Description

@cartermp
  1. Clone this solution: https://github.com/cartermp/giraffesample
  2. Add a script file in the web app project
  3. Type #load

Observe this:

exn

  <entry>
    <record>2028</record>
    <time>2017/12/13 20:56:52.395</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.&#x000D;&#x000A;Parameter name: index&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Implementation.UnaryStringRebuilder.GetChar(Char[] content, Int32 index)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Implementation.StringRebuilderForChars.get_Item(Int32 index)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Implementation.CachingTextImage.get_Item(Int32 position)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Text.Extensions.SnapshotSourceText.get_Item(Int32 position)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.FSharp.Editor.FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText sourceText, Int32 caretPosition, CompletionTriggerKind trigger, FSharpFunc`2 getInfo)&#x000D;&#x000A;   at Microsoft.VisualStudio.FSharp.Editor.FSharpCompletionProvider.ShouldTriggerCompletion(SourceText sourceText, Int32 caretPosition, CompletionTrigger trigger, OptionSet _arg1)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.&lt;&gt;c__DisplayClass33_0.&lt;ShouldTriggerCompletion&gt;b__0(CompletionProvider p)&#x000D;&#x000A;   at 
System.Linq.ImmutableArrayExtensions.Any[T](ImmutableArray`1 immutableArray, Func`2 predicate)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders.ShouldTriggerCompletion(SourceText text, Int32 caretPosition, CompletionTrigger trigger, ImmutableHashSet`1 roles, OptionSet options)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion.Controller.IsTextualTriggerCharacter(CompletionService completionService, Char ch, OptionSet options)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion.Controller.Microsoft.CodeAnalysis.Editor.ICommandHandler&lt;Microsoft.CodeAnalysis.Editor.Commands.TypeCharCommandArgs&gt;.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.CommandHandlers.AbstractCompletionCommandHandler.ExecuteCommandWorker[TCommandArgs](TCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.CommandHandlers.AbstractCompletionCommandHandler.Microsoft.CodeAnalysis.Editor.ICommandHandler&lt;Microsoft.CodeAnalysis.Editor.Commands.TypeCharCommandArgs&gt;.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.&lt;&gt;c__DisplayClass6_1`1.&lt;ExecuteHandlers&gt;b__1()&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Formatting.FormatCommandHandler.ExecuteReturnOrTypeCommand(CommandArgs args, Action nextHandler, CancellationToken cancellationToken)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Formatting.FormatCommandHandler.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.&lt;&gt;c__DisplayClass6_1`1.&lt;ExecuteHandlers&gt;b__1()&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.HandlePossibleTypingCommand(CommandArgs args, Action nextHandler, Action`1 actionIfInsideActiveSpan)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.&lt;&gt;c__DisplayClass6_1`1.&lt;ExecuteHandlers&gt;b__1()&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp.Controller.Microsoft.CodeAnalysis.Editor.ICommandHandler&lt;Microsoft.CodeAnalysis.Editor.Commands.TypeCharCommandArgs&gt;.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.CommandHandlers.SignatureHelpCommandHandler.ExecuteCommandWorker[TCommandArgs](TCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.CommandHandlers.SignatureHelpCommandHandler.Microsoft.CodeAnalysis.Editor.ICommandHandler&lt;Microsoft.CodeAnalysis.Editor.Commands.TypeCharCommandArgs&gt;.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.ExecuteHandlers[T](IList`1 commandHandlers, T args, Action lastHandler)&#x000D;&#x000A;   at 
Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.Microsoft.CodeAnalysis.Editor.ICommandHandlerService.Execute[T](IContentType contentType, T args, Action lastHandler)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecuteTypeCharacter(IntPtr pvaIn, ITextBuffer subjectBuffer, IContentType contentType, Action executeNextCommandTarget)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecuteVisualStudio2000(Guid&amp; pguidCmdGroup, UInt32 commandId, UInt32 executeInformation, IntPtr pvaIn, IntPtr pvaOut, ITextBuffer subjectBuffer, IContentType contentType)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.Exec(Guid&amp; pguidCmdGroup, UInt32 commandId, UInt32 executeInformation, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.VsKeyboardFilter.SendCommand(Guid cmdGroup, UInt32 cmdID, Object inParam)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Editor.Implementation.VsKeyboardFilter.TextInput(TextCompositionEventArgs args)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Editor.Implementation.KeyProcessorDispatcher.&lt;&gt;c.&lt;DispatchTextInputEvents&gt;b__6_0(KeyProcessor p, TextCompositionEventArgs args)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Editor.Implementation.KeyProcessorDispatcher.&lt;&gt;c__DisplayClass10_1`1.&lt;Dispatch&gt;b__0()&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

Relevant line:

Microsoft.VisualStudio.FSharp.Editor.FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText sourceText, Int32 caretPosition, CompletionTriggerKind trigger, FSharpFunc`2 getInfo)&#x000D;&#x000A;   at Microsoft.VisualStudio.FSharp.Editor.FSharpCompletionProvider.ShouldTriggerCompletion(SourceText sourceText, Int32 caretPosition, CompletionTrigger trigger, OptionSet _arg1)&#x000D;&#x000A;

x000D --> 13
x000A -->10

After making the dialog goes away, everything works. I can't reproduce this easily, but I have seen it twice today.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions