static void WriteXmlDocParameter(IXmlDocOutput output, XElement xml) { foreach (var elem in xml.DescendantNodes()) { if (elem is XText) { output.Write(XmlDocRenderer.whitespace.Replace(((XText)elem).Value, " "), TextTokenType.XmlDocSummary); } else if (elem is XElement) { var xelem = (XElement)elem; switch (xelem.Name.ToString().ToUpperInvariant()) { case "SEE": var cref = xelem.Attribute("cref"); if (cref != null) { output.Write(XmlDocRenderer.GetCref((string)cref), TextTokenType.XmlDocToolTipSeeCref); } var langword = xelem.Attribute("langword"); if (langword != null) { output.Write(((string)langword).Trim(), TextTokenType.XmlDocToolTipSeeLangword); } break; case "PARAMREF": var nameAttr = xml.Attribute("name"); if (nameAttr != null) { output.Write(((string)nameAttr).Trim(), TextTokenType.XmlDocToolTipParamRefName); } break; case "BR": case "PARA": output.WriteNewLine(); break; default: break; } } else { output.Write(elem.ToString(), TextTokenType.XmlDocSummary); } } }
static void WriteXmlDocParameter(IXmlDocOutput output, XElement xml) { foreach (var elem in xml.DescendantNodes()) { if (elem is XText) { output.Write(XmlDocRenderer.WhitespaceRegex.Replace(((XText)elem).Value, " "), BoxedTextColor.Text); } else if (elem is XElement xelem) { switch (xelem.Name.ToString().ToUpperInvariant()) { case "SEE": var cref = (string?)xelem.Attribute("cref"); if (cref is not null) { output.Write(XmlDocRenderer.GetCref(cref), BoxedTextColor.Text); } var langword = (string?)xelem.Attribute("langword"); if (langword is not null) { output.Write(langword.Trim(), BoxedTextColor.Keyword); } break; case "PARAMREF": var nameAttr = (string?)xml.Attribute("name"); if (nameAttr is not null) { output.Write(nameAttr.Trim(), BoxedTextColor.Parameter); } break; case "BR": case "PARA": output.WriteNewLine(); break; default: break; } } else { output.Write(elem.ToString(), BoxedTextColor.Text); } } }
static void AddXmlDocumentation(IXmlDocOutput output, XmlReader xml) { string lastElemName = string.Empty; bool isNewLine = true; while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { string elname = xml.Name.ToLowerInvariant(); if (!xml.IsEmptyElement) lastElemName = elname; switch (elname) { case "filterpriority": case "remarks": xml.Skip(); break; case "example": output.WriteNewLine(); output.Write("Example", TextTokenType.XmlDocToolTipExample); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteNewLine(); isNewLine = true; break; case "exception": output.WriteNewLine(); output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipExceptionCref); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "returns": output.WriteNewLine(); output.Write("Returns", TextTokenType.XmlDocToolTipReturns); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "see": output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipSeeCref); output.Write((xml["langword"] ?? string.Empty).Trim(), TextTokenType.XmlDocToolTipSeeLangword); isNewLine = false; break; case "seealso": output.WriteNewLine(); output.Write("See also", TextTokenType.XmlDocToolTipSeeAlso); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipSeeAlsoCref); isNewLine = false; break; case "paramref": output.Write((xml["name"] ?? string.Empty).Trim(), TextTokenType.XmlDocToolTipParamRefName); isNewLine = false; break; case "param": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), TextTokenType.XmlDocToolTipParamName); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "typeparam": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), TextTokenType.XmlDocToolTipTypeParamName); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "value": output.WriteNewLine(); output.Write("Value", TextTokenType.XmlDocToolTipValue); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteNewLine(); isNewLine = true; break; case "br": case "para": output.WriteNewLine(); isNewLine = true; break; default: break; } } else if (xml.NodeType == XmlNodeType.Text) { var s = whitespace.Replace(xml.Value, " "); if (isNewLine) s = s.TrimStart(); output.Write(s, lastElemName == "summary" ? TextTokenType.XmlDocSummary : TextTokenType.XmlDocToolTipText); isNewLine = false; } } }
static void WriteXmlDocParameter(IXmlDocOutput output, XElement xml) { foreach (var elem in xml.DescendantNodes()) { if (elem is XText) output.Write(XmlDocRenderer.whitespace.Replace(((XText)elem).Value, " "), TextTokenType.XmlDocSummary); else if (elem is XElement) { var xelem = (XElement)elem; switch (xelem.Name.ToString().ToUpperInvariant()) { case "SEE": var cref = xelem.Attribute("cref"); if (cref != null) output.Write(XmlDocRenderer.GetCref((string)cref), TextTokenType.XmlDocToolTipSeeCref); var langword = xelem.Attribute("langword"); if (langword != null) output.Write(((string)langword).Trim(), TextTokenType.XmlDocToolTipSeeLangword); break; case "PARAMREF": var nameAttr = xml.Attribute("name"); if (nameAttr != null) output.Write(((string)nameAttr).Trim(), TextTokenType.XmlDocToolTipParamRefName); break; case "BR": case "PARA": output.WriteNewLine(); break; default: break; } } else output.Write(elem.ToString(), TextTokenType.XmlDocSummary); } }
static void AddXmlDocumentation(IXmlDocOutput output, XmlReader xml) { bool isNewLine = true; while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { string elname = xml.Name.ToLowerInvariant(); switch (elname) { case "filterpriority": case "remarks": xml.Skip(); break; case "example": output.WriteNewLine(); output.Write("Example", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteNewLine(); isNewLine = true; break; case "exception": output.WriteNewLine(); output.Write(GetCref(xml["cref"]), BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "returns": output.WriteNewLine(); output.Write("Returns", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "see": output.Write(GetCref(xml["cref"]), BoxedTextColor.Text); output.Write((xml["langword"] ?? string.Empty).Trim(), BoxedTextColor.Keyword); isNewLine = false; break; case "seealso": output.WriteNewLine(); output.Write("See also", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); output.Write(GetCref(xml["cref"]), BoxedTextColor.Text); isNewLine = false; break; case "paramref": output.Write((xml["name"] ?? string.Empty).Trim(), BoxedTextColor.Parameter); isNewLine = false; break; case "param": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), BoxedTextColor.Parameter); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "typeparam": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), BoxedTextColor.TypeGenericParameter); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "value": output.WriteNewLine(); output.Write("Value", BoxedTextColor.Keyword); output.Write(":", BoxedTextColor.Text); output.WriteNewLine(); isNewLine = true; break; case "br": case "para": output.WriteNewLine(); isNewLine = true; break; default: break; } } else if (xml.NodeType == XmlNodeType.Text) { var s = whitespace.Replace(xml.Value, " "); if (isNewLine) { s = s.TrimStart(); } output.Write(s, BoxedTextColor.Text); isNewLine = false; } } }
static void AddXmlDocumentation(IXmlDocOutput output, XmlReader xml) { string lastElemName = string.Empty; bool isNewLine = true; while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { string elname = xml.Name.ToLowerInvariant(); if (!xml.IsEmptyElement) { lastElemName = elname; } switch (elname) { case "filterpriority": case "remarks": xml.Skip(); break; case "example": output.WriteNewLine(); output.Write("Example", TextTokenType.XmlDocToolTipExample); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteNewLine(); isNewLine = true; break; case "exception": output.WriteNewLine(); output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipExceptionCref); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "returns": output.WriteNewLine(); output.Write("Returns", TextTokenType.XmlDocToolTipReturns); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "see": output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipSeeCref); output.Write((xml["langword"] ?? string.Empty).Trim(), TextTokenType.XmlDocToolTipSeeLangword); isNewLine = false; break; case "seealso": output.WriteNewLine(); output.Write("See also", TextTokenType.XmlDocToolTipSeeAlso); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); output.Write(GetCref(xml["cref"]), TextTokenType.XmlDocToolTipSeeAlsoCref); isNewLine = false; break; case "paramref": output.Write((xml["name"] ?? string.Empty).Trim(), TextTokenType.XmlDocToolTipParamRefName); isNewLine = false; break; case "param": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), TextTokenType.XmlDocToolTipParamName); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "typeparam": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), TextTokenType.XmlDocToolTipTypeParamName); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteSpace(); isNewLine = false; break; case "value": output.WriteNewLine(); output.Write("Value", TextTokenType.XmlDocToolTipValue); output.Write(":", TextTokenType.XmlDocToolTipColon); output.WriteNewLine(); isNewLine = true; break; case "br": case "para": output.WriteNewLine(); isNewLine = true; break; default: break; } } else if (xml.NodeType == XmlNodeType.Text) { var s = whitespace.Replace(xml.Value, " "); if (isNewLine) { s = s.TrimStart(); } output.Write(s, lastElemName == "summary" ? TextTokenType.XmlDocSummary : TextTokenType.XmlDocToolTipText); isNewLine = false; } } }
static void AddXmlDocumentation(IXmlDocOutput output, XmlReader xml) { bool isNewLine = true; while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { string elname = xml.Name.ToLowerInvariant(); switch (elname) { case "filterpriority": case "remarks": xml.Skip(); break; case "example": output.WriteNewLine(); output.Write("Example", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteNewLine(); isNewLine = true; break; case "exception": output.WriteNewLine(); output.Write(GetCref(xml["cref"]), BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "returns": output.WriteNewLine(); output.Write("Returns", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "see": output.Write(GetCref(xml["cref"]), BoxedTextColor.Text); output.Write((xml["langword"] ?? string.Empty).Trim(), BoxedTextColor.Keyword); isNewLine = false; break; case "seealso": output.WriteNewLine(); output.Write("See also", BoxedTextColor.XmlDocToolTipHeader); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); output.Write(GetCref(xml["cref"]), BoxedTextColor.Text); isNewLine = false; break; case "paramref": output.Write((xml["name"] ?? string.Empty).Trim(), BoxedTextColor.Parameter); isNewLine = false; break; case "param": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), BoxedTextColor.Parameter); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "typeparam": output.WriteNewLine(); output.Write(whitespace.Replace((xml["name"] ?? string.Empty).Trim(), " "), BoxedTextColor.TypeGenericParameter); output.Write(":", BoxedTextColor.Text); output.WriteSpace(); isNewLine = false; break; case "value": output.WriteNewLine(); output.Write("Value", BoxedTextColor.Keyword); output.Write(":", BoxedTextColor.Text); output.WriteNewLine(); isNewLine = true; break; case "br": case "para": output.WriteNewLine(); isNewLine = true; break; default: break; } } else if (xml.NodeType == XmlNodeType.Text) { var s = whitespace.Replace(xml.Value, " "); if (isNewLine) s = s.TrimStart(); output.Write(s, BoxedTextColor.Text); isNewLine = false; } } }