-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Razor intellisense not finding types in referenced project that consumes a source generator #69732
Comments
@jasonmalinowski heads up, I haven't investigated this yet, but I suspect it will be coming your way as I cannot fathom how this could possibly be a Razor tooling issue 😁 |
I debugged through this and confirmed that the Roslyn LSP was not sending us back any completions. |
I'm running into this same issue as my company is transitioning to building our product in Blazor. I wrote several source generators that generate static classes, and those static classes have several readonly static properties. These live in a class library referenced by the Blazor web app project. In my razor files, text completions do not appear for any of the generated files in the referenced project. This is making it difficult to develop new pages, as the results of the source generators are used frequently, and we have to directly dig into the generated code and copy the name we want to use, or reference documentation instead of having the full list easily available in text completions. I've also made a minimal reproduction of my issue: https://github.com/mpagliaro98/IntellisenseTest There's more details in this stackoverflow post I originally made, before I was pointed here, but I believe this issue is the same as what I'm facing: https://stackoverflow.com/questions/78321911/intellisense-not-finding-generated-code-in-referenced-project |
Yep, that's the same issue. I believe this will become more of a problem over time, as source generators and razor are both growing in popularity. Here's a workaround I'm using at the moment: load the class library with the generators using An example - in the class library: <Target Name="HideFromRoslyn" AfterTargets="Build" Inputs="$(OutputPath)\$(AssemblyName).dll" Outputs="$(OutputPath)\hidden\$(AssemblyName).dll">
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll;$(OutputPath)\$(AssemblyName).pdb" DestinationFiles="$(OutputPath)\hidden\$(AssemblyName).dll;$(OutputPath)\hidden\$(AssemblyName).pdb" />
</Target> And in the web project: <Reference Include="..\ClassLib\bin\$(Configuration)\$(TargetFramework)\hidden\ClassLib.dll" /> |
What side-effects have you noticed from using this workaround? I've not done it myself, but I understand that referencing a dll instead of a project causes things like find by reference to not work on references in the dll, or issues coming up with multiple versions of the dll needing to be referenced. The project I'm working on is a large enterprise application deployed through Azure, so any workaround I go with would be safe and work in all use cases (until this gets fixed) |
I have a model project which contains generated code, produced by a source-generator in a nuget package. I also have a blazor application which references this model project and uses its types. When using Visual Studio 17.7, that works fine in .cs files, but in .razor files there is no code completion for generated types and Go To Definition doesn't work. The project builds, but it's difficult to work on it productively.
https://github.com/gulbanana-bugs/repro-razor-intellisense is a repository demonstrating the issue. Steps to reproduce:
<Reference>
instead of a<ProjectReference>
toClassLib
.Broken .razor intellisense:
Working .cs intellisense:
The text was updated successfully, but these errors were encountered: