Esempio n. 1
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            foreach (var reference in codeDirectory.References)
            {
                var project = solution.GetProject(codeDirectory.Project.AssemblyName);
                var referencedProject = solution.FindProject(reference.Name);
                if (referencedProject != null)
                {
                    project.AddReference(new ProjectReference
                    {
                        Project = referencedProject, 
                        RelativePathToProject = relativePathGenerator.GeneratePath(project.Path, referencedProject.GeneratedProjectFilePath)
                    });
                }
                else
                {
                    var assemblyReference = new AssemblyReference {Name = reference.Name, HintPath = reference.HintPath};

                    assemblyReference.HintPath = assemblyReference.HintPath;

                    project.AddReference(assemblyReference);
                }
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
        public IFileTypeHierarchy Generate(CodeDirectory codeDirectory)
        {
            var filePathDictionary = new FilePathDictionary<IEnumerable<FileType>>();
            AddFileTypes(codeDirectory, filePathDictionary);

            return new FileTypeHierarchy(filePathDictionary, wildcardMatcher);
        }
Esempio n. 3
0
        public CodeDirectory BuildFromDirectory(IDirectory directory)
        {
            var codeDirectory = new CodeDirectory(directory.Name, directory.Path);

            BuildFromDirectory(directory, codeDirectory);

            return codeDirectory;
        }
 void AddFileTypes(CodeDirectory codeDirectory, FilePathDictionary<IEnumerable<FileType>> filePathDictionary)
 {
     if (codeDirectory.FileTypes != null)
     {
         filePathDictionary.Add(codeDirectory.Path, codeDirectory.FileTypes);
     }
     codeDirectory.Directories.Each(x => AddFileTypes(x, filePathDictionary));
 }
 static CodeDirectory CreateDirectoryStructure()
 {
     var codeDirectory = new CodeDirectory("test", ".");
     var projectA = codeDirectory.AddProject("ProjectA");
     var directory = new CodeDirectory("some source folder", ".");
     projectA.AddCodeDirectory(directory);
     directory.AddProject("ProjectB");
     return codeDirectory;
 }
Esempio n. 6
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var fileTypeHierarchy = fileTypeHierarchyBuilder.Generate(codeDirectory);

            foreach (var file in solution.Projects.SelectMany(x => x.Files))
            {
                SetFileType(file, fileTypeHierarchy);
            }
        }
Esempio n. 7
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var failures = new List<SolutionValidationFailureReason>();
            
            ThereMustBeAProject(solution, failures);
            EachProjectMustHaveATemplate(solution, failures);

            if (failures.Count > 0) throw new SolutionValidationException(failures);
        }
 static void InitDirectory()
 {
     Solution = new Solution();
     CodeDirectory = TestEntityFactory.CreateCodeDirectory("test");
     var tempaltes = TestEntityFactory.CreateCodeDirectory("_templates");
     tempaltes.AddFile(new TestFile("Test") {Contents = "<root />"});
     CodeDirectory.AddCodeDirectory(tempaltes);
     Solution.AddProject(new Project {AssemblyName = "Test", Name = "Test"});
 }
Esempio n. 9
0
 void BuildFromDirectory(IDirectory directory, CodeDirectory codeDirectory)
 {
     ProcessFiles(directory.Files, codeDirectory);
     foreach (var subDirectory in directory.Directories)
     {
         var subCodeDirectory = new CodeDirectory(subDirectory.Name, subDirectory.Path);
         codeDirectory.AddCodeDirectory(subCodeDirectory);
         BuildFromDirectory(subDirectory, subCodeDirectory);
     }
 }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            if (!string.IsNullOrEmpty(codeDirectory.ProjectTemplate))
            {
                var project = solution.GetProject(codeDirectory.Project.AssemblyName);
                project.ProjectTemplate = CreateTemplate(codeDirectory.ProjectTemplate);
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
Esempio n. 11
0
        void AddFiles(Solution solution, CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy = null, Project currentProject = null)
        {
            fileInclusionHierarchy = UpdateFileInclusionPolicy(currentDirectory, fileInclusionHierarchy);
            if (currentDirectory.Project != null)
            {
                currentProject = solution.GetProject(currentDirectory.Project.AssemblyName);
            }

            AddIncludedFiles(currentDirectory, fileInclusionHierarchy, currentProject);

            currentDirectory.Directories.Each(x => AddFiles(solution, x, fileInclusionHierarchy, currentProject));
        }
Esempio n. 12
0
 void AddIncludedFiles(CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy, Project currentProject)
 {
     if (currentProject == null) return;
     foreach (var file in currentDirectory.Files.Where(x => fileInclusionHierarchy.ShouldInclude(x.FilePath)))
     {
         currentProject.AddFile(new ProjectFile
         {
             FullPath = file.FilePath,
             RelativePath = relativePathGenerator.GeneratePath(currentProject.Path, file.FilePath)
         });
     }
 }
Esempio n. 13
0
 IFileInclusionHierarchy UpdateFileInclusionPolicy(CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy)
 {
     if (fileInclusionHierarchy == null)
     {
         fileInclusionHierarchy =
             fileInclusionHierarchyBuilder.Create(currentDirectory.FileInclusionPolicy ?? new FileInclusionPolicy());
     }
     else if (currentDirectory.FileInclusionPolicy != null)
     {
         fileInclusionHierarchy = fileInclusionHierarchyBuilder.Combine(fileInclusionHierarchy,
                                                                        currentDirectory.FileInclusionPolicy);
     }
     return fileInclusionHierarchy;
 }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var libDirectory = codeDirectory.Directories.FirstOrDefault(x => x.Name.Equals("LIB", StringComparison.InvariantCultureIgnoreCase));

            if (libDirectory == null)
                return;

            var references = solution.Projects.SelectMany(x => x.AssemblyReferences.Where(y => string.IsNullOrEmpty(y.HintPath)));

            foreach (var assemblyReference in references)
            {
                assemblyReference.HintPath = FindFile(libDirectory, assemblyReference.Name);
            }
        }
Esempio n. 15
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Microsoft Visual Studio Solution File, Format Version 11.00");
            solution.Projects.Each(
                x => stringBuilder.AppendFormat("Project(\"{0:B}\") = \"{1}\", \"{2}\", \"{3:B}\"{4}EndProject{4}",
                                                x.ProjectTypeGuid, 
                                                x.Name, 
                                                relativePathGenerator.GeneratePath(solution.SolutionPath, x.GeneratedProjectFilePath), 
                                                x.Guid, 
                                                Environment.NewLine));

            fileSystem.WriteFile(Path.Combine(solution.SolutionPath, "All.sln"), stringBuilder.ToString());
        }
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     var templateFolder = codeDirectory.Directories.FirstOrDefault(x => x.Name.Equals("_templates", StringComparison.InvariantCultureIgnoreCase));
     if (templateFolder == null) return;
     foreach (var project in solution.Projects.Where(x => x.ProjectTemplate == null))
     {
         var projectType = projectTypeNamingConvention.GetProjectType(project.Name);
         var xml = templateFolder.Files.FirstOrDefault(f => f.FileName.StartsWith(projectType.Name, StringComparison.InvariantCultureIgnoreCase));
         if (xml == null)
         {
             continue;
         }
         project.ProjectTemplate = new ProjectTemplate { Xml = XDocument.Parse(xml.Contents) };
     }
 }
Esempio n. 17
0
 void ProcessFiles(IEnumerable<IFile> files, CodeDirectory codeDirectory)
 {
     foreach (var file in files)
     {
         var parser = parserRegistry.GetParserForFile(file.FileName);
         if (parser != null)
         {
             parser.Parse(file.Contents, codeDirectory);
         }
         else
         {
             codeDirectory.AddFile(file);
         }
     }
 }
        private static string FindFile(CodeDirectory directory, string referenceName)
        {
            var file = directory.Files.FirstOrDefault(x => x.FileName.StartsWith(referenceName, StringComparison.InvariantCultureIgnoreCase));

            if (file != null)
                return file.FilePath;

            foreach (var subdir in directory.Directories)
            {
                var path = FindFile(subdir, referenceName);

                if (!string.IsNullOrEmpty(path))
                    return path;
            }

            return string.Empty;
        }
Esempio n. 19
0
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            if (codeDirectory.Project != null)
            {
                solution.AddProject(new Project
                {
                    Name = codeDirectory.Project.Name,
                    Path = codeDirectory.Path,
                    Guid = codeDirectory.Project.Guid,
                    Namespace = codeDirectory.Project.Namespace,
                    OutputType = codeDirectory.Project.OutputType,
                    AssemblyName = codeDirectory.Project.AssemblyName,
                    Extension = codeDirectory.Project.Extension,
                    GeneratedProjectFilePath = Path.Combine(codeDirectory.Path, codeDirectory.Project.Name + codeDirectory.Project.Extension),
                    ProjectTypeGuid = codeDirectory.Project.ProjectTypeGuid
                });
            }

            codeDirectory.Directories.Each(x => Execute(solution, x));
        }
Esempio n. 20
0
 public static CodeDirectory AddProject(this CodeDirectory codeDirectory, string projectName, params string[] references)
 {
     var projectDirectory = new CodeDirectory(projectName, "c:\\" + projectName + "\\path")
                                {
                                    Project = new ProjectInfo
                                                  {
                                                      Name = projectName,
                                                      OutputType = "exe",
                                                      Namespace = projectName + ".namespace",
                                                      Guid = Guid.NewGuid(),
                                                      AssemblyName = projectName,
                                                      Extension = ".csproj",
                                                      ProjectTypeGuid = Guid.NewGuid()
                                                  }
                                };
     foreach (var reference in references)
     {
         projectDirectory.References.Add(new ReferenceInformation(reference, reference + "\\path"));
     }
     codeDirectory.AddCodeDirectory(projectDirectory);
     return projectDirectory;
 }
        public void Execute(Solution solution, CodeDirectory codeDirectory)
        {
            var sourceDirectory = codeDirectory.Directories.FirstOrDefault(x => IsSourceDirectory(x.Name));
            if (sourceDirectory == null) return;

            foreach (var projectFolder in sourceDirectory.Directories)
            {
                if (projectFolder.Files.Any(x => x.FileName.Equals(ParserRegistry.ProjectFileName, StringComparison.InvariantCultureIgnoreCase)))
                    continue;
                var projectType = projectTypeNamingConvention.GetProjectType(projectFolder.Name);
                projectFolder.Project = (new ProjectInfo
                {
                    AssemblyName = projectFolder.Name,
                    Name = projectFolder.Name,
                    Namespace = projectFolder.Name,
                    OutputType = projectType.OutputType,
                    Guid = guidGenerator.Generate(),
                    Extension = ".csproj",
                    ProjectTypeGuid = projectType.ProjectTypeGuid,
                });
            }
        }
Esempio n. 22
0
 public void Parse(string file, CodeDirectory codeDirectory)
 {
     codeDirectory.ProjectTemplate = file;
 }
Esempio n. 23
0
 public void Execute(CodeDirectory solutionCodeDirectory)
 {
     var solution = new Solution { SolutionPath = solutionCodeDirectory.Path };
     var steps = stepsBuilder.BuildSteps();
     steps.Each(x => x.Execute(solution, solutionCodeDirectory));
 }
Esempio n. 24
0
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     AddFiles(solution, codeDirectory);
 }
Esempio n. 25
0
 public void AddCodeDirectory(CodeDirectory codeDirectory)
 {
     if (codeDirectory == null) throw new ArgumentNullException("codeDirectory");
     directories.Add(codeDirectory);
 }
 public void Execute(Solution solution, CodeDirectory codeDirectory)
 {
     solution.Projects.Each(FixReferencesForProject);
 }