コード例 #1
0
ファイル: BuildItem_Tests.cs プロジェクト: nikson/msbuild
        public void CloneVirtual()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m1", "v1");
            item.SetMetadata("m2", "v2");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("v1", clone.GetMetadata("m1"));
            Assertion.AssertEquals("v2", clone.GetMetadata("m2"));

            clone.SetMetadata("m2", "newValue");

            Assertion.AssertEquals("v2", item.GetMetadata("m2"));
            Assertion.AssertEquals("newValue", clone.GetMetadata("m2"));
        }
コード例 #2
0
ファイル: BuildItem.cs プロジェクト: nikson/msbuild
        /// <summary>
        /// Create a clone of the parent item with all the information from the child item.
        /// </summary>
        /// <remarks>
        /// FUTURE: It is unclear what this Whidbey code is for -- the callers already have a child item don't they?
        /// Can this be eliminated to avoid excess cloning?
        /// </remarks>
        internal static BuildItem CreateClonedParentedItem(BuildItem childItem, BuildItem parentItem)
        {
            BuildItem newItem = parentItem.Clone();
            newItem.SetEvaluatedItemSpecEscaped(childItem.EvaluatedItemSpec);
            newItem.SetFinalItemSpecEscaped(childItem.FinalItemSpecEscaped);

            // If this item was defined based on another item, grab that other
            // item's attributes.
            newItem.CloneVirtualMetadata();
            newItem.ImportVirtualMetadataFrom(childItem);

            // BUT if this item itself has attributes declared in the project file,
            // then these should clearly win.
            newItem.ImportVirtualMetadataFrom(parentItem);

            // Set up the parent/child relationship.  The "parent" is the actual item
            // tag as declared in the project file.  The "child" is the item that
            // it evaluated to.  For example, a parent <Blah Include="*.cs"/>
            // may evaluate to many children <Blah Include="a.cs"/>, b.cs, c.cs, etc.
            newItem.ParentPersistedItem = parentItem;
            return newItem;
        }
コード例 #3
0
ファイル: BuildItemTest.cs プロジェクト: GirlD/mono
		public void TestClone1 ()
		{
			item = new BuildItem ("name", "1;2;3");
			item.SetMetadata ("a", "b");

			BuildItem item2 = item.Clone ();

			Assert.AreEqual ("1;2;3", item2.FinalItemSpec, "A1");
			Assert.AreEqual ("1;2;3", item2.Include, "A2");
			Assert.AreEqual (String.Empty, item2.Exclude, "A3");
			Assert.AreEqual (String.Empty, item2.Condition, "A4");
			Assert.AreEqual (false, item2.IsImported, "A5");
			Assert.AreEqual ("name", item2.Name, "A6");
		}
コード例 #4
0
ファイル: BuildItem_Tests.cs プロジェクト: nikson/msbuild
        public void VirtualClone()
        {
            BuildItem item = new BuildItem("i", "i1");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("i", clone.Name);
            Assertion.AssertEquals("i1", clone.EvaluatedItemSpec);
            Assertion.AssertEquals("i1", clone.FinalItemSpec);
            Assertion.AssertEquals("i1", clone.FinalItemSpecEscaped);
        }