public void Basic()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta = XmlTestUtilities.AddChildElementWithInnerText(item, "Defines", "DEBUG");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(group);
            library.Evaluate(null);

            Assertion.AssertEquals("DEBUG", library.GetDefaultMetadataValue("ccompile", "defines"));
        }        
        public void SameGroupTwoChildrenSameItemTypeDifferentMetadata()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item1 = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta1 = XmlTestUtilities.AddChildElementWithInnerText(item1, "Defines", "DEBUG");
            XmlElement item2 = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta2 = XmlTestUtilities.AddChildElementWithInnerText(item1, "WarningLevel", "W4");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(group);
            library.Evaluate(null);

            Assertion.AssertEquals("DEBUG", library.GetDefaultMetadataValue("ccompile", "defines"));
            Assertion.AssertEquals("W4", library.GetDefaultMetadataValue("ccompile", "warninglevel"));
        }
        private static ItemDefinitionLibrary NewAndEvaluateItemDefinitionLibraryXml(XmlElement group)
        {
            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(group);

            BuildPropertyGroup properties = new BuildPropertyGroup();
            properties.SetProperty("p1", "v1");            
            library.Evaluate(properties);

            return library;
        }
Esempio n. 4
0
 private static BuildItem CreateBuildItemFromXmlDocument(XmlDocument doc)
 {
     ItemDefinitionLibrary itemDefinitionLibrary = new ItemDefinitionLibrary(new Project());
     itemDefinitionLibrary.Evaluate(new BuildPropertyGroup());
     BuildItem item = new BuildItem((XmlElement)doc.FirstChild, false, itemDefinitionLibrary);
     return item;
 }
Esempio n. 5
0
        internal static BuildItem GetXmlBackedItemWithDefinitionLibrary()
        {
            string content = @"<i  xmlns='http://schemas.microsoft.com/developer/msbuild/2003' Include='i1'/>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);

            XmlElement groupElement = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement itemElement = XmlTestUtilities.AddChildElement(groupElement, "i");
            XmlElement metaElement = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "m", "m1");
            XmlElement metaElement2 = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "o", "o1");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(groupElement);
            library.Evaluate(null);

            BuildItem item = new BuildItem((XmlElement)doc.FirstChild, false, library);
            item.SetMetadata("n", "n1");
            return item;
        }
        public void PropertyInMetadataValue()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta = XmlTestUtilities.AddChildElementWithInnerText(item, "Defines", "$(p1)");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());
            library.Add(group);
            BuildPropertyGroup pg1 = new BuildPropertyGroup();
            pg1.SetProperty("p1", "v1");
            library.Evaluate(pg1);

            Assertion.AssertEquals("v1", library.GetDefaultMetadataValue("ccompile", "defines"));

            // Change the original property group -- should not affect the metadata value which was
            // already evaluated
            pg1.SetProperty("p1", "v1b");

            Assertion.AssertEquals("v1", library.GetDefaultMetadataValue("ccompile", "defines"));

            // Reevaluate with another property value
            BuildPropertyGroup pg2 = new BuildPropertyGroup();
            pg2.SetProperty("p1", "v2");
            library.Evaluate(pg2);

            Assertion.AssertEquals("v2", library.GetDefaultMetadataValue("ccompile", "defines"));
        }
Esempio n. 7
0
 internal static ItemDefinitionLibrary CreateEmptyEvaluatedItemDefinitionLibrary()
 {
     ItemDefinitionLibrary itemDefinitionLibrary = new ItemDefinitionLibrary(new Project());
     itemDefinitionLibrary.Evaluate(new BuildPropertyGroup());
     return itemDefinitionLibrary;
 }