视觉工作室 |带关键字 'null' 的摘要
VisualStudio | summary with keyword 'null'
我有一个 property
可以是 null
。我想在 summary
中对此进行记录,这是我的问题。
cref
/// <summary>
/// Can be <see cref="null"/>.
/// </summary>
public object FooProperty;
ReSharper
说,有一个 Syntax Error
,但突出显示按预期工作!
cref 嵌套
/// <summary>
/// Can be <see><cref>null</cref></see>.
/// </summary>
public object FooProperty;
将其格式化为 nested
时,突出显示不再 工作。
语言
/// <summary>
/// Can be <see langword="null"/>.
/// </summary>
public object FooProperty;
langword
有效,但 VisualStudio
中没有 intelliSense
。
谁能告诉我记录这些 keywords
和 IntelliSense
支持的正确方法是什么!
解决方法
- VisualStudio | CodeSnippet for inside comment/summary block (IntelliSense)
langword 是必经之路。你是对的,没有 Intellisense 支持这个。可能是因为它不是 officially recommended XML comment tag 属性。但是可以根据您的评论生成文档的工具,例如Sandcastle Help File Builder 或 VSdocman(免责声明,我是 VSdocman 的开发者)将识别此语法并生成特殊文本。例如,VSdocman 生成:
空引用(Nothing 在 Visual Basic 中)
同样适用于other reserved words,如真实、抽象等
虽然 Intellisense 无法帮助您,但 VSdocman 有一个所见即所得的评论编辑器,可以帮助您处理更复杂的评论。
请注意 <see cref="null"/>
。这将为名为 null 的 class、方法或 属性 创建一个 link。这在 C# 中是不可能的,你需要在保留字的名称前加上 @:
/// <summary>
/// <see cref="@null"/>
/// </summary>
public class MyClass
{
public void @null() {}
}
但这在 VB .NET 中完全有效:
''' <summary>
''' <see cref="null"/>
''' </summary>
Public Class MyClass
ReadOnly Property null As String
End Class
我有一个 property
可以是 null
。我想在 summary
中对此进行记录,这是我的问题。
cref
/// <summary>
/// Can be <see cref="null"/>.
/// </summary>
public object FooProperty;
ReSharper
说,有一个 Syntax Error
,但突出显示按预期工作!
cref 嵌套
/// <summary>
/// Can be <see><cref>null</cref></see>.
/// </summary>
public object FooProperty;
将其格式化为 nested
时,突出显示不再 工作。
语言
/// <summary>
/// Can be <see langword="null"/>.
/// </summary>
public object FooProperty;
langword
有效,但 VisualStudio
中没有 intelliSense
。
谁能告诉我记录这些 keywords
和 IntelliSense
支持的正确方法是什么!
解决方法
- VisualStudio | CodeSnippet for inside comment/summary block (IntelliSense)
langword 是必经之路。你是对的,没有 Intellisense 支持这个。可能是因为它不是 officially recommended XML comment tag 属性。但是可以根据您的评论生成文档的工具,例如Sandcastle Help File Builder 或 VSdocman(免责声明,我是 VSdocman 的开发者)将识别此语法并生成特殊文本。例如,VSdocman 生成:
空引用(Nothing 在 Visual Basic 中)
同样适用于other reserved words,如真实、抽象等
虽然 Intellisense 无法帮助您,但 VSdocman 有一个所见即所得的评论编辑器,可以帮助您处理更复杂的评论。
请注意 <see cref="null"/>
。这将为名为 null 的 class、方法或 属性 创建一个 link。这在 C# 中是不可能的,你需要在保留字的名称前加上 @:
/// <summary>
/// <see cref="@null"/>
/// </summary>
public class MyClass
{
public void @null() {}
}
但这在 VB .NET 中完全有效:
''' <summary>
''' <see cref="null"/>
''' </summary>
Public Class MyClass
ReadOnly Property null As String
End Class