Roslyn: Lots of code refactoring providers crashes when entering [ before a function argument.

Created on 18 Oct 2019  路  4Comments  路  Source: dotnet/roslyn

_This issue has been moved from a ticket on Developer Community._


The following refactoring providers crashes when I try to type a [ before a function argument with almost the same stacktrace:

  • ReplacePropertyWithMethodsCodeRefactoringProvider
  • ReplaceMethodWithPropertyCodeRefactoringProvider
  • CSharpIntroduceUsingStatementCodeRefactoringProvider
  • CSharpConvertAnonymousTypeToClassCodeRefactoringProvider
  • CSharpInitializeMemberFromParameterCodeRefactoringProvider
  • CSharpAddParameterCheckCodeRefactoringProvider

Stacktrace (I just put one as an example since all are the same down to at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringContextExtensions.TryGetRelevantNodeAsync[TSyntaxNode](<Unknown Parameters>):

System.ArgumentOutOfRangeException : Specified argument was out of the range of valid values.
Parameter name: position
   at Microsoft.CodeAnalysis.SyntaxNode.FindTokenCore(Int32 position,Boolean findInsideTrivia)
   at Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeExtensions.GetInitialToken(SyntaxNode root,Int32 position,Boolean includeSkipped,Boolean includeDirectives,Boolean includeDocumentationComments)
   at Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeExtensions.FindTokenOnRightOfPosition(SyntaxNode root,Int32 position,Boolean includeSkipped,Boolean includeDirectives,Boolean includeDocumentationComments)
   at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.GetStartOfNodeExcludingAttributes(SyntaxNode node)
   at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.IsOnHeader[THoleSyntax](Int32 position,SyntaxNode ownerOfHeader,SyntaxNodeOrToken lastTokenOrNodeOfHeader,ImmutableArray`1 holes)
   at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.IsOnHeader(Int32 position,SyntaxNode ownerOfHeader,SyntaxNodeOrToken lastTokenOrNodeOfHeader)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxFactsService.IsOnParameterHeader(SyntaxNode root,Int32 position,SyntaxNode& parameter)
   at Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2. <ExtractNodesInHeader>d__7.MoveNext()
   at System.Linq.Enumerable. <OfTypeIterator>d__95`1.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2.AddNonHiddenCorrectTypeNodes[TSyntaxNode](IEnumerable`1 nodes,ArrayBuilder`1 resultBuilder,CancellationToken cancellationToken)
   at async Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2.GetRelevantNodesAsync[TExpressionSyntax,TArgumentSyntax,TSyntaxNode](<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringContextExtensions.GetRelevantNodesAsync[TSyntaxNode](<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringContextExtensions.TryGetRelevantNodeAsync[TSyntaxNode](<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.ReplacePropertyWithMethods.AbstractReplacePropertyWithMethodsService`5.GetPropertyDeclarationAsync[TIdentifierNameSyntax,TExpressionSyntax,TCrefSyntax,TStatementSyntax,TPropertySyntax]( <Unknown Parameters>)
   at async Microsoft.CodeAnalysis.ReplacePropertyWithMethods.ReplacePropertyWithMethodsCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Original Comments

Visual Studio Feedback System on 10/15/2019, 11:25 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Visual Studio Feedback System on 10/18/2019, 09:43 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

Area-IDE Bug Developer Community IDE-CodeStyle Resolution-Fixed

Most helpful comment

It was me that added this issue to Visual Studio Feedback, so if there is anything just notfiy me!

All 4 comments

馃摑 This is very similar to #38502, but this issue was reported with version 16.3.5, which is newer than the version where this was supposed to be fixed.

It was me that added this issue to Visual Studio Feedback, so if there is anything just notfiy me!

Thanks for reporting @dozer75 . I verified this reproduces on 16.3 but is fixed in 16.4 preview 2. If this is causing issue you can upgrade to the preview channel, or just wait for 16.4 to release out of preview.

Also, thanks for the comments on repro steps and clear report. It makes my life much easier :)

@ryzngard Can you set the specific milestone for this issue and update #39775 to match?

Was this page helpful?
0 / 5 - 0 ratings