示例#1
0
 protected override void AfterSetItemFrom(CustomItemNode item)
 {
     if (item is ItemNode)
     {
         if (tag != null && item.Tag is LeafSetEx)
         {
             tag.T216LeafID1 = ((LeafSetEx)item.Tag).LeafID;
         }
     }
 }
示例#2
0
		public async Task FlavorRemoveExtendedPropertiesWithUnknownProperty ()
		{
			// Unknown data should be kept in the file

			string projFile = Util.GetSampleProject ("extended-project-properties", "test-unknown-data.myproj");

			var tn = new MyEmptyProjectTypeNode ();
			var fn = new CustomItemNode<FlavorWithData> ();
			MSBuildProjectService.RegisterCustomItemType (tn);
			WorkspaceObject.RegisterCustomExtension (fn);
			try {
				var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
				Assert.IsInstanceOf<MyEmptyProject> (p);
				var mp = (MyEmptyProject)p;

				var f = mp.GetFlavor<FlavorWithData> ();
				Assert.NotNull (f.Data);
				Assert.AreEqual (f.Data.Foo, "bar");
				Assert.AreEqual (f.SimpleData, "Test");

				f.Data = null;

				await mp.SaveAsync (Util.GetMonitor ());

				string projectXml1 = File.ReadAllText (Util.GetSampleProject ("extended-project-properties", "test-extra-data.myproj"));

				string projectXml2 = File.ReadAllText (projFile);
				Assert.AreEqual (projectXml1, projectXml2);

			} finally {
				MSBuildProjectService.UnregisterCustomItemType (tn);
				WorkspaceObject.UnregisterCustomExtension (fn);
			}
		}
示例#3
0
		public async Task FlavorLoadExtendedProperties_InitialEmptyGroup ()
		{
			// Check that data load works when it is not defined in the main group
			// Test for BXC 41774.
			string projFile = Util.GetSampleProject ("extended-project-properties", "test-data-empty-group.myproj");

			var tn = new MyEmptyProjectTypeNode ();
			var fn = new CustomItemNode<FlavorWithData> ();
			MSBuildProjectService.RegisterCustomItemType (tn);
			WorkspaceObject.RegisterCustomExtension (fn);
			try {
				var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
				Assert.IsInstanceOf<MyEmptyProject> (p);
				var mp = (MyEmptyProject)p;

				var f = mp.GetFlavor<FlavorWithData> ();
				Assert.NotNull (f.Data);
				Assert.AreEqual (f.Data.Foo, "bar");
				Assert.AreEqual (f.SimpleData, "Test");
			} finally {
				MSBuildProjectService.UnregisterCustomItemType (tn);
				WorkspaceObject.UnregisterCustomExtension (fn);
			}
		}
        public async Task TestWorkspaceFilesCache_UsedOnLoad()
        {
            // First we create the cache by loading the solution.
            string solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln");

            await IdeServices.Workspace.OpenWorkspaceItem(solFile);

            await IdeServices.TypeSystemService.ProcessPendingLoadOperations();

            var sol = IdeServices.Workspace.GetAllItems <Solution> ().First();

            IdeServices.Workspace.ActiveConfigurationId = sol.DefaultConfigurationId;

            var p = sol.FindProjectByName("ConsoleProject") as DotNetProject;
            // Check cache created for active configuration.
            var cacheInfo = GetProjectCacheInfo(sol, p);

            Assert.IsNotNull(cacheInfo);

            await IdeServices.Workspace.Close(false);

            // Load the solution again.
            var fn = new CustomItemNode <DelayGetReferencesProjectExtension> ();

            WorkspaceObject.RegisterCustomExtension(fn);

            await IdeServices.Workspace.OpenWorkspaceItem(solFile);

            await IdeServices.TypeSystemService.ProcessPendingLoadOperations();

            sol = IdeServices.Workspace.GetAllItems <Solution> ().First();
            IdeServices.Workspace.ActiveConfigurationId = sol.DefaultConfigurationId;

            p = sol.FindProjectByName("ConsoleProject") as DotNetProject;
            try {
                // Check cache created for active configuration.
                cacheInfo = GetProjectCacheInfo(sol, p);
                Assert.IsNotNull(cacheInfo);

                var ws = IdeServices.TypeSystemService.GetWorkspace(sol);

                var projectId = ws.GetProjectId(p);
                foreach (var file in p.Files)
                {
                    var docId = ws.GetDocumentId(projectId, file.FilePath);
                    var doc   = ws.GetDocument(docId);
                    Assert.IsNotNull(doc);
                }

                foreach (var reference in p.References)
                {
                    var analysisProject  = ws.CurrentSolution.GetProject(projectId);
                    var matchedReference = analysisProject
                                           .MetadataReferences
                                           .OfType <MonoDevelopMetadataReference.Snapshot> ()
                                           .FirstOrDefault(r => ((FilePath)r.FilePath).FileNameWithoutExtension == reference.Include);
                    Assert.IsNotNull(matchedReference, "Reference not found: " + reference.Include);
                }

                var ext = p.GetFlavor <DelayGetReferencesProjectExtension> ();
                ext.TaskCompletionSource.TrySetResult(true);
                Assert.IsTrue(ext.IsCalled);
            } finally {
                WorkspaceObject.UnregisterCustomExtension(fn);
                TypeSystemServiceTestExtensions.UnloadSolution(sol);
            }
        }
示例#5
0
		public async Task SerializedWrite ()
		{
			var node = new CustomItemNode<SerializedSaveTestExtension> ();
			WorkspaceObject.RegisterCustomExtension (node);

			try {
				string solFile = Util.GetSampleProject ("console-project", "ConsoleProject.sln");
				Solution sol = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
				var p = (DotNetProject) sol.Items [0];

				var op1 = p.SaveAsync (Util.GetMonitor ());
				var op2 = p.SaveAsync (Util.GetMonitor ());
				await op1;
				await op2;
				Assert.AreEqual (2, SerializedSaveTestExtension.SaveCount);
			} finally {
				WorkspaceObject.UnregisterCustomExtension (node);
			}
		}
示例#6
0
        public async Task TestWorkspaceFilesCache_MultiTargetProjectReference_UsedOnLoad()
        {
            // First we create the cache by loading the solution.
            string solFile = Util.GetSampleProject("multi-target-project-ref", "multi-target.sln");

            await IdeServices.Workspace.OpenWorkspaceItem(solFile);

            await IdeServices.TypeSystemService.ProcessPendingLoadOperations();

            var sol = IdeServices.Workspace.GetAllItems <Solution> ().First();

            IdeServices.Workspace.ActiveConfigurationId = sol.DefaultConfigurationId;

            var project = sol.FindProjectByName("multi-target-ref") as DotNetProject;

            // Check cache created for active configuration.
            var cacheInfo = GetProjectCacheInfo(sol, project, "netstandard1.4");

            Assert.IsNotNull(cacheInfo);
            cacheInfo = GetProjectCacheInfo(sol, project, "net472");
            Assert.IsNotNull(cacheInfo);

            await IdeServices.Workspace.Close(false);

            // Load the solution again.
            var fn = new CustomItemNode <DelayGetReferencesProjectExtension> ();

            WorkspaceObject.RegisterCustomExtension(fn);

            await IdeServices.Workspace.OpenWorkspaceItem(solFile);

            await IdeServices.TypeSystemService.ProcessPendingLoadOperations();

            sol = IdeServices.Workspace.GetAllItems <Solution> ().First();
            IdeServices.Workspace.ActiveConfigurationId = sol.DefaultConfigurationId;

            project = sol.FindProjectByName("multi-target-ref") as DotNetProject;
            var referencedProject = sol.FindProjectByName("multi-target") as DotNetProject;

            try {
                var ws = IdeServices.TypeSystemService.GetWorkspace(sol);

                var projectIds = ws.CurrentSolution.ProjectIds.ToArray();
                var projects   = ws.CurrentSolution.Projects.ToArray();

                var netframeworkProject    = projects.FirstOrDefault(p => p.Name == "multi-target (net471)");
                var netstandardProject     = projects.FirstOrDefault(p => p.Name == "multi-target (netstandard1.0)");
                var netframeworkProjectRef = projects.FirstOrDefault(p => p.Name == "multi-target-ref (net472)");
                var netstandardProjectRef  = projects.FirstOrDefault(p => p.Name == "multi-target-ref (netstandard1.4)");

                Assert.AreEqual(4, projectIds.Length);
                Assert.AreEqual(4, projects.Length);

                // Check project references.
                var projectReferences = netstandardProjectRef.ProjectReferences.ToArray();

                Assert.AreEqual(1, projectReferences.Length);
                Assert.AreEqual(netstandardProject.Id, projectReferences [0].ProjectId);

                projectReferences = netframeworkProjectRef.ProjectReferences.ToArray();

                Assert.AreEqual(1, projectReferences.Length);
                Assert.AreEqual(netframeworkProject.Id, projectReferences [0].ProjectId);

                var ext = project.GetFlavor <DelayGetReferencesProjectExtension> ();
                ext.TaskCompletionSource.TrySetResult(true);
            } finally {
                WorkspaceObject.UnregisterCustomExtension(fn);
                TypeSystemServiceTestExtensions.UnloadSolution(sol);
            }
        }