Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#XML文档中引用泛型类型的泛型类型?_C#_Visual Studio 2008_Generics_Resharper_Xml Documentation - Fatal编程技术网

在C#XML文档中引用泛型类型的泛型类型?

在C#XML文档中引用泛型类型的泛型类型?,c#,visual-studio-2008,generics,resharper,xml-documentation,C#,Visual Studio 2008,Generics,Resharper,Xml Documentation,为谓词助手类编写一些XML文档。但我不知道引用表达式时是否会出现语法错误。有可能吗?我试过这个: <see cref="Expression{Func{T, bool}}"/> 有人有线索吗 更新: 给出的答案(我也接受了)似乎奏效了。但现在我开始收到很多关于无法解决问题的警告。我有一个名为ExpressionBuilder的类,它经常与Expression一起工作。所以我当然想在我的XML注释中提到这一点 我已经尝试了我知道的两个版本: <see cref="Expres

为谓词助手类编写一些XML文档。但我不知道引用
表达式时是否会出现语法错误。有可能吗?我试过这个:

<see cref="Expression{Func{T, bool}}"/>
有人有线索吗


更新:

给出的答案(我也接受了)似乎奏效了。但现在我开始收到很多关于无法解决问题的警告。我有一个名为
ExpressionBuilder
的类,它经常与
Expression
一起工作。所以我当然想在我的XML注释中提到这一点

我已经尝试了我知道的两个版本:

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

但两者都不起作用。(在最后一个例子中,ReSharper在
{T,Boolean}}
下放了一个蓝色的波形符号,我在使用它的地方都会得到两个警告:

  • “blah blah”上的XML注释具有无法解析的cref属性“Expression>”
  • 类型参数声明必须是标识符而不是类型。另请参阅错误CS0081
  • 我试图引用的
    Range
    Range
    也不起作用。使用{}和

    我不应该引用这些类型的泛型吗?

    //使用“”而不是“”符号。
    
    // Use "&lt;" instead of "<" symbol and "&gt;" instead of ">" symbol.
    
    // Sample:
    
    <see cref="Expression&lt;Func&lt;T, bool&gt;&gt;"/>
    
    //样本:
    您希望它链接到什么

    文档中没有
    表达式
    ,因此链接到该表达式显然不起作用

    您可以链接到
    表达式
    ,因为它存在

    至于什么有效或无效,Visual Studio 2008/.NET 3.5中的以下两项都不适用于我:

    /// <see cref="Expression&lt;Func&lt;T&gt;&gt;"/>.
    /// <see cref="Expression{Func{T}}"/>.
    
    //。
    /// .
    
    但这是可行的:

    /// <see cref="Expression{T}"/>.
    
    //。
    

    因此,显然泛型类型参数不必与声明中的参数相同。

    在XML文档中似乎无法引用泛型的泛型,因为实际上,无法引用任何特定类型的泛型

    Lasse V Karlsen让我很高兴:

    如果您编写
    ,编译器只使用“Int32”作为类型参数名,而不是类型参数。编写
    也可以。这是有意义的,因为MSDN中没有特定页面可供您的文档链接到“int的IEnumerable”

    要正确记录您的类,我认为您必须编写如下内容:

    <summary>
    Returns an <see cref="IEnumerable{T}" /> of <see cref="KeyValuePair{T,U}" /> 
    of <see cref="String" />, <see cref="Int32" />.
    </summary>
    
    
    返回一个
    属于
    

    我希望你喜欢文本。

    我现在遇到了这个问题,因为我有一个函数返回一个
    列表。
    。是的,它很难看,但我没有写。我知道标准免责声明

    无论如何,在2017年VS与R#Ultimate 2017.1的比赛中,这份文件评论

    <returns><see cref="List{List{Byte}}" /> of split frames</returns>
    
    分割帧的
    
    
    …给我一个语法错误。但是,这

    分割帧的列表{List{byte}}

    …没有。真有趣

    还丑吗?是的


    作为丑陋?我认为它没有使用
    我自己那么可怕。

    不要使用空的see元素(
    ),而是将文本放在see元素中

    <see cref="IEnumerable{T}">IEnumerable</see>&lt;<see cref="..."/>$gt;
    
    IEnumerable$gt;
    
    我尝试了堆栈溢出的所有方法,以获得在几种情况下都能工作的结果。这里有一个适合我的解决方案。(这是对其他人的主观判断。)

  • 产生可点击的链接
  • 将鼠标悬停在标识符上可以工作
  • 正确生成.xml文件
  • 在intellisense中不产生错误
  • 适用于可为空的泛型类型参数
  • 在Resharper及其内置的XML文档窗口中工作(Resharper->Edit->Show Quick Documentation)
  • 在Atomineer Pro Documentation Visual Studio扩展的XAM文档预览中工作
  • 使用泛型类型的泛型类型
  • 示例#1

    //
    ///此实例字段包含对
    ///作为
    ///包含
    ///当前打开并显示的所有PDF的列表。
    /// 
    private ConcurrentDictionary openedPdfs=默认值!;
    注:
    ConcurrentDictionary{Decimal,Boolean}将正确生成
    悬停时可单击ConcurrentDictionary{TKey,TValue}的链接
    T:ConcurrentDictionaryCIMAL,布尔?确保读者
    关于TKey和TValue是什么类型的信息。
    
    示例2(使用“T”)

    //
    ///此实例字段包含对
    ///作为
    ///包含
    ///当前打开并显示的所有PDF的列表。
    /// 
    private ConcurrentDictionary openedPdfs=默认值!;
    
    噢,天哪……这很难看……但它确实有效=/为什么它只接受一种类型的{},而不接受更多类型的{}?确定什么?就像我说的,当使用
    表达式{TDelegate}
    或例如
    列表{String}时,我没有看到红色的曲线
    。事实上,当我写这篇文章时,我注意到红色的曲线不是Visual Studio,很可能是ReSharper或Refactor!Pro,它们有时也会被混淆。相信编译器。Visual Studio 2010会用警告标记这样的东西。显然,MS觉得在2008年不这样做是一个bug。不需要
    ,这是一个很好的形式ed XML:
    所以没有办法引用带有特殊类型参数的泛型类型?就像我有一个返回列表的函数,我只能说它返回了列表?这是因为“String”然后用作泛型类型名称。试试列表,它也会很好地工作。我正要问同样的问题。我花了一些时间才找到这个问题,因为标题不是很关键字y。我可以建议“如何在C#XML文档中引用泛型类型的泛型类型”?您还可以添加“泛型”标记。我没有代表自己来做。在VS2015中工作正常,重塑器9消息说“类型参数声明必须是标识符而不是类型”;例如,如果您有
    <see cref="IEnumerable{T}">IEnumerable</see>&lt;<see cref="..."/>$gt;
    
      /// <summary>
      ///  This instance field holds a reference to the
      ///  <see cref="ConcurrentDictionary{Decimal, Boolean}"/> as
      ///  <see cref="T:ConcurrentDictionary&lt;decimal, bool?&gt;"/> that contains
      ///  the list of all PDF's that are currently opened and being displayed.
      /// </summary>
      private ConcurrentDictionary<decimal, bool?> openedPdfs = default!;
    
      Note: 
        The ConcurrentDictionary{Decimal, Boolean} will correctly produce a
        clickable link of ConcurrentDictionary{TKey, TValue} on hovering while
        T:ConcurrentDictionary&lt;decimal, bool?&gt; makes sure the reader gets
        information on what type TKey and TValue are.
    
      /// <summary>
      ///  This instance field holds a reference to the
      ///  <see cref="ConcurrentDictionary{TKey, TValue}"/> as
      ///  <see cref="T:ConcurrentDictionary&lt;decimal, bool?&gt;"/> that contains
      ///  the list of all PDF's that are currently opened and being displayed.
      /// </summary>
      private ConcurrentDictionary<decimal, bool?> openedPdfs = default!;