Skip to content

Razor/Roslyn Cohosting: Use #line directives instead of ISpanMappingService #72136

@davidwengier

Description

@davidwengier

Currently Razor tooling provides an implementation of ISpanMappingService, and various features in Roslyn call into it in order to map locations in Razor generated C# code, back to the originating .razor or .cshtml file. With cohosting, we want to remove the need for this service and have Roslyn honour #line directives instead. Some of all of these items could potentially be limited to only supporting enhanced line directives, to ensure full fidelity of results. Further, it might be desirable to only support #line directives if there isn't an ISpanMappingService for the document in question, to allow venus/legacy Razor editor to be unaffected.

Things that might need specific changes

Things that can be changed to use line directives
(with varying degrees of difficulty, and appropriate API changes to ensure relevant Location data is available)

  • RemoteCodeLensReferencesService.FixUpDescriptorsAsync

  • VisualStudioDocumentNavigationService.GetNavigationCallbackAsync

  • VisualStudioWorkspaceImpl.ShouldApplyChangesToMappedDocuments

    • called from VisualStudioWorkspaceImpl.GetMappedTextChangesAsync
      • called from VisualStudioWorkspaceImpl.ApplyMappedFileChanges
  • ProtocolConversions.GetMappedSpanResultAsync

    • called from ProtocolConversions.ChangedDocumentsToTextDocumentEditsAsync
      • called from RenameHandler.HandleRequestAsync
    • called from ProtocolConversions.TextSpanToLocationAsync
      • called from WorkspaceSymbolsHandler.AddItemAsync
      • called from AbstractGoToDefinitionHandler.GetDefinitionAsync
  • AbstractDocumentSpanEntry.TryMapAndGetFirstAsync

Part of dotnet/razor#9519

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions