Was in the middle of editing some code to test some scenarios, and with this code:
got a bunch of exceptions thrown from the binder. The code is broken, but throwing exceptions isn't great.
StreamJsonRpc.RemoteInvocationException: Unexpected value 'Field' of type 'Microsoft.CodeAnalysis.SymbolKind'
at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\Core\BrokeredServiceConnection.cs:line 217
RPC server exception:
System.InvalidOperationException: Unexpected value 'Field' of type 'Microsoft.CodeAnalysis.SymbolKind'
at Microsoft.CodeAnalysis.Remote.ThrowingTraceListener.Fail(String message, String detailMessage) in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Host\ThrowingTraceListener.cs:line 27
at System.Diagnostics.TraceInternal.Fail(String message)
at System.Diagnostics.Debug.Assert(Boolean condition, String message)
at Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(Object o) in F:\Projects\Roslyn\src\Compilers\Core\Portable\InternalUtilities\ExceptionUtilities.cs:line 21
at Microsoft.CodeAnalysis.CSharp.Symbols.SymbolExtensions.GetOverriddenMember(Symbol member) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Symbols\MemberSymbolExtensions.cs:line 609
at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.<TryCalculateRequiredMembers>g__addCurrentTypeMembers|88_0(Builder& requiredMembersBuilder) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Symbols\NamedTypeSymbol.cs:line 615
at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.TryCalculateRequiredMembers(Builder& requiredMembersBuilder) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Symbols\NamedTypeSymbol.cs:line 604
at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.CalculateRequiredMembersIfRequired() in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Symbols\NamedTypeSymbol.cs:line 565
at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.get_HasRequiredMembersError() in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Symbols\NamedTypeSymbol.cs:line 521
at Microsoft.CodeAnalysis.CSharp.Binder.CheckRequiredMembersInObjectInitializer(MethodSymbol constructor, ImmutableArray`1 initializers, SyntaxNode creationSyntax, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 5000
at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(SyntaxNode node, String typeName, SyntaxNode typeNode, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, InitializerExpressionSyntax initializerSyntaxOpt, TypeSymbol initializerTypeOpt, Boolean wasTargetTyped) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 5545
at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, String typeName, BindingDiagnosticBag diagnostics, TypeSymbol initializerType) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 4475
at Microsoft.CodeAnalysis.CSharp.Binder.<BindObjectCreationExpression>g__bindObjectCreationExpression|431_1(ObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 4247
at Microsoft.CodeAnalysis.CSharp.Binder.BindObjectCreationExpression(ObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 4223
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 584
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 517
at Microsoft.CodeAnalysis.CSharp.Binder.BindValue(ExpressionSyntax node, BindingDiagnosticBag diagnostics, BindValueKind valueKind) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 235
at Microsoft.CodeAnalysis.CSharp.Binder.BindPossibleArrayInitializer(ExpressionSyntax node, TypeSymbol destinationType, BindValueKind valueKind, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1730
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) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1035
at Microsoft.CodeAnalysis.CSharp.Binder.BindVariableDeclaration(LocalDeclarationKind kind, Boolean isVar, VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, TypeWithAnnotations declTypeOpt, AliasSymbol aliasOpt, BindingDiagnosticBag diagnostics, Boolean includeBoundType, CSharpSyntaxNode associatedSyntaxNode) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 939
at Microsoft.CodeAnalysis.CSharp.Binder.BindDeclarationStatementParts(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 706
at Microsoft.CodeAnalysis.CSharp.Binder.BindLocalDeclarationStatement(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 681
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 66
at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1792
at Microsoft.CodeAnalysis.CSharp.Binder.BindBlock(BlockSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1780
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 63
at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 3563
at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 3418
at Microsoft.CodeAnalysis.CSharp.MethodBodySemanticModel.Bind(Binder binder, CSharpSyntaxNode node, BindingDiagnosticBag diagnostics) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MethodBodySemanticModel.cs:line 106
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.<EnsureNullabilityAnalysisPerformedIfNecessary>g__bind|131_0(CSharpSyntaxNode root, Binder& binder, <>c__DisplayClass131_0& ) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 1973
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.EnsureNullabilityAnalysisPerformedIfNecessary() in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 1949
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 2059
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetLowerBoundNode(CSharpSyntaxNode node) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 552
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node, CSharpSyntaxNode& bindableNode, BoundNode& lowestBoundNode, BoundNode& highestBoundNode, BoundNode& boundParent) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 1336
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\MemberSemanticModel.cs:line 1214
at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\SyntaxTreeSemanticModel.cs:line 219
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfo(ExpressionSyntax expression, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\CSharpSemanticModel.cs:line 565
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\CSharpSemanticModel.cs:line 4910
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\CSharp\Portable\Compilation\CSharpSemanticModel.cs:line 5009
at Microsoft.CodeAnalysis.SemanticModel.GetSymbolInfo(SyntaxNode node, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\Core\Portable\Compilation\SemanticModel.cs:line 99
at Microsoft.CodeAnalysis.ModelExtensions.GetSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Compilers\Core\Portable\Compilation\Extensions.cs:line 21
at Microsoft.CodeAnalysis.CSharp.Classification.OperatorOverloadSyntaxClassifier.AddClassifications(SyntaxNode syntax, SemanticModel semanticModel, ClassificationOptions options, ArrayBuilder`1 result, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Workspaces\CSharp\Portable\Classification\SyntaxClassification\OperatorOverloadSyntaxClassifier.cs:line 31
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.Worker.ClassifyNode(SyntaxNode syntax) in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs:line 131
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.Worker.ClassifyNodeOrToken(SyntaxNodeOrToken nodeOrToken) in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs:line 114
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.Worker.ProcessNodes() in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs:line 99
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.Worker.Classify(SemanticModel semanticModel, TextSpan textSpan, ArrayBuilder`1 list, Func`2 getNodeClassifiers, Func`2 getTokenClassifiers, ClassificationOptions options, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs:line 67
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.AddSemanticClassifications(SemanticModel semanticModel, TextSpan textSpan, Func`2 getNodeClassifiers, Func`2 getTokenClassifiers, ArrayBuilder`1 result, ClassificationOptions options, CancellationToken cancellationToken) in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs:line 60
at Microsoft.CodeAnalysis.Classification.AbstractSyntaxClassificationService.<AddSemanticClassificationsAsync>d__6.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs:line 43
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.CodeAnalysis.Classification.AbstractClassificationService.<AddClassificationsInCurrentProcessAsync>d__7.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Core\Portable\Classification\AbstractClassificationService.cs:line 160
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.CodeAnalysis.Remote.RemoteSemanticClassificationService.<>c__DisplayClass20_0.<<GetClassificationsAsync>b__0>d.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Services\SemanticClassification\RemoteSemanticClassificationService.cs:line 44
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<SlowGetSolutionAndRunAsync>d__11`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 199
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<SlowGetSolutionAndRunAsync>d__11`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__10`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 139
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunWithSolutionAsync>d__11`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Services\BrokeredServiceBase.cs:line 92
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<RunServiceImplAsync>d__14`1.MoveNext() in F:\Projects\Roslyn\src\Workspaces\Remote\ServiceHub\Services\BrokeredServiceBase.cs:line 118
Was in the middle of editing some code to test some scenarios, and with this code:
got a bunch of exceptions thrown from the binder. The code is broken, but throwing exceptions isn't great.