Ejemplo 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);
 }
Ejemplo 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));
 }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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;
        }
Ejemplo 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;
        }
Ejemplo 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());
            }
        }
Ejemplo 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());
            }
        }
Ejemplo 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;
        }
Ejemplo 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;
        }
Ejemplo 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);
        }
Ejemplo 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;
 }
Ejemplo n.º 13
0
 internal MethodCallParser(SDRepository repository, CSharpSolution solution)
     : base(repository) 
 {
     _solution = solution;
 }