private static void AddCommentsTo(CodeElement codeElement) { if (CodeElementsThatNeedDocComment.Contains(codeElement.Kind)) { if (string.IsNullOrWhiteSpace(codeElement.GetDocComment())) { if (codeElement.IsInherited() || codeElement.OverridesSomething()) { codeElement.SetDocComment(@"<DOC><inheritdoc/></DOC>"); } else { switch (codeElement.Kind) { case vsCMElement.vsCMElementProperty: AddDocCommentToProperty(codeElement as CodeProperty); break; case vsCMElement.vsCMElementFunction: AddDocCommentToFunction(codeElement as CodeFunction); break; case vsCMElement.vsCMElementEnum: AddGhostDogCommand(codeElement); break; case vsCMElement.vsCMElementStruct: AddGhostDogCommand(codeElement); break; case vsCMElement.vsCMElementInterface: AddDocCommentToInterface(codeElement as CodeInterface); break; case vsCMElement.vsCMElementEvent: AddGhostDogCommand(codeElement); break; case vsCMElement.vsCMElementClass: AddDocCommentToClass(codeElement as CodeClass); break; case vsCMElement.vsCMElementVariable: AddGhostDogCommand(codeElement); break; } } } } if (CodeElementsWithChildren.Contains(codeElement.Kind)) { foreach (CodeElement child in codeElement.Children) { AddCommentsTo(child); } } }
public static void AppendToDocComment(this CodeElement codeElement, string text) { var docComment = codeElement.GetDocComment(); docComment = docComment.Replace("<DOC>", string.Empty); docComment = docComment.Replace("<doc>", string.Empty); docComment = docComment.Replace("</DOC>", string.Empty); docComment = docComment.Replace("</doc>", string.Empty); docComment = "<doc>" + Environment.NewLine + docComment.Trim() + Environment.NewLine + text + Environment.NewLine + "</doc>"; codeElement.SetDocComment(docComment); }