The VCCodeParameter.Name property returns an empty string in Visual Studio 2005 (907298)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Express Edition

SYMPTOMS

When you use the VCCodeParameter.Name property to obtain the name of a template parameter in Microsoft Visual Studio 2005, the VCCodeParameter.Name property returns an empty string.

WORKAROUND

To work around this problem, use the VCCodeParameter.TypeString property. The VCCodeParameter.TypeString property returns the name of the parameter preceded by the text "typename." The following text is an example of the text that is returned by the VCCodeParameter.TypeString property:typename T

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. Start Visual Studio 2005.
  2. Expand Visual C++, and then click Win32.
  3. Create a new Win32 console application that is named Test.
  4. Add the following code to the Test.cpp file.
    template <class T> class TEST
    {};
  5. To display Macro Explorer, press ALT+F8.
  6. Click Tools, click Macros, and then click New Macro Project.
  7. Add a new macro project that is named MacroProject1.
  8. In Macro Explorer, expand MacroProject1, and then double-click Module1.
  9. In Project Explorer, add a reference to the Microsoft.VisualStudio.VCCodeModel.dll component.
  10. Add the following Imports statements before the definition of Module1.
    Imports Microsoft.VisualStudio.VCCodeModel
  11. Add the following code to Module1.
    Sub Macro1()
    	Dim fcm As VCFileCodeModel = DTE.ActiveDocument.ProjectItem.FileCodeModel()
    	Dim c1 As VCCodeClass = fcm.Classes.Item(1)
    	Dim p1 As VCCodeParameter = c1.TemplateParameters.Item(1)
    	MsgBox(p1.Name)
    End Sub
  12. Close the Macros IDE.
  13. Put the insertion point in the Test.cpp file.
  14. In Macro Explorer, right-click Macro1, and then click Run.

    You receive a message that contains an empty string.

Modification Type:MajorLast Reviewed:2/4/2006
Keywords:kbinfo kbBug kbtshoot kbProgramming kbprb KB907298 kbAudDeveloper kbAudITPRO