dotnet / dotnet/roslyn

Constant errors regarding "Diagnostic Analyzer runner" crashing

Open
#78,025 18 comments 4 reactions 0 assignees View on GitHub
Area-Analyzers Area-Compilers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Using visual studio 2022 Version 17.13.5 multiple times a day i get a message saying that the diagnostic analyser has crashed. Often seem to happen when i paste C# stuff into my code. visual studio.

If i open my C# program, paste this text, I will get the error. Closing down visual studio, opening it and pasting it again and i can reproduce it.

`var inputTracks = new List();
foreach (var track in tracks) // however you have your ISRC/UPC list
{
inputTracks.Add(new BigQueryStruct
{
{ "isrc", track.Isrc },
{ "upc", track.Upc }
});
}
`

Here is the stack trace:

```
StreamJsonRpc.RemoteInvocationException: Specified argument was out of the range of valid values. (Parameter 'character')
at StreamJsonRpc.JsonRpc.d__156`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 Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.d__18`1.MoveNext()
RPC server exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'character')
at Microsoft.CodeAnalysis.Text.LinePosition..ctor(Int32 line, Int32 character)
at Microsoft.CodeAnalysis.Text.TextLineCollection.GetLinePosition(Int32 position)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.GetLineSpan(TextSpan span, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.SourceLocation.GetLineSpan()
at Microsoft.CodeAnalysis.Diagnostics.DiagnosticData.CreateLocation(TextDocument document, Location location)
at Microsoft.CodeAnalysis.Diagnostics.DiagnosticData.Create(Diagnostic diagnostic, TextDocument document)
at Microsoft.CodeAnalysis.Workspaces.Diagnostics.DiagnosticAnalysisResultBuilder.AddDocumentDiagnostic(Dictionary`2& map, TextDocument document, Diagnostic diagnostic)
at Microsoft.CodeAnalysis.Workspaces.Diagnostics.DiagnosticAnalysisResultBuilder.AddDiagnostic(Dictionary`2& lazyLocals, SyntaxTree tree, Diagnostic diagnostic)
at Microsoft.CodeAnalysis.Workspaces.Diagnostics.DiagnosticAnalysisResultBuilder.AddDiagnostics(Dictionary`2& lazyLocals, SyntaxTree tree, IEnumerable`1 diagnostics)
at Microsoft.CodeAnalysis.Diagnostics.Extensions.g__AddDiagnosticsToResult|7_1(ImmutableArray`1 diagnostics, DiagnosticAnalysisResultBuilder& result, SyntaxTree tree, DocumentId additionalDocumentId, Nullable`1 span, AnalysisKind kind, ImmutableArray`1 diagnosticIdsToFilter, Boolean includeSuppressedDiagnostics)
at Microsoft.CodeAnalysis.Diagnostics.Extensions.ToResultBuilderMapAsync(AnalysisResultPair analysisResult, ImmutableArray`1 additionalPragmaSuppressionDiagnostics, DocumentAnalysisScope documentAnalysisScope, Project project, VersionStamp version, ImmutableArray`1 projectAnalyzers, ImmutableArray`1 hostAnalyzers, SkippedHostAnalyzersInfo skippedAnalyzersInfo, Boolean includeSuppressedDiagnostics, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.AnalyzeAsync(CompilationWithAnalyzersPair compilationWithAnalyzers, BidirectionalMap`2 analyzerToIdMap, ImmutableArray`1 projectAnalyzers, ImmutableArray`1 hostAnalyzers, SkippedHostAnalyzersInfo skippedAnalyzersInfo, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetNormalPriorityDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass3_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<g__ProcessSolutionAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.CalculateDiagnosticsAsync(Checksum solutionChecksum, DiagnosticArguments arguments, CancellationToken cancellationToken)

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash in Visual Studio 2022 version 17.13.5 by opening a C# program and pasting the supplied snippet. Start with the DiagnosticComputer and DiagnosticData stack-trace entries, then verify that the diagnostic analyzer runner no longer crashes and that the reported out-of-range character error is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.