带有DocFX的.NET API文档-如何在代码示例中正确显示方法调用

时间:2019-01-30 21:15:26

标签: c# visual-studio-2017 docfx

我试图利用Visual Studio中的XML表示法功能来构建我正在编写的API的文档。我遇到一个问题,在不自动填充参数类型的情况下,我无法弄清楚如何在代码示例中引用方法名称

示例:

    /// <summary>
    /// Exports the certificate corresponding to the specified certificate thumbprint to a Base64-encoded text file
    /// </summary>
    /// <param name="certThumbprint">Certificate thumbprint (case-insensitive)</param>
    /// <param name="exportPath">Fully-qualified path to where the Base64-encoded file should be written (a ".cer" file extension will be added if no file extension is detected)</param>
    /// <param name="certStore">(Optional) The certificate store where the encryption certificate resides (Default: <see cref="CertStore"/>.<see cref="CertStore.CurrentUser"/>)</param>
    /// <param name="verbose">True enables verbose logging</param>
    /// <returns>The fully-qualified path to where the Base64-encoded certificate file was ultimately written</returns>
    /// <example>
    /// <code>
    /// string thumbprint = @"ccdc673c40ebb2a433300c0c8a2ba6f443da5688";
    /// string exportPath = @"C:\data\cert";
    /// <see cref="CertStore"/> certStore = <see cref="CertStore"/>.<see cref="CertStore.CurrentUser"/>;
    /// string finalExportPath = <see cref="X509Utils"/>.ExportCert(thumbprint, exportPath, certStore);
    /// //finalExportPath is @"C:\data\cert.cer"
    /// </code>
    /// </example>

这使用DocX获得了以下结果:

Rendered documentation

为什么在不自动显示参数类型的情况下不能引用方法名称?我是否需要在示例中使用字符串文字作为方法调用,而不是引用它?

1 个答案:

答案 0 :(得分:0)

所提供的内容来自API文档的缓存版本。完全删除并重新创建DocFX项目解决了该问题。我上面的示例中的XML文档可以正确呈现。