VS2019 添加类注释和方法注释笔记
1. Class类注释
找到D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ItemTemplates\CSharp\Code\2052\Class\Class.cs 文件
打开编辑: 添加红色字体即可。
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
$endif$
namespace $rootnamespace$
{
/// <summary>
/// Author: JC
/// Description: 类描述
/// CreateTime: $time$
/// </summary>
class $safeitemrootname$
{
}
}
效果:新加class后,如下:
2.方法注释:使用 Macros for Visual Studio 扩展
2.1 安装:
2.2使用:
添加以下代码:
var date = new Date();
var year = date.getYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
month = month < 10 ? ("0" + month) : ("" + month);
day = day < 10 ? ("0" + day) : ("" + day);
hours = hours < 10 ? ("0" + hours) : ("" + hours);
minutes = minutes < 10 ? ("0" + minutes) : ("" + minutes);
var doc = dte.ActiveDocument;
doc.Selection.Text = "///";
doc.Selection.LineDown();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<remark>";
doc.Selection.NewLine();
doc.Selection.LineUp();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Author : JC";
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Date : " + year + "-" + month + "-" + day + " " + hours + ":" + minutes;
效果:可在方法上面使用 ctrl +M +回车键
3. 参考:
https://blog.csdn.net/lvfeng19806001/article/details/124213600
https://blog.csdn.net/CsethCRM/article/details/102952851