public CodeNamespace() { this.imports = new CodeNamespaceImportCollection(); this.comments = new CodeCommentStatementCollection(); this.classes = new CodeTypeDeclarationCollection(); this.namespaces = new CodeNamespaceCollection(); }
private CodeNamespace(SerializationInfo info, StreamingContext context) { this.imports = new CodeNamespaceImportCollection(); this.comments = new CodeCommentStatementCollection(); this.classes = new CodeTypeDeclarationCollection(); this.namespaces = new CodeNamespaceCollection(); }
public void Constructor1_NullItem () { CodeCommentStatement[] statements = new CodeCommentStatement[] { new CodeCommentStatement (), null }; CodeCommentStatementCollection coll = new CodeCommentStatementCollection ( statements); }
/// <summary> /// Add to CodeCommentStatementCollection summary documentation /// </summary> /// <param name="codeStatmentColl">Collection of CodeCommentStatement</param> /// <param name="comment">summary text</param> internal static void CreateSummaryComment(CodeCommentStatementCollection codeStatmentColl, string comment) { codeStatmentColl.Add(new CodeCommentStatement("<summary>", true)); string[] lines = comment.Split(new[] { '\n' }); foreach (string line in lines) codeStatmentColl.Add(new CodeCommentStatement(line.Trim(), true)); codeStatmentColl.Add(new CodeCommentStatement("</summary>", true)); }
public static CodeCommentStatementCollection Clone(CodeCommentStatementCollection codestatementcol) { var col = new CodeCommentStatementCollection(); foreach(CodeCommentStatement cstat in codestatementcol) { col.Add(Clone(cstat)); } return col; }
public void Constructor0 () { CodeCommentStatementCollection coll = new CodeCommentStatementCollection (); Assert.IsFalse (((IList) coll).IsFixedSize, "#1"); Assert.IsFalse (((IList) coll).IsReadOnly, "#2"); Assert.AreEqual (0, coll.Count, "#3"); Assert.IsFalse (((ICollection) coll).IsSynchronized, "#4"); Assert.IsNotNull (((ICollection) coll).SyncRoot, "#5"); }
public static string GetDocumentCommentString(CodeCommentStatementCollection comments) { var info = new StringBuilder(); foreach(CodeCommentStatement com in comments) { if(com.Comment.DocComment) info.AppendLine(com.Comment.Text); } return info.ToString(); }
void Comment(Dictionary<string, Documentation> docs, string name, CodeCommentStatementCollection comments) { if (comments.Count > 0 && comments[0].Comment.Text == "<remarks/>") { comments.RemoveAt(0); } if (docs.ContainsKey(name)) { comments.Insert(0, new CodeCommentStatement("<summary>" + docs[name].Text + "</summary>", true)); docs[name].Used = true; } }
/// <summary> /// emit all the documentation comments for an element's documentation child /// (if the element does not have a documentation child emit some standard "missing comments" comment /// </summary> /// <param name="element">the element whose documentation is to be displayed</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> public static void EmitSummaryComments(MetadataItem item, CodeCommentStatementCollection commentCollection) { Debug.Assert(item != null, "item parameter is null"); Debug.Assert(commentCollection != null, "commentCollection parameter is null"); Documentation documentation = GetDocumentation(item); string [] summaryComments = null; if (documentation != null && !MetadataUtil.IsNullOrEmptyOrWhiteSpace(documentation.Summary)) { // we have documentation to emit summaryComments = GetFormattedLines(documentation.Summary, true); } else { string summaryComment; // no summary content, so use a default switch (item.BuiltInTypeKind) { case BuiltInTypeKind.EdmProperty: summaryComment = Strings.MissingPropertyDocumentation(((EdmProperty)item).Name); break; case BuiltInTypeKind.ComplexType: summaryComment = Strings.MissingComplexTypeDocumentation(((ComplexType)item).FullName); break; default: { PropertyInfo pi = item.GetType().GetProperty("FullName"); if (pi == null) { pi = item.GetType().GetProperty("Name"); } object value = null; if (pi != null) { value = pi.GetValue(item, null); } if (value != null) { summaryComment = Strings.MissingDocumentation(value.ToString()); } else { summaryComment = Strings.MissingDocumentationNoName; } } break; } summaryComments = new string[] { summaryComment }; } EmitSummaryComments(summaryComments, commentCollection); EmitOtherDocumentationComments(documentation, commentCollection); }
public void AddRange(CodeCommentStatementCollection value) { if (value == null) { throw new ArgumentNullException("value"); } int count = value.Count; for (int i = 0; i < count; i++) { this.Add(value[i]); } }
public void Constructor1 () { CodeCommentStatement ccs1 = new CodeCommentStatement (); CodeCommentStatement ccs2 = new CodeCommentStatement (); CodeCommentStatement[] statements = new CodeCommentStatement[] { ccs1, ccs2 }; CodeCommentStatementCollection coll = new CodeCommentStatementCollection ( statements); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, coll.IndexOf (ccs1), "#2"); Assert.AreEqual (1, coll.IndexOf (ccs2), "#3"); }
public void Constructor1_Deny_Unrestricted () { CodeCommentStatementCollection coll = new CodeCommentStatementCollection (array); coll.CopyTo (array, 0); Assert.AreEqual (1, coll.Add (ccs), "Add"); Assert.AreSame (ccs, coll[0], "this[int]"); coll.AddRange (array); coll.AddRange (coll); Assert.IsTrue (coll.Contains (ccs), "Contains"); Assert.AreEqual (0, coll.IndexOf (ccs), "IndexOf"); coll.Insert (0, ccs); coll.Remove (ccs); }
private CodeCommentStatementCollection AddFileBanner(string sInFile, string sOutFile) { CodeCommentStatementCollection coll = new CodeCommentStatementCollection(); coll.Add(new CodeCommentStatement("--------------------------------------------------------------------------------------------")); coll.Add(new CodeCommentStatement(string.Format( "Copyright (c) {0}, SIL International. All rights reserved.", DateTime.Now.Year))); coll.Add(new CodeCommentStatement("")); coll.Add(new CodeCommentStatement("File: " + Path.GetFileName(sOutFile))); coll.Add(new CodeCommentStatement("Responsibility: Generated by IDLImporter")); coll.Add(new CodeCommentStatement("Last reviewed: ")); coll.Add(new CodeCommentStatement("")); coll.Add(new CodeCommentStatement("<remarks>")); coll.Add(new CodeCommentStatement("Generated by IDLImporter from file " + Path.GetFileName(sInFile))); coll.Add(new CodeCommentStatement("")); coll.Add(new CodeCommentStatement("You should use these interfaces when you access the COM objects defined in the mentioned")); coll.Add(new CodeCommentStatement("IDL/IDH file.")); coll.Add(new CodeCommentStatement("</remarks>")); coll.Add(new CodeCommentStatement("--------------------------------------------------------------------------------------------")); return coll; }
public void AddExtensionWarningComments(CodeCommentStatementCollection comments, ServiceDescriptionFormatExtensionCollection extensions) { foreach (object obj2 in extensions) { if (!extensions.IsHandled(obj2)) { string localName = null; string namespaceURI = null; if (obj2 is XmlElement) { XmlElement element = (XmlElement) obj2; localName = element.LocalName; namespaceURI = element.NamespaceURI; } else if (obj2 is ServiceDescriptionFormatExtension) { XmlFormatExtensionAttribute[] customAttributes = (XmlFormatExtensionAttribute[]) obj2.GetType().GetCustomAttributes(typeof(XmlFormatExtensionAttribute), false); if (customAttributes.Length > 0) { localName = customAttributes[0].ElementName; namespaceURI = customAttributes[0].Namespace; } } if (localName != null) { if (extensions.IsRequired(obj2)) { this.warnings |= ServiceDescriptionImportWarnings.RequiredExtensionsIgnored; AddWarningComment(comments, System.Web.Services.Res.GetString("WebServiceDescriptionIgnoredRequired", new object[] { localName, namespaceURI })); } else { this.warnings |= ServiceDescriptionImportWarnings.OptionalExtensionsIgnored; AddWarningComment(comments, System.Web.Services.Res.GetString("WebServiceDescriptionIgnoredOptional", new object[] { localName, namespaceURI })); } } } } }
public void Constructor1_Null () { CodeCommentStatementCollection coll = new CodeCommentStatementCollection ( (CodeCommentStatement[]) null); }
protected override void GenerateCommentStatements(CodeCommentStatementCollection e) { foreach (CodeCommentStatement statement in e) { if (!this.IsDocComment(statement)) { this.GenerateCommentStatement(statement); } } foreach (CodeCommentStatement statement2 in e) { if (this.IsDocComment(statement2)) { this.GenerateCommentStatement(statement2); } } }
private static void AddSummary(CodeCommentStatementCollection comments, string summary) { if (String.IsNullOrEmpty(summary)) return; comments.Add(new CodeCommentStatement("<summary>", true)); comments.Add(new CodeCommentStatement(Util.XmlEncode(summary), true)); comments.Add(new CodeCommentStatement("</summary>", true)); }
/// <summary> /// emit documentation comments between xml open and close tags /// </summary> /// <param name="tag">the xml tag name</param> /// <param name="summaryComments">the lines of comments to emit</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> private static void EmitXmlComments(string tag, string[] summaryComments, CodeCommentStatementCollection commentCollection) { Debug.Assert(tag != null); Debug.Assert(summaryComments != null); Debug.Assert(commentCollection != null); commentCollection.Add(new CodeCommentStatement(string.Format(CultureInfo.InvariantCulture, "<{0}>", tag), true)); EmitComments(summaryComments, commentCollection, true); commentCollection.Add(new CodeCommentStatement(string.Format(CultureInfo.InvariantCulture, "</{0}>", tag), true)); }
public void Remove_Null () { CodeCommentStatementCollection coll = new CodeCommentStatementCollection (); coll.Remove ((CodeCommentStatement) null); }
/// <summary> /// Emit the other (than Summary) documentation comments from a Documentation element /// </summary> /// <param name="documentation">the schema Docuementation element</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> private static void EmitOtherDocumentationComments(Documentation documentation, CodeCommentStatementCollection commentCollection) { Debug.Assert(commentCollection != null); if (documentation == null) return; if (!string.IsNullOrEmpty(documentation.LongDescription)) EmitXmlComments("LongDescription", GetFormattedLines(documentation.LongDescription, true), commentCollection); }
/// <summary> /// Emit the summary comments /// </summary> /// <param name="summaryComments"></param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> private static void EmitSummaryComments(string[] summaryComments, CodeCommentStatementCollection commentCollection) { Debug.Assert(summaryComments != null); Debug.Assert(commentCollection != null); EmitXmlComments("summary", summaryComments, commentCollection); }
/// <summary> /// Emit documentation comments for a method parameter /// </summary> /// <param name="parameter">the parameter being commented</param> /// <param name="comment">the comment text</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> public static void EmitParamComments(CodeParameterDeclarationExpression parameter, string comment, CodeCommentStatementCollection commentCollection) { Debug.Assert(parameter != null, "parameter parameter is null"); Debug.Assert(comment != null, "comment parameter is null"); string paramComment = string.Format(System.Globalization.CultureInfo.CurrentCulture, "<param name=\"{0}\">{1}</param>", parameter.Name, comment); commentCollection.Add(new CodeCommentStatement(paramComment, true)); }
/// <summary> /// Emit some lines of comments /// </summary> /// <param name="commentLines">the lines of comments to emit</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> /// <param name="docComment">true if the comments are 'documentation' comments</param> public static void EmitComments(string[] commentLines, CodeCommentStatementCollection commentCollection, bool docComment) { Debug.Assert(commentLines != null, "commentLines parameter is null"); Debug.Assert(commentCollection != null, "commentCollection parameter is null"); foreach (string comment in commentLines) { commentCollection.Add(new CodeCommentStatement(comment, docComment)); } }
/// <summary> /// Emit summary comments from a string /// </summary> /// <param name="summaryComments">the summary comments to be emitted</param> /// <param name="commentCollection">the comment collection of the CodeDom object to be commented</param> public static void EmitSummaryComments(string summaryComments, CodeCommentStatementCollection commentCollection) { Debug.Assert(commentCollection != null, "commentCollection parameter is null"); if (string.IsNullOrEmpty(summaryComments) || string.IsNullOrEmpty(summaryComments = summaryComments.TrimEnd())) return; EmitSummaryComments(SplitIntoLines(summaryComments), commentCollection); }
public void Init(CodeMemberProperty property) { propertyName = property.Name; returnType = (XCodeTypeReference)property.Type; if(returnType.fullTypeName!=null && returnType.fullTypeName != returnType.BaseType) { returnType = new XCodeTypeReference(returnType.fullTypeName); } hasSet = property.HasSet; wrappedPropertyAttributes = property.Attributes; codeCommentStatementCollection = property.Comments; }
internal static void AddWarningComment(CodeCommentStatementCollection comments, string text) { Debug.Assert(comments != null); comments.Add(new CodeCommentStatement(Res.GetString(Res.XmlCodegenWarningDetails, text), false)); }
/// <summary> /// Get summary CodeCommentStatementCollection comment /// </summary> /// <param name="text">Summary text comment</param> /// <returns>CodeCommentStatementCollection comment</returns> internal static CodeCommentStatementCollection GetSummaryComment(string text) { var comments = new CodeCommentStatementCollection { new CodeCommentStatement("<summary>", true), new CodeCommentStatement(text, true), new CodeCommentStatement("</summary>", true) }; return comments; }
public void Constructor2 () { CodeCommentStatement ccs1 = new CodeCommentStatement (); CodeCommentStatement ccs2 = new CodeCommentStatement (); CodeCommentStatementCollection c = new CodeCommentStatementCollection (); c.Add (ccs1); c.Add (ccs2); CodeCommentStatementCollection coll = new CodeCommentStatementCollection (c); Assert.AreEqual (2, coll.Count, "#1"); Assert.AreEqual (0, coll.IndexOf (ccs1), "#2"); Assert.AreEqual (1, coll.IndexOf (ccs2), "#3"); }
private CodeCommentStatementCollection GetSummaryComment(params string[] comments) { CodeCommentStatementCollection collection = new CodeCommentStatementCollection(); if (comments != null && comments.Length > 0) { for (int i = 0; i < comments.Length; i++) if (!String.IsNullOrEmpty(comments[i])) collection.Add(new CodeCommentStatement(comments[i], true)); } if (collection.Count == 0) return collection; collection.Insert(0, new CodeCommentStatement("<summary>", true)); collection.Add(new CodeCommentStatement("</summary>", true)); return collection; }
protected virtual void GenerateCommentStatements (CodeCommentStatementCollection statements) { foreach (CodeCommentStatement comment in statements) GenerateCommentStatement (comment); }