-
Notifications
You must be signed in to change notification settings - Fork 416
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
What plans exist regarding C# source generator support? #1934
Comments
So from the Roslyn perspective, we expected that the core support added to the Roslyn Workspace APIs was going to mean support in Omnisharp lit up automatically, but it seems it's not always working reliably. There's a couple of bugs we're currently investigating and working on fixing. We are trying to use source generators in the Roslyn project itself, and since we have some developers using VS Code we are working to make sure we don't break ourselves! |
To update this, basic scenarios (completion, hover, semantic colorization) seem to work. However, things like go-to-def create ugly errors that need to be resolved somehow. |
With
The generator project looks like this: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>libflare-gen</AssemblyName>
<RootNamespace>Flare.Generator</RootNamespace>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.8.0-3.final" />
<!-- TODO: Remove these in the final .NET 5.0 release. -->
<PackageReference Include="System.Collections.Immutable" Version="5.0.0-rc.1.20451.14" />
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0-rc.1.20451.14" />
</ItemGroup>
</Project> I'm guessing there's probably some sort of version mismatch between the generator project and the Roslyn version used by OmniSharp? |
@alexrp generators need to target |
@amis92 I recall I switched from |
yes it's the same requirement for analyzers |
Am i correct, that completion end basic things should work in the "latest" omnisharp path? Edit: i managed to make it work, but its a bit of a hassle: I hope this can be improved a bit in the near future :) |
So, I've been experimenting with source generators recently. My experience is better than what @SeidChr reported back in November, in that I don't need to be on a preview branch (I'm using OmniSharp 1.37.6), and I don't seem to need to restart OmniSharp each time I rebuild the generator DLL. That said, what doesn't work at all is any diagnostics reported by the generator via Edit: Also, "Go To Definition" is still broken. |
Exists some workaround for the "Go To Definition"? |
This adds a new response element to gotodefinition responses: SourceGeneratedFileInfo. This is similar to MetadataSource, except that unlike MetadataSource it's not tracked on a type/project basis, but rather as a document/project basis. Retrieving info about a source generated file can be done through the SourceGeneratedFileService endpoints: * SourceGeneratedFileInfo - Gets the file content of a source generated file. * UpdateSourceGeneratedFileInfo - Gets the updated content of a source generated file, if it has changed since the last time information was returned. * SourceGeneratedFileClosed - Sent to the server to inform it that the editor has closed the generated file and it can stop tracking Document version info for that file. Currently, the only way to get the info needed to open a source-generated file is via the gotodefinition endpoint. We'll want to add info to find-usages as well, but that's a job for another day. Contributes to OmniSharp#1934.
This adds a new response element to gotodefinition responses: SourceGeneratedFileInfo. This is similar to MetadataSource, except that unlike MetadataSource it's not tracked on a type/project basis, but rather as a document/project basis. Retrieving info about a source generated file can be done through the SourceGeneratedFileService endpoints: * SourceGeneratedFileInfo - Gets the file content of a source generated file. * UpdateSourceGeneratedFileInfo - Gets the updated content of a source generated file, if it has changed since the last time information was returned. * SourceGeneratedFileClosed - Sent to the server to inform it that the editor has closed the generated file and it can stop tracking Document version info for that file. Currently, the only way to get the info needed to open a source-generated file is via the gotodefinition endpoint. We'll want to add info to find-usages as well, but that's a job for another day. Contributes to OmniSharp#1934.
This adds a new response element to gotodefinition responses: SourceGeneratedFileInfo. This is similar to MetadataSource, except that unlike MetadataSource it's not tracked on a type/project basis, but rather as a document/project basis. Retrieving info about a source generated file can be done through the SourceGeneratedFileService endpoints: * SourceGeneratedFileInfo - Gets the file content of a source generated file. * UpdateSourceGeneratedFileInfo - Gets the updated content of a source generated file, if it has changed since the last time information was returned. * SourceGeneratedFileClosed - Sent to the server to inform it that the editor has closed the generated file and it can stop tracking Document version info for that file. Currently, the only way to get the info needed to open a source-generated file is via the gotodefinition endpoint. We'll want to add info to find-usages as well, but that's a job for another day. Contributes to OmniSharp#1934.
Go to def support was added in #2170 |
Hello,
I saw this blog post on the .NET blog recently, which indicates that source generators are far enough along that they're actually usable in practice. So, in one of my projects, I ported a T4 template to a C# source generator to try it out. While this worked fine during build, it turns out that OmniSharp doesn't currently support them well: The generated types do not show up in IntelliSense, so lots of errors appear throughout the solution.
In an earlier post, it says:
Restarting OmniSharp, or even VS Code as a whole, does not appear to help.
So, I just wanted to check if there are any plans regarding support for C# source generators in OmniSharp? (Assuming that this is a lack of support, and not just a bug.)
The text was updated successfully, but these errors were encountered: