CS1574 on <see cref="[explicit interface implementation method]">

G

Gergely Varadi

public class A : IComparable
{
int IComparable.CompareTo(object obj)
{
return 1;
}
}

/// <summary>
/// <see cref="A.System.IComparable.CompareTo"/>
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
....
}

warning CS1574: XML comment on 'mynamespace
..Form1' has cref attribute 'A.System.IComparable.CompareTo' that could not be found
 
B

Brian W

You get this because "A.System.IComparable.CompareTo" is not defined in your
project.


HTH
Brian W



Gergely Varadi said:
public class A : IComparable
{
int IComparable.CompareTo(object obj)
{
return 1;
}
}

/// <summary>
/// <see cref="A.System.IComparable.CompareTo"/>
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
...
}

warning CS1574: XML comment on 'mynamespace
.Form1' has cref attribute 'A.System.IComparable.CompareTo' that could not
be found
 
G

Gergely Varadi

SBNH (Sorry, but not helped) :)

I don't understand your answer. If I extend the previous example with:

public class A : IComparable
{
int IComparable.CompareTo(object obj)
{
return 1;
}

void blabla()
{
}
}

/// <summary>
/// <see cref="A.System.IComparable.CompareTo"/>,
/// <see cref="A.blabla"/>
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
A kakukk = new A();
kakukk.blabla();
((IComparable)kakukk).CompareTo(7);
}
}

, the second reference ('<see cref="A.blabla"/>') is accepted, the
first one not. If I watch the model using Reflector, it views
-A
-blabla() : void
-System.IComparable.CompareTo(Object) : Int32

and if I invoke blabla(), the call stack in the debugger is:

TrySerializable.exe!proba46.A.blabla() Line 29 C#

while invoking the CompareTo method:

TrySerializable.exe!proba46.A.System.IComparable.CompareTo(System.Object
obj = {7}) Line 24 C#



So, what am I doing wrong?
 
B

Brian W

Simply put, A.System.IComparable.CompareTo does not exist. And the doc
generator seems to have trouble with the interface implementation using that
signature.

IIRC reflection is not used to generate the doc XML, it comes straight from
the source.

Try defining A this way

public class A : IComparable
{
public int CompareTo(object obj)
{
return 1;
}

void blabla()
{
}
}

Then Form1 this way, (note the comment

/// <summary>
/// <see cref="A.CompareTo"/>,
/// <see cref="A.blabla"/>
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
A kakukk = new A();
kakukk.blabla();
((IComparable)kakukk).CompareTo(7);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top