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 开发者_C百科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
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.
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)
{
...
}
You can use <remarks></remarks>
tag. Doesn't exist special tag for optional params.
精彩评论