VS code generation

I'm working on custom Designer.

This designer must generate code files with partial classes definition (like Form designer generates Class.Designer.cs) in C#,mC++,VB,J#.

I have no problems with generating Class prototypes (using DTE CodeModel)

The question is: Is there any VS classes that allow me to parse methods: for I need to generate something like Initialize methods of Form designer.



Answer this question

VS code generation

  • houtexwebdev

    Its buried deep within Microsoft.VisualStudio.dll, generic rather than specific to each language, in three classes: VsCodeDomProvider, VsCodeDomGenerator, VsCodeDomParser. The parser actually uses an existing hierarchy of Code* objects (i.e., CodeElement, CodeClass, CodeFunction, etc. which are part of the DTE automation hierarchy) to build its CodeDom.

    One of the annoying things about the internal VS parser is that it adds line pragmas all over the place (#line in C Sharp), which really mucks up the code and any attempts to process the CodeDom.

    Considering that the internal ICodeParser (VsCodeDomParser) simply rebuilds a hierarchy from another hierarchy, it might be easier to just use the DTE hierarchy directly, or use it to build your own CodeDom without the line pragmas.


  • Frens

    Thank you for the reply.

    What do VS designers use for parsing methods

    I assume that they have ICodeParser interface fully implemented somewhere for each language. How can I get it

    Thanks.

    D.O.


  • ujjwalprakash

    The designers that ship with Visual Studio all use the CodeDOM to produce their output. The CodeDOM is more flexible in generating code, but not as good as parsing code.

    Craig



  • VS code generation