简体   繁体   English

为什么我没有收到公共 API 上缺少 xml 文档的警告?

[英]Why am I not getting warnings for missing xml documentation on public API?

My C# project (a Unity Package library) is not getting warnings on missing xmldoc of public classes, properties or methods.我的 C# 项目(一个 Unity Package 库)没有收到关于缺少公共类、属性或方法的 xmldoc 的警告。

I want to ensure all of my public API has XML documentation in code, but I've noticed there's undocumented public methods with no warnings.我想确保我所有的公共 API 在代码中都有 XML 文档,但我注意到有未记录的公共方法,没有警告。 The csproj for my lib was basically copied from the csproj auto-generated by Unity, with a few changes.我的 lib 的 csproj 基本上是从 Unity 自动生成的 csproj 中复制的,并进行了一些更改。 I'm not suppressing any warnings related to documentation as far as I can tell.据我所知,我并没有压制与文档相关的任何警告。

What I wanted was basically CS1591 :我想要的基本上是CS1591

Missing XML comment for publicly visible type or member 'Type_or_Member'缺少 XML 公开可见类型或成员“Type_or_Member”的评论

The DocumentationFile compiler option was specified, but one or more constructs did not have comments.指定了DocumentationFile编译器选项,但一个或多个构造没有注释。

It seems I have to make sure the <DocumentationFile> tag is specified to a non-empty file path (and WarningLevel 4 is not disabled) in the csproj.看来我必须确保在 csproj 中将<DocumentationFile>标记指定为非空文件路径(并且未禁用 WarningLevel 4)。

<DocumentationFile>some/path/AssemblyName.xml</DocumentationFile>

I hadn't specified it before because I don't actually need documentation in a separate xml if my lib will be distributed as source code (Unity already picks the docs from code comments).我之前没有指定它,因为如果我的 lib 将作为源代码分发(Unity 已经从代码注释中选择文档),我实际上不需要单独的 xml 中的文档。 I would need it if I had to compile the dll.如果我必须编译 dll,我会需要它。

After specifying the DocumentationFile to some temp path, VSCode / Omnisharp will emit warnings like CS1591, CS0419.将 DocumentationFile 指定到某个临时路径后,VSCode / Omnisharp 将发出警告,如 CS1591、CS0419。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM