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

Support opening of source-generated files over LSP #5858

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasonmalinowski
Copy link
Member

@jasonmalinowski jasonmalinowski commented Jun 24, 2023

This depends on dotnet/roslyn#68771 for the server-side piece. But, if you don't have the server side piece, we won't return a URI that will trigger this code, so it's fine to have it in now.

@@ -662,6 +663,17 @@ function registerRazorCommands(context: vscode.ExtensionContext, languageServer:
}));
}

function registerSourceGeneratedFilesContentProvider(context: vscode.ExtensionContext, languageServer: RoslynLanguageServer) {
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('source-generated', new class implements vscode.TextDocumentContentProvider {
// TODO: also implement eventing for when the file changes
Copy link
Member Author

Choose a reason for hiding this comment

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

For now I'm just doing a small implementation of TextDocumentContentProvider here; the Omnisharp side has a fuller implementation that does support eventing but will require a bit of refactoring to be able to reuse.

@jasonmalinowski jasonmalinowski self-assigned this Jun 26, 2023
@jasonmalinowski jasonmalinowski force-pushed the opening-source-generated-documents-over-lsp branch 2 times, most recently from 1c5daac to f4180b8 Compare July 8, 2023 01:16
@jasonmalinowski jasonmalinowski marked this pull request as ready for review July 10, 2023 19:07
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner July 10, 2023 19:07
@CyrusNajmabadi
Copy link
Member

Will review tomorrow!

);
return result.text;
}
})()
Copy link
Member

Choose a reason for hiding this comment

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

so i personally really dont' like these sorts of anonymous inner classes. my pref is a distinct class with clear cpatures. but i don't feel strongly enough to block. if you feel like this is ok, then i'm ok with it.

@moander
Copy link

moander commented Oct 11, 2023

Any chance this will get merged soon?

@jasonmalinowski
Copy link
Member Author

@moander Hopefully in a week or two; unfortunately my attention is in a different direction for the rest of this week...

@pragone
Copy link

pragone commented Oct 11, 2023

I thought I'd leave a comment here thanking you for the great work, and also echoing the ask to merge this soon.
This is making development in projects with source generated code quite difficult. Because as soon as you hit this bug the best thing to do is to restart VSCode.
Thanks again

@glen-84
Copy link

glen-84 commented Nov 29, 2023

@jasonmalinowski Apologies for the ping, but is there any update on this? It's painful working with source generators in VS Code.

@jasonmalinowski
Copy link
Member Author

@glen-84 Thanks for the friendly ping! Hopefully can get this in a week or two -- I recognize that's what I said a few weeks go but that prior work turned into more than expected. But that work is now cleared so this is towards the top.

@jasonmalinowski jasonmalinowski force-pushed the opening-source-generated-documents-over-lsp branch from f4180b8 to cbda2b5 Compare December 16, 2023 02:43
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this pull request Dec 21, 2023
We had some code that slipped in that was calling
ProtocolConversions.CreateAbsoluteUri(document.FilePath), which is fine
for regular documents but skips the special handling around source
generated files, so we'd break in those cases.

This "fixes" the UriFormatExceptions people are getting, in the sense
that you won't get a UriFormatException anymore. If you try to actually
go to a source generated document, that'll still be broken until we
merge dotnet/vscode-csharp#5858, but at least
this means something like a find reference won't completely break if
it has a location somewhere in a source generated file.
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.
@jasonmalinowski jasonmalinowski force-pushed the opening-source-generated-documents-over-lsp branch from cbda2b5 to d344426 Compare January 27, 2024 00:40
@moander
Copy link

moander commented Feb 16, 2024

@jasonmalinowski any updates on this one? I'm really looking forward to this patch. Have a nice weekend! :)

@jasonmalinowski
Copy link
Member Author

@moander I think I'm going to have the Roslyn side of the change today, assuming no other random fires come up. (They've been coming up a lot recently. 😢 )

@jacobjmarks
Copy link

Bump on this; I believe @jasonmalinowski has gone on leave. Are we able to reassign?

@zaevi
Copy link

zaevi commented May 13, 2024

Is there any progress?

@Delsin-Yu
Copy link

Will there be any further progress on this? cc @dibarbet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants