如何在XML注释中引用通用接口的具体实现? [英] How to reference specific implementations of generic interfaces in XML comments?

查看:117
本文介绍了如何在XML注释中引用通用接口的具体实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这种情况,2个接口,1个通用:

Consider this scenario, 2 interfaces, 1 generic:

public IGenericAdder<T>
{
   T Add(T, T);
}

public IIntAdder : IGenericAdder<Int32>
{
}

有什么地方可以做通用的添加方法,所以intellisense将显示添加Int32如果我做:

Is there someway that I can do XML comments on the generic add method, so that intellisense will show "Adds the Int32" if I do a:

IIntAdder foo;
foo.Add(  //Show intellisense here


推荐答案

p>我不认为有办法,你可以:

I don't think there is a way. You could:


  • 使评论通用,足以工作(即项一起),并让用户从Visual Studio生成的文档/工具提示中推断类型。

  • 隐藏 T Add(T,T) 的方法 new int Add(int,int) / code>并将特定的XML文档放在引用正确类型(即将两个int加在一起)上。

  • 使用< see cref =T />在XML文档中,但Visual Studio只是引用它 T

  • Make the comment generic enough to work (ie. "Adds two items together") and let the user infer the type from the Visual Studio generated docs/tooltip.
  • Hide the T Add(T, T) method of IGenericAdder with new int Add(int, int) in IIntAdder and put specific XML docs on it that refer to the correct types (ie. "Adds two ints together").
  • Use <see cref="T"/> in the XML docs, but Visual Studio just refers to it as T.

这些都不是你原来问的。

None of these really do what you originally asked though.

这篇关于如何在XML注释中引用通用接口的具体实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆