C# 有没有办法将C XML注释转换成C注释?
更新: ILSPY、DotPeek和JustDecompile自动支持我正在查找的内容 我只想将我的C XML注释转换为注释 输入 ....... ...... 产出C# 有没有办法将C XML注释转换成C注释?,c#,xml,c#-4.0,C#,Xml,C# 4.0,更新: ILSPY、DotPeek和JustDecompile自动支持我正在查找的内容 我只想将我的C XML注释转换为注释 输入 ....... ...... 产出 如果没有更多的上下文来解释您最终想要从中得到什么,那么应该将Xml转换为注释。这里没有什么棘手的事情 string content = @"<member name=""P:...""> <summary>This is the summary.</summary> <return
如果没有更多的上下文来解释您最终想要从中得到什么,那么应该将Xml转换为注释。这里没有什么棘手的事情
string content =
@"<member name=""P:..."">
<summary>This is the summary.</summary>
<returns>This is the return info.</returns>
</member>";
XDocument doc = XDocument.Parse(content);
foreach (var member in doc.Descendants("member"))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("/// <summary>");
sb.AppendLine("/// " + member.Descendants("summary").Select(e => e.Value).FirstOrDefault());
sb.AppendLine("/// </summary>");
sb.AppendLine("/// <returns>");
sb.AppendLine("/// " + member.Descendants("returns").Select(e => e.Value).FirstOrDefault());
sb.AppendLine("/// </returns>");
// sb.ToString() contains the comments for this member
}
您可能需要做更多的工作才能得到您想要的结果。有什么问题吗?我有一个很大的C注释xml文件。我需要将其转换为C注释。手工操作对我来说很痛苦,@JaroslawWaliszkoOkay。。。您的方法有什么问题?@BobHorn,目前我正在创建现有程序集的一些扩展方法。我有这个程序集的xml文件。因此,我需要使用与我的扩展中的程序集中使用的相同的C特殊注释method@user960567除了summary和Returns之外,xml注释文件中还有很多其他内容,我同意,但是您没有说更多的内容,也没有在输入/输出中包含这些内容。一个更精确的问题会给你一个更精确的答案。这就是试图回答这类一般性问题的问题。干得好。我需要将assembly.xml中的所有内容转换为C注释。@user960567问题是您给了我们要求,并希望我们为您完成这项工作。你需要展示你在完成这个问题上所做的努力,然后问一些问题,看看你在哪里被卡住了。如果你想让我为你做这件事,我们可以谈谈我做这件事的费用。
string content =
@"<member name=""P:..."">
<summary>This is the summary.</summary>
<returns>This is the return info.</returns>
</member>";
XDocument doc = XDocument.Parse(content);
foreach (var member in doc.Descendants("member"))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("/// <summary>");
sb.AppendLine("/// " + member.Descendants("summary").Select(e => e.Value).FirstOrDefault());
sb.AppendLine("/// </summary>");
sb.AppendLine("/// <returns>");
sb.AppendLine("/// " + member.Descendants("returns").Select(e => e.Value).FirstOrDefault());
sb.AppendLine("/// </returns>");
// sb.ToString() contains the comments for this member
}