New bug,ArgumentOutOfRangeException

SyntaxEditor for Windows Forms Forum

Posted 7 months ago by hehui - manager, foxtable
Version: 22.1.1
Platform: .NET 5.0
Environment: Windows 10 (64-bit)
Avatar

I enter the following code in syntax editor:

Dim r As Row = Tables("a").Current
If r IsNot Nothing Then
    For Each c As Col In Tables("a").Cols
        If c.name Then
            Dim i As Integer
        End If
    Next

Then click a button to rearrange the format of the above code. The code of the button is:

       Me.ActiveView.ExecuteEditAction(New FormatDocumentAction())


After clicking the button, an argumentoutofrangeexception error will appear:

System.ArgumentOutOfRangeException
HResult=0x80131502
Message=startIndex cannot be larger than the string length.
Arg_ParamName_Name
Source=mscorlib
StackTrace:
at system.string. Substring(Int32 startIndex, Int32 length)
at ActiproSoftware. Internal. K7. ToString (Int32, Int32)
at ActiproSoftware. Internal. Oy. GetSubstring (TextRange LineTerminator)
at ActiproSoftware. Internal. Oy. GetSubstring (Int32, Int32)
at ActiproSoftware. Text. Languages. VB. Implementation. VBTextFormatter. PmM (XR, IToken)
at ActiproSoftware. Text. Languages. VB. Implementation. VBTextFormatter. LMK (XR, IToken)
at ActiproSoftware. Text. Languages. VB. Implementation. VBTextFormatter. XmR (XR, IToken)
at ActiproSoftware. Text. Languages. VB. Implementation. VBTextFormatter. The Format (ITextSnapshot snapshot,ITextPositionRangeCollection selectionPositionRanges, TextFormatMode mode)
ar ActiproSoftware. UI. WinForms. Controls. SyntaxEditor. EditActions. FormatDocumentAction. Execute (IEditorView view)
at ActiproSoftware. UI. WinForms. Controls. SyntaxEditor. Primitives. EditorView. ExecuteEditAction (IEditAction action)
......

[Modified 7 months ago]

Comments (3)

Posted 7 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I'm sorry but I'm not seeing this happen when I paste the code snippet into our Visual Basic Editor demo and press the format document button.  Can you verify that you can reproduce this using that demo, and tell us exactly which version/build you are using?


Actipro Software Support

Posted 7 months ago by hehui - manager, foxtable
Avatar

The version I use is 22.1.2, which is a preview version.
There is no problem with the new example, but this problem does exist in my project, but it doesn't matter. I'll use the try statement to solve it. Please check the code of "actiprosoftware. Internal. K7". This method does not judge the legitimacy of position and length when using "substring".

Now I submit a new bug,copy the following code into "syntaxeditor", and then and press the format document button:

Dim lklb As String = "123"
Dim FCURe As String = "ncd"
Select Case lklb
    Case "11", "22"
        If True Then
            If True Then

                Select Case FCURe
                    Case "a", "b", "c"
                        Dim s As String
                    Case Else
                        Dim xmsa() As String = {"1", "2", "3" }
                        For i As Integer = 0 To xmsa.Length - 1
                            If 1 = 1 Then
                            Dim i As Integer = 100
            End If
            Next

End Select
End If

End If
End Select

You will find that the code has not changed. Normally, the code should be:

Dim lklb As String = "123"
Dim FCURe As String = "ncd"
Select Case lklb
    Case "11", "22"
        If True Then
            If True Then
                Select Case FCURe
                    Case "a", "b", "c"
                        Dim s As String
                    Case Else
                        Dim xmsa() As String = {"1", "2", "3" }
                        For i As Integer = 0 To xmsa.Length - 1
                            If 1 = 1 Then
                                Dim i As Integer = 100
                            End If
                        Next
                End Select
            End If
        End If
End Select
Posted 7 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We would need to be able to debug the issue locally for the substring issue to be able to isolate what could cause that.  If you can tell us how to reproduce it in one of our samples, that would be helpful.

We found the cause of the indenting problem.  It was due to how the parser was assigning an offset range to a switch label AST node when there was a "Case Else" scenario.  It should now be fixed for the next maintenance release.


Actipro Software Support

The latest build of this product (v22.1.3) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.