Beispiel #1
0
        public ScannedProject(string typeName, string path, IDictionary <string, string> properties, string condition)
        {
            try
            {
                this.Type = (ScannedProjectType)Enum.Parse(typeof(ScannedProjectType), typeName);
            }
            catch (ArgumentException)
            {
                this.Type = ScannedProjectType.Unknown;
            }

            this.Path       = path;
            this.Properties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            if (null != properties)
            {
                foreach (KeyValuePair <string, string> kvp in properties)
                {
                    this.Properties.Add(kvp.Key, kvp.Value);
                }
            }

            if (!String.IsNullOrEmpty(condition))
            {
                this.Condition = condition;
            }

            this.Key = ScannedProject.CalculateKey(this.Path, this.Properties);

            this.SourceFiles    = new List <ScannedSourceFile>();
            this.SourceProjects = new List <ScannedProject>();
            this.TargetProjects = new List <ScannedProject>();
        }
Beispiel #2
0
        private IEnumerable <ProcessPath> ProcessProjectFile(ProcessPath process, ScanResult result)
        {
            List <ProcessPath> newFiles = new List <ProcessPath>();

            // If this project is not processed already, read through it all.
            ScannedProject scannedProject;
            string         key = ScannedProject.CalculateKey(process.Path, process.Properties);

            if (!result.ProjectFiles.TryGetValue(key, out scannedProject))
            {
                Project project       = new Project(process.Path, process.Properties, null);
                string  projectFolder = Path.GetDirectoryName(project.FullPath);
                string  type          = project.GetPropertyValue("OutputType");

                scannedProject = new ScannedProject(type, project.FullPath, process.Properties, null);
                ICollection <ProjectItem> projectReferences = project.GetItemsIgnoringCondition("ProjectReference");
                if (this.RecurseProjects && projectReferences != null)
                {
                    foreach (ProjectItem projectReference in projectReferences)
                    {
                        // TODO: process Property metadata.
                        string include = Path.Combine(projectFolder, projectReference.EvaluatedInclude);
                        newFiles.Add(new ProcessPath(include)
                        {
                            Project = scannedProject
                        });
                    }
                }

                ICollection <ProjectItem> compiles = project.GetItemsIgnoringCondition("Compile");
                if (compiles != null)
                {
                    foreach (ProjectItem item in compiles)
                    {
                        // TODO: process DefineConstants property.
                        string include = Path.Combine(projectFolder, item.EvaluatedInclude);
                        newFiles.Add(new ProcessPath(include)
                        {
                            Project = scannedProject
                        });
                    }
                }

                Debug.Assert(key == scannedProject.Key, String.Format("{0} should equal {1}", key, scannedProject.Key));
                result.ProjectFiles.Add(scannedProject.Key, scannedProject);
            }

            // If there is a parent project, create a reference between the two projects.
            if (process.Project != null)
            {
                process.Project.TargetProjects.Add(scannedProject);
                scannedProject.SourceProjects.Add(process.Project);
                //result.ProjectToProjectReferences.Add(new ScannedProjectProjectReference() { SourceProject = process.Project, TargetProject = scannedProject });
            }

            return(newFiles);
        }