Example #1
0
        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"));
        }
Example #2
0
        public void GetMetadataBeforeEvaluate()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);
            library.GetDefaultMetadataValue("ccompile", "defines");
        }
Example #3
0
        public void TwoGroups()
        {
            XmlElement group1 = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item1  = XmlTestUtilities.AddChildElement(group1, "CCompile");
            XmlElement meta1  = XmlTestUtilities.AddChildElementWithInnerText(item1, "Defines", "DEBUG");
            XmlElement group2 = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item2  = XmlTestUtilities.AddChildElement(group2, "CppCompile");
            XmlElement meta2  = XmlTestUtilities.AddChildElementWithInnerText(item2, "WarningLevel", "W4");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group1);
            library.Add(group2);
            library.Evaluate(null);

            Assertion.AssertEquals("DEBUG", library.GetDefaultMetadataValue("ccompile", "defines"));
            Assertion.AssertEquals("W4", library.GetDefaultMetadataValue("CppCompile", "warninglevel"));
            Assertion.AssertEquals(null, library.GetDefaultMetadataValue("CppCompile", "defines"));
        }
Example #4
0
        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);
        }
Example #5
0
        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"));
        }
Example #6
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);
        }