1

Given a generic interface how can I document the implementation of the generic types?

public interface ICommand<in T, in T2>
{
  void Execute(T arg1, T2 arg2);
}

public class MyCommand : ICommand<string, string>
{
}

Whats is the correct way to document the meaning of the T:"string" and T1:"string"?

EDIT

I forgot to add the ICommand interface to the MyComand class definition. The class is no duplicated, the other question asks about the documentation of the generic prameter T, I am askin about the documentation of the implementation of the generic parameter T.

nohros
  • 318
  • 1
  • 17

1 Answers1

3
public class MyCommand<string, string>

It will not compile.

You can only provide identifiers (T, T1, TKey etc...) in the type parameter declaration. However, you can provide XML comments for type parameters in the following way.

/// <summary>
/// Description
/// </summary>
/// <typeparam name="T">The type of xxxx</typeparam>
/// <typeparam name="T2">The type of xxxx</typeparam>
public interface ICommand<in T, in T2>
{
  void Execute(T arg1, T2 arg2);
}
Saeed
  • 71
  • 1
  • 5
  • My question has an error, very sorry about that and thanks for your answer, but I want to know how to document the parameters of the MyComand class and not the parameters of the ICommand interface. – nohros Apr 20 '13 at 19:15
  • 1
    You can't. Since, MyCommand is not generic type, therefore, you cannot document the parameters. Verify your code design, rethink what you really want. – Saeed Apr 24 '13 at 10:09