Bug Report T890796
Visible to All Users

Visual Studio's Extract Method refactoring throws NullReferenceException when CodeRush is installed

created 5 years ago (modified 5 years ago)

[DevExpress Support Team: CLONED FROM T877993: Constant CodeRush exceptions]

I get a similar error. If I uninstall coderush the error stops. Not sure why the stack trace doesn't include any reference to coderush, but the error certainly starts and stops based on if its installed and running. I have VS 2019 (Version 16.5.5) with the latest version of DevExpress Coderush v20.1.3

Clipboard-File-1.png

System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.GenerateMethodNameFromUserPreference()
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.GenerateMethodNameForStatementGenerators()
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.SingleStatementCodeGenerator.CreateMethodName()
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator…ctor(InsertionPoint insertionPoint,SelectionResult selectionResult,AnalyzerResult analyzerResult,OptionSet options,Boolean localFunction)
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.Create(InsertionPoint insertionPoint,SelectionResult selectionResult,AnalyzerResult analyzerResult,OptionSet options,Boolean localFunction)
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.GenerateCodeAsync(InsertionPoint insertionPoint,SelectionResult selectionResult,AnalyzerResult analyzeResult,OptionSet options,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ExtractLocalFunction(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

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.

    created 5 years ago (modified 5 years ago)

    Updated on 13-Jul-2020

    We've finally found a way to replicate this problem and confirm that CodeRush is involved in this situation. Let me take a moment to apologize for misinforming you in our previous replies.

    We have prepared a patched CodeRush build that should fix these exceptions - DevExpress.CodeRush-20.1.5.20195.vsix. Please give it a try a let us know whether or not this helps.

    Old answer

    Joseph, unfortunately, I didn't managed to reproduce the issue locally.

    I have used a clean machine with the same setup as yours (Visual Studio v16.5.5, CodeRush v20.1.3) but my attempts were unsuccessful. I've also discussed this issue with our team, but it's still unclear for us how CodeRush might affect the built-in Visual Studio functionality.

    Having searched for this error over the web, I have found that a similar problem was reported in the dotnet/roslyn repository:
    ExtractMethodCodeRefactoringProvider encountered an error and has been disabled. This issue was closed as a duplicate, but the original issue is still open. It looks like CodeRush somehow provokes this issue, but the problem itself seems the be related to a bug in Visual Studio and we cannot do much to address it at the CodeRush level.

      Show previous comments (13)
      SG SG
      Stephane Grobety 5 years ago

        Thank you Alex. I didn't realize that was a different version. It seems to have solved the issue for me.

        DevExpress Support Team 5 years ago

          Stephane,

          Thank you for keeping me informed. Should any further questions arise, feel free to contact us.

          DL DL
          Darren Lawrence 5 years ago

            I would like to comment that since the update I have not had any more occurrences so it does indeed appear solved

            Now I just need to stop the constant out of memory issues with VS with large solutions! after some time (No DevExpress related)

            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.