一、简介
GhostDoc是Visual Studio的一个免费插件,可以为开发人员自动生成XML格式的注释文档。
二、下载
需要的朋友可以去这里下载,填个Email地址就可以下了:GhostDoc下载地址
三、安装
下载安装完成后,可以在Visual Studio的工具菜单下找到GhostDoc的身影。
三、使用
在使用的时候,主要是进行设置,设置好了调用快捷键就可以了。
下面附上,注释的原始文件。
文件注释:
- <#@ template language="C#" #>
- // ***********************************************************************
- // Assembly : <#= Context.AssemblyName #>
- // Author : <#= Context.GetGlobalProperty("UserName") #>
- // Created : <#= Context.DestinationFileCreationDateTime.ToString("MM-dd-yyyy") #>
- //
- // Last Modified By : <#= Context.GetGlobalProperty("UserName") #>
- // Last Modified On : <#= Context.DestinationFileModificationDateTime.ToString("MM-dd-yyyy") #>
- // ***********************************************************************
- // <copyright file="<#= System.IO.Path.GetFileName(Context.DestinationFile) #>" company="<#= Context.GetGlobalProperty("CompanyName") #>">
- // Copyright (c) <#= Context.GetGlobalProperty("CompanyName") #>. All rights reserved.
- // </copyright>
- // <summary></summary>
- // ***********************************************************************
类注释:
- <#@ template language="C#" #>
- <# CodeElement codeElement = Context.CurrentCodeElement; #>
- /// <summary>
- ///<# GenerateSummaryText(); #>
- /// </summary>
- <# if(codeElement.HasTypeParameters)
- {
- for(int i = 0; i < codeElement.TypeParameters.Length; i++)
- {
- TypeParameter typeParameter = codeElement.TypeParameters[i];
- #>
- /// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>
- <# }
- }
- #>
- <#= Context.GetNonGeneratedTags() #>
- <# GenerateRemarksText(); #>
- <#+
- private void GenerateSummaryText()
- {
- if(Context.HasExistingTagText("summary"))
- {
- this.WriteLine(Context.GetExistingTagText("summary"));
- }
- else
- {
- this.WriteLine("Class " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));
- }
- }
- private void GenerateTypeParamText(TypeParameter typeParameter, int index)
- {
- if(Context.HasExistingTagText("typeparam", index))
- {
- this.Write(Context.GetExistingTagText("typeparam", index));
- }
- else
- {
- string typeParameterName = typeParameter.Name;
- if(typeParameterName != null)
- {
- if(typeParameterName.Length == 1)
- {
- this.Write("");
- }
- else
- {
- this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");
- }
- }
- }
- }
- private void GenerateRemarksText()
- {
- if(Context.HasExistingTagText("remarks"))
- { #>
- /// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>
- <#+ }
- else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))
- {
- // Should you require a default comment, set it in
- // Options -> Global Properties -> DefaultBlankRemarksText
- #>
- /// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>
- <#+ }
- }
- #>
接口注释
- <#@ template language="C#" #>
- <# CodeElement codeElement = Context.CurrentCodeElement; #>
- /// <summary>
- ///<# GenerateSummaryText(); #>
- /// </summary>
- <# if(codeElement.HasTypeParameters)
- {
- for(int i = 0; i < codeElement.TypeParameters.Length; i++)
- {
- TypeParameter typeParameter = codeElement.TypeParameters[i];
- #>
- /// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>
- <# }
- }
- #>
- <#= Context.GetNonGeneratedTags() #>
- <# GenerateRemarksText(); #>
- <#+
- private void GenerateSummaryText()
- {
- if(Context.HasExistingTagText("summary"))
- {
- this.WriteLine(Context.GetExistingTagText("summary"));
- }
- else
- {
- this.WriteLine("Interface " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));
- }
- }
- private void GenerateTypeParamText(TypeParameter typeParameter, int index)
- {
- if(Context.HasExistingTagText("typeparam", index))
- {
- this.Write(Context.GetExistingTagText("typeparam", index));
- }
- else
- {
- string typeParameterName = typeParameter.Name;
- if(typeParameterName != null)
- {
- if(typeParameterName.Length == 1)
- {
- this.Write("");
- }
- else
- {
- this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");
- }
- }
- }
- }
- private void GenerateRemarksText()
- {
- if(Context.HasExistingTagText("remarks"))
- { #>
- /// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>
- <#+ }
- else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))
- {
- // Should you require a default comment, set it in
- // Options -> Global Properties -> DefaultBlankRemarksText
- #>
- /// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>
- <#+ }
- }
- #>