Skip to content

IncrementallyParse fails for certain text changes #47234

@sharwell

Description

@sharwell

Version Used: 16.8 IntPreview 3

Steps to Reproduce:

🔗 AB#1180669
🔗 AB#1193786
🔗 AB#1216814
🔗 AB#1217030
🔗 AB#1217491
🔗 AB#1220119
🔗 AB#1221787

  1. Create a Xunit test project(.NET core)
  2. Add test property and priority label to the method
[Fact]
        [Trait("cat", "TA")]
 
        [Trait("cat", "TB")]
        public void Test4()
        {
 
        }
[Fact]
        [Trait("cat", "TA")]
      
        public void Test6()
        {
 
        }
 
        [Fact]
       
        [Trait("cat", "TB")]
        public void Test2()
        {
 
        }
 
        [Fact]
        [Trait("cat", "TA")]
        [Trait("cat", "TB")]
        public void Test34()
        {
 
        }

Notes:

This seems similar to #39258, but occurs in a much newer build.

Actual Behavior:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: start
 at Microsoft.CodeAnalysis.Text.TextSpan..ctor(Int32 start, Int32 length)
 at Microsoft.CodeAnalysis.Text.ChangedText.Merge(ImmutableArray`1 oldChanges, ImmutableArray`1 newChanges)
 at Microsoft.CodeAnalysis.Text.ChangedText.Merge(IReadOnlyList`1 changeSets)
 at Microsoft.CodeAnalysis.Text.ChangedText.GetChangeRanges(SourceText oldText)
 at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChangedText(SourceText newText)
 at Microsoft.CodeAnalysis.DocumentState.IncrementallyParse(TextAndVersion newTextAndVersion, TreeAndVersion oldTreeAndVersion, CancellationToken cancellationToken)
 at Microsoft.CodeAnalysis.DocumentState.<IncrementallyParseTreeAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
--- 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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.CodeAnalysis.DocumentState.<GetSyntaxTreeAsync>d__48.MoveNext()
 at Microsoft.CodeAnalysis.Shared.Extensions.DocumentExtensions.<GetRequiredSyntaxTreeAsync>d__9.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.CodeAnalysis.Document.<GetSyntaxRootAsync>d__20.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.CodeAnalysis.Remote.RemoteDocumentDifferenceService.<GetDifferenceAsync>d__2.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.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.<EnqueueWorkItemAsync>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.<EnqueueWorkItemAsync>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.<EnqueueWorkItemAsync>d__44.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.CodeAnalysis.Shared.Extensions.DocumentExtensions.<GetRequiredSemanticModelAsync>d__8.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.CodeAnalysis.Classification.AbstractSyntaxClassificationService.<AddSemanticClassificationsAsync>d__5.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.CodeAnalysis.Classification.AbstractClassificationService.<AddSemanticClassificationsInCurrentProcessAsync>d__4.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.CodeAnalysis.Remote.CodeAnalysisService.<>c__DisplayClass35_0.<<GetSemanticClassificationsAsync>b__0>d.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.CodeAnalysis.Remote.ServiceBase.<RunServiceAsync>d__18`1.MoveNext()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions