views:

687

answers:

1

Title says it all; <see cref="switch" />, for example, doesn't work - I get the compilation warning: XML comment on ... has syntactically incorrect cref attribute 'switch'


Context for those who are interested...

/// <summary>Provides base functionality for hand-coded abstractions of API method wrappers, mostly those that abstract over
/// parameters that are required to be JSON-encoded.</summary>
public class FacebookArgs : Dictionary<String, Object>
{
    /// <summary>Initializes an instance of <see cref="FacebookArgs" />.</summary>
    public FacebookArgs() { }

    /// <summary>Intializes an instance of <see cref="FacebookArgs" />, that contains elements copied from <paramref name="dictionary "/>.</summary>
    /// <param name="dictionary"></param>
    public FacebookArgs(IDictionary<String, Object> dictionary)
        : base(dictionary) { }

    /// <summary>Gets or sets the value associated with the specified key.</summary>
    /// <param name="key">The key of the value to get or set.</param>
    /// <returns>The value associated with the specified key.</returns>
    /// <remarks>This implementation hides the base indexer implementation such that specifying a key that does not exist returns null rather than throwing a <see cref="KeyNotFoundException" />.</remarks>
    public new Object this[String key]
    {
        get
        {
            Object value;
            if (this.TryGetValue(key, out value)) return value;
            else return null;
        }
        set { base[key] = value; }
    }

    /// <summary>In derived classes, provides specialized serialization logic for specific properties contained in this object.</summary>
    /// <param name="key">The key of the property to serialize.</param>
    /// <param name="args">A reference to a dictionary of arguments that will be passed directly to a <see cref="FacebookRequest" /> object.</param>
    /// <remarks>
    /// <para>This method allows specialized serialization logic, such as JSON encoding, to be applied to specific properties.</para>
    /// <para>To implement, use a <c>switch</c> (<c>Select</c> in VB.NET) statement to filter based on <paramref name="key" /> and provide the property-specific logic.
    /// The resulting value should then be added to <paramref name="args" /> using the same <paramref name="key "/>.
    /// </para>
    /// <para>Properties that do not require additional processing (strings, integral values, etc) should be ignored.</para>
    /// </remarks>
    protected virtual void SerializeProperty(String key, ref IDictionary<String, Object> args) { }

    /// <summary>Returns a dictionary of key/value pairs suitable to be passed a <see cref="FacebookRequest" /> object.</summary>
    /// <returns>A dictionary of key/value pairs suitable to be passed a <see cref="FacebookRequest" /> object.</returns>
    /// <remarks>This method calls the <see cref="SerializeProperty" /> for each key in the object, which allows property-specific processing
    /// to be done on any property.</remarks>
    /// <seealso cref="SerializeProperty" />
    public IDictionary<String, Object> GetArgs()
    {
        IDictionary<String, Object> args = new Dictionary<String, Object>();

        foreach (String key in this.Keys)
        {
            this.SerializeProperty(key, ref args);

            if (!args.ContainsKey(key) && this[key] != null)
            {
                args.Add(key, this[key]);
            }
        }

        return args;
    }
}


The tag in question can be found in the <remarks> tag for SerializeProperty. I'm erring on the side of verbose documentation. I also plan on providing some <example>s, I just haven't gotten around to it yet.

+7  A: 

cref is meant to refer to another member - a class, a method etc.

What would you expect it to link to in this case? In general, what do you want the overall effect to be?

According to this excellent XML doc guide, the <see> tag has an undocumented attribute langword:

<see langword="switch" />

Would that help you? It might be worth trying it just to see what it does.

If you just want to use a normal hyperlink, use href instead of cref:

<see href="http://msdn.microsoft.com/en-us/library/06tc147t.aspx"&gt;switch&lt;/a&gt;
Jon Skeet
The MSDN article for the switch keyword: http://msdn.microsoft.com/en-us/library/06tc147t.aspx
Daniel Schaffer
And that's why you've more rep than god...
Daniel Schaffer
It even works for VB.NET within a C# project! To implement, use a <see langword="switch" /> (<see langword="Select" /> in VB.NET)
Daniel Schaffer
I have to admit, I'd never seen that attribute before. I just knew of the page, and saw what it had to say for itself :)
Jon Skeet
Well it is an awesome article. Thanks! :D
Daniel Schaffer
The XML doc guide linked is currently returning a 404. Here's a link to the same article on the wayback machine: http://web.archive.org/web/20080623060531/http://thoughtpad.net/alan-dean/cs-xml-documentation.html
Iain
@Iain: Yes, that page went away a while ago... thanks for the replacement; will edit.
Jon Skeet