visual studio go to defintion resorts to symbol search when importing modules

M3 116 Reputation points
2021-11-24T22:01:32.307+00:00

I have isolated a case where go to definition (f12) does not work as expected.
If I import a (unused) module then go to definition in the code below (e.g. with cursor in polygon) does not work, but instead a symbol search is done. The symbol search results can be quite large and can include inexact matches from other namespaces or even matches nested inside other classes. Go to definition works fine if the import expression is commented out (it isn't needed for main to compile)

main.cpp (in its own project):
#include <boost/geometry/geometries/polygon.hpp>
import sc2_shared; // go to defintion does a symbol search with incorrect matches if this is imported. works fine with this line commented
struct Point { float x, y; };
typedef boost::geometry::model::polygon<Point> my_poly;
int main() { return 0; }

sc2_shared.ixx (in its own project):

module;
export module sc2_shared;
export import "sc2/sc2_common.h";

sc2_common.cc (in it's own project):

#include "sc2_common.h"

and finally sc2_common.h

#pragma once
#include <algorithm>

Go to definition has not worked for me and my project for more a very long time and has failed on multiple versions of VS. This version is 2022 current. I hope this report helps find a work around or fix.
I'm using the most recent boost supported by vcpkg. I believe it is 1.75, although I don't think that is important. It is installed system wide using "vcpkg integrate install" command.

I realize the configuration is a bit involved with 3 separate projects and I'm uncertain whether that is needed to reproduce this behavior. If you want a .git let me know and I'll try to push it to github

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,606 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
{count} votes