It seems that Visual Studio has issues with files that are stored under WSL 2. Whilst it can access the files and edit them and compile project correctly, it seems unable to use them for IntelliSense and cannot re-open the views on them when restarting. In this case the code is C++, but the editor is common.
Microsoft have proven incapable of finding a solution so I wondered if anybody else has experienced this and possibly found a solution.
I've also had problems adding files to Python projects. It is unable to add files if they are in WSL, but if I add the paths to the XML project file manually it can edit and debug the project correctly.
What I have tried:
Tried creating hard links to the WSL share in file explorer and mapping the WSL folders as a network drive. VS just seems to have problems when the folder is under WSL, but it can access the files to edit and compile them.