コード例 #1
0
ファイル: RoslynParser.cs プロジェクト: ranganathsb/sharpDox
        public SDSolution GetParsedSolution(string solutionFile, ICoreConfigSection sharpDoxConfig, Dictionary <string, string> tokens, bool parseMethodCalls, bool ignoreExcludes = false)
        {
            var sdSolution = new SDSolution(solutionFile);
            var solution   = _roslynLoader.LoadSolutionFile(solutionFile);

            var parserOptions = new ParserOptions();

            parserOptions.CodeSolution   = solution;
            parserOptions.SDSolution     = sdSolution;
            parserOptions.SharpDoxConfig = sharpDoxConfig;
            parserOptions.Tokens         = tokens;
            parserOptions.IgnoreExcludes = ignoreExcludes;

            ParseProjects(parserOptions);
            CleanUpNamespaces(sdSolution);

            if (parseMethodCalls)
            {
                ParseMethodCalls(parserOptions);
            }
            ResolveSeeTokens(parserOptions);
            ResolveUses(parserOptions);

            return(sdSolution);
        }
コード例 #2
0
ファイル: NRefactoryParser.cs プロジェクト: llenroc/sharpDox
        private SDSolution ParseSolution(CSharpSolution solution, ICoreConfigSection sharpDoxConfig, Dictionary <string, string> tokens, bool structured)
        {
            var sdSolution     = new SDSolution(solution.SolutionFile);
            var targetFxParser = new SDTargetFxParser();

            _currentProjectIndex = 1;
            _totalProjects       = solution.Projects.Count;
            for (var i = 0; i < solution.Projects.Count; i++)
            {
                ExecuteOnStepProgress((int)(((double)i / (double)solution.Projects.Count) * 50) + 20);

                var project         = solution.Projects[i];
                var projectFileName = project.FileName;
                var targetFx        = targetFxParser.GetTargetFx(projectFileName);

                var sdRepository = sdSolution.GetExistingOrNew(targetFx);
                if (structured)
                {
                    StructureParseNamespaces(project, sdRepository);
                    StructureParseTypes(project, sdRepository);
                }
                else
                {
                    ParseNamespaces(project, sdRepository, sharpDoxConfig, tokens);
                    ParseTypes(project, sdRepository, sharpDoxConfig);

                    // Because of excluding privates, internals and protected members
                    // it is possible, that a namespace has no visible namespaces at all.
                    // It is necessary to remove empty namespaces.
                    RemoveEmptyNamespaces(sdRepository);
                }
                _currentProjectIndex++;
            }

            ExecuteOnStepProgress(80);
            if (!structured)
            {
                var i = 0;
                foreach (var sdRepository in sdSolution.Repositories)
                {
                    ParseMethodCalls(solution, sdRepository);
                    ResolveUses(sdRepository);
                }
            }

            return(sdSolution);
        }
コード例 #3
0
ファイル: RoslynParser.cs プロジェクト: ranganathsb/sharpDox
        private void CleanUpNamespaces(SDSolution sdSolution)
        {
            for (int i = 0; i < sdSolution.Repositories.Count; i++)
            {
                var sdRepository = sdSolution.Repositories[i];
                ExecuteOnStepMessage(string.Format(_parserStrings.CleanUp, sdRepository.TargetFx.Name));
                ExecuteOnStepProgress((int)((double)i / sdSolution.Repositories.Count * 10) + 50);

                foreach (var sdNamespace in sdRepository.GetAllNamespaces())
                {
                    if (sdNamespace.Types.Count == 0)
                    {
                        sdRepository.RemoveNamespace(sdNamespace);
                    }
                }
            }
            ExecuteOnStepProgress(50);
        }
コード例 #4
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");
            this.Write("\r\n");

            #line 11 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"

//First merge all namespace and types to create a navigation for all available targets
            var consolidatedNamespaces = new List <SDNamespace>();
            var targetNamespaces       = SDSolution.GetAllSolutionNamespaces();
            foreach (var targetNamespace in targetNamespaces)
            {
                var consolidatedNamespace = targetNamespace.Value.Values.First();
                foreach (var sdNamespace in targetNamespace.Value.Values.Skip(1))
                {
                    foreach (var sdType in sdNamespace.Types)
                    {
                        if (consolidatedNamespace.Types.SingleOrDefault(s => s.Identifier == sdType.Identifier) == null)
                        {
                            consolidatedNamespace.Types.Add(sdType);
                        }
                    }
                }
                consolidatedNamespaces.Add(consolidatedNamespace);
            }

            foreach (var sdNamespace in consolidatedNamespaces)
            {
                var namespaceNavTemplate = new NamespaceNavigation {
                    Namespace = sdNamespace
                };

            #line default
            #line hidden
                this.Write("\t{\r\n\t\tid: \'");

            #line 35 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(sdNamespace.Identifier));

            #line default
            #line hidden
                this.Write("\',\r\n\t\ttext: \'");

            #line 36 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(sdNamespace.Fullname));

            #line default
            #line hidden
                this.Write("\',\r\n\t\ticon: \'./assets/icons/namespace_public.png\',\r\n\t\ta_attr: { href : \'#/namespa" +
                           "ce/");

            #line 38 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(sdNamespace.Identifier));

            #line default
            #line hidden
                this.Write("\' },\r\n\t\tchildren: [\r\n\t\t\t");

            #line 40 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(namespaceNavTemplate.TransformText()));

            #line default
            #line hidden
                this.Write("\r\n\t\t]\r\n\t},\r\n");

            #line 43 "D:\Github\SharpDox.Plugins.Html\src\Templates\Navigation\ApiNavigation.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n");
            return(this.GenerationEnvironment.ToString());
        }