public ProjectItemRelationship(ProjectItem parentProjectItem, SD.ProjectItem msbuildProjectItem)
		{
			this.ParentProjectItem = parentProjectItem;
			this.MSBuildProjectItem = msbuildProjectItem;
			this.Project = parentProjectItem.ContainingProject;
			GetRelationship();
		}
Пример #2
0
		bool IgnoreChildProjectItem(ProjectItem item)
		{
			if (item != null) {
				return SeenChildProjectItemBefore(item);
			}
			return true;
		}
Пример #3
0
		bool SeenChildProjectItemBefore(ProjectItem childProjectItem)
		{
			if (ProjectItems.Any(item => item.IsMatchByName(childProjectItem.Name))) {
				return true;
			}
			ProjectItems.Add(childProjectItem);
			return false;
		}
Пример #4
0
		void CreateProjectItemProperties()
		{
			project = new TestableDTEProject();
			msbuildProject = project.TestableProject;
			msbuildFileProjectItem = new SD.FileProjectItem(msbuildProject, SD.ItemType.Compile);
			projectItem = new ProjectItem(project, msbuildFileProjectItem);
			properties = projectItem.Properties;
		}
Пример #5
0
		void CreateProjectItemProperties()
		{
			project = new TestableDTEProject();
			msbuildProject = project.TestableProject;
			msbuildFileProjectItem = new SD.FileProjectItem(msbuildProject, SD.ItemType.Compile);
			projectItem = new ProjectItem(project, msbuildFileProjectItem);
			properties = (ICSharpCode.PackageManagement.EnvDTE.Properties)projectItem.Properties;
			
			IWorkbench workbench = MockRepository.GenerateStub<IWorkbench>();
			ICSharpCode.SharpDevelop.SD.Services.AddService(typeof(IWorkbench), workbench);
		}
Пример #6
0
        public void Item_GetFileProjectItemByNameWhenProjectHasOneFileInFolderThreeLevelsDeep_ReturnsFileProjectItem()
        {
            CreateProjectItems(@"d:\projects\MyProject\MyProject.csproj");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\jQueryPlugin\jQueryPlugin.ps1");
            DTE.ProjectItem codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            DTE.ProjectItem scaffolderFolderItem    = GetChildItem(codeTemplatesFolderItem.ProjectItems, "Scaffolders");
            DTE.ProjectItem jqueryPluginFolderItem  = GetChildItem(scaffolderFolderItem.ProjectItems, "jQueryPlugin");

            global::EnvDTE.ProjectItem jqueryPluginFileItem = jqueryPluginFolderItem.ProjectItems.Item("jQueryPlugin.ps1");

            Assert.AreEqual("jQueryPlugin.ps1", jqueryPluginFileItem.Name);
        }
Пример #7
0
        public void GetEnumerator_ProjectHasOneFileInFolderThreeLevelsDeep_FileReturnedInProjectItems()
        {
            CreateProjectItems(@"d:\projects\myproject\myproject.csproj");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\jQueryPlugin\jQueryPlugin.ps1");
            DTE.ProjectItem codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            DTE.ProjectItem scaffolderFolderItem    = GetChildItem(codeTemplatesFolderItem.ProjectItems, "Scaffolders");
            DTE.ProjectItem jqueryPluginFolderItem  = GetChildItem(scaffolderFolderItem.ProjectItems, "jQueryPlugin");

            DTE.ProjectItem jqueryPluginFileItem = GetFirstChildItem(jqueryPluginFolderItem.ProjectItems);

            Assert.AreEqual("jQueryPlugin.ps1", jqueryPluginFileItem.Name);
        }
Пример #8
0
        public void AddFromDirectory_EmptyDirectoryInsideProject_ProjectItemIsReturnedForNewDirectory()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\myproject\myproject.csproj";
            string directory = @"d:\projects\myproject\tools";

            DTE.ProjectItem item = projectItems.AddFromDirectory(directory);
            string          name = item.Name;

            Assert.AreEqual("tools", name);
            Assert.AreEqual(project, item.ContainingProject);
            Assert.AreEqual(Constants.vsProjectItemKindPhysicalFolder, item.Kind);
        }
Пример #9
0
        public void GetEnumerator_ProjectHasTwoFilesInFolderTwoLevelsDeepButParentFolderHasDifferentCase_TopLevelFolderOnlyHasOneProjectItemForChildFolder()
        {
            CreateProjectItems(@"d:\projects\MyProject\MyProject.csproj");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\File1.cs");
            msbuildProject.AddFile(@"CodeTemplates\SCAFFOLDERS\File2.cs");

            DTE.ProjectItem        codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            List <DTE.ProjectItem> childItems = GetAllChildItems(codeTemplatesFolderItem.ProjectItems);

            DTE.ProjectItem scaffoldersFolderItem = childItems.FirstOrDefault();

            Assert.AreEqual(1, childItems.Count);
            Assert.AreEqual("Scaffolders", scaffoldersFolderItem.Name);
        }
Пример #10
0
        public void Item_GetItemFromControllersFolderProjectItemsWhenProjectHasTwoFilesOneInRootAndOneInControllersFolder_ReturnsFileFromControllersFolder()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\MyProject\MyProject.csproj";
            msbuildProject.AddFile(@"AccountController.generated.cs");
            msbuildProject.AddFile(@"Controllers\AccountController.cs");

            DTE.ProjectItem projectItem = projectItems
                                          .Item("Controllers")
                                          .ProjectItems
                                          .Item(1);

            Assert.AreEqual("AccountController.cs", projectItem.Name);
        }
Пример #11
0
        public void GetEnumerator_ProjectHasOneFileInFolderTwoLevelsDeep_FolderTwoLevelsDeepFullPathIsFullDirectoryName()
        {
            CreateProjectItems(@"d:\projects\MyProject\myproject.csproj");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\Program.cs");

            DTE.ProjectItem codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            DTE.ProjectItem scaffolderFolderItem    = GetChildItem(codeTemplatesFolderItem.ProjectItems, "Scaffolders");

            string directory = (string)scaffolderFolderItem.Properties.Item(DTE.ProjectItem.FullPathPropertyName).Value;

            string expectedDirectory = @"d:\projects\MyProject\CodeTemplates\Scaffolders";

            Assert.AreEqual(expectedDirectory, directory);
        }
Пример #12
0
        public void AddFromFile_FullFileNameIsInsideProject_ProjectItemReturned()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\myproject\myproject.csproj";
            string fileName = @"d:\projects\myproject\tools\test.cs";

            msbuildProject.ItemTypeToReturnFromGetDefaultItemType = ItemType.Page;
            DTE.ProjectItem item = projectItems.AddFromFile(fileName);

            string fullPath = (string)item.Properties.Item("FullPath").Value;

            Assert.AreEqual("test.cs", item.Name);
            Assert.AreEqual(@"d:\projects\myproject\tools\test.cs", fullPath);
        }
Пример #13
0
        public void AddFromFile_AddFromFileFromProjectItemsBelongingToFile_ReturnsProjectItemAdded()
        {
            string projectFileName = @"d:\projects\myproject\MyProject.csproj";

            CreateProjectWithOneFileInProjectFolder("MainForm.cs", projectFileName);
            CreateFileProjectItemsFromFileInProjectFolder("MainForm.cs");
            string fileName = @"d:\projects\myproject\MainForm.Designer.cs";

            DTE.ProjectItem itemAdded = fileProjectItems.AddFromFile(fileName);

            string fullPath = (string)itemAdded.Properties.Item("FullPath").Value;

            Assert.AreEqual("MainForm.Designer.cs", itemAdded.Name);
            Assert.AreEqual(fileName, fullPath);
        }
Пример #14
0
        public void AddFromDirectory_DirectoryContainsOneFile_ProjectItemReturnedHasDirectoryName()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\myproject\myproject.csproj";
            string directory = @"d:\projects\myproject\tools";

            AddFileToFakeFileSystem(directory, "a.txt");

            DTE.ProjectItem item = projectItems.AddFromDirectory(directory);
            string          name = item.Name;

            Assert.AreEqual("tools", name);
            Assert.AreEqual(project, item.ContainingProject);
            Assert.AreEqual(Constants.vsProjectItemKindPhysicalFolder, item.Kind);
        }
Пример #15
0
        public void GetEnumerator_ProjectHasTwoDuplicateFileNamesInFolderTwoLevelsDeep_FolderTwoLevelsDownOnlyReturnsOneFileProjectItem()
        {
            CreateProjectItems(@"d:\projects\MyProject\MyProject.csproj");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\duplicate.cs");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\duplicate.cs");

            DTE.ProjectItem        codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            DTE.ProjectItem        scaffolderFolderItem    = GetChildItem(codeTemplatesFolderItem.ProjectItems, "Scaffolders");
            List <DTE.ProjectItem> childItems = GetAllChildItems(scaffolderFolderItem.ProjectItems);

            DTE.ProjectItem duplicateFileItem = GetFirstChildItem(scaffolderFolderItem.ProjectItems);

            Assert.AreEqual(1, childItems.Count);
            Assert.AreEqual("duplicate.cs", duplicateFileItem.Name);
        }
Пример #16
0
        public void GetEnumerator_ProjectHasTwoFilesInFolderTwoLevelsDeepAndProjectItemsForChildFolderCalledTwice_TopLevelFolderOnlyHasOneProjectItemForChildFolder()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\MyProject\MyProject.csproj";
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\File1.cs");
            msbuildProject.AddFile(@"CodeTemplates\Scaffolders\File2.cs");

            DTE.ProjectItem        codeTemplatesFolderItem = GetChildItem(projectItems, "CodeTemplates");
            List <DTE.ProjectItem> childItems = GetAllChildItems(codeTemplatesFolderItem.ProjectItems);

            // Call ProjectItems again.
            childItems = GetAllChildItems(codeTemplatesFolderItem.ProjectItems);
            DTE.ProjectItem scaffoldersFolderItem = childItems.FirstOrDefault();

            Assert.AreEqual(1, childItems.Count);
            Assert.AreEqual("Scaffolders", scaffoldersFolderItem.Name);
        }
Пример #17
0
        public void AddFromDirectory_DirectoryContainsChildDirectoryWithNoFiles_DirectoryProjectItemReturnedForParentDirectory()
        {
            CreateProjectItems();
            msbuildProject.FileName = @"d:\projects\myproject\myproject.csproj";
            string parentDirectory = @"d:\projects\myproject\tools";

            AddDirectoryToFakeFileSystem(parentDirectory, "packages");

            DTE.ProjectItem item = projectItems.AddFromDirectory(parentDirectory);
            string          name = item.Name;

            DTE.ProjectItem childItem = item.ProjectItems.Item("packages");

            Assert.AreEqual("tools", name);
            Assert.AreEqual(project, item.ContainingProject);
            Assert.AreEqual(Constants.vsProjectItemKindPhysicalFolder, item.Kind);
            Assert.AreEqual(1, item.ProjectItems.Count);
            Assert.AreEqual(Constants.vsProjectItemKindPhysicalFolder, childItem.Kind);
        }
Пример #18
0
		public FileProjectItems(ProjectItem projectItem)
			: this(projectItem, new PackageManagementFileService())
		{
		}
Пример #19
0
		public FileProjectItems(ProjectItem projectItem, IPackageManagementFileService fileService)
			: base((Project)projectItem.ContainingProject, projectItem, fileService)
		{
			this.projectItem = projectItem;
			this.fileService = fileService;
		}
Пример #20
0
 public FileProjectItems(ProjectItem projectItem)
     : base((Project)projectItem.ContainingProject, projectItem)
 {
     this.projectItem = projectItem;
     this.fileService = Project.FileService;
 }
Пример #21
0
		public DirectoryProjectItems(ProjectItem projectItem)
			: base((Project)projectItem.ContainingProject, projectItem)
		{
			this.projectItem = projectItem;
		}
Пример #22
0
		public FileProjectItems(ProjectItem projectItem)
			: base((Project)projectItem.ContainingProject, projectItem)
		{
			this.projectItem = projectItem;
			this.fileService = Project.FileService;
		}
Пример #23
0
 internal void RemoveProjectItem(ProjectItem projectItem)
 {
     projectService.RemoveProjectItem(MSBuildProject, projectItem.MSBuildProjectItem);
 }
Пример #24
0
 void CreateFileProjectItemsFromFileInProjectFolder(string include)
 {
     DTE.ProjectItem projectItem = (DTE.ProjectItem)project.ProjectItems.Item(include);
     fileProjectItems = new DTE.FileProjectItems(projectItem);
 }
 public ProjectItemPropertyFactory(ProjectItem projectItem)
 {
     this.projectItem = projectItem;
 }
Пример #26
0
		public ChildProjectItems(ProjectItem projectItem)
		{
			this.ProjectItem = projectItem;
			this.Project = projectItem.ContainingProject;
			this.ProjectItems = new List<ProjectItem>();
		}
		public ProjectItemPropertyFactory(ProjectItem projectItem)
		{
			this.projectItem = projectItem;
		}
Пример #28
0
		public ProjectItemProperty(ProjectItem projectItem, string name)
			: base(name)
		{
			this.projectItem = projectItem;
		}
		public DirectoryProjectItems(ProjectItem projectItem)
			: base(projectItem.ContainingProject, projectItem, new PackageManagementFileService())
		{
			this.projectItem = projectItem;
		}
Пример #30
0
 void CreateFileProjectItemsFromFileInProjectFolder(string include)
 {
     DTE.ProjectItem projectItem = project.ProjectItems.Item(include);
     fileProjectItems = new DTE.FileProjectItems(projectItem, fakeFileService);
 }