Bug Report T892197
Visible to All Users

Code Cleanup - An error occurred when saving a Visual Basic file

created 5 years ago (modified 5 years ago)

CodeRush won't organize/cleanup the following code:

Visual Basic
Imports System.Xml Imports System.Xml.Linq Public Class Class1 Private Function ParseSyntaxData() As Dictionary(Of String, String) ' Do not get address as that should be brought in from Epicor Dim dicResult As New Dictionary(Of String, String) Dim strLines() As String '= Me.mmoDetailsCaseNotes.Lines Dim intStart As Integer = 0 Dim intEnd As Integer = 0 Dim intStartSearch As Integer = 0 Dim intErrorCount As Integer = 0 Dim intCount As Integer = 0 SearchAgain: ' This will find the most recent xml For i As Integer = intStartSearch To strLines.Length - 1 If Trim(strLines(i)).IndexOf("<ServicePro>") = 0 Then intStart = i ElseIf Trim(strLines(i)).IndexOf("</ServicePro>") = 0 Then intEnd = i intStartSearch = i + 1 Exit For End If If i = strLines.Length - 1 Then GoTo Finish Next If intStart + intEnd >= 2 Then Dim strSyntax As String strSyntax = "<?xml version=""1.0""?>" For i As Integer = intStart To intEnd strSyntax += strLines(i) Next XMLFIX: Try intCount += 1 Catch ex As XmlException ' XML quick fix strSyntax = strSyntax.Replace(CChar("&"), "&amp;") strSyntax = strSyntax.Replace(CChar("'"), "&apos;") intErrorCount += 1 If intErrorCount <= 1 Then GoTo XMLFIX End If If intErrorCount > 1 Then ex.Data.Add("xmlTest", strSyntax) 'ex.Data.Add("Case", Me.txtCaseNumber.Text) 'ex.Data.Add("Call", Me.txtCallNumber.Text) Dim intResult As Integer = msgAdv.Show($"{MessageStrings.DispatchSyntaxTestingError1}{intCount}. {MessageStrings.DispatchSyntaxTestingError2}", MessageBoxButtons.YesNo) If intResult = vbYes Then GoTo SearchAgain Else GoTo Finish End If End Try Try Dim xml As System.Xml.Linq.XDocument = XDocument.Parse(strSyntax) For Each node In xml.Elements("ServicePro").Nodes Select Case node.NodeType Case System.Xml.XmlNodeType.Element dicResult(DirectCast(node, XElement).Name.ToString) = DirectCast(node, XElement).Value End Select Next Catch ex As Exception ex.Data.Add("xmlTest", strSyntax) 'ex.Data.Add("Case", Me.txtCaseNumber.Text) 'ex.Data.Add("Call", Me.txtCallNumber.Text) Dim strMessage As String = MessageStrings.DispatchSyntaxProcessingError msgAdv.ShowException(ex, False, strMessage) GoTo Finish End Try If intStartSearch < strLines.Length Then GoTo SearchAgain End If Finish: Return dicResult End Function End Class

The following is taken from the error log after attempting to save the vb file.

Code
2020.05.21 12:28:55.4442 Error: ApplyCount for Apply variable declaration style provider exceeded on Class1.vb document 2020.05.21 12:28:55.4452 Error: Message: One or more errors occurred. 2020.05.21 12:28:55.4452 Error: Type: System.AggregateException 2020.05.21 12:28:55.4452 Error: Source: mscorlib 2020.05.21 12:28:55.4452 Error: StackTrace: 2020.05.21 12:28:55.4452 Error: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 2020.05.21 12:28:55.4452 Error: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 2020.05.21 12:28:55.4452 Error: at System.Threading.Tasks.Task`1.get_Result() 2020.05.21 12:28:55.4452 Error: at DevExpress.CodeRush.Foundation.CodeCleanUp.CleanUpOnSaveService.ProcessDocumentSaved(ITextDocument textDocument) 2020.05.21 12:28:55.4452 Error: InnerException: 2020.05.21 12:28:55.4452 Error: Message: Exception of type 'DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpHangedException' was thrown. 2020.05.21 12:28:55.4452 Error: Type: DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpHangedException 2020.05.21 12:28:55.4452 Error: Source: DevExpress.CodeAnalysis 2020.05.21 12:28:55.4452 Error: StackTrace: 2020.05.21 12:28:55.4452 Error: at DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpEngine.<Apply>d__22.MoveNext() 2020.05.21 12:28:55.4452 Error: --- End of stack trace from previous location where exception was thrown --- 2020.05.21 12:28:55.4452 Error: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 2020.05.21 12:28:55.4452 Error: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2020.05.21 12:28:55.4452 Error: at DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpEngine.<Apply>d__31.MoveNext()

I also attached the my CodeRush Settings.

Any ideas what I might be doing wrong or what is causing CodeRush to fail?

Thanks,
Nathan

Comments (1)
DevExpress Support Team 5 years ago

    Hi Nathan,

    Thank you for reaching out to us and for your code sample. I replicated this behavior and forwarded this thread to our R&D team for further research. We will update this thread once we have any news.

    Answers approved by DevExpress Support

    created 5 years ago

    We have addressed the issue described in this ticket and will include a fix in our next maintenance update. To apply this solution before official release, request a hotfix by clicking the appropriate version link.

    Note: Hotfixes may be unavailable for betas/updates set for release within a week.

      Comments (2)

        Thank you for the hotfix. It fixed the issue.

        DevExpress Support Team 5 years ago

          You're welcome, Nathan!
          Feel free to contact us in case of any further difficulty.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.