Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exception inChangeSignatureCodeRefactoringProvider after wrong automatic closing brace placement #65298

Closed
Labels
Area-IDEuntriagedIssues and PRs which have not yet been triaged by a lead
@jhinder

Description

@jhinder

Version Used: VS 2022 17.4.0

Steps to Reproduce:

  1. Place the cursor at the marked location
  2. Insert{.
  3. Press theReturn key.

Note that the parentheses are balanced at the start.

namespaceN;internalclassC{privatevoidM(){M1(x=>M2("a", y=>M3<int>(z=> $$)));}privatevoidM1(Action<object>a){}privatevoidM2(stringa,Action<object>e){}privatevoidM3<T>(Action<T>a){}}

Expected Behavior:

  1. The closing brace is placed at the correct location, forming an empty statement block:
    M1(x => M2("a", y => M3<int>(z => { })));
  2. The refactoring does not crash due to the malformed syntax.

Actual Behavior:

  1. The closing brace is placed between the second and third closing parenthesis, leading to malformed syntax:M1(x => M2("a", y => M3<int>(z => {))});
  2. After pressingReturn theChangeSignatureCodeRefactoringProvider throws an exception, leading to a gold bar. The stack trace is posted below.

The second problem does not seem to occur when the namespace declaration is missing.

System.NullReferenceException : Object reference not set to an instance of an object.   at Microsoft.CodeAnalysis.ChangeSignature.AbstractChangeSignatureService.GetParameterIndexFromInvocationArgument(SyntaxNode argument,Document document,SemanticModel semanticModel,CancellationToken cancellationToken)   at async Microsoft.CodeAnalysis.CSharp.ChangeSignature.CSharpChangeSignatureService.GetInvocationSymbolAsync(<Unknown Parameters>)   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at async Microsoft.CodeAnalysis.ChangeSignature.AbstractChangeSignatureService.GetChangeSignatureContextAsync(<Unknown Parameters>)   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at async Microsoft.CodeAnalysis.ChangeSignature.AbstractChangeSignatureService.GetChangeSignatureCodeActionAsync(<Unknown Parameters>)   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at async Microsoft.CodeAnalysis.ChangeSignature.ChangeSignatureCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp