-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Version 6.1.4 on .NET 5
We were using the following code to include multiple XMLs for comments (model dlls, app parts etc).
This was working for years until a dev referenced an external commercial library with it's own XML comment file (130k lines / 7 MB) and the generation time for the swagger.json went from ~600ms to 40s+ for each request.
Of course filtering out this file fixed the issue, however I don't think performance degradation should be that bad for a mere 130k lines of additional xml and even if it takes 40s why the swagger.json is it taking so long for subsequent requests.
I havn't looked at your code, yet it feels like you're not using a dictionary lookup and just search the xml nodes over and over again and the end result is not cached at all.
c.IncludeXmlComments(() =>
{
try
{
var directory = Path.GetDirectoryName(typeof(Startup).Assembly.Location);
var xdocs = Directory.EnumerateFiles(directory, "*.xml")
.Select(x => XDocument.Load(x).Element("doc")?.Descendants()).ToList();
var doc = new XDocument(new XElement("doc", xdocs));
return new XPathDocument(doc.CreateReader());
}
catch (Exception)
{
var doc = new XDocument(new XElement("doc"));
return new XPathDocument(doc.CreateReader());
}
}, true);
Update:
var paramNode = _xmlNavigator.SelectSingleNode(
$"/doc/members/member[@name='{methodMemberName}']/param[@name='{parameterInfo.Name}']");eww xpath.. that explains it