这些XML注释是如何在C#代码隐藏中自动生成的?
当我查看后面的代码时,我看到了很多关于每个属性和类名的这些XML注释是如何在C#代码隐藏中自动生成的?,c#,.net,visual-studio,C#,.net,Visual Studio,当我查看后面的代码时,我看到了很多关于每个属性和类名的//xml注释,但是这些注释是如何生成的呢 自动地?通过第三方?我想我的前同事并不是在为每个属性和类键入// 自动生成的方式是什么(工具/短键/任何东西) public interface IRepository<TEntity> where TEntity : class { /// <summary> /// Gets the list of items from the repository
//
xml注释,但是这些注释是如何生成的呢
自动地?通过第三方?我想我的前同事并不是在为每个属性和类键入//
自动生成的方式是什么(工具/短键/任何东西)
public interface IRepository<TEntity> where TEntity : class
{
/// <summary>
/// Gets the list of items from the repository
/// </summary>
/// <returns></returns>
IEnumerable<TEntity> Get();
/// <summary>
/// Gets the single entity from the repository
/// </summary>
/// <param name="id">Id of the entity</param>
/// <returns></returns>
TEntity Get(Int32 id);
/// <summary>
/// Adds an entity to the repository
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
TEntity Add(TEntity entity);
/// <summary>
/// Updates an entity in the repository
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
Int32 Update(TEntity entity);
}
公共接口假定,其中tenty:class
{
///
///从存储库中获取项目列表
///
///
IEnumerable Get();
///
///从存储库中获取单个实体
///
///实体的Id
///
TEntity-Get(Int32-id);
///
///将实体添加到存储库中
///
///
///
TEntity Add(TEntity实体);
///
///更新存储库中的实体
///
///
///
Int32更新(TEntity实体);
}
如果在Visual Studio中任何属性/类/方法声明上方的行中键入三次/
,它将生成这些代码段
intellisense和其他第三方工具使用它们为项目生成文档。如果在Visual Studio中任何属性/类/方法声明上方的行中键入三次
/
,它将生成这些代码段
intellisense和其他第三方工具使用它们为项目生成文档。当您在visual studio中的方法/类/属性上方键入
//
时,它将自动生成一个结构,其中包含一些项,如参数和该项的返回值(如果适用)。这将在本MSDN文章中进一步详细说明。当您在visual studio中的方法/类/属性上方键入//
时,它将自动生成一个结构,其中包括该项的参数和返回值等项(如果适用)。这将在这篇MSDN文章中进一步详细介绍。您可以使用它自动生成xml注释
GhostDoc是一个自动生成XML的Visual Studio扩展
基于类型的方法和属性的文档注释,
参数、名称和其他上下文信息
您可以使用它自动生成xml注释
GhostDoc是一个自动生成XML的Visual Studio扩展
基于类型的方法和属性的文档注释,
参数、名称和其他上下文信息
将有助于您自动生成XmlComment
如果您想手动执行此操作,那么当您在任何属性、方法、构造函数、类或接口上方键入/3次(//
)时,将自动生成相关注释,其中包含空摘要、参数和返回值,并且您必须编写自己关于实现的定义/说明。这些注释用于Intellisense
工作原理:
如果我有以下带XML注释的构造函数:
/// <summary>
/// The constructor sets the name, age and cash
/// </summary>
/// <param name="name">The name of the guy</param>
/// <param name="cash">The amount of cash the guy starts with</param>
public Guy(string name, int age, int cash) {
//This is constructor implementation with XML Comments
}
//
///构造函数设置名称、年龄和现金
///
///那家伙的名字
///那家伙一开始就有多少现金
public Guy(字符串名称、整数年龄、整数现金){
//这是带有XML注释的构造函数实现
}
然后,当您初始化或使用此构造函数时,intellisense将显示此XML注释,如下图所示
将有助于您自动生成XmlComment
如果您想手动执行此操作,那么当您在任何属性、方法、构造函数、类或接口上方键入/3次(//
)时,将自动生成相关注释,其中包含空摘要、参数和返回值,并且您必须编写自己关于实现的定义/说明。这些注释用于Intellisense
工作原理:
如果我有以下带XML注释的构造函数:
/// <summary>
/// The constructor sets the name, age and cash
/// </summary>
/// <param name="name">The name of the guy</param>
/// <param name="cash">The amount of cash the guy starts with</param>
public Guy(string name, int age, int cash) {
//This is constructor implementation with XML Comments
}
//
///构造函数设置名称、年龄和现金
///
///那家伙的名字
///那家伙一开始就有多少现金
public Guy(字符串名称、整数年龄、整数现金){
//这是带有XML注释的构造函数实现
}
然后,当您初始化或使用此构造函数时,intellisense将显示此XML注释,如下图所示
听起来你最好的选择是问问你的前同事。也许是幽灵医生?我觉得它很像幽灵医生。它确实试图自己写出评论,但却一帆风顺。我让ghost doc生成评论,然后如果它们需要扩展或没有意义,我会自己修改它们。听起来你最好的选择是询问你的前同事。也许是幽灵医生?我觉得它很像幽灵医生。它确实试图自己写出评论,但却一帆风顺。我让ghost文档生成注释,然后如果它们需要扩展或没有意义,我自己修改它们。