Find all references, go to definition do not work across VB/C# projects in same solution
While using Visual Studio today I noticed an anomaly. When I bring up a file in VS2008 Solution Explorer AuditEventPublisher.vb in MyVbProject.vbproj
Scroll down to the Publish method, right click and select “find all references”, Visual Studio does not report on the instances in which the method is used in the namespace MyCSharpProject.csproj. MyCSharpProject has a Project reference to MyVbProject and both are in the same solution.
I tried a number of things and did some research – but could not get it to work or find an explanation. Also, when I bring up this class in the IDE ClientAuditMessageInspector.cs in MyCSharpProject.csproj and right click on the AuditEventPublisher.Publish() method and select “go to definition” – it brings up a metadata class instead of the actual code.
The only theory I have is that the fact that one project is in VB and the other in C# in the same solution - is this the cause. ?
This is a known bug / limitation in VS 2008 SP1 . The same thing happens in Vs2010 Beta 2 as well.
Reason from Product Team:
This issue is by design given our current architecture and has always existed in the product. The reason this occurs is because a different compiler is used for each type of project (the C# one for C# projects and the VB one for VB projects) and they each populate a separate symbol table. This symbol table is not shared in a live way across the two types of projects – symbol sharing occurs once an assembly has been flushed to disk.
The project-to-project reference between a C# and VB project is treated like a file assembly reference where all symbols are treated as if coming from metadata.
link here..
Comments
Anonymous
July 28, 2011
This is the most ridiculous reasoning considering that it works the other way (VB.NET to C#). Fix it alreadyAnonymous
April 04, 2012
It would be super nice to have Find All References have the option to find only references to a particular definition of ToString() - and even show where it is implicitly called. Now THAT would be SWEET!