【问题标题】:How to show generic types in C# XML summary如何在 C# XML 摘要中显示泛型类型
【发布时间】:2013-03-29 16:43:06
【问题描述】:
/// <summary>
/// Something about this generic method which works with ??? type.
/// </summary>
/// <typeparam name="T">∙∙∙</typeparam>
/// <returns></returns>
public T Foo<T>()
{
    ∙∙∙
}

是否可以在摘要标记中写注释以显示当前给定的泛型类型。 (就像视觉工作室一样)?

例如我们可以在Foo&lt;string&gt;()的工具提示中看到Something about this generic method which works with string type.

【问题讨论】:

  • 这不会误导吗?
  • 在某些情况下不是,我猜是这样。
  • @HarisHasan 例如,我们将能够看到elementName1 ("xxx") 参数的提示:The element name of type bool in Foo&lt;T1, T2&gt;(string elementName1, string elementName2)Foo&lt;bool, int&gt;("xxx", "yyy")。这不是很有帮助吗?

标签: c# generics summary


【解决方案1】:

这个标签应该这样做&lt;typeparamref name="T"/&gt;

Recommended Tags for Documentation Comments (C# Programming Guide)

【讨论】:

  • 我以前试过这个,但没有成功!在重构(重命名)类型参数名称以自动更新的情况下很有用。
【解决方案2】:

我认为你应该使用 GhostDocGhostDoc Link。使用快捷键 Ctrl + Shift + d 关于方法。它正在生成文档。

【讨论】:

  • For 方法如下所示: /// /// 获取指定的 id。 /// /// id。 /// public string Get(int id) { return "value"; }
  • 我在stackoverflow中找到了这个链接stackoverflow.com/questions/641364/…。您可能需要编辑返回: /// /// 序列化对象。 /// /// 实现对象的类型。 /// 要序列化的对象。 // / 返回序列化字符串。 public string SerializeObject(T objectToSerialize)
  • 感谢@Mvcdev。我检查了他们,但我找不到任何相关的答案。你介意举一个具体的例子吗?
  • @Mimi 我确实在上面放了两个例子。我还是不明白你在找什么具体的例子?
  • 不!亲爱的@Mvcdev,这个新示例与您的第二个示例完全相同。 (问题不在于 标签。)正如我上面所讨论的,我正在 的内容中寻找一些特殊标签 标记以显示作为通用参数传递给方法的内容。据我所知,XML 摘要中目前没有这样的标签。我只是猜想这个功能会很有用,希望以后能添加。尽管如此,任何解决方法都值得赞赏!
猜你喜欢
  • 2016-02-13
  • 1970-01-01
  • 2012-12-07
  • 2010-10-15
  • 1970-01-01
  • 2017-05-09
  • 1970-01-01
  • 1970-01-01
  • 2021-03-17
相关资源
最近更新 更多