如何为复杂表达式添加 c# xml cref 注释?
How to add c# xml cref comment for a complex expression?
我想为表达式 Bars[0].Name
添加 cref
这是代码,但它会生成 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; }
}
}
如何在不生成警告的情况下添加此 cref?
不能这么直接做。
你可以像这样把它分成两部分来接近:
/// <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>
我想为表达式 Bars[0].Name
这是代码,但它会生成 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; }
}
}
如何在不生成警告的情况下添加此 cref?
不能这么直接做。
你可以像这样把它分成两部分来接近:
/// <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>