VisualStudio |摘要,关键字' null'

时间:2017-12-08 08:12:57

标签: visual-studio documentation resharper summary

我有一个property,可以是null。我想在summary中记录这一点,这是我的问题。

CREF

/// <summary>
/// Can be <see cref="null"/>.
/// </summary>
public object FooProperty;

ReSharper说,有一个Syntax Error,但突出显示正在按预期工作!

Syntax Error highlight

cref nested

/// <summary>
/// Can be <see><cref>null</cref></see>.
/// </summary>
public object FooProperty;

not working

将其格式化为nested时,高强度 不再有效。

langword

/// <summary>
/// Can be <see langword="null"/>.
/// </summary>
public object FooProperty;

langword正在运作,但intelliSense中没有VisualStudio

有人可以告诉我记录这些keywords的正确方法是什么,IntelliSense支持会很好!

解决方案

1 个答案:

答案 0 :(得分:1)

langword 是要走的路。你是对的,没有Intellisense对此的支持。这可能是因为它不是officially recommended XML comment tag属性。但是可以根据您的评论生成文档的工具,例如: Sandcastle帮助文件生成器或VSdocman(免责声明,我是VSdocman的开发人员)将识别此语法并生成特殊文本。例如,VSdocman生成:

null引用(Visual Basic中 Nothing

同样适用于other reserved words,例如true,abstract等。

虽然Intellisense不会帮助你,但VSdocman有一个WYSIWYG评论编辑器可以帮助你处理更复杂的评论。

<see cref="null"/>还有一个注释。这将创建指向名为 null 的类,方法或属性的链接。这在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
相关问题