Skip to content

Fix handling for source generated documents in LSIF#59891

Merged
jasonmalinowski merged 2 commits intodotnet:mainfrom
jasonmalinowski:fix-lsif-handling-of-generated-files
Mar 18, 2022
Merged

Fix handling for source generated documents in LSIF#59891
jasonmalinowski merged 2 commits intodotnet:mainfrom
jasonmalinowski:fix-lsif-handling-of-generated-files

Conversation

@jasonmalinowski
Copy link
Copy Markdown
Member

We correctly handled them in the core generation code, but failed as we were actually serializing out JSON.

Fixes #59692

We correctly handled them in the core generation code, but failed as
we were actually serializing out JSON.

Fixes dotnet#59692
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner March 2, 2022 20:33
@ghost ghost added the Area-IDE label Mar 2, 2022
@jasonmalinowski jasonmalinowski self-assigned this Mar 2, 2022
// TODO: when we move to .NET Core, is there a way to reduce allocations here?
contentBase64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(text.ToString()));

uri = "source-generated://" + syntaxTree.FilePath.Replace('\\', '/');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be good to land on a consistent URI scheme for source generated documents

For example currently LSP does this - https://github.com/dotnet/roslyn/blob/main/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs#L33

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dibarbet, ah right my commit message of "we should figure a standard" didn't get updated here. 😄

The bigger thing we need is not just the prefix, but also what the other parts of the URI are as well, since we also need something to differentiate different projects/targets. Did you do anything for that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not yet - the general idea would be to encode them as parameters.

Perhaps its OK to wait to unify until we start actually doing the virtual docs support. But maybe at least for now we should use the same prefix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I chose source-generated rather than just "generated" to keep the scheme more explicit, since we may also have other schemes like metadata-as-source or source-link or something else and those need to go to different LSP handlers or something.

This scheme is arbitrary for now and just gives LSIF consuming tools
a better idea where these files come from. Once we standardize a
proper form for these for LSP, we should update this to match.
@jasonmalinowski jasonmalinowski force-pushed the fix-lsif-handling-of-generated-files branch from 8bd3b32 to 64b5510 Compare March 17, 2022 21:04
@jasonmalinowski jasonmalinowski merged commit 044254c into dotnet:main Mar 18, 2022
@jasonmalinowski jasonmalinowski deleted the fix-lsif-handling-of-generated-files branch March 18, 2022 17:42
@ghost ghost added this to the Next milestone Mar 18, 2022
@allisonchou allisonchou modified the milestones: Next, 17.2.P3 Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSIF tool has uncaught exception when Uri is relative path

4 participants