Hi!
I'm creating a program that looks at source files and performs certain checks on them. This is all done at the source file level (i.e. there is no reference to a project or solution). I'm adding functionality so that when a user double clicks on a node in a GUI (where there is one for every method and property in a file) it loads up visual studio and highlights that method or property.
Before launching a new Visual Studio, I check all the open visual studios to see if they have a Solution which already contains this file and if so perform all the logic on that. This works great as the source file has already be parsed and has a lovely FileCodeModel for me to iterate through and fine the method (complete with start and end points!).
The problem comes when there a) isnt a visual studio instance open or b) the file being checked doesnt belong to an open project. In this situations the FileCodeModel is null. Now when I check the project for this its called "Miscellaneous Files" or something similar; so I assume when ever you open just a single file in Visual Studio it goes in here.
What I don't understand is why can't I access the member collection for this file? Obviously Visual Studio does have the information for it, because all the members / classes / enums etc are in the drop downs at the top of the file (in the IDE). Is there another way to access this information or force Visual Studio to create a FileCodeModel for this? The only (hack) solution I can think of is creating a new Visual Studio process, where I create a new solution and project in this to force it to make a model. This how ever will be expencive; I'm sure the information is already stored somewhere!
Thanks.