Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>CodeModelMacros Sample: Demonstrates How to Use the Code Model Functions</title></head><body><h1>CodeModelMacros Sample: Demonstrates How to Use the Code Model Functions</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>This sample is a collection of macros that use the Code Model to perform useful tasks. The macros included are:  </p><ul><li><p><b>HierarchyGenerator</b>   Generates an HTML file with an inheritance tree for the classes, structs, and interfaces in a project. </p><p>This macro first assembles a collection of the terminal classes, structs, or interfaces (those that don't have any derived types). It does this by verifying that no other code element has the class, struct, or interface in question in its bases collection. Then it generates an HTML report listing the terminal objects with all of its bases. The macro adds this file to the first project in the solution. </p></li><li><p><b>InterfaceDocGenerator</b>   Generates HTML documentation for the implemented interfaces in a project. It gathers the comments from the class functions that implement the interface methods. </p><p>This macro enumerates the interfaces contained in the CodeModel.Interfaces collection, and then it finds the classes that implement each interface. For each class, it looks up the interface's methods implementation and stores the comments in an HTML file. </p></li><li><p><b>UserTypeGenerator</b>   Generates a file named usertype.dat containing the names of the classes in your project. If you place this file in the same location where devenv.exe resides (for example, c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE), the source code editor will colorize your class names. </p><p>This macro writes to a file (usertype.dat) the names of the classes contained in the CodeModel.Classes collection. </p></li><li><p><b>VirtualFunctionFinder</b>   Adds a TODO comment to the virtual functions found in the project. </p><p>The VirtualFunctionFinder finds the virtual functions declared in the project by recursively verifying the functions of each class or struct. Then it adds a comment to each one by changing the CodeFunction.Comment property.</p></li></ul><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Installing and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To install the macros</h4><div class="subSection"><ol><li><p>Copy the file CodeModelMacros.vsmacros to your hard drive.</p></li><li><p>Start Visual Studio.</p></li><li><p>From the <b>Tools</b> menu, point to <b>Macros</b> and then click <b>Macro Explorer</b>. This will open the Macro Explorer window.</p></li><li><p>From the <b>Tools</b> menu, point to <b>Macros</b> and then click <b>Load Macro Project</b>. This will open the <b>Add Macro Project</b> dialog box.</p></li><li><p>Browse to the CodeModelMacros.vsmacros file and click the <b>Open</b> button. This action will load the macros file and the macros will appear in the Macro Explorer.</p></li><li><p>Expand the <b>CodeModelMacros</b> node. You will see one module for each macro.</p></li></ol></div><h4 class="subHeading">To execute HierarchyGenerator</h4><div class="subSection"><ol><li><p>Expand the <b>HierarchyGenerator</b> node in the Macro Explorer.</p></li><li><p>Double-click the <b>HierarchyGenerator</b> macro. This will execute the macro and add an HTML file to the first project in your solution.</p></li></ol></div><h4 class="subHeading">To execute InterfaceDocGenerator</h4><div class="subSection"><ol><li><p>Expand the <b>InterfaceDocGenerator</b> node in the Macro Explorer.</p></li><li><p>Double-click the <b>InterfaceDocGenerator</b> macro. This will execute the macro and add an HTML file to the first project in your solution.</p></li></ol></div><h4 class="subHeading">To execute UserTypeGenerator</h4><div class="subSection"><ol><li><p>Expand the <b>UserTypeGenerator</b> node in the Macro Explorer.</p></li><li><p>Double-click the <b>UsertypeC</b> macro. This will execute the macro and will create a usertype.dat file in the root directory of your C: drive.</p></li></ol></div><h4 class="subHeading">To execute VirtualFunctionFinder</h4><div class="subSection"><ol><li><p>Expand the <b>VirtualFunctionFinder</b> node in the Macro Explorer.</p></li><li><p>Double-click the <b>MainVirtualFunctionFinder</b> macro. This will execute the macro and will add a TODO comment to the virtual functions declared in your project.</p></li></ol></div></div><h1 class="heading">Keywords</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>This sample demonstrates the following keywords:</p><p>CodeClass::Members; CodeElement.CodeTypeFromFullName; CodeElement::Children; CodeElement::FullName; CodeElement::Kind; CodeFunction::CanOverride; CodeFunction::Comment; CodeFunction::InfoLocation; CodeFunction::Name; CodeInterface::Name; CodeModel::CodeElements; CodeModel::Language; CodeNamespace::Members; CodeStruct::Members; CodeType::Bases; Project::CodeModel; Solution::Count; VCCodeBase::FullName; VCCodeBase::Name; VCCodeClass::Functions; VCCodeClass::ImplementedInterfaces; VCCodeClass::IsSelf; VCCodeClass::Name; VCCodeFunction::Attributes; VCCodeFunction::Comment; VCCodeFunction::IsVirtual; VCCodeInterface::Functions; VCCodeModel::Classes; VCCodeModel::Interfaces</p></div></div><div id="footer"><div class="footerLine"></div>
          © Microsoft Corporation. All rights reserved.  Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :CodeModelMacros Sample: Demonstrates How to Use the Code Model Functions">comments</a> about this topic to Microsoft.
      </div></div></body></html>