views:

313

answers:

3

Is there a way to document a member inline in .Net? Let me explain. Most tools that extract documentation from comments support some kind of inline documentation where you can add a brief after the member declaration. Something like:

public static string MyField; /// <summary>Information about MyField.</summary>

Is there a way to do this in C# or the .NET languages?

+2  A: 

Yep, just put it BEFORE the thing you want to comment

/// <summary>Information about MyField.</summary>
public static string MyField;
GeekyMonkey
I know I can put it before. I'm asking if I can put it after in the same line.
Curro
That's not an inline comment.
Scott Dorman
// specifies an inline comment as opposed to /* for multilineThis is what I thought you meant. No, there is no way of putting it AFTER. How would the compiler know you didn't want to apply it to the following line?
GeekyMonkey
Most parsers use a character to understand that the documentation is referring to the symbol prior to the comment. Something like:public static string MyField; //- <summary>Information</summary>When the parser sees //- as opposed to /// it knows it is documentation for the preciding symbol.
Curro
+4  A: 

No, you can't. XML comments are only supported as a block level comment, meaning it must be placed before the code element you are documenting. The common tools for extracting XML comments from .NET code do not understand how to parse inline comments like that. If you need this ability you will need to write your own parser.

Scott Dorman
+2  A: 

There is not a built-in way to do this. The XML documentation system is hierarchical; it defines a relationship between the tag <summary /> and the data that immediately follows it.

Robert S.