Inheritance: MonoDevelop.Projects.Extensions.ProjectTypeNode
        public async Task LoadSaveExtendedPropertiesWithUnknownProperty()
        {
            // Unknown data should be kept in the file

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

            var tn = new MyProjectTypeNode();

            MSBuildProjectService.RegisterCustomItemType(tn);
            try {
                var p = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projFile);

                Assert.IsInstanceOf <MyProject> (p);
                var mp = (MyProject)p;

                Assert.NotNull(mp.Data);
                Assert.AreEqual(mp.Data.Foo, "bar");
                Assert.AreEqual(mp.SimpleData, "Test");

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

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

                p.Dispose();
            } finally {
                MSBuildProjectService.UnregisterCustomItemType(tn);
            }
        }
        public async Task WriteExtendedProperties()
        {
            var tn = new MyProjectTypeNode();

            MSBuildProjectService.RegisterCustomItemType(tn);
            try {
                var p = Services.ProjectService.CreateProject(tn.Guid);
                Assert.IsInstanceOf <MyProject> (p);
                var mp = (MyProject)p;
                mp.ItemId = "{74FADC4E-C9A8-456E-9A2C-DB933220E073}";
                string dir = Util.CreateTmpDir("WriteExtendedProperties");
                mp.FileName = Path.Combine(dir, "test.sln");
                mp.Data     = new MyProjectData {
                    Foo = "bar"
                };
                mp.DataProperty = new MyProjectData {
                    Foo = "rep"
                };
                mp.SimpleData = "Test";
                await p.SaveAsync(Util.GetMonitor());

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

                string projectXml1 = File.ReadAllText(referenceFile);
                string projectXml2 = File.ReadAllText(mp.FileName);
                Assert.AreEqual(Util.ToWindowsEndings(projectXml1), projectXml2);

                p.Dispose();
            } finally {
                MSBuildProjectService.UnregisterCustomItemType(tn);
            }
        }
        public async Task RemoveExtendedProperties()
        {
            // Whole ProjectExtensions section should be removed

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

            var tn = new MyProjectTypeNode();

            MSBuildProjectService.RegisterCustomItemType(tn);
            try {
                var p = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projFile);

                Assert.IsInstanceOf <MyProject> (p);
                var mp = (MyProject)p;

                Assert.NotNull(mp.Data);
                Assert.AreEqual(mp.Data.Foo, "bar");
                Assert.AreEqual(mp.SimpleData, "Test");

                mp.Data = null;

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

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

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

                p.Dispose();
            } finally {
                MSBuildProjectService.UnregisterCustomItemType(tn);
            }
        }
        public async Task LoadExtendedProperties()
        {
            string projFile = Util.GetSampleProject("extended-project-properties", "test-data.myproj");

            var tn = new MyProjectTypeNode();

            MSBuildProjectService.RegisterCustomItemType(tn);
            try {
                var p = await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projFile);

                Assert.IsInstanceOf <MyProject> (p);
                var mp = (MyProject)p;

                Assert.NotNull(mp.Data);
                Assert.AreEqual(mp.Data.Foo, "bar");
                Assert.AreEqual(mp.SimpleData, "Test");

                p.Dispose();
            } finally {
                MSBuildProjectService.UnregisterCustomItemType(tn);
            }
        }
Ejemplo n.º 5
0
		public async Task RemoveExtendedPropertiesWithUnknownProperty ()
		{
			// Unknown data should be kept in the file

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

			var tn = new MyProjectTypeNode ();
			MSBuildProjectService.RegisterCustomItemType (tn);
			try {
				var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
				Assert.IsInstanceOf<MyProject> (p);
				var mp = (MyProject)p;

				Assert.NotNull (mp.Data);
				Assert.AreEqual (mp.Data.Foo, "bar");
				Assert.AreEqual (mp.SimpleData, "Test");

				mp.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);
			}
		}
Ejemplo n.º 6
0
		public async Task LoadExtendedProperties ()
		{
			string projFile = Util.GetSampleProject ("extended-project-properties", "test-data.myproj");

			var tn = new MyProjectTypeNode ();
			MSBuildProjectService.RegisterCustomItemType (tn);
			try {
				var p = await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile);
				Assert.IsInstanceOf<MyProject> (p);
				var mp = (MyProject)p;

				Assert.NotNull (mp.Data);
				Assert.AreEqual (mp.Data.Foo, "bar");
				Assert.AreEqual (mp.SimpleData, "Test");
			} finally {
				MSBuildProjectService.UnregisterCustomItemType (tn);
			}
		}
Ejemplo n.º 7
0
		public async Task WriteExtendedProperties ()
		{
			var tn = new MyProjectTypeNode ();
			MSBuildProjectService.RegisterCustomItemType (tn);
			try {
				var p = Services.ProjectService.CreateProject (tn.Guid);
				Assert.IsInstanceOf<MyProject> (p);
				var mp = (MyProject)p;
				mp.ItemId = "{74FADC4E-C9A8-456E-9A2C-DB933220E073}";
				string dir = Util.CreateTmpDir ("WriteExtendedProperties");
				mp.FileName = Path.Combine (dir, "test.sln");
				mp.Data = new MyProjectData { Foo = "bar" };
				mp.DataProperty = new MyProjectData { Foo = "rep" };
				mp.SimpleData = "Test";
				await p.SaveAsync (Util.GetMonitor ());

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

				string projectXml1 = File.ReadAllText (referenceFile);
				string projectXml2 = File.ReadAllText (mp.FileName);
				Assert.AreEqual (Util.ToWindowsEndings (projectXml1), projectXml2);
			} finally {
				MSBuildProjectService.UnregisterCustomItemType (tn);
			}
		}