Resharper selects wrong project for IntelliSense Follow
After a new project (for Documentation only) was introduced in my solution IntelliSense often is unable to resolve includes, class names, etc. Most often this can be resolved by selecting the right project again in the left most field in the navigation bar. Apart from manually selecting the right project being cumbersome this does also not always work. Can you give me a hint on how Resharper can interfere with the project selection for IntelliSense or help me to understand better what's exactly the problem?
As the solution is quite big and complex I have no idea how to reproduce this behaviour in a minimal example. Also I feel unable to describe the problem clearly enough to file a bug ticket.
Clearing the Resharper cache didn't solve the problem. Only removing the project again works reliably.
JetBrains ReSharper 2022.1.1 Build 221.0.20220428.93142 built on 2022-04-28
ReSharper C++ 2022.1.20220428.100917
Microsoft Visual Studio Professional 2019
Please sign in to leave a comment.
I believe the navigation bar is of no help here. At the moment the project from the bar is used to select the context only if the same file is included into several projects. For debug purposes, you can open the Alt+Enter menu and then type "/internal dump inclusion context". This command will dump some debugging info including what .cpp file was used to parse the current file ("Base project file"), include paths, etc.
So your documentation project includes the header file where there are issues, but it does not provide the necessary include paths? Could you please check with the above command that a file from the documentation project is used as the context for this header file?
In your scenario it's probably better to completely exclude the documentation project from indexing. Add it to "Skipped code" on the third-party code options page (https://www.jetbrains.com/help/resharper/Reference_Options_Code_Editing_Third_Party_Code.html).
thanks for your fast answer!
It seems like my first post is missing some information about the documentation project. This project is used for generating the doxygen documentation and thus doesn't have it's own files but includes all files of the project. So in this case I guess the navigation bar could still be relevant.
I'm also not sure, if I described the problem well enough. One situation is e.g. that I have three files MyClass.h, MyClass.cpp and SomeType.h where MyClass.cpp includes MyClass.h and MyClass.h includes SomeType.h. However in MyClass.cpp Resharper and Intellisense complaing that they cannot resolve SomeType, even though it's included by MyClass.h. Also in the inclusion context dump MyClass.h is listed as an included file but SomeType.h isn't.
I think excluding the documentation project in that case isn't possible, as it doesn't have its own files.
Does this make my problem more clear?
I see, thanks for the clarification. I'm not entirely sure what happened in your scenario, but probably during indexing R# decided to use the documentation project to get the compilation properties. Since there are no include paths, the include for SomeType.h in MyClass.h didn't get resolved and got cached.
With third-party code you can exclude files separately from each project, but I guess it would be cumbersome in your scenario. I'm not sure about the best workaround. Could you please try unloading the documentation project from the solution, does that solve the issue?
Yes, this seems to solve the issue. After unloading the documentation project Resharper sometimes had trouble jumping from the declaration to the definition but after restarting my PC it seems to be fully working again. Does this explain what's going wrong here?
As I mentioned R# is likely confused about what project to use when indexing a file. The best workaround is probably to keep the documentation project separate from the main solution. Would it be possible to split it out into a separate solution used just to generate the docs?
I have a similar problem with Resharper++, which I am evaluating at the moment (latest version, of course, and with latest MSVC 2022).
My solution is large, but to make it simple:
I have 2 projects, listed in this order, in the solution:
They share most of the source code, but with different global #defines (to activate different source code parts)
While I select "MyProject_number2" as startup project, Resharper++ uses the #defines of MyProject_number1. This is the problem.
If I unload MyProject_number1, Resharper++ selects properly the #defines of MyProject_number2.
If I reload MyProject_number1, Resharper++ selects again the #defines of MyProject_number1, while the startup project is MyProject_number2.
But this procedure is not a solution to have an effective workflow.
Igor Akhmetov Alright, thanks a lot for your help. Probably it would work to split the documentation project out but my co-workers in the meantime found another solution. It's something about "switching to a directory based source file discovery" for the doxygen dependencies which seams to solve the problems.
Andreas P. Thanks for the update!
Philwave Startup project is not relevant here. You need to choose the file context from a dropdown at the top of the editor window. It might not work depending on what files you work with. If it doesn't, please describe your situation in more details - the file you have opened, what projects it belongs to, and please also attach the output of "/internal dump inclusion context" from the Alt+Enter menu as described above.
Thanks. Indeed, this works (even if for me the Startup Project would have made sense).