Bug 319515 (MONO76685) - [/doc] XML doc does not support reference to indexer.
Summary: [/doc] XML doc does not support reference to indexer.
Status: RESOLVED FIXED
Alias: MONO76685
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Atsushi Enomoto
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-12 21:22 UTC by Gert Driesen
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
fix (am attaching it here since mcs/tests does not work on windows now) (2.57 KB, patch)
2005-11-13 13:04 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:37:48 UTC


---- Reported by gert.driesen@pandora.be 2005-11-12 14:22:28 MST ----

mcs's support for /doc does not support references to indexers (using, 
for example, <see cref="...." />).

To reproduce compile the following code snippet (using mcs /doc:test.xml 
test.cs):

using System.Collections;

/// <summary><see cref="IDictionary.this[object]" /></summary>
public class Test {
	static void Main () {
	}
}

Actual result:

test.cs(4,14): warning CS1584: XML Comment on 'Test' has syntactically 
incorrect cref attribute 'IDictionary.this[object]'

Expected result:

Successful compilation, and the generated XML doc should look like this:

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>test</name>
    </assembly>
    <members>
        <member name="T:Test">
            <summary><see cref="P:System.Collections.IDictionary.Item
(System.Object)"/></summary>
        </member>
    </members>
</doc>



---- Additional Comments From gert.driesen@pandora.be 2005-11-13 05:22:34 MST ----

This code snippet exposes another issue with regards to indexers:

using System.Collections;

/// <summary>
///   <para><see cref="IDictionary.this[object]" /></para>
///   <para><see cref="A.this" /></para>
///   <para><see cref="B.this" /></para>
/// </summary>
public class Test
{
  static void Main()
  {
  }

  private class A
  {
    public object this[int index] {
      get { return null; }
    }

    public object this[string index] {
      get { return null; }
    }
  }

  private class B
  {
    public object this[int index] {
      get { return null; }
    }
  }
}

Let me know if you want me to create a separate bug report for this.



---- Additional Comments From atsushi@ximian.com 2005-11-13 06:04:18 MST ----

Created an attachment (id=168806)
fix (am attaching it here since mcs/tests does not work on windows now)




---- Additional Comments From atsushi@ximian.com 2005-11-13 06:07:36 MST ----

Yes, you're right. The latter one is problematic and mcs should report
warning unlike csc 1.x. 2.0 csc report CS0419.

76685a.cs(5,24): warning CS0419: Ambiguous reference in cref attribute:
        'A.this'. Assuming 'Test.A.this[int]', but could have also
matched other

        overloads including 'Test.A.this[string]'.

With the patch above it reports CS0419 (by the nature of our
implementation :-)

I will apply the patch above after I validated it.



---- Additional Comments From gert.driesen@pandora.be 2005-11-13 06:28:39 MST ----

The patch seems to work fine (thx!), but the warning message of mcs 
is less detailed.

The message output by mcs is :

test2.cs(4,14): error CS0419: Ambiguous reference in cref attribute 
`A.this'. Assuming `Test.A.Item' but other overloads including 
`Test.A.Item' have also matched

while csc reports this:

test.cs(4,14): error CS0419: Ambiguous reference in cref 
attribute: 'A.this'. Assuming 'Test.A.this[int]', but could have 
also matched other overloads including 'Test.A.this[string]'.

Would it be possible to have the warning message match that of csc 
(meaning retain the 'this' keyword in the message instead of 'Item', 
and include the indexer args in the message) ?



---- Additional Comments From atsushi@ximian.com 2005-11-13 07:56:39 MST ----

Turned out that the patch breaks xml-030 test.

I would like to fix those remaining matters you mentioned above, but
the primary fix might come first.



---- Additional Comments From atsushi@ximian.com 2005-11-13 11:10:17 MST ----

The bug itself is fixed in svn (r52972). I also have a patch that
fixes the error message, but I need others' review since it is
typemanager.cs and may affect on elsewhere.



---- Additional Comments From atsushi@ximian.com 2005-11-13 14:25:30 MST ----

http://lists.ximian.com/pipermail/mono-devel-list/2005-November/015717.html



---- Additional Comments From gert.driesen@pandora.be 2005-11-13 17:56:50 MST ----

Atsushi,

Apparently, a non-qualified reference to an indexer (using 
<type>.this, eg. A.this) results in a different cref usng mcs than 
when compiled using csc.

For example, when you compile this code snippet:

/// <summary>
///   <para><see cref="A.this" /></para>
/// </summary>
public class Test
{
  static void Main()
  {
  }

  private class A
  {
    public object this[int index] {
      get { return null; }
    }

    public object this[string index] {
      get { return null; }
    }
  }
}

then the resulting cref in the generated XML doc will be

P:Test.A.Item(System.String)   using mcs

and

P:Test.A.Item(System.Int32)    using csc

Again, let me know if you want a separate bug report for this.



---- Additional Comments From atsushi@ximian.com 2005-11-13 18:16:28 MST ----

The difference is nothing; there is NO reason that we must take int
one instead of string one.



---- Additional Comments From gert.driesen@pandora.be 2005-11-14 04:49:17 MST ----

Including transcript of private email conversation (as requested by 
Atsushi):

==== Gert ====

I'm not sure I understand your last remarks for this bug:

"The difference is nothing; there is NO reason that we must take int 
one
instead of string one."

I don't see why you say that there is no difference. The generated 
doc will
be different when built using mcs, as the cref will point to another
overload.

I ran into this as part of a (offline) test suite I have for catching
regressions in Mono.

Thanks for fixing the /doc bugs so fast !

=== Atsushi ===

There is no reason that /doc support must prefer this[int] over
this[string] when cref just references "this", as long as it
corresponds to what the warning message tells users. I return
the first item from FindMembers(). It's like expecting ordered
items from Hashtable. This is what we call implementation details.

BTW it should be no problem that this talk goes on the bugzilla
itself. Private talk contributes nothing to public.

Oh, and also thanks for you too for filing many bugs, as usual.




---- Additional Comments From atsushi@ximian.com 2005-11-15 17:53:30 MST ----

The second problem is also fixed in svn (r53091).

Imported an attachment (id=168806)

Unknown operating system unknown. Setting to default OS "Other".