繁体   English   中英

由于注释中的 cref 引用,在 C# 应用程序中出现不明确的引用错误?

[英]Getting ambiguous reference error in C# app due to cref reference in comments?

这是我以前从未见过的新问题。 它发生在 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。 我提到这一点,以防它可能相关。

在 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>

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

例如,假设您的Easy.GetInfo有一个将 int 作为参数的重载。 您可以使用<see cref="Easy.GetInfo(int)"/>引用该特定函数。 可以这么说,似乎o:事情“破坏了参考”。 (我没有详细介绍这个。)

此外,在您的参数类型涉及泛型的情况下,您必须对<>字符进行转义。 就我而言, function(IList<uint>)必须写成function(IList&lt;uint&gt;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM