Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the Type in an XML Comment <return> comment

In my C# XML Comment's <return> comment, I would like the output (I'm using Sandcastle) to specify the Type that is returned, but I am unable to find out how to do that.

Psuedo Example:

///<summary>
///Serves as a hash function for a particular type.
///</summary>
///<returns **Type="System.Int32"**>
///A hash code for the current Object.
///</returns>
public virtual int GetHashCode(){...}

The example above is a mock of what my guess is to tell Sandcastle how to specify the return type that is documented in the Syntax section of the documentation - not so.

For clarity, here is a screenshot of MSDN's documentation of the GetHastCode() method that shows the return type that I'm shooting for.

Do we have to manually specify the Type, or can we specify a Type (similar to the mock example) and let Sandcastle determine how to display/format the output - similar to how Sandcastle automatically displays/formats the Type for parameters via the <param> tag.

enter image description here

like image 966
Jed Avatar asked Feb 21 '12 23:02

Jed


2 Answers

You shouldn't need to specify it in the XML documentation - after all, that would be redundant, given that it's in the method declaration.

I suspect it's a matter of tweaking the Sandcastle style if you really want it - but do you find it particularly useful? It's not like users can't just click on the return type in the method signature. (At least that's what seems to be the case for the Prototype style in SHFB. See the Noda Time documentation for an example of what that looks like.)

In MSDN, then method signature doesn't have links (at least not in Chrome; I don't know if it's different in IE) but personally I would prefer it to be in the signature instead of cluttering up the actual documentation.

like image 121
Jon Skeet Avatar answered Oct 24 '22 22:10

Jon Skeet


This post (July 2011) has a response from Eric Woodruff (SHFB Author) regarding the lack of the return type being displayed within the <return> tag:

Sandcastle doesn't render the type information for the return information and I don't think it ever has. Provided the information is in the reflection information file, the XSL transformations could be modified to render it. I don't have time to look into it now but may be able to at some point to find out if its possible.

I suppose the official answer to my OP is; Sandcastle doesn't have an automatic way of specifying the return Type but, like Skeet already alluded to, it may be possible to accomplish this by modifying the XSL transformations.

like image 32
Jed Avatar answered Oct 24 '22 23:10

Jed