Esempio n. 1
0
 private IProjectContent AddAllAssemblyReferences(CSharpSolution solution, Project msbuildProject, IProjectContent pc)
 {
     foreach (var assemblyFile in ResolveAssemblyReferences(msbuildProject))
     {
         var assembly = solution.LoadAssembly(assemblyFile);
         pc = pc.AddAssemblyReferences(new[] { assembly });
     }
     return(pc);
 }
Esempio n. 2
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));
 }
Esempio n. 3
0
        public CSharpProject(CSharpSolution solution, string title, string fileName)
        {
            Files = new List<CSharpFile>();
            CompilerSettings = new CompilerSettings();
            Solution = solution;
            Title = title;
            FileName = fileName;

            LoadCSharpProject(solution, fileName);
        }
Esempio n. 4
0
        public CSharpProject(CSharpSolution solution, string title, string fileName)
        {
            Files            = new List <CSharpFile>();
            CompilerSettings = new CompilerSettings();
            Solution         = solution;
            Title            = title;
            FileName         = fileName;

            LoadCSharpProject(solution, fileName);
        }
Esempio n. 5
0
        public CSharpSolution LoadSolution()
        {
            _buildMessenger.ExecuteOnStepProgress(0);
            _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.LoadingSolution);

            var solution = new CSharpSolution(_sdBuildStrings, _buildMessenger);
            solution.LoadSolution(_config.InputPath);
            PostSolutionLoadSummary(solution);

            _buildMessenger.ExecuteOnStepProgress(100);

            return solution;
        }
Esempio n. 6
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;
        }
Esempio n. 7
0
        private void LoadCSharpProject(CSharpSolution solution, string fileName)
        {
            try
            {
                var msbuildProject = LoadAndInitProject(solution, fileName);

                var pc = CreateCSharpProjectContent(fileName);
                pc = AddCompileFilesToProject(msbuildProject, pc);
                pc = AddAllAssemblyReferences(solution, msbuildProject, pc);
                pc = AddAllProjectReferences(msbuildProject, pc);

                ProjectContent = pc;
            }
            catch (InvalidProjectFileException invalidproject)
            {
                Trace.TraceWarning(invalidproject.ToString());
            }
        }
Esempio n. 8
0
        private void LoadCSharpProject(CSharpSolution solution, string fileName)
        {
            try
            {
                var msbuildProject = LoadAndInitProject(solution, fileName);

                var pc = CreateCSharpProjectContent(fileName);
                pc = AddCompileFilesToProject(msbuildProject, pc);
                pc = AddAllAssemblyReferences(solution, msbuildProject, pc);
                pc = AddAllProjectReferences(msbuildProject, pc);

                ProjectContent = pc;
            }
            catch (InvalidProjectFileException invalidproject)
            {
                Trace.TraceWarning(invalidproject.ToString());
            }
        }
Esempio n. 9
0
        private Project LoadAndInitProject(CSharpSolution solution, string fileName)
        {
            var globalProperties = new Dictionary<string, string>();
            globalProperties.Add("SolutionDir", solution.Directory);

            var msbuildProject = 
                new Project(fileName, globalProperties, null, 
                ProjectCollection.GlobalProjectCollection, ProjectLoadSettings.IgnoreMissingImports);

            AssemblyName = msbuildProject.GetPropertyValue("AssemblyName");
            CompilerSettings.AllowUnsafeBlocks = GetBoolProperty(msbuildProject, "AllowUnsafeBlocks") ?? false;
            CompilerSettings.CheckForOverflow = GetBoolProperty(msbuildProject, "CheckForOverflowUnderflow") ?? false;

            var defineConstants = msbuildProject.GetPropertyValue("DefineConstants");
            foreach (var symbol in defineConstants.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries))
                CompilerSettings.ConditionalSymbols.Add(symbol.Trim());

            return msbuildProject;
        }
Esempio n. 10
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;
        }
Esempio n. 11
0
        private Project LoadAndInitProject(CSharpSolution solution, string fileName)
        {
            var globalProperties = new Dictionary <string, string>();

            globalProperties.Add("SolutionDir", solution.Directory);

            var msbuildProject =
                new Project(fileName, globalProperties, null,
                            ProjectCollection.GlobalProjectCollection, ProjectLoadSettings.IgnoreMissingImports);

            AssemblyName = msbuildProject.GetPropertyValue("AssemblyName");
            CompilerSettings.AllowUnsafeBlocks = GetBoolProperty(msbuildProject, "AllowUnsafeBlocks") ?? false;
            CompilerSettings.CheckForOverflow  = GetBoolProperty(msbuildProject, "CheckForOverflowUnderflow") ?? false;

            var defineConstants = msbuildProject.GetPropertyValue("DefineConstants");

            foreach (var symbol in defineConstants.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                CompilerSettings.ConditionalSymbols.Add(symbol.Trim());
            }

            return(msbuildProject);
        }
Esempio n. 12
0
 private IProjectContent AddAllAssemblyReferences(CSharpSolution solution, Project msbuildProject, IProjectContent pc)
 {
     foreach (var assemblyFile in ResolveAssemblyReferences(msbuildProject))
     {
         var assembly = solution.LoadAssembly(assemblyFile);
         pc = pc.AddAssemblyReferences(new[] { assembly });
     }
     return pc;
 }
Esempio n. 13
0
 internal MethodCallParser(SDRepository repository, CSharpSolution solution)
     : base(repository) 
 {
     _solution = solution;
 }