[英]How to add c# xml cref comment for a complex expression?
我想為表達式Bars[0].Name
添加一個 cref
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.