Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - Summary Tag Comments - Optional Params

When specifying summary tag comments, is there a way with the <param> tag to note that a parameter is optional, ie. the client can supply a value or null, such as: <param name="Mime" optional="true">.

Googling has failed to provide me with a set list of attributes or allowed values.

/// <summary>
/// Sets data associated with instance
/// </summary>
/// <param name="Key">The key defining the data</param>
/// <param name="Value">The data</param>
/// <param name="Mime">The mime type of the data (optional)</param>     <----- Mark as optional

Thanks

like image 749
cweston Avatar asked Sep 07 '11 13:09

cweston


2 Answers

No, you can't. The only attribute being recognized by VS is the name, like that:

<param name="FileName" >The filename of the file to be loaded.</param>

The only thing that you can do - is to set xsl transform for your output document. But this won't have any effect on Intellisense.

like image 174
VMAtm Avatar answered Oct 04 '22 17:10

VMAtm


You should provide an overload that omits the optional parameter:

/// <summary>
/// Sets data associated with the instance using the default media type.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
public void SetData(object key, object value)
{
    SetData(key, value, null);
}

/// <summary>
/// Sets data associated with the instance using the specified media type.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
/// <param name="mime">The media type of the data.</param>
public void SetData(object key, object value, string mime)
{
    ...
}

Alternatively, you can declare the parameter as optional:

/// <summary>
/// Sets data associated with the instance.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
/// <param name="mime">The media type of the data.</param>
public void SetData(object key, object value, string mime = null)
{
    ...
}
like image 38
dtb Avatar answered Oct 04 '22 18:10

dtb