private void LoadFile(FileInfo fileInfo) { if (!fileInfo.Exists) { Log.Error($"Docs xml file does not exist: {fileInfo.FullName}"); return; } if (fileInfo.Name.StartsWith("ns-")) { Log.Warning($"Skipping namespace file: {fileInfo.FullName}"); return; } xDoc = XDocument.Load(fileInfo.FullName); if (xDoc.Root == null) { Log.Error($"Docs xml file does not have a root element: {fileInfo.FullName}"); return; } if (xDoc.Root.Name == "Namespace") { Log.Error($"Skipping namespace file (should have been filtered already): {fileInfo.FullName}"); return; } if (xDoc.Root.Name != "Type") { Log.Error($"Docs xml file does not have a 'Type' root element: {fileInfo.FullName}"); return; } if (!xDoc.Root.HasElements) { Log.Error($"Docs xml file Type element does not have any children: {fileInfo.FullName}"); return; } if (xDoc.Root.Elements("Docs").Count() != 1) { Log.Error($"Docs xml file Type element does not have a Docs child: {fileInfo.FullName}"); return; } DocsType docsType = new DocsType(fileInfo.FullName, xDoc, xDoc.Root); bool add = false; // If it's an interface, add it if the user allowed it if (docsType.Name.StartsWith('I') && !Config.SkipInterfaceImplementations) { add = true; } // Otherwise, add the API only if it's part of the included assemblies // or included types and is not among the excluded types else if (!IsAssemblyExcluded(docsType)) { foreach (string included in Config.IncludedAssemblies) { if (docsType.AssemblyInfos.Count(x => x.AssemblyName.StartsWith(included)) > 0 || docsType.FullName.StartsWith(included)) { add = true; if (Config.IncludedTypes.Count() > 0) { if (!Config.IncludedTypes.Contains(docsType.Name)) { add = false; } } if (Config.ExcludedTypes.Count() > 0) { if (Config.ExcludedTypes.Contains(docsType.Name)) { add = false; } } break; } } } if (add) { int totalMembersAdded = 0; Types.Add(docsType); if (XmlHelper.TryGetChildElement(xDoc.Root, "Members", out XElement xeMembers)) { foreach (XElement xeMember in xeMembers.Elements("Member")) { DocsMember member = new DocsMember(fileInfo.FullName, docsType, xeMember); totalMembersAdded++; Members.Add(member); } } string message = $"Type {docsType.DocId} added with {totalMembersAdded} member(s) included."; if (docsType.Name.StartsWith('I')) { Log.Magenta("[Interface] - " + message); } else if (totalMembersAdded == 0) { Log.Warning(message); } else { Log.Success(message); } } }
private void LoadFile(FileInfo fileInfo) { if (!fileInfo.Exists) { Log.Error(string.Format("Docs xml file does not exist: {0}", fileInfo.FullName)); return; } xDoc = XDocument.Load(fileInfo.FullName); if (xDoc.Root == null) { Log.Error("Docs xml file does not have a root element: {0}", fileInfo.FullName); return; } if (xDoc.Root.Name != "Type") { Log.Error("Docs xml file does not have a 'Type' root element: {0}", fileInfo.FullName); return; } if (!xDoc.Root.HasElements) { Log.Error("Docs xml file Type element does not have any children: {0}", fileInfo.FullName); return; } if (xDoc.Root.Elements("Docs").Count() != 1) { Log.Error("Docs xml file Type element does not have a Docs child: {0}", fileInfo.FullName); return; } DocsType docsType = new DocsType(fileInfo.FullName, xDoc, xDoc.Root); bool add = false; foreach (string included in CLArgumentVerifier.IncludedAssemblies) { if (docsType.AssemblyInfos.Count(x => x.AssemblyName.StartsWith(included)) > 0) { add = true; break; } } foreach (string excluded in CLArgumentVerifier.ExcludedAssemblies) { if (docsType.AssemblyInfos.Count(x => x.AssemblyName.StartsWith(excluded)) > 0) { add = false; Log.Warning("Docs xml file excluded: {0}", fileInfo.FullName); break; } } if (add) { Containers.Add(docsType); XElement xeMembers = XmlHelper.GetChildElement(xDoc.Root, "Members"); if (xeMembers != null) { foreach (XElement xeMember in xeMembers.Elements("Member")) { DocsMember member = new DocsMember(fileInfo.FullName, xDoc, xeMember); Members.Add(member); } } Log.Success("Docs xml file included: {0}", fileInfo.FullName); } }