| Author: |
Carlos J. Quintero (Microsoft MVP) |
Applies to: |
Microsoft Visual Studio 2005 |
| Date: |
May 2011 |
|
Microsoft Visual Studio 2008 |
| |
|
|
Microsoft Visual Studio 2010 |
Introduction
The automation model (EnvDTE80) of Visual Studio provides classes for code elements such as
EnvDTE80.CodeClass2, EnvDTE80.CodeEvent, etc. which have Comment and DocComment properties.
The Comment property returns "" for code elements with no comment. The DocComment property returns
<doc>\n</doc> for code elements with no comment.
However, for C# code events, EnvDTE80.CodeEvent.Comment returns <doc>\n</doc> instead of "", which is inconsistent with other C# code elements, or with VB.NET code events.
More Information
Steps to reproduce the problem:
- Create a macro with the following code:
| Language: VB.NET | Copy Code (IE only) |
Sub Macro1()
Dim codeClass As EnvDTE80.CodeClass2
Dim codeEvent As EnvDTE80.CodeEvent
Dim projectItem As ProjectItem
projectItem = DTE.ActiveDocument.ProjectItem
codeClass = DirectCast(projectItem.FileCodeModel.CodeElements.Item(1), EnvDTE80.CodeClass2)
codeEvent = DirectCast(codeClass.Members.Item(1), EnvDTE80.CodeEvent)
MsgBox("Comment of " & codeClass.FullName & ":" & codeClass.Comment)
MsgBox("Comment of " & codeEvent.FullName & ":" & codeEvent.Comment)
End Sub
- Create a C# project and paste this code in the Class1.cs file:
| Language: C# | Copy Code (IE only) |
public class Class1
{
public event System.EventHandler Event1;
}
- Execute the macro when the Class1.cs file is active. While the returned comment
for the class is "", it is <doc>\n</doc> for the event.
Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this
|