Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use IEnumerable<String> in documenting code

I have this method which I am trying to generate documentation.

    /// <summary>
    /// This method demonstrates taking a Func as argument and perform that action(Func) on a list of strings.</summary>
    /// <param name="listOfStrings"> ... </param>
    /// <param name="ActionToPerformOnEach"> ... </param>
    /// <returns>Returns an <see cref="IEnumerable{String}" /> which has elements that resulted due to the Func action </returns>
    public static IEnumerable<String> ActOnListWithFunc(List<string> listOfStrings, Func<string, string> ActionToPerformOnEach) {
        foreach (string s in listOfStrings) {
            string actedString = ActionToPerformOnEach(s);
            yield return actedString;
        }
    }

This generates documentation like this (only Return Value section is shown)

Return Value
Type: IEnumerable<String>
Returns an IEnumerable<T> which has elements that resulted due to the Func action

Where I am describing the return value of the method, I want to use IEnumerable<string> but if you look the desscription it is generating IEnumerable<T>. The Type: (second line above) although is been picked up properly as IEnumerable<string>. Just the description line for the return value is not correct.

How do we describe IEnumerable<string> or IEnumerable<int> or any other specific type of enumeration in descriptions of parameters or return values, that is betwween <param> </param> or <returns> </returns> tags of the Method being documentated.

like image 452
Jatin Avatar asked Jun 29 '14 10:06

Jatin


People also ask

What is IEnumerable string?

IEnumerable is an interface defining a single method GetEnumerator() that returns an IEnumerator interface. It is the base interface for all non-generic collections that can be enumerated. This works for read-only access to a collection that implements that IEnumerable can be used with a foreach statement.

What is IEnumerable string in C#?

IEnumerable in C# is an interface that defines one method, GetEnumerator which returns an IEnumerator interface. This allows readonly access to a collection then a collection that implements IEnumerable can be used with a for-each statement.

When should I use IEnumerable?

IEnumerable is best to query data from in-memory collections like List, Array etc. IEnumerable doesn't support add or remove items from the list. Using IEnumerable we can find out the no of elements in the collection after iterating the collection. IEnumerable supports deferred execution.


1 Answers

You can show the appropriate text using <see cref="IEnumerable{String}">IEnumerable&lt;string&gt;</see>. However the link will still be to IEnumerable<T> as there is no specific documentation for IEnumerable<string>

like image 188
John Koerner Avatar answered Sep 30 '22 16:09

John Koerner