参照泛型类型C#XML文档中的泛型类型的? [英] Referring to a generic type of a generic type in C# XML documentation?

查看:300
本文介绍了参照泛型类型C#XML文档中的泛型类型的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

写一些XML文档谓词辅助类。但我想不通,我可以指一个表达式来; Func键< T,BOOL>> 没有得到一个语法错误。它甚至有可能?我曾尝试这样的:

 <见CREF =表达{Func键{T,布尔}}/> 



但我得到下红色波浪线{T,布尔}} 。这工作虽然:

 <见CREF =表达式{} TDelegate/> 



任何人都有一个线索?






更新:



这给予(我接受)答案看似没有工作。但现在我已经开始得到了很多关于不能够解决的东西警告。我有一个名为的ExpressionBuilder<类; T> 和表达式来; Func键< T,BOOL>> 很多。所以我当然想指的是在我的XML注释



我已经试过两个版本,我知道的:

 <见CREF =表达与放大器; LT; Func键和放大器; LT; T,布尔和放大器; GT;&放大器; GT;/> 
<见CREF =表达式{{Func键T,布尔}}/>



但是,无论工作。 (而在最后一个,ReSharper的将一个蓝色的波浪在 {T,布尔}} 我得到正在编制两个警告我到处都用它它说:





  1. 在等等等等XML注释已CREF属性表达>'不能被解析

  2. 类型参数声明必须是一个标识符不是一个类型的。参见错误CS0081。




有同样问题的地方我试着参考范围和LT;可空< DateTime的>> 范围和LT; DateTime的> 没有工作或者都用{}和&放大器; LT;&放大器; GT;



我是不是应该把这些种仿制药的?


解决方案

有似乎没有办法来指一般的。一个通用的XML文档中的,因为实际上,没有办法来指一般的任何特定类型的



拉塞V卡尔森的的回答使得点击我:



如果你写<见CREF =的IEnumerable {的Int32}/> ,编译器只是使用的Int32作为类型参数名称,而不是类型参数。写<见CREF ={IEnumerable的的HelloWorld}/> 将工作一样好。这是有道理的,因为在MSDN没有具体的页面,你的文档,可以链接到诠释的IEnumerable的。



要正确地记录您的课,我想你会有写是这样的:

 <总结> 
返回<见CREF =IEnumerable的横置/>的<见CREF ={KeyValuePair T,U}/>的<
;见CREF =字符串/>中<见CREF =的Int32/取代。
< /总结>



我希望你喜欢的文字。


Writing some XML documentation for a predicate helper class. But I can't figure out I can refer to an Expression<Func<T, bool>> without getting a syntax error. Is it even possible? I have tried this:

<see cref="Expression{Func{T, bool}}"/>

But I get a red squiggly line under {T, bool}}. This works though:

<see cref="Expression{TDelegate}"/>

Anyone have a clue?


Update:

The answer that was given (and I accepted) seemingly did work. But now I have started to get a lot of warnings about stuff not being able to resolve. I have a class called ExpressionBuilder<T> which works with Expression<Func<T, bool>> a lot. So I of course want to refer to that in my XML comments.

I have tried both versions that I know about:

<see cref="Expression&lt;Func&lt;T, Boolean&gt;&gt;"/>
<see cref="Expression{Func{T, Boolean}}"/>

But neither work. (And on the last one, ReSharper puts a blue squiggly under {T,Boolean}} I get two warnings under compilation everywhere I have used it which says that:

  1. XML comment on 'blah blah' has cref attribute 'Expression>' that could not be resolved
  2. Type parameter declaration must be an identifier not a type. See also error CS0081.

Have the same issue somewhere I tried to refer to Range<Nullable<DateTime>> (Range<DateTime?> didnt work either. Both with { } and with &lt; &gt;)

Am I not supposed to refer to these kinds of generics?

解决方案

There seems to be no way to refer to a generic of a generic in XML documentation, because actually, there's no way to refer to a generic of any specific type.

Lasse V Karlsen's answer made it click for me:

If you write <see cref="IEnumerable{Int32}" />, the compiler just uses "Int32" as the type parameter name, not the type argument. Writing <see cref="IEnumerable{HelloWorld}" /> would work just as well. This makes sense because there is no specific page in MSDN for "IEnumerable of int" that your documentation could link to.

To document your class properly, I think you'd have to write something like:

<summary>
Returns an <see cref="IEnumerable{T}" /> of <see cref="KeyValuePair{T,U}" /> 
of <see cref="String" />, <see cref="Int32" />.
</summary>

I hope you like text.

这篇关于参照泛型类型C#XML文档中的泛型类型的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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