示例#1
0
            public void ImportOutputProperties()
            {
                BuildPropertyGroup pg = new BuildPropertyGroup();
                pg.SetProperty("foo", "fooval");
                pg.SetProperty(new BuildProperty("bar", "barval", PropertyType.EnvironmentProperty));
                pg.SetProperty(new BuildProperty("baz", "bazval", PropertyType.GlobalProperty));
                pg.SetProperty(new BuildProperty("caz", "cazval", PropertyType.ImportedProperty));
                pg.SetProperty(new BuildProperty("barb", "barbval", PropertyType.OutputProperty));

                BuildPropertyGroup pgo = new BuildPropertyGroup();
                pgo.SetProperty(new BuildProperty("foo", "fooout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("bar", "barout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("baz", "bazout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("caz", "cazout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("barb", "barbout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("gaz", "gazout", PropertyType.OutputProperty));

                pg.ImportProperties(pgo);

                Assertion.AssertEquals(6, pg.Count);
                Assertion.AssertEquals("fooout", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barout", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazout", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazout", pg["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pg["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pg["gaz"].FinalValueEscaped);

                pg.SetProperty(new BuildProperty("foo", "fooout2", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("gaz", "gazout2", PropertyType.OutputProperty));

                Assertion.AssertEquals("fooout2", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("gazout2", pg["gaz"].FinalValueEscaped);

                pg.RemoveProperty("baz");
                pg.RevertAllOutputProperties();

                Assertion.AssertEquals(3, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertNull(pg["baz"]);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
            }
示例#2
0
		public void TestRemoveProperty3 ()
		{
			BuildPropertyGroup bpg = new BuildPropertyGroup ();
			bpg.SetProperty ("a", "b");
			bpg.SetProperty ("c", "d");

			bpg.RemoveProperty ("value_not_in_group");
			bpg.RemoveProperty (new BuildProperty ("name", "value"));

			BuildProperty bp = bpg ["a"];

			bpg.RemoveProperty (bp);
		}
示例#3
0
		public void TestRemoveProperty1 ()
		{
			BuildPropertyGroup bpg = new BuildPropertyGroup ();
			bpg.RemoveProperty ((BuildProperty) null);
		}
示例#4
0
		public void TestRemoveProperty2 ()
		{
			BuildPropertyGroup bpg = new BuildPropertyGroup ();
			bpg.SetProperty ("a", "b");
			bpg.SetProperty ("c", "d");

			bpg.RemoveProperty ((string) null);
		}
        public void RemovePropertyByBuildPropertyWithNullProperty()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            BuildProperty property = null;

            group.RemoveProperty(property);
        }
示例#6
0
        public virtual int AddCfgsOfCfgName(string name, string cloneName, int fPrivate)
        {
            // First create the condition that represent the configuration we want to clone
            string condition = String.Format(CultureInfo.InvariantCulture, configString, cloneName).Trim();

            // Get all configs
            MSBuild.BuildPropertyGroupCollection configGroup   = this.project.BuildProject.PropertyGroups;
            MSBuild.BuildPropertyGroup           configToClone = null;

            if (cloneName != null)
            {
                // Find the configuration to clone
                foreach (MSBuild.BuildPropertyGroup currentConfig in configGroup)
                {
                    // Only care about conditional property groups
                    if (currentConfig.Condition == null || currentConfig.Condition.Length == 0)
                    {
                        continue;
                    }

                    // Skip if it isn't the group we want
                    if (String.Compare(currentConfig.Condition.Trim(), condition, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        continue;
                    }

                    configToClone = currentConfig;
                }
            }

            MSBuild.BuildPropertyGroup newConfig = null;
            if (configToClone != null)
            {
                // Clone the configuration settings
                newConfig = this.project.ClonePropertyGroup(configToClone);
                //Will be added later with the new values to the path
                newConfig.RemoveProperty("OutputPath");
            }
            else
            {
                // no source to clone from, lets just create a new empty config
                newConfig = this.project.BuildProject.AddNewPropertyGroup(false);
                // Get the list of property name, condition value from the config provider
                IList <KeyValuePair <KeyValuePair <string, string>, string> > propVals = this.NewConfigProperties;
                foreach (KeyValuePair <KeyValuePair <string, string>, string> data in propVals)
                {
                    KeyValuePair <string, string> propData = data.Key;
                    string value = data.Value;
                    MSBuild.BuildProperty newProperty = newConfig.AddNewProperty(propData.Key, value);
                    if (!String.IsNullOrEmpty(propData.Value))
                    {
                        newProperty.Condition = propData.Value;
                    }
                }
            }


            //add the output path
            string outputBasePath = this.ProjectMgr.OutputBaseRelativePath;

            if (outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                outputBasePath = Path.GetDirectoryName(outputBasePath);
            }
            newConfig.AddNewProperty("OutputPath", Path.Combine(outputBasePath, name) + Path.DirectorySeparatorChar.ToString());

            // Set the condition that will define the new configuration
            string newCondition = String.Format(CultureInfo.InvariantCulture, configString, name);

            newConfig.Condition = newCondition;

            NotifyOnCfgNameAdded(name);
            return(VSConstants.S_OK);
        }
        public void RemovePropertyByBuildPropertyOneOfSeveral()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            BuildProperty property = GetSpecificBuildPropertyOutOfBuildPropertyGroup(group, "n2");

            group.RemoveProperty(property);

            Assertion.AssertEquals(2, group.Count);
            Assertion.AssertEquals("v1", group["n1"].Value);
            Assertion.AssertNull(group["n2"]);
            Assertion.AssertEquals("v3", group["n3"].Value);
        }
        public void RemovePropertyByBuildPropertyAllOfSeveral()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            BuildProperty[] property = new BuildProperty[] 
                {
                    GetSpecificBuildPropertyOutOfBuildPropertyGroup(group, "n1"),
                    GetSpecificBuildPropertyOutOfBuildPropertyGroup(group, "n2"),
                    GetSpecificBuildPropertyOutOfBuildPropertyGroup(group, "n3")
                };

            group.RemoveProperty(property[0]);
            group.RemoveProperty(property[1]);
            group.RemoveProperty(property[2]);

            Assertion.AssertEquals(0, group.Count);
            Assertion.AssertNull(group["n1"]);
            Assertion.AssertNull(group["n2"]);
            Assertion.AssertNull(group["n3"]);
        }
        public void RemovePropertyByNameThatIsAnEmptyString()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n", "v");

            group.RemoveProperty(String.Empty);

            Assertion.AssertEquals(1, group.Count);
        }
示例#10
0
        public void RemovePropertyByNameWhenNameIsNull()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            string name = null;

            group.RemoveProperty(name);
        }
示例#11
0
        public void RemovePropertyByNameOfANonExistingProperty()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n", "v");

            group.RemoveProperty("not");

            Assertion.AssertEquals(1, group.Count);
        }
示例#12
0
        public void RemovePropertyByNameAllOfSeveral()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            group.RemoveProperty("n1");
            group.RemoveProperty("n2");
            group.RemoveProperty("n3");

            Assertion.AssertEquals(0, group.Count);
            Assertion.AssertNull(group["n1"]);
            Assertion.AssertNull(group["n2"]);
            Assertion.AssertNull(group["n3"]);
        }
示例#13
0
        public void CountAfterRemovingAllProperties()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            group.RemoveProperty("n1");
            group.RemoveProperty("n2");
            group.RemoveProperty("n3");

            Assertion.AssertEquals(0, group.Count);
        }