-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve IncludeXmlComments performance
Co-authored-by: steven.darby <steven.darby@tribalgroup.com>
- Loading branch information
Showing
9 changed files
with
191 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XPathNavigatorExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Linq; | ||
using System.Xml.XPath; | ||
|
||
namespace Swashbuckle.AspNetCore.SwaggerGen | ||
{ | ||
internal static class XPathNavigatorExtensions | ||
{ | ||
internal static XPathNavigator SelectFirstChild(this XPathNavigator navigator, string name) | ||
{ | ||
return navigator.SelectChildren(name, "") | ||
?.Cast<XPathNavigator>() | ||
.FirstOrDefault(); | ||
} | ||
|
||
internal static XPathNavigator SelectFirstChildWithAttribute(this XPathNavigator navigator, string childName, string attributeName, string attributeValue) | ||
{ | ||
return navigator.SelectChildren(childName, "") | ||
?.Cast<XPathNavigator>() | ||
.FirstOrDefault(n => n.GetAttribute(attributeName, "") == attributeValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsDocumentHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml.XPath; | ||
|
||
namespace Swashbuckle.AspNetCore.SwaggerGen | ||
{ | ||
internal static class XmlCommentsDocumentHelper | ||
{ | ||
internal static IReadOnlyDictionary<string, XPathNavigator> GetMemberDictionary(XPathDocument xmlDoc) | ||
{ | ||
var members = xmlDoc.CreateNavigator() | ||
.SelectFirstChild("doc") | ||
?.SelectFirstChild("members") | ||
?.SelectChildren("member", "") | ||
?.OfType<XPathNavigator>(); | ||
|
||
if (members == null) | ||
{ | ||
return new Dictionary<string, XPathNavigator>(); | ||
} | ||
|
||
return members.ToDictionary(memberNode => memberNode.GetAttribute("name", "")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.