Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<inheritdoc cref> has bad default for path attribute, leading to senseless inherited doc #45994

Open
AArnott opened this issue Jul 15, 2020 · 2 comments
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-IntelliSense Completion, Signature Help, Quick Info
Projects
Milestone

Comments

@AArnott
Copy link
Contributor

AArnott commented Jul 15, 2020

Version Used: 16.8 (30313.166.master)

Steps to Reproduce:

public class C
{
    /// <param name="a"><inheritdoc cref="M(int,int)" path="/param[@name='a']"/></param>
    public void M(int a)
    {
        if (a > 0)
        {
        }
    }

    /// <summary>summary</summary>
    /// <param name="a">A description</param>
    /// <param name="b">B description</param>
    public void M(int a, int b)
    {
        if (a > 0 || b > 0)
        {
        }
    }
}

Expected Behavior:

I expect the default path to provide the same meaning as the explicitly specified path, as shown here:

image

Actual Behavior:

Instead, I see a concatenation of all param docs together, with not so much as a delimiter:

image

@sharwell sharwell added Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-IntelliSense Completion, Signature Help, Quick Info labels Jul 15, 2020
@sharwell
Copy link
Member

Currently, for the example scenario the path attribute is defaulting to /param/node()[not(self::overloads)]. The implementation for the default path attribute value is:

static string BuildXPathForElement(XElement element)
{
if (ElementNameIs(element, "member") || ElementNameIs(element, "doc"))
{
// Avoid string concatenation allocations for inheritdoc as a top-level element
return "/*/node()[not(self::overloads)]";
}
var path = "/node()[not(self::overloads)]";
for (var current = element; current != null; current = current.Parent)
{
var currentName = current.Name.ToString();
if (ElementNameIs(current, "member") || ElementNameIs(current, "doc"))
{
// Allow <member> and <doc> to be used interchangeably
currentName = "*";
}
path = "/" + currentName + path;
}
return path;
}

The code needs to be updated to recognize that the containing param element has a name attribute, and add a predicate:

-/param/node()[not(self::overloads)]
+/param[@name="a"]/node()[not(self::overloads)]

@sharwell sharwell added this to InQueue in Small Fixes via automation Jul 15, 2020
@sharwell sharwell added this to the Backlog milestone Jul 15, 2020
@sharwell
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-IntelliSense Completion, Signature Help, Quick Info
Projects
Small Fixes
  
InQueue
Development

No branches or pull requests

2 participants