Example #1
0
        void AnalyseProject(FileInfo project)
        {
            if (!project.Exists)
            {
                progressMonitor.MissingProject(project.FullName);
                return;
            }

            try
            {
                var csProj = new CsProjFile(project);

                foreach (var @ref in csProj.References)
                {
                    AssemblyInfo resolved = assemblyCache.ResolveReference(@ref);
                    if (!resolved.Valid)
                    {
                        UnresolvedReference(@ref, project.FullName);
                    }
                    else
                    {
                        UseReference(resolved.Filename);
                    }
                }

                foreach (var src in csProj.Sources)
                {
                    // Make a note of which source files the projects use.
                    // This information doesn't affect the build but is dumped
                    // as diagnostic output.
                    UseSource(new FileInfo(src));
                }

                ++succeededProjects;
            }
            catch (Exception ex)  // lgtm[cs/catch-of-all-exceptions]
            {
                ++failedProjects;
                progressMonitor.FailedProjectFile(project.FullName, ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Reads all the source files and references from the given list of projects.
        /// </summary>
        /// <param name="projectFiles">The list of projects to analyse.</param>
        void AnalyseProjectFiles(FileInfo[] projectFiles)
        {
            progressMonitor.AnalysingProjectFiles(projectFiles.Count());

            foreach (var proj in projectFiles)
            {
                try
                {
                    var csProj = new CsProjFile(proj);

                    foreach (var @ref in csProj.References)
                    {
                        AssemblyInfo resolved = assemblyCache.ResolveReference(@ref);
                        if (!resolved.Valid)
                        {
                            UnresolvedReference(@ref, proj.FullName);
                        }
                        else
                        {
                            UseReference(resolved.Filename);
                        }
                    }

                    foreach (var src in csProj.Sources)
                    {
                        // Make a note of which source files the projects use.
                        // This information doesn't affect the build but is dumped
                        // as diagnostic output.
                        UseSource(new FileInfo(src));
                    }
                    ++succeededProjects;
                }
                catch (Exception ex)
                {
                    ++failedProjects;
                    progressMonitor.FailedProjectFile(proj.FullName, ex.Message);
                }
            }
        }