[英]How to add c# xml cref comment for a complex expression?
I would like to add a cref for the expression Bars[0].Name
我想为表达式Bars[0].Name
添加一个 cref
Here is the code but it generates 2 warnings这是代码,但它会生成 2 个警告
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?如何在不生成警告的情况下添加此 cref?
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.