Skip to content

Crash on CSharpConvertToRecordRefactoringProvider caused by abstract member #78664

@John-Leitch

Description

@John-Leitch

Version Used:

Encountered in VS 2022 17.14.0 Preview 7.0. Also repro'ed in main.

Steps to Reproduce:

Attempt to convert the following code to a record:

namespace N
{
    public abstract class C
    {
        public string? S { get; set; }

        public abstract System.Guid F();
    }
}

Expected Behavior:
Conversion to record.

Actual Behavior:
Crash:

Image

Stack Trace:

System.InvalidOperationException : Operation is not valid due to the current state of the object.
   at Microsoft.CodeAnalysis.Shared.Extensions.SemanticModelExtensions.GetRequiredOperation(SemanticModel semanticModel,SyntaxNode node,CancellationToken cancellationToken)
   at async Microsoft.CodeAnalysis.CSharp.ConvertToRecord.ConvertToRecordEngine.ConvertToPositionalRecordAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass16_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugCommunityThe pull request was submitted by a contributor who is not a Microsoft employee.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions