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

VS17.8.0 crash in LinqEnumerableCodeFixProvider #216

Open
yaakov-h opened this issue Nov 23, 2023 · 1 comment
Open

VS17.8.0 crash in LinqEnumerableCodeFixProvider #216

yaakov-h opened this issue Nov 23, 2023 · 1 comment
Labels

Comments

@yaakov-h
Copy link
Member

When pressing Ctrl+. over the WTG3013 error produced by the following function:

public override AttributeCollection GetAttributes()
{
    var attributes = base.GetAttributes()?
        .Cast<Attribute>()
        .Concat(new[] { new ResourceStringKeyOverrideAttribute(dataType.Name) })
        .ToArray();
    return new AttributeCollection(attributes);
}

The LinqEnumerableCodeFixProvider crashes with the following stack trace:

System.NullReferenceException : Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.CSharp.SyntaxFactory.FindConditionalAccessNodeForBinding(CSharpSyntaxNode node)
   at Microsoft.CodeAnalysis.CSharp.Binder.GetReceiverForConditionalBinding(ExpressionSyntax binding,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMemberBindingExpression(MemberBindingExpressionSyntax node,Boolean invoked,Boolean indexed,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindInvocationExpression(InvocationExpressionSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindParenthesizedExpression(ExpressionSyntax innerExpression,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindLeftOfPotentialColorColorMemberAccess(ExpressionSyntax left,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMemberAccess(MemberAccessExpressionSyntax node,Boolean invoked,Boolean indexed,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindInvocationExpression(InvocationExpressionSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindConditionalAccessExpression(ConditionalAccessExpressionSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,BindingDiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindInferredVariableInitializer(BindingDiagnosticBag diagnostics,ExpressionSyntax initializer,BindValueKind valueKind,CSharpSyntaxNode errorSyntax)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindVariableDeclaration(SourceLocalSymbol localSymbol,LocalDeclarationKind kind,Boolean isVar,VariableDeclaratorSyntax declarator,TypeSyntax typeSyntax,TypeWithAnnotations declTypeOpt,AliasSymbol aliasOpt,BindingDiagnosticBag diagnostics,Boolean includeBoundType,CSharpSyntaxNode associatedSyntaxNode)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindDeclarationStatementParts(LocalDeclarationStatementSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindLocalDeclarationStatement(LocalDeclarationStatementSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlock(BlockSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode declaration,BlockSyntax blockBody,ArrowExpressionClauseSyntax expressionBody,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode syntax,BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.EnsureNullabilityAnalysisPerformedIfNecessary()
   at Microsoft.CodeAnalysis.CSharp.MethodBodySemanticModel.TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel,Int32 position,StatementSyntax statement,PublicSemanticModel& speculativeModel)
   at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel,Int32 position,StatementSyntax statement,PublicSemanticModel& speculativeModel)
   at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.TryGetSpeculativeSemanticModel(Int32 position,StatementSyntax statement,SemanticModel& speculativeModel)
   at Microsoft.CodeAnalysis.CSharp.Utilities.SpeculationAnalyzer.CreateSpeculativeSemanticModelForNode(SyntaxNode nodeToSpeculate,SemanticModel semanticModel,Int32 position,Boolean isInNamespaceOrTypeContext)
   at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService`3.<>c__DisplayClass15_1.<ReduceAsync>b__0[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService`3.ReduceAsync[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService`3.ReduceCoreAsync[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService`3.ReduceAsync[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.CleanupDocumentAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.PostProcessChangesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.PostProcessChangesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.PostProcessAsync(<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.GetPreviewResultAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.PreviewChangesSuggestedAction.CreateAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.GetPreviewChangesFlavorAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.CreateAllFlavorsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

Interestingly, we don't seem to be in that stack trace at all.

@yaakov-h yaakov-h added the bug label Nov 23, 2023
@brian-reichle
Copy link
Contributor

I suspect this would be a bug in Roslyn itself, but we should reduce it to a more direct reproduction first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants