knowledge of classes within project

How does Visual Studio know about Classes within a project For example if I had 2 source files, each being a class library, Class1 and Class2. If I add an instance of Class2 in Class1 intellisense knows about Class2's constructor, methods, etc. I'm wondering if this will be a problem with the Package we are creating that contains our own proprietary language. Currently we call an assembly that uses reflection on the project references to validate the objects used in the program. How would we validate objects used by other source files in the same project



Answer this question

knowledge of classes within project

  • NeerajKaushik.123

    Knowing about code elements such as namespaces, classes, and enums are done through references in a project. When you add a reference to an assembly, it uses the metadata of that assembly to find what is available, then the different languages display the intellisense window when you type the appropriate character in the editor. If you produce outputs in a format that projects can consume (dlls or exe files), then you should not need to do anything special for those projects to consume the outputs.

    Craig



  • willox2112

    This is specific to each project system. For example, VB is always compiling code in the background and they generate their intellisense based upon the code that is compiled. VC++ will do a language parse (they do not generate an output, just an abstract symbol tree) and then generate the intellisense information from that tree.

    If you are creating your own project system, then you can use any method that is appropriate for your language, and there is no set 'standard' for generating that information.

    Craig



  • chen55347

    We have the same requirement for a custom language within VS. We created a code parser that runs in the background looking to parse the code in our project that then populates a Code DOM list of classes.

    This way we can access the Code DOM list from our Language service when the code completion needs to be invoked.

    You can be smart about the background process by making sure it is only re-parsing files that have been changed since the last run through.


  • another_noob

    What I was wondering in the case that you have multiple classes that will generate 1 output class library. How do classes know about other classes within that same project In this case there is no project reference to add because all of the source files defining the classes are contained within the same project.

    Mike


  • Jack0000

    Craig Skibo wrote:

    This is specific to each project system. For example, VB is always compiling code in the background and they generate their intellisense based upon the code that is compiled. VC++ will do a language parse (they do not generate an output, just an abstract symbol tree) and then generate the intellisense information from that tree.

    If you are creating your own project system, then you can use any method that is appropriate for your language, and there is no set 'standard' for generating that information.

    Craig

    Yes, this is what I was getting at in my above post... We have created a system much like VC++ where it is parsing the code in all the project files and creating a Code DOM tree of all the information.

    We then access this tree for our custom Language Service to provide intellisense on our custom language.


  • d bonamie

    Hi,

    I have the similar problem and i am actually trying to do what Craig posted. Would it be possible to post a short code exaple showing what you are explainging.

    Thanks in advance,

    Ranju



  • knowledge of classes within project