roslyn: ArgumentOutOfRangeException in CompletionService.GetCompletionsAsync

Version Used: 2.3.2

Steps to Reproduce: Unfortunately I don’t know how to isolate this. This is something I see in logs of my Roslyn-based project, and I wasn’t able to reproduce it locally (however I consistently see it in logs).

I hope you might be able to guess something from the stack trace, or suggest a way to get more information about this.

Stack trace (cleaned up from Application Insights):

System.AggregateException: One or more errors occurred.
Microsoft.CodeAnalysis.DocumentState+<GetSyntaxTreeAsync>d__41.MoveNext
Microsoft.CodeAnalysis.CSharp.Completion.Providers.AttributeNamedParameterCompletionProvider+<ProvideCompletionsAsync>d__5.MoveNext
Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders+<GetContextAsync>d__31.MoveNext
Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders+<ComputeNonEmptyCompletionContextsAsync>d__24.MoveNext
Microsoft.CodeAnalysis.Completion.CompletionServiceWithProviders+<GetCompletionsAsync>d__22.MoveNext

System.AggregateException: One or more errors occurred.
Microsoft.CodeAnalysis.DocumentState+<IncrementallyParseTreeAsync>d__15.MoveNext

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
 Parameter name: start
Microsoft.CodeAnalysis.Text.TextSpan..ctor
Microsoft.CodeAnalysis.Text.ChangedText.Merge
Microsoft.CodeAnalysis.Text.ChangedText.Merge
Microsoft.CodeAnalysis.Text.ChangedText.GetChangeRanges
Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChangedText
Microsoft.CodeAnalysis.DocumentState.IncrementallyParse
Microsoft.CodeAnalysis.DocumentState+<IncrementallyParseTreeAsync>d__15.MoveNext

Expected Behavior: There are no exceptions from CompletionService.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

@ashmind Ah, so yeah, so there’s some bug in our GetTextChanges function between two snapshots of changed text:

            var startingText = SourceText.From(new string('a', 1000));
            var endingText = startingText.WithChanges(new TextChange(new TextSpan(36, 710), ""))
                                         .WithChanges(new TextChange(new TextSpan(36, 36), "bc"))
                                         .WithChanges(new TextChange(new TextSpan(38, 38), "defg"));

            var diff = endingText.GetTextChanges(startingText);

…is an isolated repo. @dpoeschl looks like you can ‘enjoy’ some really gnarly span manipulation code from here.