Skip to content

ArgumentOutOfRangeException in CompositeText.RemoveSplitLineBreaksAndEmptySegments #78985

@mavasani

Description

@mavasani

Version Used: 4.14.0

Regression Information: I verified that the issue does not repro with the same code against MS.CA version 4.10.0. Investigating a bit, I see that the method CompositeText.RemoveSplitLineBreaksAndEmptySegments was added with this commit last August: 8e98fc9#diff-f7aa04037254dd4688389954443cbad14c756cc9edcdb5536ce52c8904b1252f
This confirms that this is a recent regression from this commit

Steps to Reproduce:
Unzip and Run the attached console app:

ConsoleApp1.zip

  • It works fine with MS.CA 4.10.0
  • ArgumentOutOfRangeException with MS.CA 4.14.0
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'span')
   at Microsoft.CodeAnalysis.Text.SubText..ctor(SourceText text, TextSpan span)
   at Microsoft.CodeAnalysis.Text.SubText.GetSubText(TextSpan span)
   at Microsoft.CodeAnalysis.Text.CompositeText.RemoveSplitLineBreaksAndEmptySegments(ArrayBuilder`1 segments)
   at Microsoft.CodeAnalysis.Text.CompositeText.ToSourceText(ArrayBuilder`1 segments, SourceText original, Boolean adjustSegments)
   at Microsoft.CodeAnalysis.Text.SourceText.WithChanges(IEnumerable`1 changes)
   at Microsoft.CodeAnalysis.Text.SourceText.WithChanges(TextChange[] changes)
   at Program.<Main>$(String[] args) in Q:\source\ConsoleApp1\ConsoleApp2\Program.cs:line 11

Q:\source\ConsoleApp1\ConsoleApp2\bin\Debug\net8.0\ConsoleApp2.exe (process 183496) exited with code -532462766 (0xe0434352).
Press any key to close this window . . .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions