Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTianqi Zhang <TianqiZhang@users.noreply.github.com>2021-09-07 08:19:34 +0300
committerGitHub <noreply@github.com>2021-09-07 08:19:34 +0300
commit8090c2456c7f9b680662bd376c1b4ea08cb61e92 (patch)
tree25de5e2b3f1f1fb4aa7bc60743c1a21c42adafd1
parent71e3f1652386d190dca14156d57c0eee8f63fd33 (diff)
parente2a59f23ec95ee5559fe87ffe8932fa9d76b82f3 (diff)
Merge pull request #573: Automatically include xmls to import for bootstrap command
Automatically include xmls to import for bootstrap command
-rw-r--r--mdoc/Mono.Documentation/frameworksbootstrapper.cs53
1 files changed, 43 insertions, 10 deletions
diff --git a/mdoc/Mono.Documentation/frameworksbootstrapper.cs b/mdoc/Mono.Documentation/frameworksbootstrapper.cs
index 28f1bc02..f6d83108 100644
--- a/mdoc/Mono.Documentation/frameworksbootstrapper.cs
+++ b/mdoc/Mono.Documentation/frameworksbootstrapper.cs
@@ -34,17 +34,50 @@ namespace Mono.Documentation
.OrderBy(d => d.Name)
.ToArray();
+ var frameworks = new List<XElement>();
+ var assemblyVersionMappings = new Dictionary<string, Dictionary<string, string>>();
foreach (var d in data)
- Console.WriteLine (d.Name);
-
- var doc = new XDocument (
- new XElement("Frameworks",
- data.Select(d => new XElement(
- "Framework",
- new XAttribute("Name", d.Name),
- new XAttribute("Source", d.Path),
- new XElement("assemblySearchPath", Path.Combine("dependencies", d.Name)))))
- );
+ {
+ Console.WriteLine(d.Name);
+ var assemblyVersionMapping = new Dictionary<string, string>();
+ assemblyVersionMappings.Add(d.Name, assemblyVersionMapping);
+ string sourcePath = Path.Combine(frameworkPath, d.Path);
+ foreach (var xmlPath in Directory.GetFiles(sourcePath, "*.xml"))
+ {
+ string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(xmlPath);
+ string dllPath = Path.Combine(sourcePath, fileNameWithoutExtension + ".dll");
+ if (File.Exists(dllPath))
+ {
+ var version = FileVersionInfo.GetVersionInfo(dllPath).FileVersion;
+ if (!string.IsNullOrEmpty(version))
+ {
+ assemblyVersionMapping.Add(Path.GetFileName(xmlPath), version);
+ }
+ }
+ }
+ frameworks.Add(new XElement(
+ "Framework",
+ new XAttribute("Name", d.Name),
+ new XAttribute("Source", d.Path),
+ new XElement("assemblySearchPath", Path.Combine("dependencies", d.Name))));
+ }
+
+ var maxVersions = assemblyVersionMappings.SelectMany(f => f.Value)
+ .GroupBy(m => m.Key)
+ .ToDictionary(g => g.Key, g => g.Max(m => m.Value));
+
+ foreach (var framework in frameworks)
+ {
+ foreach (var assembly in assemblyVersionMappings[framework.Attribute("Name").ToString().Split('"')[1]])
+ {
+ if (maxVersions.ContainsKey(assembly.Key) && assembly.Value == maxVersions[assembly.Key])
+ {
+ framework.Add(new XElement("import", string.Format("{0}\\{1}", framework.Attribute("Source").ToString().Split('"')[1], assembly.Key)));
+ }
+ }
+ }
+
+ var doc = new XDocument(new XElement("Frameworks", frameworks));
var configPath = Path.Combine (frameworkPath, "frameworks.xml");
var settings = new XmlWriterSettings { Indent = true };