1

I would like to add a cref for the expression Bars[0].Name

Here is the code but it generates 2 warnings
enter image description here enter image description here

using System.Collections.Generic;

namespace MyProject
{
    class IFoo
    {
        public Bars Bars { get; } = new Bars();

        /// <summary>
        /// Returns true if <see cref="Bars[0].Name"/>  is empty or null.
        /// </summary>
        /// <value>Indicates if name is empty or null</value>
        public bool IsFirstBarChildNameEmptyOrNull() =>
            Bars.Count == 0 || string.IsNullOrEmpty(Bars[0].Name);
    }

    class Bars
    {
        private List<Child> _children = new List<Child>();

        public Child this[int index] => _children[index];
        public int Count => _children.Count;
    }

    class Child
    {
        public string Name { get; set; }
    }
}

How can I add this cref without generating a warning?

3
  • What would you expect this would link to? Child.Name? Commented Mar 10, 2021 at 9:15
  • @KlausGütter Good question. What would developers expect? Commented Mar 10, 2021 at 9:33
  • I have found that if I add P: then the warning goes away. E.g. <see cref="P:Bars[0].Name"/> But I don't know if this is a good solution or not Commented Mar 10, 2021 at 9:35

1 Answer 1

0

You can't do it directly like that.

You could get close by splitting it into two like so:

/// <summary>
/// Returns true if <see cref="Bars"/>[0].<see cref="Child.Name"/> is empty or null.
/// </summary>
/// <value>Indicates if name is empty or null</value>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.