Bug Report T875734
Visible to All Users

Code Cleanup - An exception is thrown if code contains the VB.NET ‘Handles’ clause

created 5 years ago (modified 5 years ago)

Hello,

I have been experiencing issues with CodeRush Cleanup. It doesn't run on certain files. I have tried to uninstall the CodeRush extension and then reinstall it with no success. I uninstalled the extension using the instructions found here: https://supportcenter.devexpress.com/ticket/details/t713743

The following text is from the Package Log. I opened Visual Studio and opened a file that is causing the issue and then saved it. CodeRush should have ran and changed the header along with other minor changes.

Code
2020.03.31 10:41:28.4638 Error: Message: One or more errors occurred. 2020.03.31 10:41:28.4638 Error: Type: System.AggregateException 2020.03.31 10:41:28.4638 Error: Source: mscorlib 2020.03.31 10:41:28.4638 Error: StackTrace: 2020.03.31 10:41:28.4638 Error: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 2020.03.31 10:41:28.4638 Error: at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 2020.03.31 10:41:28.4638 Error: at System.Threading.Tasks.Task`1.get_Result() 2020.03.31 10:41:28.4638 Error: at DevExpress.CodeRush.Foundation.CodeCleanUp.CleanUpOnSaveService.ProcessDocumentSaved(ITextDocument textDocument) 2020.03.31 10:41:28.4638 Error: InnerException: 2020.03.31 10:41:28.4638 Error: Message: Unable to cast object of type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.MemberAccessExpressionSyntax' to type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.IdentifierNameSyntax'. 2020.03.31 10:41:28.4648 Error: Type: System.InvalidCastException 2020.03.31 10:41:28.4648 Error: Source: Microsoft.CodeAnalysis.VisualBasic 2020.03.31 10:41:28.4648 Error: StackTrace: 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitHandlesClauseItem(HandlesClauseItemSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.HandlesClauseItemSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitListElement[TNode](TNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitList[TNode](SeparatedSyntaxList`1 list) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitHandlesClause(HandlesClauseSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.HandlesClauseSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitMethodStatement(MethodStatementSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.MethodStatementSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitMethodBlock(MethodBlockSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.MethodBlockSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitListElement[TNode](TNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitList[TNode](SyntaxList`1 list) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitClassBlock(ClassBlockSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.ClassBlockSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitListElement[TNode](TNode node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitList[TNode](SyntaxList`1 list) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.VisitCompilationUnit(CompilationUnitSyntax node) 2020.03.31 10:41:28.4648 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.CompilationUnitSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor) 2020.03.31 10:41:28.4658 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxRewriter.Visit(SyntaxNode node) 2020.03.31 10:41:28.4658 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replacer`1.Visit(SyntaxNode node) 2020.03.31 10:41:28.4658 Error: at Microsoft.CodeAnalysis.VisualBasic.Syntax.SyntaxReplacer.Replace[TNode](SyntaxNode root, IEnumerable`1 nodes, Func`3 computeReplacementNode, IEnumerable`1 tokens, Func`3 computeReplacementToken, IEnumerable`1 trivia, Func`3 computeReplacementTrivia) 2020.03.31 10:41:28.4658 Error: at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode.ReplaceCore[TNode](IEnumerable`1 nodes, Func`3 computeReplacementNode, IEnumerable`1 tokens, Func`3 computeReplacementToken, IEnumerable`1 trivia, Func`3 computeReplacementTrivia) 2020.03.31 10:41:28.4658 Error: at Microsoft.CodeAnalysis.SyntaxNodeExtensions.ReplaceNode[TRoot](TRoot root, SyntaxNode oldNode, SyntaxNode newNode) 2020.03.31 10:41:28.4658 Error: at DevExpress.CodeAnalysis.VisualBasic.CodeStyle.ApplyThisQualifierStyleRuleProvider.<Stylize>d__10.MoveNext() 2020.03.31 10:41:28.4658 Error: --- End of stack trace from previous location where exception was thrown --- 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 2020.03.31 10:41:28.4658 Error: at DevExpress.CodeAnalysis.VisualBasic.CodeCleanUp.Providers.ApplyThisStyleCodeCleanUp.<Apply>d__4.MoveNext() 2020.03.31 10:41:28.4658 Error: --- End of stack trace from previous location where exception was thrown --- 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2020.03.31 10:41:28.4658 Error: at DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpEngine.<Apply>d__22.MoveNext() 2020.03.31 10:41:28.4658 Error: --- End of stack trace from previous location where exception was thrown --- 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 2020.03.31 10:41:28.4658 Error: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2020.03.31 10:41:28.4658 Error: at DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpEngine.<Apply>d__31.MoveNext()

I am also attaching the log file for you to analyze. Hopefully there is something that I am doing wrong and can be corrected. I have some files that work and some files that don't. I also attached the VB code file that is causing the error and not running Cleanup.

I can manually run Organize Methods and it works. If I try to run Code Cleanup manually, it will fail with this same log.

BTW, the IDE when setting up this ticket does not populate. It just says 'No results found'. I am using Visual Studio Professional 2017 Version 15.9.21

Thank you for your assistance!
Nathan

Show previous comments (1)
PW PW
Przemyslaw Wlodarczak (DevExpress) 5 years ago

    Nathan,

    Thank you for such a detailed report. With your data, I was able to reproduce the issue with ease. We will let you know when we fix it. Please bear with us.

      Przemyslaw,

      Thank you for the update.

      DevExpress Support Team 5 years ago

        Hello Nathan,

        BTW, the IDE when setting up this ticket does not populate. It just says 'No results found'.

        We've created a separate thread for this part of your initial post and will examine it:

        The IDE list is not populated when creating a CodeRush-related ticket

        Thank you for drawing our attention to this issue.

        Answers approved by DevExpress Support

        created 5 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Comments (3)
          DevExpress Support Team 5 years ago

            We have published the requested patched build and are looking forward to hearing about your results. Meanwhile, we would like to mark this ticket as Public, if you do not mind, to include it in the What's New lists for future maintenance updates.

              Thank you for the HotFix. I will be downloading and applying the fix. I have also marked this as public. Thank you for all the hard work you guys do!

              DevExpress Support Team 5 years ago

                You're welcome, Nathan. Please feel free to contact us in case you face any issues.

                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.