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 a TextDocumentContentProvider for source-generated files #7581

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Sep 19, 2024

Resolves #6426

This allows the Roslyn LSP to return document references with a roslyn-source-generated URI, and we'll turn around and ask the LSP for those files when they're opened.

For now we don't worry about refreshing files if they've changed, just to keep this simple.

Requires dotnet/roslyn#75180

vscode.workspace.registerTextDocumentContentProvider(
'roslyn-source-generated',
new (class implements vscode.TextDocumentContentProvider {
async provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): Promise<string> {
Copy link
Member Author

Choose a reason for hiding this comment

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

we definitely need to add refresh support in. There is some interesting behavior where VSCode doesn't actually always call didClose on the document even if the only active view closes (it calls sometimes much later). So the content gets reused even if the view is closed and another go to def request is made.

I could implement a command to refresh, or refresh on textview changing, but IMHO we should just implement server side refresh instead.

jasonmalinowski and others added 3 commits October 3, 2024 16:53
This allows the Roslyn LSP to return document references with a
roslyn-source-generated URI, and we'll turn around and ask the LSP
for those files when they're opened.

For now we don't worry about refreshing files if they've changed,
just to keep this simple.
@dibarbet dibarbet force-pushed the open_source_generated_documents branch from da298f4 to 6a17673 Compare October 3, 2024 23:58
@dibarbet dibarbet marked this pull request as ready for review October 4, 2024 00:39
@dibarbet dibarbet requested a review from a team as a code owner October 4, 2024 00:39
@JoeRobich
Copy link
Member

We should definitely have a test for this. I think it is fine if it comes in a follow up.

@dibarbet dibarbet merged commit 52dfbd4 into dotnet:main Oct 4, 2024
16 checks passed
@dibarbet dibarbet deleted the open_source_generated_documents branch October 4, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go to definition for a source generated file fails to open the generated file
3 participants