Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

This is a new problem I've never seen before. It's occurring in an open source wrapper for LibCURL.NET:

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

I am getting an ambiguous reference "warning as error", but the odd part is that it's happening due to a CREF reference in one of the LibCURL source files (see below). There are indeed several different overloads for for the method named Easy.GetInfo(), but I have no idea how to fix this since the offending code isn't a method call to Easy.GetInfo(), in fact it isn't code at all, but instead it's a CREF element in the comments for an Enum. Does anyone know how to fix this?

/// <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
{
    ...

Note: I re-targeted LibCURL.NET for the .NET framework version 4.5.1. I am mentioning this in case it might be related.

like image 706
Robert Oschler Avatar asked Nov 02 '15 04:11

Robert Oschler


People also ask

What is ambiguous error in C#?

ambiguity error is that you named field and property tha same name "colour". change the property definition f.e. public string Colour { get { return colour;} set { colour = value;} }


2 Answers

Got an answer on Twitter, my thanks to Peter Foot. It's really an obscure solution so I'm putting it here for others to find as a community Wiki answer. All I had to do was prefix the CREF target with "o:" and that tells the compiler to accept the reference to an overloaded function. See below:

    /// <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>
like image 149
Robert Oschler Avatar answered Sep 24 '22 04:09

Robert Oschler


Also answering for history: You can reference a specific overloaded function by specifying its parameters.

For example, say your Easy.GetInfo had an overload that takes an int as a parameter. You could reference that specific function with <see cref="Easy.GetInfo(int)"/>. It seems the o: thing "breaks the reference", so to speak. (I did not go into the details of this.)

Also, in the case where your parameters type involve generics you'll have to escape the < and > characters. In my case, function(IList<uint>) had to be written function(IList&lt;uint&gt;)

like image 38
Eliott Gaboreau Avatar answered Sep 21 '22 04:09

Eliott Gaboreau