Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add O# EA accessor for DocumentId.CreateFromSerialized #70229

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructur
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureOptions.ToBlockStructureOptions() -> Microsoft.CodeAnalysis.Structure.BlockStructureOptions!
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureService
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockTypes
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Workspace.OmniSharpDocumentId
override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeActions.OmniSharpCodeActionOptions.GetHashCode() -> int
override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Completion.OmniSharpCompletionOptions.GetHashCode() -> int
override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Formatting.OmniSharpSyntaxFormattingOptionsWrapper.GetHashCode() -> int
Expand Down Expand Up @@ -358,6 +359,7 @@ static Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockT
static Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockTypes.PreprocessorRegion.get -> string!
static Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockTypes.Statement.get -> string!
static Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockTypes.Type.get -> string!
static Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Workspace.OmniSharpDocumentId.CreateFromSerialized(Microsoft.CodeAnalysis.ProjectId! projectId, System.Guid id, bool isSourceGenerated, string? debugName) -> Microsoft.CodeAnalysis.DocumentId!
virtual Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.NavigateTo.OmniSharpNavigateToSearcher.OmniSharpNavigateToCallback.Invoke(Microsoft.CodeAnalysis.Project! project, in Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.NavigateTo.OmniSharpNavigateToSearchResult result, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeActions.OmniSharpCodeActionOptions.Equals(object obj) -> bool
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CodeActions.OmniSharpCodeActionOptions.ToString() -> string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Workspace
{
internal static class OmniSharpDocumentId
{
public static DocumentId CreateFromSerialized(ProjectId projectId, Guid id, bool isSourceGenerated, string? debugName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the use case where omnisharp needs to create a doc-id from a serialized form? How does it even get the value to pass into bool isSourceGenerated? we don't expose that property public on our doc-id in the first place. Thanks! :)

Copy link
Member Author

@JoeRobich JoeRobich Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The O# navigation service can return source generated file info as part of a GoToDefinition response (See omnisharp/omnisharp-roslyn/GoToDefinitionServiceV2.cs). When this navigation item is selected by the user the client will then request the document from the server and provide it to the editor (See dotnet/vscode-csharp/SourceGeneratedDocumentProvider.ts and omnisharp/omnisharp-roslyn/SourceGeneratedFileService). So,we are round tripping the DocumentId.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand. you are undoing things to get the guid and pass that along. instead of doing that, why not actually send the DocID itself instead? i.e. instead of document.Id.Id, just send doument.Id.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyrusNajmabadi I think the case here is similar to what we have for LSP: we can take the document ID as a GUID and send that over the wire, and when we get it back we know it's source generated based on the URI prefix or something similar.

=> DocumentId.CreateFromSerialized(projectId, id, isSourceGenerated, debugName);
}
}
Loading