Exemple #1
0
        private void LoadSystemAssemblyDoc(INMemberReference memberRef, MemberReference typeReference)
        {
            NDocumentApi doc          = null;
            var          assemblyPath = Path.GetFullPath(typeReference.Module.FullyQualifiedName);

            if (!mapModuleToDoc.TryGetValue(assemblyPath, out doc))
            {
                var frameworkPath = Utility.GetFrameworkRootDirectory();
                if (assemblyPath.StartsWith(frameworkPath))
                {
                    var assemblyName      = Path.GetFileNameWithoutExtension(assemblyPath);
                    var assemblyDirectory = Path.GetDirectoryName(assemblyPath);

                    // TODO: improve replace
                    assemblyDirectory = assemblyDirectory.Replace(@"\Framework64\", @"\Framework\");

                    var assemblyXml = Path.Combine(Path.Combine(assemblyDirectory, "en"), assemblyName + ".xml");
                    Logger.Message("Load system documentation [{0}]", assemblyName);
                    doc = NDocumentApi.Load(assemblyXml);
                }
                mapModuleToDoc.Add(assemblyPath, doc);
            }

            if (doc != null)
            {
                memberRef.DocNode = doc.FindMemberDoc(memberRef.Id);
            }
        }
Exemple #2
0
        private NDocumentApi LoadAssemblyDocumentation(string source)
        {
            var xmlDoc = NDocumentApi.Load(source);

            var node = xmlDoc.Document.SelectSingleNode("/doc/assembly/name");

            if (node == null)
            {
                Logger.Fatal("Not valid xml documentation for source [{0}]", source);
            }

            return(xmlDoc);
        }
Exemple #3
0
        /// <summary>
        /// Loads all assembly sources/xml doc and references
        /// </summary>
        public List <NAssemblySource> Load(Config config)
        {
            // Preload references
            foreach (var assemblyRef in config.References)
            {
                if (!File.Exists(assemblyRef))
                {
                    Logger.Error("Assembly reference file [{0}] not found", assemblyRef);
                }
                else
                {
                    AssemblyReferences.Add(AssemblyDefinition.ReadAssembly(assemblyRef, new ReaderParameters(ReadingMode.Deferred)));
                }
            }


            var configPath = Path.GetDirectoryName(Path.GetFullPath(config.FilePath));

            configPath = configPath ?? Environment.CurrentDirectory;
            // Load all sources
            foreach (var source in config.Sources)
            {
                // Setup full path
                if (!string.IsNullOrEmpty(source.AssemblyPath))
                {
                    source.AssemblyPath = Path.Combine(configPath, source.AssemblyPath);
                }

                if (!string.IsNullOrEmpty(source.DocumentationPath))
                {
                    source.DocumentationPath = Path.Combine(configPath, source.DocumentationPath);
                }

                source.MergeGroup = source.MergeGroup ?? "default";
                Load(source);
            }

            var finalSources = new List <NAssemblySource>();

            // Check that all source assemblies have valid Xml associated with it
            foreach (var assemblySource in AssemblySources.Where(node => node.Assembly != null))
            {
                int          countXmlDocFound = 0;
                NDocumentApi docFound         = null;
                string       assemblyName     = ((AssemblyDefinition)assemblySource.Assembly).Name.Name;

                var docSources = new List <NAssemblySource>();
                if (assemblySource.Document != null)
                {
                    docSources.Add(assemblySource);
                }
                docSources.AddRange(AssemblySources.Where(node => node.Assembly == null));

                foreach (var doc in docSources)
                {
                    var node = doc.Document.Document.SelectSingleNode("/doc/assembly/name");
                    if (assemblyName == node.InnerText.Trim())
                    {
                        docFound = doc.Document;
                        countXmlDocFound++;
                    }
                }

                if (countXmlDocFound == 0)
                {
                    Logger.Fatal("Unable to find documentation for assembly [{0}]", assemblyName);
                }
                else if (countXmlDocFound > 1)
                {
                    Logger.Fatal("Cannot load from multiple ([{0}]) documentation sources for assembly [{1}]", countXmlDocFound, assemblyName);
                }

                assemblySource.Document = docFound;
                finalSources.Add(assemblySource);
            }
            return(finalSources);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NAssemblySource"/> class.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 /// <param name="document">The document.</param>
 public NAssemblySource(object assembly, NDocumentApi document)
 {
     Assembly = assembly;
     Document = document;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NAssemblySource"/> class.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 /// <param name="document">The document.</param>
 public NAssemblySource(object assembly, NDocumentApi document)
 {
     Assembly = assembly;
     Document = document;
 }