我想知道是否可能在注释中引用一个动态的泛型类名,并且在IDE中有条件地解析它?
简单的基础类示例:
// <summary>
// Retrieves all <T> members from the database.
// </summary>
public void GetAll<T>()
{
//magic
}
如果我现在从这个类继承并且恰好是类 User,那么我希望 IntelliSense 将我的注释显示为“从数据库检索所有用户成员”。
这可能吗?
我想知道是否可能在注释中引用一个动态的泛型类名,并且在IDE中有条件地解析它?
简单的基础类示例:
// <summary>
// Retrieves all <T> members from the database.
// </summary>
public void GetAll<T>()
{
//magic
}
如果我现在从这个类继承并且恰好是类 User,那么我希望 IntelliSense 将我的注释显示为“从数据库检索所有用户成员”。
这可能吗?
无法让Intellisense自动写入用于特定调用的泛型类型名称。最好的方法是使用typeparamref
标签,这会告诉Visual Studio(更重要的是任何文档生成器),你正在引用泛型类型参数(在本例中为T
)。
// <summary>
// Retrieves all <typeparamref name="T"/> members from the database.
// </summary>
public void GetAll<T>()
{
//magic
}