Skip to content

F12ing from C# -> Razor on an unnavigable item red-bars #5261

@NTaylorMullen

Description

@NTaylorMullen

Repro:
Type Counter anywhere in C# and F12 on it in the default app

We explode with an argument out of range exception:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: lineNumber
   at Microsoft.VisualStudio.Text.Implementation.UnaryStringRebuilder.GetLineFromLineNumber(Int32 lineNumber, Span& extent, Int32& lineBreakLength)
   at Microsoft.VisualStudio.Text.Implementation.CachingTextImage.GetLineFromLineNumber(Int32 lineNumber)
   at Microsoft.CodeAnalysis.Text.Extensions.SnapshotSourceText.LineInfo.get_Item(Int32 index)
   at Microsoft.VisualStudio.LanguageServerClient.Razor.VSLSPRangeExtensions.AsTextSpan(Range range, SourceText sourceText)
   at Microsoft.VisualStudio.LanguageServerClient.Razor.CSharpSpanMappingService.<MapSpansAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServerClient.Razor.CSharpSpanMappingService.<MapSpansAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSpanMappingServiceWrapper.<MapSpansAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.<>c__DisplayClass12_0.<<GetMappedSpan>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task`1 task, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.GetMappedSpan(ISpanMappingService spanMappingService, Document generatedDocument, TextSpan textSpan)
   at Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.TryNavigateToLocation(Workspace workspace, DocumentId documentId, Func`2 getTextSpanForMapping, Func`2 getVsTextSpan, OptionSet options)
   at Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioDocumentNavigationService.TryNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan, OptionSet options)
   at Microsoft.CodeAnalysis.DocumentSpanExtensions.TryNavigateTo(DocumentSpan documentSpan, Boolean showInPreviewTab, Boolean activateTab)
   at Microsoft.CodeAnalysis.FindUsages.DefinitionItem.DefaultDefinitionItem.TryNavigateTo(Workspace workspace, Boolean showInPreviewTab, Boolean activateTab)
   at Microsoft.CodeAnalysis.Editor.Host.IStreamingFindUsagesPresenterExtensions.<TryNavigateToOrPresentItemsAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
   at Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionHelpers.TryGoToDefinition(ISymbol symbol, Solution solution, IThreadingContext threadingContext, IStreamingFindUsagesPresenter streamingPresenter, CancellationToken cancellationToken, Boolean thirdPartyNavigationAllowed)
   at Microsoft.CodeAnalysis.Editor.GoToDefinition.AbstractGoToDefinitionService.TryGoToDefinition(Document document, Int32 position, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionCommandHandler.TryExecuteCommand(Document document, Int32 caretPosition, IGoToDefinitionService goToDefinitionService, CommandExecutionContext context)
   at Microsoft.CodeAnalysis.Editor.GoToDefinition.GoToDefinitionCommandHandler.ExecuteCommand(GoToDefinitionCommandArgs args, CommandExecutionContext context)
   at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.<>c__DisplayClass14_1`1.<ExecuteStartingAtIndex>b__0()
   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate`1 exceptionFilter)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions