Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in CSharpInlineMethodRefactoringProvider when multiple fields are declared in a field declaration #76656

Open
jhinder opened this issue Jan 7, 2025 · 0 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@jhinder
Copy link
Contributor

jhinder commented Jan 7, 2025

Version Used: VS 17.12.2

Steps to Reproduce:

static class C
{
    static readonly object A = M(),
                           B = M();

    private static object M() => null!;
}

Place the caret at some location in the RHS of any of the field assignment expressions. If the exception doesn't yet occur, try opening the lightbulb menu.

Expected Behavior: No exception.

Actual Behavior:

System.InvalidOperationException : Sequence contains more than one element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at Microsoft.CodeAnalysis.InlineMethod.AbstractInlineMethodRefactoringProvider`4.GetCallerSymbol(TInvocationSyntax calleeMethodInvocationNode,SemanticModel semanticModel,CancellationToken cancellationToken)
   at async Microsoft.CodeAnalysis.InlineMethod.AbstractInlineMethodRefactoringProvider`4.ComputeRefactoringsAsync[TMethodDeclarationSyntax,TStatementSyntax,TExpressionSyntax,TInvocationSyntax](<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.<>c__DisplayClass12_0.<GetRefactoringFromProviderAsync>b__0(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant