dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

Feature "Diagnostic analyzer runner" is currently unavailable due to an internal error (due to an assert) #67015

Open AlekseyTs opened 1 year ago

AlekseyTs commented 1 year ago

Start with (but the same happens for records as well)

class C1(int x);

class C3(int a10000, int a20000) : C1(a10000 + 1)
{
    int F1 = a10000;

    int M1() => a10000 + a20000;
}

Set cursor right before the 1 in C1(a10000 + 1) and start pressing BackSpace button

Observed:

StreamJsonRpc.RemoteInvocationException: Assertion failed
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__145`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.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\Core\BrokeredServiceConnection.cs:line 192
RPC server exception:
System.InvalidOperationException: Assertion failed
      at Microsoft.CodeAnalysis.Remote.ThrowingTraceListener.Fail(String message, String detailMessage) in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Host\ThrowingTraceListener.cs:line 27
      at System.Diagnostics.TraceInternal.Fail(String message)
      at System.Diagnostics.Debug.Assert(Boolean condition)
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.GetOperationsToAnalyze(ImmutableArray`1 operationBlocks) in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 3083
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.<>c__DisplayClass12_0.<TryExecuteDeclaringReferenceActions>g__getOperationsToAnalyzeWithStackGuard|4(ImmutableArray`1 operationBlocksToAnalyze) in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 2836
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.<>c__DisplayClass12_0.<TryExecuteDeclaringReferenceActions>g__executeExecutableCodeActions|3() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 2803
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions(SyntaxReference decl, Int32 declarationIndex, SymbolDeclaredCompilationEvent symbolEvent, AnalysisScope analysisScope, AnalysisState analysisState, GroupedAnalyzerActions coreActions, GroupedAnalyzerActions additionalPerSymbolActions, Boolean shouldExecuteSyntaxNodeActions, Boolean shouldExecuteOperationActions, Boolean shouldExecuteCodeBlockActions, Boolean shouldExecuteOperationBlockActions, Boolean isInGeneratedCode, CancellationToken cancellationToken) in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 2719
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver`1.TryExecuteDeclaringReferenceActions(SymbolDeclaredCompilationEvent symbolEvent, AnalysisScope analysisScope, AnalysisState analysisState, Boolean isGeneratedCodeSymbol, IGroupedAnalyzerActions additionalPerSymbolActions, CancellationToken cancellationToken) in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 2607
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.<TryProcessSymbolDeclaredAsync>d__137.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1710
   --- 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.Diagnostics.AnalyzerDriver.<TryProcessEventCoreAsync>d__136.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1662
   --- 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.Diagnostics.AnalyzerDriver.<ProcessEventAsync>d__134.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1573
   --- 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.Diagnostics.AnalyzerDriver.<ProcessCompilationEventsCoreAsync>d__133.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1560
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.<>c__DisplayClass132_0.<<ProcessCompilationEventsAsync>b__2>d.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1469
   --- 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.Diagnostics.AnalyzerDriver.<ProcessCompilationEventsAsync>d__132.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 1481
   --- 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.Diagnostics.AnalyzerDriver.<ExecutePrimaryAnalysisTaskAsync>d__99.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 703
   --- 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.Diagnostics.AnalyzerDriver.<AttachQueueAndProcessAllEventsAsync>d__97.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerDriver.cs:line 636
   --- 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.Diagnostics.CompilationWithAnalyzers.<ComputeAnalyzerDiagnosticsCoreAsync>d__72.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 1045
   --- 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.Diagnostics.CompilationWithAnalyzers.<>c__DisplayClass67_3.<<ComputeAnalyzerDiagnosticsAsync>b__1>d.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 841
   --- 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.Diagnostics.CompilationWithAnalyzers.<ComputeAnalyzerDiagnosticsAsync>d__67.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 860
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.<ComputeAnalyzerSemanticDiagnosticsAsync>d__66.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 708
   --- 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.Diagnostics.CompilationWithAnalyzers.<GetAnalysisResultCoreAsync>d__64.MoveNext() in D:\GitHub\roslyn\src\Compilers\Core\Portable\DiagnosticAnalyzer\CompilationWithAnalyzers.cs:line 681
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Diagnostics.Extensions.<GetAnalysisResultAsync>d__8.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Core\Portable\Diagnostics\Extensions.cs:line 348
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Diagnostics.Extensions.<GetAnalysisResultAsync>d__7.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Core\Portable\Diagnostics\Extensions.cs:line 315
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<AnalyzeAsync>d__12.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Services\DiagnosticAnalyzer\DiagnosticComputer.cs:line 128
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.<GetDiagnosticsAsync>d__11.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Services\DiagnosticAnalyzer\DiagnosticComputer.cs:line 110
   --- 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`1.ConfiguredTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass4_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Services\DiagnosticAnalyzer\RemoteDiagnosticAnalyzerService.cs:line 78
   --- 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.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 179
   --- 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__7`1.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 119
   --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<RunWithSolutionAsync>d__7`1.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Host\RemoteWorkspace.cs:line 130
   --- 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 D:\GitHub\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.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<CalculateDiagnosticsAsync>d__4.MoveNext() in D:\GitHub\roslyn\src\Workspaces\Remote\ServiceHub\Services\DiagnosticAnalyzer\RemoteDiagnosticAnalyzerService.cs:line 63

If I comment out the assert Debug.Assert(operationBlock.Kind == OperationKind.Invocation);, things seem to be working fine and the "golden bar" no longer appears.

AlekseyTs commented 1 year ago

CC @akhera99