2 // doc.cs: Support for XML documentation comment.
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Licensed under the terms of the GNU GPL
9 // (C) 2004 Novell, Inc.
13 using System.Collections;
14 using System.Collections.Specialized;
16 using System.Reflection;
17 using System.Reflection.Emit;
18 using System.Runtime.CompilerServices;
19 using System.Runtime.InteropServices;
20 using System.Security;
21 using System.Security.Permissions;
25 using Mono.CompilerServices.SymbolWriter;
27 namespace Mono.CSharp {
30 // Support class for XML documentation.
32 public static class DocUtil
37 // Generates xml doc comments (if any), and if required,
38 // handle warning report.
40 internal static void GenerateTypeDocComment (TypeContainer t,
43 GenerateDocComment (t, ds);
45 if (t.DefaultStaticConstructor != null)
46 t.DefaultStaticConstructor.GenerateDocComment (t);
48 if (t.InstanceConstructors != null)
49 foreach (Constructor c in t.InstanceConstructors)
50 c.GenerateDocComment (t);
53 foreach (TypeContainer tc in t.Types)
54 tc.GenerateDocComment (t);
56 if (t.Parts != null) {
57 IDictionary comments = RootContext.Documentation.PartialComments;
58 foreach (ClassPart cp in t.Parts) {
59 if (cp.DocComment == null)
66 foreach (Enum en in t.Enums)
67 en.GenerateDocComment (t);
69 if (t.Constants != null)
70 foreach (Const c in t.Constants)
71 c.GenerateDocComment (t);
74 foreach (Field f in t.Fields)
75 f.GenerateDocComment (t);
78 foreach (Event e in t.Events)
79 e.GenerateDocComment (t);
81 if (t.Indexers != null)
82 foreach (Indexer ix in t.Indexers)
83 ix.GenerateDocComment (t);
85 if (t.Properties != null)
86 foreach (Property p in t.Properties)
87 p.GenerateDocComment (t);
89 if (t.Methods != null)
90 foreach (Method m in t.Methods)
91 m.GenerateDocComment (t);
93 if (t.Operators != null)
94 foreach (Operator o in t.Operators)
95 o.GenerateDocComment (t);
99 private static readonly string lineHead =
100 Environment.NewLine + " ";
102 private static XmlNode GetDocCommentNode (MemberCore mc,
105 // FIXME: It could be even optimizable as not
106 // to use XmlDocument. But anyways the nodes
107 // are not kept in memory.
108 XmlDocument doc = RootContext.Documentation.XmlDocumentation;
110 XmlElement el = doc.CreateElement ("member");
111 el.SetAttribute ("name", name);
112 string normalized = mc.DocComment;
113 el.InnerXml = normalized;
114 // csc keeps lines as written in the sources
115 // and inserts formatting indentation (which
116 // is different from XmlTextWriter.Formatting
117 // one), but when a start tag contains an
118 // endline, it joins the next line. We don't
119 // have to follow such a hacky behavior.
121 normalized.Split ('\n');
123 for (int i = 0; i < split.Length; i++) {
124 string s = split [i].TrimEnd ();
128 el.InnerXml = lineHead + String.Join (
129 lineHead, split, 0, j);
131 } catch (XmlException ex) {
132 Report.Warning (1570, 1, mc.Location, "XML comment on '{0}' has non-well-formed XML ({1}).", name, ex.Message);
133 XmlComment com = doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name));
139 // Generates xml doc comments (if any), and if required,
140 // handle warning report.
142 internal static void GenerateDocComment (MemberCore mc,
145 if (mc.DocComment != null) {
146 string name = mc.GetDocCommentName (ds);
148 XmlNode n = GetDocCommentNode (mc, name);
150 XmlElement el = n as XmlElement;
152 mc.OnGenerateDocComment (ds, el);
154 // FIXME: it could be done with XmlReader
155 foreach (XmlElement inc in n.SelectNodes (".//include"))
156 HandleInclude (mc, inc);
158 // FIXME: it could be done with XmlReader
159 DeclSpace dsTarget = mc as DeclSpace;
160 if (dsTarget == null)
163 foreach (XmlElement see in n.SelectNodes (".//see"))
164 HandleSee (mc, dsTarget, see);
165 foreach (XmlElement seealso in n.SelectNodes (".//seealso"))
166 HandleSeeAlso (mc, dsTarget, seealso);
167 foreach (XmlElement see in n.SelectNodes (".//exception"))
168 HandleException (mc, dsTarget, see);
171 n.WriteTo (RootContext.Documentation.XmlCommentOutput);
173 else if (mc.IsExposedFromAssembly (ds)) {
174 Constructor c = mc as Constructor;
175 if (c == null || !c.IsDefault ())
176 Report.Warning (1591, 4, mc.Location,
177 "Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
182 // Processes "include" element. Check included file and
183 // embed the document content inside this documentation node.
185 private static void HandleInclude (MemberCore mc, XmlElement el)
187 string file = el.GetAttribute ("file");
188 string path = el.GetAttribute ("path");
190 Report.Warning (1590, 1, mc.Location, "Invalid XML 'include' element; Missing 'file' attribute.");
191 el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
193 else if (path == "") {
194 Report.Warning (1590, 1, mc.Location, "Invalid XML 'include' element; Missing 'path' attribute.");
195 el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
198 XmlDocument doc = RootContext.Documentation.StoredDocuments [file] as XmlDocument;
201 doc = new XmlDocument ();
203 RootContext.Documentation.StoredDocuments.Add (file, doc);
204 } catch (Exception) {
205 el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (String.Format (" Badly formed XML in at comment file '{0}': cannot be included ", file)), el);
206 Report.Warning (1592, 1, mc.Location, "Badly formed XML in included comments file -- '{0}'", file);
209 bool keepIncludeNode = false;
212 XmlNodeList nl = doc.SelectNodes (path);
214 el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" No matching elements were found for the include tag embedded here. "), el);
216 keepIncludeNode = true;
218 foreach (XmlNode n in nl)
219 el.ParentNode.InsertBefore (el.OwnerDocument.ImportNode (n, true), el);
220 } catch (Exception ex) {
221 el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Failed to insert some or all of included XML "), el);
222 Report.Warning (1589, 1, mc.Location, "Unable to include XML fragment '{0}' of file {1} -- {2}.", path, file, ex.Message);
225 if (!keepIncludeNode)
226 el.ParentNode.RemoveChild (el);
231 // Handles <see> elements.
233 private static void HandleSee (MemberCore mc,
234 DeclSpace ds, XmlElement see)
236 HandleXrefCommon (mc, ds, see);
240 // Handles <seealso> elements.
242 private static void HandleSeeAlso (MemberCore mc,
243 DeclSpace ds, XmlElement seealso)
245 HandleXrefCommon (mc, ds, seealso);
249 // Handles <exception> elements.
251 private static void HandleException (MemberCore mc,
252 DeclSpace ds, XmlElement seealso)
254 HandleXrefCommon (mc, ds, seealso);
257 static readonly char [] wsChars =
258 new char [] {' ', '\t', '\n', '\r'};
261 // returns a full runtime type name from a name which might
262 // be C# specific type name.
264 private static Type FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref)
266 bool isArray = false;
267 string identifier = name;
268 if (name [name.Length - 1] == ']') {
269 string tmp = name.Substring (0, name.Length - 1).Trim (wsChars);
270 if (tmp [tmp.Length - 1] == '[') {
271 identifier = tmp.Substring (0, tmp.Length - 1).Trim (wsChars);
275 Type t = FindDocumentedTypeNonArray (mc, identifier, ds, cref);
276 if (t != null && isArray)
277 t = Array.CreateInstance (t, 0).GetType ();
281 private static Type FindDocumentedTypeNonArray (MemberCore mc,
282 string identifier, DeclSpace ds, string cref)
284 switch (identifier) {
288 return typeof (uint);
290 return typeof (short);
292 return typeof (ushort);
294 return typeof (long);
296 return typeof (ulong);
298 return typeof (float);
300 return typeof (double);
302 return typeof (char);
304 return typeof (decimal);
306 return typeof (byte);
308 return typeof (sbyte);
310 return typeof (object);
312 return typeof (bool);
314 return typeof (string);
316 return typeof (void);
318 FullNamedExpression e = ds.LookupType (identifier, mc.Location, false);
320 if (!(e is TypeExpr))
322 return ((TypeExpr) e).ResolveType (ds.EmitContext);
324 int index = identifier.LastIndexOf ('.');
328 Type parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref);
331 // no need to detect warning 419 here
332 return FindDocumentedMember (mc, parent,
333 identifier.Substring (index + 1),
335 ds, out warn, cref) as Type;
339 // Returns a MemberInfo that is referenced in XML documentation
340 // (by "see" or "seealso" elements).
342 private static MemberInfo FindDocumentedMember (MemberCore mc,
343 Type type, string memberName, Type [] paramList,
344 DeclSpace ds, out int warningType, string cref)
347 MethodSignature msig = new MethodSignature (memberName, null, paramList);
348 MemberInfo [] mis = type.FindMembers (
350 BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
351 MethodSignature.method_signature_filter,
353 if (mis.Length > 0) {
354 if (IsAmbiguous (mis))
359 if (paramList.Length == 0) {
360 // search for fields/events etc.
361 mis = type.FindMembers (
363 BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
368 if (IsAmbiguous (mis))
373 // search for operators (whose parameters exactly
374 // matches with the list) and possibly report CS1581.
376 string returnTypeName = null;
377 if (memberName.StartsWith ("implicit operator ")) {
378 oper = "op_Implicit";
379 returnTypeName = memberName.Substring (18).Trim (wsChars);
381 else if (memberName.StartsWith ("explicit operator ")) {
382 oper = "op_Explicit";
383 returnTypeName = memberName.Substring (18).Trim (wsChars);
385 else if (memberName.StartsWith ("operator ")) {
386 oper = memberName.Substring (9).Trim (wsChars);
388 // either unary or binary
390 oper = paramList.Length == 2 ?
391 Binary.oper_names [(int) Binary.Operator.Addition] :
392 Unary.oper_names [(int) Unary.Operator.UnaryPlus];
395 oper = paramList.Length == 2 ?
396 Binary.oper_names [(int) Binary.Operator.Subtraction] :
397 Unary.oper_names [(int) Unary.Operator.UnaryNegation];
401 oper = Unary.oper_names [(int) Unary.Operator.LogicalNot]; break;
403 oper = Unary.oper_names [(int) Unary.Operator.OnesComplement]; break;
406 oper = "op_Increment"; break;
408 oper = "op_Decrement"; break;
410 oper = "op_True"; break;
412 oper = "op_False"; break;
415 oper = Binary.oper_names [(int) Binary.Operator.Multiply]; break;
417 oper = Binary.oper_names [(int) Binary.Operator.Division]; break;
419 oper = Binary.oper_names [(int) Binary.Operator.Modulus]; break;
421 oper = Binary.oper_names [(int) Binary.Operator.BitwiseAnd]; break;
423 oper = Binary.oper_names [(int) Binary.Operator.BitwiseOr]; break;
425 oper = Binary.oper_names [(int) Binary.Operator.ExclusiveOr]; break;
427 oper = Binary.oper_names [(int) Binary.Operator.LeftShift]; break;
429 oper = Binary.oper_names [(int) Binary.Operator.RightShift]; break;
431 oper = Binary.oper_names [(int) Binary.Operator.Equality]; break;
433 oper = Binary.oper_names [(int) Binary.Operator.Inequality]; break;
435 oper = Binary.oper_names [(int) Binary.Operator.LessThan]; break;
437 oper = Binary.oper_names [(int) Binary.Operator.GreaterThan]; break;
439 oper = Binary.oper_names [(int) Binary.Operator.LessThanOrEqual]; break;
441 oper = Binary.oper_names [(int) Binary.Operator.GreaterThanOrEqual]; break;
444 Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", paramList.Length == 2 ? "binary" : "unary");
445 Report.Warning (1584, 1, mc.Location, "XML comment on '{0}' has syntactically incorrect attribute '{1}'", mc.GetSignatureForError (), cref);
449 // here we still don't consider return type (to
450 // detect CS1581 or CS1002+CS1584).
451 msig = new MethodSignature (oper, null, paramList);
452 mis = type.FindMembers (
454 BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static,
455 MethodSignature.method_signature_filter,
458 return null; // CS1574
459 MemberInfo mi = mis [0];
460 Type expected = mi is MethodInfo ?
461 ((MethodInfo) mi).ReturnType :
463 ((PropertyInfo) mi).PropertyType :
465 if (returnTypeName != null) {
466 Type returnType = FindDocumentedType (mc, returnTypeName, ds, cref);
467 if (returnType == null || returnType != expected) {
469 Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute '{0}'", cref);
476 private static bool IsAmbiguous (MemberInfo [] members)
478 if (members.Length < 2)
480 if (members.Length > 2)
482 if (members [0] is EventInfo && members [1] is FieldInfo)
484 if (members [1] is EventInfo && members [0] is FieldInfo)
490 // Processes "see" or "seealso" elements.
491 // Checks cref attribute.
493 private static void HandleXrefCommon (MemberCore mc,
494 DeclSpace ds, XmlElement xref)
496 string cref = xref.GetAttribute ("cref").Trim (wsChars);
497 // when, XmlReader, "if (cref == null)"
498 if (!xref.HasAttribute ("cref"))
500 if (cref.Length == 0)
501 Report.Warning (1001, 1, mc.Location, "Identifier expected");
502 // ... and continue until CS1584.
504 string signature; // "x:" are stripped
505 string name; // method invokation "(...)" are removed
506 string parameters; // method parameter list
508 // strip 'T:' 'M:' 'F:' 'P:' 'E:' etc.
509 // Here, MS ignores its member kind. No idea why.
510 if (cref.Length > 2 && cref [1] == ':')
511 signature = cref.Substring (2).Trim (wsChars);
515 int parensPos = signature.IndexOf ('(');
516 if (parensPos > 0 && signature [signature.Length - 1] == ')') {
517 name = signature.Substring (0, parensPos).Trim (wsChars);
518 parameters = signature.Substring (parensPos + 1, signature.Length - parensPos - 2);
522 parameters = String.Empty;
524 Normalize (mc, ref name);
526 string identifier = name;
528 if (name.Length > 0 && name [name.Length - 1] == ']') {
529 string tmp = name.Substring (0, name.Length - 1).Trim (wsChars);
530 if (tmp [tmp.Length - 1] == '[')
531 identifier = tmp.Substring (0, tmp.Length - 1).Trim (wsChars);
534 // Check if identifier is valid.
535 // This check is not necessary to mark as error, but
536 // csc specially reports CS1584 for wrong identifiers.
537 string [] nameElems = identifier.Split ('.');
538 for (int i = 0; i < nameElems.Length; i++) {
539 string nameElem = nameElems [i];
540 if (nameElem.EndsWith ("[]"))
541 nameElem = nameElem.Substring (
542 nameElem.Length - 2);
544 Normalize (mc, ref nameElem);
545 if (!Tokenizer.IsValidIdentifier (nameElem)
546 && nameElem.IndexOf ("operator") < 0) {
547 Report.Warning (1584, 1, mc.Location, "XML comment on '{0}' has syntactically incorrect attribute '{1}'", mc.GetSignatureForError (), cref);
548 xref.SetAttribute ("cref", "!:" + signature);
553 // check if parameters are valid
554 Type [] parameterTypes = Type.EmptyTypes;
555 if (parameters.Length > 0) {
556 string [] paramList = parameters.Split (',');
557 ArrayList plist = new ArrayList ();
558 for (int i = 0; i < paramList.Length; i++) {
559 string paramTypeName = paramList [i].Trim (wsChars);
560 Normalize (mc, ref paramTypeName);
561 Type paramType = FindDocumentedType (mc, paramTypeName, ds, cref);
562 if (paramType == null) {
563 Report.Warning (1580, 1, mc.Location, "Invalid type for parameter '{0}' in XML comment cref attribute '{1}'", i + 1, cref);
566 plist.Add (paramType);
568 parameterTypes = plist.ToArray (typeof (Type)) as Type [];
569 StringBuilder sb = new StringBuilder ();
571 for (int i = 0; i < parameterTypes.Length; i++) {
572 Type t = parameterTypes [i];
575 sb.Append (t.FullName.Replace ('+', '.'));
578 parameters = sb.ToString ();
581 Type type = FindDocumentedType (mc, name, ds, cref);
583 // delegate must not be referenced with args
584 && (!type.IsSubclassOf (typeof (System.Delegate))
585 || parameterTypes.Length == 0)) {
586 xref.SetAttribute ("cref", "T:" + type.FullName.Replace ("+", "."));
590 // don't use identifier here. System[] is not alloed.
591 if (Namespace.IsNamespace (name)) {
592 xref.SetAttribute ("cref", "N:" + name);
593 return; // a namespace
596 int period = name.LastIndexOf ('.');
598 string typeName = name.Substring (0, period);
599 string memberName = name.Substring (period + 1);
600 Normalize (mc, ref memberName);
601 type = FindDocumentedType (mc, typeName, ds, cref);
604 MemberInfo mi = FindDocumentedMember (mc, type, memberName, parameterTypes, ds, out warnResult, cref);
605 if (warnResult == 419)
606 Report419 (mc, memberName);
607 else if (warnResult > 0)
610 xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + type.FullName.Replace ("+", ".") + "." + memberName + parameters);
611 return; // a member of a type
617 MemberInfo mi = FindDocumentedMember (mc, ds.TypeBuilder, name, parameterTypes, ds, out warnResult, cref);
618 if (warnResult == 419)
619 Report419 (mc, name);
620 else if (warnResult > 0)
623 xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + ds.TypeBuilder.FullName.Replace ("+", ".") + "." + name);
624 return; // local member name
628 Report.Warning (1574, 1, mc.Location, "XML comment on '{0}' has cref attribute '{1}' that could not be resolved in '{2}'.", mc.GetSignatureForError (), cref, ds.GetSignatureForError ());
630 xref.SetAttribute ("cref", "!:" + name);
633 static void Report419 (MemberCore mc, string memberName)
635 Report.Warning (419, 3, mc.Location, "Ambiguous member specification in cref attribute: '{0}'. Check overloaded members and supply exact parameters.", memberName);
639 // Get a prefix from member type for XML documentation (used
640 // to formalize cref target name).
642 static string GetMemberDocHead (MemberTypes type)
645 case MemberTypes.Constructor:
646 case MemberTypes.Method:
648 case MemberTypes.Event:
650 case MemberTypes.Field:
652 case MemberTypes.NestedType:
653 case MemberTypes.TypeInfo:
655 case MemberTypes.Property:
664 // Returns a string that represents the signature for this
665 // member which should be used in XML documentation.
667 public static string GetMethodDocCommentName (MethodCore mc, DeclSpace ds)
669 Parameter [] plist = mc.Parameters.FixedParameters;
670 Parameter parr = mc.Parameters.ArrayParameter;
671 string paramSpec = String.Empty;
673 StringBuilder psb = new StringBuilder ();
674 foreach (Parameter p in plist) {
675 psb.Append (psb.Length != 0 ? "," : "(");
676 psb.Append (p.ParameterType.FullName.Replace ("+", "."));
678 paramSpec = psb.ToString ();
681 paramSpec += String.Concat (
682 paramSpec == String.Empty ? "(" : ",",
683 parr.ParameterType.FullName.Replace ("+", "."));
685 if (paramSpec.Length > 0)
688 string name = mc is Constructor ? "#ctor" : mc.Name;
689 string suffix = String.Empty;
690 Operator op = mc as Operator;
692 switch (op.OperatorType) {
693 case Operator.OpType.Implicit:
694 case Operator.OpType.Explicit:
695 suffix = "~" + op.OperatorMethodBuilder.ReturnType.FullName.Replace ('+', '.');
699 return String.Concat (mc.DocCommentHeader, ds.Name, ".", name, paramSpec, suffix);
703 // Raised (and passed an XmlElement that contains the comment)
704 // when GenerateDocComment is writing documentation expectedly.
706 // FIXME: with a few effort, it could be done with XmlReader,
707 // that means removal of DOM use.
709 internal static void OnMethodGenerateDocComment (
710 MethodCore mc, DeclSpace ds, XmlElement el)
712 Hashtable paramTags = new Hashtable ();
713 foreach (XmlElement pelem in el.SelectNodes ("param")) {
715 string xname = pelem.GetAttribute ("name");
717 continue; // really? but MS looks doing so
718 if (xname != "" && mc.Parameters.GetParameterByName (xname, out i) == null)
719 Report.Warning (1572, 2, mc.Location, "XML comment on '{0}' has a 'param' tag for '{1}', but there is no such parameter.", mc.Name, xname);
720 else if (paramTags [xname] != null)
721 Report.Warning (1571, 2, mc.Location, "XML comment on '{0}' has a duplicate param tag for '{1}'", mc.Name, xname);
722 paramTags [xname] = xname;
724 Parameter [] plist = mc.Parameters.FixedParameters;
726 foreach (Parameter p in plist) {
727 if (paramTags.Count > 0 && paramTags [p.Name] == null)
728 Report.Warning (1573, 4, mc.Location, "Parameter '{0}' has no matching param tag in the XML comment for '{1}' (but other parameters do)", mc.Name, p.Name);
734 public static void GenerateEnumDocComment (Enum e, DeclSpace ds)
736 GenerateDocComment (e, ds);
737 foreach (string name in e.ordered_enums) {
738 MemberCore mc = e.GetDefinition (name);
739 GenerateDocComment (mc, e);
743 private static void Normalize (MemberCore mc, ref string name)
745 if (name.Length > 0 && name [0] == '@')
746 name = name.Substring (1);
747 else if (Tokenizer.IsKeyword (name) && !IsTypeName (name))
748 Report.Warning (1041, 1, mc.Location, String.Format ("Identifier expected, '{0}' is a keyword", name));
751 private static bool IsTypeName (string name)
777 // Implements XML documentation generation.
779 public class Documentation
781 public Documentation (string xml_output_filename)
783 docfilename = xml_output_filename;
784 XmlDocumentation = new XmlDocument ();
785 XmlDocumentation.PreserveWhitespace = false;
788 private string docfilename;
791 // Used to create element which helps well-formedness checking.
793 public XmlDocument XmlDocumentation;
796 // The output for XML documentation.
798 public XmlWriter XmlCommentOutput;
801 // Stores XmlDocuments that are included in XML documentation.
802 // Keys are included filenames, values are XmlDocuments.
804 public Hashtable StoredDocuments = new Hashtable ();
807 // Stores comments on partial types (should handle uniquely).
808 // Keys are PartialContainers, values are comment strings
809 // (didn't use StringBuilder; usually we have just 2 or more).
811 public IDictionary PartialComments = new ListDictionary ();
814 // Outputs XML documentation comment from tokenized comments.
816 public bool OutputDocComment (string asmfilename)
818 XmlTextWriter w = null;
820 w = new XmlTextWriter (docfilename, null);
822 w.Formatting = Formatting.Indented;
823 w.WriteStartDocument ();
824 w.WriteStartElement ("doc");
825 w.WriteStartElement ("assembly");
826 w.WriteStartElement ("name");
827 w.WriteString (Path.ChangeExtension (asmfilename, null));
828 w.WriteEndElement (); // name
829 w.WriteEndElement (); // assembly
830 w.WriteStartElement ("members");
831 XmlCommentOutput = w;
832 GenerateDocComment ();
833 w.WriteFullEndElement (); // members
834 w.WriteEndElement ();
835 w.WriteWhitespace (Environment.NewLine);
836 w.WriteEndDocument ();
838 } catch (Exception ex) {
839 Report.Error (1569, "Error generating XML documentation file '{0}' ('{1}')", docfilename, ex.Message);
848 // Fixes full type name of each documented types/members up.
850 public void GenerateDocComment ()
852 TypeContainer root = RootContext.Tree.Types;
853 if (root.Interfaces != null)
854 foreach (Interface i in root.Interfaces)
855 DocUtil.GenerateTypeDocComment (i, null);
857 if (root.Types != null)
858 foreach (TypeContainer tc in root.Types)
859 DocUtil.GenerateTypeDocComment (tc, null);
861 if (root.Parts != null) {
862 IDictionary comments = PartialComments;
863 foreach (ClassPart cp in root.Parts) {
864 if (cp.DocComment == null)
870 if (root.Delegates != null)
871 foreach (Delegate d in root.Delegates)
872 DocUtil.GenerateDocComment (d, null);
874 if (root.Enums != null)
875 foreach (Enum e in root.Enums)
876 DocUtil.GenerateEnumDocComment (e, null);
878 IDictionary table = new ListDictionary ();
879 foreach (ClassPart cp in PartialComments.Keys) {
880 table [cp.PartialContainer] += cp.DocComment;
882 foreach (PartialContainer pc in table.Keys) {
883 pc.DocComment = table [pc] as string;
884 DocUtil.GenerateDocComment (pc, null);