由于注释中的 cref 引用,我的 C# 应用程序出现了模棱两可的引用错误?

9

这是一个我从未见过的新问题。它发生在LibCURL.NET的开源包装器中:

http://sourceforge.net/projects/libcurl-net/

我收到了一个不明确的引用"警告作为错误",但奇怪的是,这是由于LibCURL源文件中的CREF引用导致的(见下文)。确实有几个名为Easy.GetInfo()的方法重载,但我不知道如何修复这个问题,因为有问题的代码并不是对Easy.GetInfo()方法的调用,事实上它根本不是代码,而是一个Enum注释中的CREF元素。有人知道如何解决这个问题吗?

/// <summary>
/// This enumeration is used to extract information associated with an
/// <see cref="Easy"/> transfer. Specifically, a member of this
/// enumeration is passed as the first argument to
/// <see cref="Easy.GetInfo"/> specifying the item to retrieve in the
/// second argument, which is a reference to an <c>int</c>, a
/// <c>double</c>, a <c>string</c>, a <c>DateTime</c> or an <c>object</c>.
/// </summary>
public enum CURLINFO
{
    ...

注意:我对LibCURL.NET进行了重新定位,以适应.NET框架版本4.5.1。提到这一点是为了防止有关联情况的发生。
2个回答

9

在Twitter上得到了答案,感谢Peter Foot。这确实是一个晦涩的解决方案,所以我将其放在这里作为社区Wiki答案供其他人查找。我所要做的就是在CREF目标前加上“o:”,这告诉编译器接受对重载函数的引用。请参见下面:

    /// <summary>
    /// Pass a <c>bool</c>. If it is <c>true</c>, libcurl will attempt to get
    /// the modification date of the remote document in this operation. This
    /// requires that the remote server sends the time or replies to a time
    /// querying command. The <see cref="o:Easy.GetInfo"/> function with the
    /// <see cref="CURLINFO.CURLINFO_FILETIME"/> argument can be used after a
    /// transfer to extract the received time (if any).
    /// </summary>

8

回答历史问题:您可以通过指定其参数来引用特定的重载函数。

例如,假设您的 Easy.GetInfo 有一个接受 int 参数的重载。您可以使用 <see cref="Easy.GetInfo(int)"/> 引用该特定函数。 似乎 o: 这个东西“破坏了引用”,就是这样。 (我没有详细了解这个。)

此外,在涉及泛型的情况下,您需要转义 <> 字符。在我的情况下,function(IList<uint>) 必须写成 function(IList&lt;uint&gt;)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接