我尝试为Visual Studio编写一个用于XML代码文档的litte插件。 但是我创建XML的代码无法正常工作:
XElement rootElement = new XElement("doc");
XElement summaryElement = new XElement("summary");
var refElement = new XElement("see");
refElement.Add(new XAttribute("cref", codeFunction.Name));
summaryElement.Value = string.Format("Initializes a new instance of the {0} class.", seeRefElement);
rootElement.Add(summaryElement);
comment = rootElement.ToString();
这是输出。
<doc>\r\n <summary>Initializes a new instance of the <see cref="Form1" /> class.</summary>\r\n</doc>
应该是:
<doc>\r\n <summary>Initializes a new instance of the <see cref="Form1" />class.</summary>\r\n</doc>
我应该使用其他方式来创建我的XML吗?任何提示和改进都是值得赞赏的。
答案 0 :(得分:4)
替换以下行
summaryElement.Value = string.Format("Initializes a new instance of the {0} class.", refElement);
与
summaryElement.Add(new XText("Initializes a new instance of the "));
summaryElement.Add(refElement);
summaryElement.Add(new XText(" class."));
答案 1 :(得分:0)
是的,它正在逃避&lt;理所当然。在其他地方有一个关于此的线索,有一些建议的解决方法:
答案 2 :(得分:0)
最简单的方法是从摘要XML生成API文档是使用Sandcastle。请参阅此主题以获取链接:Are there any good automated tools to document REST APIs