简体   繁体   English

是否可以在 Visual Studio 2019+ 中更改默认 XML 注释?

[英]Is it possible to change default XML comments in Visual Studio 2019+?

Before this gets marked as duplicate, I know this question has been asked in the past [1] [2] , but the answers are extremely outdated and only contain workarounds and 3rd party tools.在这被标记为重复之前,我知道这个问题在过去[1] [2]中被问过,但答案非常过时,只包含解决方法和 3rd 方工具。

The exact question here would be: Is it possible to change the xml comment template generated by typing "///" in Visual Studio 2019+ without using 3rd party tools?这里的确切问题是:是否可以更改通过在 Visual Studio 2019+ 中键入“///”生成的 xml 注释模板而不使用 3rd 方工具? For example, add custom tags to the template?例如,向模板添加自定义标签?

For example, replace:例如,替换:

/// <summary>
/// 
/// </summary>
/// <param name="myParam"></param>
/// <returns></returns>
public int MyMethod(string myParam) { }

with:和:

/// <summary>
/// 
/// </summary>
/// <param name="myParam"></param>
/// <myTag></myTag>
/// <returns></returns>
public int MyMethod(string myParam) { }

Yes/No, one can create a code snippet which can give you the basic format, but getting the parameters dynamically will be problematic.是/否,可以创建一个可以为您提供基本格式的代码片段,但动态获取参数将是有问题的。

I would suggest using a hybrid method where after running the standard xml comment that the code snippet deletes (if needed) and adds more tag(s) and other items which you may need.我建议使用混合方法,在运行标准 xml 注释后,代码片段会删除(如果需要)并添加更多标签和您可能需要的其他项目。

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

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