예제 #1
0
        public SolutionTest()
        {
            var path = Environment.CurrentDirectory + "/Solution/minimal/minimal.sln";

            _solution = new CSharpSolution(path, new Logger(Verbosity.Verbose));
            _solution.LoadSolution();
        }
예제 #2
0
        static ISolution LoadSolution(string solutionPath, Logger logger)
        {
            solutionPath = solutionPath.ApplyPathReplacementsForServer();
            ISolution solution;

            if (Directory.Exists(solutionPath))
            {
                var slnFiles = Directory.GetFiles(solutionPath, "*.sln");
                Console.WriteLine(slnFiles.Length);
                if (slnFiles.Length == 1)
                {
                    solutionPath = slnFiles[0];
                    logger.Debug("Found solution file - " + solutionPath);
                    solution = new CSharpSolution(solutionPath, logger);
                }
                else
                {
                    solution = new CSharpFolder(solutionPath, logger);
                }
            }
            else
            {
                solution = new CSharpSolution(solutionPath, logger);
            }
            return(solution);
        }
예제 #3
0
        private void ParseMethodCalls(CSharpSolution solution, SDRepository sdRepository)
        {
            var methodCallParser = new MethodCallParser(sdRepository, solution);

            methodCallParser.OnItemParseStart += (n) => { ExecuteOnStepMessage(_parserStrings.ParsingMethod + ": " + n); };
            methodCallParser.ParseMethodCalls();
        }
예제 #4
0
        private static void StartServer(string solutionPath, string clientPathMode, int port, Verbosity verbosity)
        {
            var logger = new Logger(verbosity);

            try
            {
                Configuration.ConfigurationLoader.Load(clientPathMode);

                ISolution solution;
                if (Directory.Exists(solutionPath))
                {
                    solution = new CSharpFolder(logger);
                }
                else
                {
                    solution = new CSharpSolution(logger);
                }

                Console.CancelKeyPress +=
                    (sender, e) =>
                {
                    solution.Terminate();
                    Console.WriteLine("Ctrl-C pressed");
                    e.Cancel = true;
                };
                var nancyHost = new NancyHost(new Bootstrapper(
                                                  solution,
                                                  new NativeFileSystem(),
                                                  logger),
                                              new HostConfiguration {
                    RewriteLocalhost = false
                },
                                              new Uri("http://localhost:" + port));

                nancyHost.Start();
                logger.Debug("OmniSharp server is listening");
                solution.LoadSolution(solutionPath.ApplyPathReplacementsForServer());
                logger.Debug("Solution has finished loading");
                while (!solution.Terminated)
                {
                    Thread.Sleep(1000);
                }

                Console.WriteLine("Quit gracefully");
                nancyHost.Stop();
            }
            catch (Exception e)
            {
                if (e is SocketException || e is HttpListenerException)
                {
                    logger.Error("Detected an OmniSharp instance already running on port " + port + ". Press a key.");
                    Console.ReadKey();
                    return;
                }
                throw;
            }
        }
예제 #5
0
 private void PostSolutionLoadSummary(CSharpSolution solution)
 {
     _buildMessenger.ExecuteOnBuildMessage(
         string.Format(_sdBuildStrings.ProjectsLoaded,
                       solution.AllFiles.Sum(f => f.LinesOfCode),
                       solution.AllFiles.Sum(f => f.OriginalText.Length) / 1024.0 / 1024.0,
                       solution.AllFiles.Count(),
                       solution.Projects.Count));
 }
        public ICSharpSolution ToSolution()
        {
            var solution = new CSharpSolution()
            {
                AzureAttachConsoleApp.ToProject(),
                AzureAttachModel.ToProject()
            };

            solution.Name = _settings.OutputName;
            return(solution);
        }
예제 #7
0
        private CSharpSolution LoadSolution(string solutionFile)
        {
            var solution = new CSharpSolution();

            solution.OnLoadingProject += (m) => ExecuteOnStepMessage(string.Format(_parserStrings.ReadingProject, m));
            solution.OnLoadedProject  += (t, i) => ExecuteOnStepProgress((int)(((double)i / (double)t) * 20));

            solution.LoadSolution(solutionFile);

            return(solution);
        }
예제 #8
0
        public CSharpSolution LoadSolution()
        {
            _buildMessenger.ExecuteOnStepProgress(0);
            _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.LoadingSolution);

            var solution = new CSharpSolution(_sdBuildStrings, _buildMessenger);

            solution.LoadSolution(_coreConfigSection.InputPath);
            PostSolutionLoadSummary(solution);

            _buildMessenger.ExecuteOnStepProgress(100);

            return(solution);
        }
예제 #9
0
        public SDRepository ParseStructure(CSharpSolution solution)
        {
            _solution   = solution;
            _repository = new SDRepository();

            _buildMessenger.ExecuteOnStepProgress(0);
            _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.ParsingSolution);

            ParseNamespaces();
            ParseTypes();

            _buildMessenger.ExecuteOnStepProgress(100);

            return(_repository);
        }
예제 #10
0
        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);
        }
예제 #11
0
        private static void StartServer(string solutionPath, int port, bool verbose)
        {
            try
            {
                Configuration.ConfigurationLoader.Load();
                var solution = new CSharpSolution();
                Console.CancelKeyPress +=
                    (sender, e) =>
                {
                    solution.Terminated = true;
                    Console.WriteLine("Ctrl-C pressed");
                    e.Cancel = true;
                };

                var nancyHost = new NancyHost(new Bootstrapper(solution, new NativeFileSystem(), verbose), new HostConfiguration {
                    RewriteLocalhost = false
                }, new Uri("http://localhost:" + port));

                nancyHost.Start();
                Console.WriteLine("OmniSharp server is listening");
                solution.LoadSolution(solutionPath);
                Console.WriteLine("Solution has finished loading");
                while (!solution.Terminated)
                {
                    Thread.Sleep(1000);
                }

                Console.WriteLine("Quit gracefully");
                nancyHost.Stop();
            }
            catch (Exception e)
            {
                if (e is SocketException || e is HttpListenerException)
                {
                    Console.Error.WriteLine("Detected an OmniSharp instance already running on port " + port + ". Press a key.");
                    Console.ReadKey();
                    return;
                }
                throw;
            }
        }
예제 #12
0
        public SDRepository ParseSolution(CSharpSolution solution, List <string> excludedIdentifiers)
        {
            _solution            = solution;
            _excludedIdentifiers = excludedIdentifiers ?? new List <string>();
            _repository          = new SDRepository();

            _buildMessenger.ExecuteOnStepProgress(0);
            _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.ParsingSolution);

            GetProjectInfos();
            GetImages();
            ParseNamespaces();
            ParseTypes();
            ParseArticles();
            ParseMethodCalls();
            ResolveUses();

            _buildMessenger.ExecuteOnStepProgress(100);

            return(_repository);
        }
예제 #13
0
파일: Program.cs 프로젝트: wan17/vim-ide
        private static void StartServer(string solutionPath, int port, bool verbose)
        {
            var lockfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lockfile-" + port);

            try
            {
                using (new FileStream(lockfile, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
                {
                    var solution = new CSharpSolution(solutionPath);
                    Console.CancelKeyPress +=
                        (sender, e) =>
                    {
                        solution.Terminated = true;
                        Console.WriteLine("Ctrl-C pressed");
                        e.Cancel = true;
                    };

                    var nancyHost = new NancyHost(new Bootstrapper(solution, verbose), new Uri("http://localhost:" + port));

                    nancyHost.Start();

                    while (!solution.Terminated)
                    {
                        Thread.Sleep(1000);
                    }

                    Console.WriteLine("Quit gracefully");
                    nancyHost.Stop();
                }
                DeleteLockFile(lockfile);
            }
            catch (IOException)
            {
                Console.WriteLine("Detected an OmniSharp instance already running on port " + port + ". Press a key.");
                Console.ReadKey();
            }
        }
예제 #14
0
 internal MethodCallParser(SDRepository repository, CSharpSolution solution)
     : base(repository)
 {
     _solution = solution;
 }