How to collapse C# XML doc comments like in VB.NET


B

Billy

Anybody know how I can set environment in C# so that when you will
press "-" sign in front XML doc comment (///) it will collapse like in
VB.NET, With that i mean you will see only summary text and not only
<summary> tag.

Let me show example and results in both languages.

In VB.NET:
''' <summary>
''' Add two whole numbers
''' </summary>
''' <param name="intNr1">First number</param>
''' <param name="intNr2">Second number</param>
''' <returns></returns>
''' <remarks></remarks>
Function AddNumbers(ByVal intNr1 As Integer, ByVal intNr2 As
Integer) As Integer
Return intNr1 + intNr2
End Function

when I press "-" to collapse comment I get nicely only this row above
procedure:

Add two whole numbers
Function AddNumbers(ByVal intNr1 As Integer, ByVal intNr2 As Integer)
As Integer
Return intNr1 + intNr2
End Function

But for same procedure in C#:

/// <summary>
/// Add two whole numbers
/// </summary>
/// <param name="intNr1">First number</param>
/// <param name="intNr2">Second number</param>
/// <returns></returns>
/// <remarks></remarks>
public int AddNumbers(int intNr1, int intNr2)
{
return intNr1 + intNr2;
}

when I press "-" next to the comment I get this:

/// <summary> ...
public int AddNumbers(int intNr1, int intNr2)
{
return intNr1 + intNr2;
}

So what is the point of collapsing of such comment in C# if you cannot
see at the top what is the most important when you collapse comment?

So my quesitons is: How to see same summary also in C# like it is in
VB.NET?
 
J

Jeff Johnson

So my quesitons is: How to see same summary also in C# like it is in
VB.NET?
You can't. The C# and VB.NET editors are different; it's not just the
languages. In most situations I think the C# experience is superior, but
there are cases where VB.NET has an edge, and this is one of them.
 
B

Billy

You can't. The C# and VB.NET editors are different; it's not just the
languages. In most situations I think the C# experience is superior, but
there are cases where VB.NET has an edge, and this is one of them.
Yes, I completly agree that C# is more intuitive and more natural, but
that flaw should be implemented by design already.
 
A

Adam Clauss

Anybody know how I can set environment in C# so that when you will
press "-" sign in front XML doc comment (///) it will collapse like in
VB.NET, With that i mean you will see only summary text and not only
<summary> tag.

Let me show example and results in both languages.

In VB.NET:
'''<summary>
''' Add two whole numbers
'''</summary>
'''<param name="intNr1">First number</param>
'''<param name="intNr2">Second number</param>
'''<returns></returns>
'''<remarks></remarks>
Function AddNumbers(ByVal intNr1 As Integer, ByVal intNr2 As
Integer) As Integer
Return intNr1 + intNr2
End Function

when I press "-" to collapse comment I get nicely only this row above
procedure:

Add two whole numbers
Function AddNumbers(ByVal intNr1 As Integer, ByVal intNr2 As Integer)
As Integer
Return intNr1 + intNr2
End Function

But for same procedure in C#:

///<summary>
/// Add two whole numbers
///</summary>
///<param name="intNr1">First number</param>
///<param name="intNr2">Second number</param>
///<returns></returns>
///<remarks></remarks>
public int AddNumbers(int intNr1, int intNr2)
{
return intNr1 + intNr2;
}

when I press "-" next to the comment I get this:

///<summary> ...
public int AddNumbers(int intNr1, int intNr2)
{
return intNr1 + intNr2;
}

So what is the point of collapsing of such comment in C# if you cannot
see at the top what is the most important when you collapse comment?

So my quesitons is: How to see same summary also in C# like it is in
VB.NET?
If you modify the comment format slightly, it will give you a result
closer to what you want. That is, move the <summary> tags and content
onto a single line:

///<summary>Add two whole numbers</summary>
///<param name="intNr1">First number</param>
///<param name="intNr2">Second number</param>
///<returns></returns>
///<remarks></remarks>
public int AddNumbers(int intNr1, int intNr2)
{
return intNr1 + intNr2;
}

Not necessarily the "standard" way I see C# docs written, but it gives
the result you are looking for.

-Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top