// ========================================================================================= // Methods // ========================================================================================= /// <summary> /// Gets a project property. /// </summary> /// <param name="propertyName">The name of the property to get.</param> /// <returns> /// Value of the property, or null if the property is unset or inconsistent across configurations. /// </returns> public override string GetProperty(string propertyName) { if (propertyName == WixProjectFileConstants.DefineConstants) { string unifiedValue = null; ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); for (int i = 0; i < this.ProjectConfigs.Count; i++) { ProjectConfig config = this.ProjectConfigs[i]; string constantsString = property.GetValue(false, new ProjectConfig[] { config }); if (constantsString != null) { List<string> constants = new List<string>(constantsString.Split(';')); WixHelperMethods.RemoveAllMatch(constants, DebugDefine); constantsString = String.Join(";", constants.ToArray()); } if (i == 0) { unifiedValue = constantsString; } else if (constantsString != unifiedValue) { unifiedValue = null; } } return unifiedValue; } else if (propertyName == WixProjectFileConstants.WarningLevel) { CheckState pedantic = this.GetPropertyCheckState(WixProjectFileConstants.Pedantic); CheckState suppressAllWarnings = this.GetPropertyCheckState(WixProjectFileConstants.SuppressAllWarnings); if (pedantic == CheckState.Indeterminate || suppressAllWarnings == CheckState.Indeterminate || (pedantic == CheckState.Checked && suppressAllWarnings == CheckState.Checked)) { return null; } else if (pedantic == CheckState.Checked) { return ((int)WixWarningLevel.Pedantic).ToString(CultureInfo.InvariantCulture); } else if (suppressAllWarnings == CheckState.Checked) { return ((int)WixWarningLevel.None).ToString(CultureInfo.InvariantCulture); } else { return ((int)WixWarningLevel.Normal).ToString(CultureInfo.InvariantCulture); } } else { return base.GetProperty(propertyName); } }
public void InvalidSetValueBuiltInProperty() { Assert.Throws <InvalidOperationException>(() => { Project project = new Project(); ProjectProperty property = project.GetProperty("MSBuildProjectDirectory"); property.UnevaluatedValue = "v"; } ); }
public void SetValueSameValue() { Project project = new Project(); ProjectProperty property = project.SetProperty("p", "v1"); project.ReevaluateIfNecessary(); property.UnevaluatedValue = "v1"; Assert.False(project.IsDirty); }
public void PropertySetViaProperty() { Assert.Throws <InvalidOperationException>(() => { Project project = GetProject(); ProjectProperty property = GetProperty(project); // This should throw property.UnevaluatedValue = NewValue; } ); }
public void PropertyRemove() { Assert.Throws <InvalidOperationException>(() => { Project project = GetProject(); ProjectProperty property = GetProperty(project); // This should throw project.RemoveProperty(property); } ); }
private bool IsScriptSharpProject(Project project) { ProjectProperty scriptSharpProperty = project.GetProperty("ScriptSharp"); if ((scriptSharpProperty != null) && scriptSharpProperty.EvaluatedValue.Equals("true", StringComparison.OrdinalIgnoreCase)) { return(true); } return(false); }
public void UpdateProjectNumbers_NullLand() { // Arrange var projectProperty = new ProjectProperty() { PropertyType = PropertyTypes.Land, }; // Act // Assert Assert.Throws <InvalidOperationException>(() => projectProperty.UpdateProjectNumbers("3")); }
public async Task <IActionResult> Create(ProjectProperty projectProperty) { if (ModelState.IsValid) { projectProperty.OwnerProject = _context.Projects.Find(projectProperty.OwnerProject.ProjectId); _context.Add(projectProperty); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(projectProperty)); }
public void RemoveProjectNumber_NullBuilding() { // Arrange var projectProperty = new ProjectProperty() { PropertyType = PropertyTypes.Building, }; // Act // Assert Assert.Throws <InvalidOperationException>(() => projectProperty.RemoveProjectNumber("3")); }
private string GetValueOrStringEmpty(params string[] keys) { foreach (string key in keys) { ProjectProperty value = Properties.FirstOrDefault(x => x.Name == key); if (value != null && !string.IsNullOrEmpty(value.EvaluatedValue)) { return(value.EvaluatedValue); } } return(string.Empty); }
private void VerifyPropertyFromImplicitImport(Project project, string propertyName, string expectedContainingProjectPath, string expectedValue) { ProjectProperty property = project.GetProperty(propertyName); Assert.NotNull(property?.Xml?.ContainingProject?.FullPath); Assert.Equal(expectedContainingProjectPath, property.Xml.ContainingProject.FullPath); Assert.True(property.IsImported); Assert.Equal(expectedValue, property.EvaluatedValue); }
public IProjectProperty AddProperty(string propertyName) { var propertyNode = new XElement(Xmlns.GetName(propertyName)); Node.Add(propertyNode); var property = new ProjectProperty(ProjectFile, this, propertyNode, propertyNode.Name.LocalName); Items.Add(property); return(property); }
/// <summary> /// Sets a project property. /// </summary> /// <param name="propertyName">Name of the property to set.</param> /// <param name="value">Value of the property.</param> public virtual void SetProperty(string propertyName, string value) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName); string oldValue = this.GetProperty(propertyName); if (!String.Equals(value, oldValue, StringComparison.Ordinal)) { property.SetValue(value, this.projectConfigs); this.IsDirty = true; } }
public void SetPropertyWithPropertyExpression() { Project project = new Project(); project.SetProperty("p0", "v0"); ProjectProperty property = project.SetProperty("p1", "v1"); property.UnevaluatedValue = "$(p0)"; Assert.AreEqual("v0", project.GetPropertyValue("p1")); Assert.AreEqual("v0", property.EvaluatedValue); Assert.AreEqual("$(p0)", property.UnevaluatedValue); }
public void SetValue_Escaped() { Project project = new Project(); ProjectProperty property = project.SetProperty("p", "v1"); project.ReevaluateIfNecessary(); property.UnevaluatedValue = "v%282%29"; Assert.Equal("v(2)", property.EvaluatedValue); Assert.Equal("v%282%29", property.UnevaluatedValue); Assert.True(project.IsDirty); }
public void SetPropertyWithItemAndMetadataExpression() { Project project = new Project(); project.SetProperty("p0", "v0"); ProjectProperty property = project.SetProperty("p1", "v1"); property.UnevaluatedValue = "@(i)-%(m)"; Assert.AreEqual("@(i)-%(m)", project.GetPropertyValue("p1")); Assert.AreEqual("@(i)-%(m)", property.EvaluatedValue); Assert.AreEqual("@(i)-%(m)", property.UnevaluatedValue); }
public void SetValue() { Project project = new Project(); ProjectProperty property = project.SetProperty("p", "v1"); project.ReevaluateIfNecessary(); property.UnevaluatedValue = "v2"; Assert.AreEqual("v2", property.EvaluatedValue); Assert.AreEqual("v2", property.UnevaluatedValue); Assert.AreEqual(true, project.IsDirty); }
private void addCategoryAndPropertyToProject(Project prj, ProjectCategory newCat, string propName, string propDesc, string propValue) { ///add to pipingProject, the PnPProject under piping.dcf bool added = prj.AddProjectCategory(newCat); if (added) { ProjectProperty pp = new ProjectProperty(newCat.Name, propName, propDesc, propDesc); prj.AddProjectProperty(pp); ///above created a "DBInfo_DBInstance" column in PnPProject table under piping.dcf prj.SetProjectPropertyValue(pp, propValue); } }
private static bool IsGlobalProperty(ProjectProperty projectProperty) { // This property isn't available on xbuild (mono) var property = typeof(ProjectProperty).GetProperty("IsGlobalProperty", BindingFlags.Public | BindingFlags.Instance); if(property != null) { return (bool)property.GetValue(projectProperty, null); } // REVIEW: Maybe there's something better we can do on mono // Just return false if the property isn't there return false; }
public ProjectView(SolutionView sol, ProjectInSolution sp) { solutionProject = sp; solution = sol; ProjectRootElement projectRootElt = ProjectRootElement.Open(solutionProject.AbsolutePath); project = new Project(solutionProject.AbsolutePath, null, null, sol.IDE.projectCollection); string [] props = { "EnableDefaultItems", "EnableDefaultCompileItems", "EnableDefaultNoneItems", "EnableDefaultEmbeddedResourceItems" }; foreach (string pr in props) { ProjectProperty pp = project.AllEvaluatedProperties.Where(ep => ep.Name == pr).FirstOrDefault(); if (pp == null) { project.SetGlobalProperty(pr, "true"); } } //ide.projectCollection.SetGlobalProperty ("DefaultItemExcludes", "obj/**/*;bin/**/*"); project.ReevaluateIfNecessary(); cmdSave = new Crow.Command(new Action(() => Save())) { Caption = "Save", Icon = new SvgPicture("#Icons.save.svg"), CanExecute = true }; cmdOpen = new Crow.Command(new Action(() => populateTreeNodes())) { Caption = "Open", Icon = new SvgPicture("#Icons.open.svg"), CanExecute = false }; cmdCompile = new Crow.Command(new Action(() => Compile("Restore"))) { Caption = "Restore", }; cmdSetAsStartProj = new Crow.Command(new Action(() => setAsStartupProject())) { Caption = "Set as Startup Project" }; cmdNewFile = new Crow.Command(new Action(() => AddNewFile())) { Caption = "Add New File", Icon = new SvgPicture("#Icons.blank-file.svg"), CanExecute = true }; Commands = new ObservableList <Crow.Command> (new Crow.Command [] { cmdOpen, cmdSave, cmdSetAsStartProj, cmdCompile, cmdNewFile }); populateTreeNodes(); }
public void RemoveAllConfigs(ReferencedValues val) { //foreach(MSBProject proj in val.Projects) Parallel.ForEach(val.Projects, proj => { //Debug.Print("Project: {0}", proj.FullPath); // Iterate through all global properties and set the value IDictionary <string, List <string> > conProps = proj.ConditionedProperties; List <String> configs = conProps[CONFIG]; List <String> platforms = conProps[PLATFORM]; var previousConfig = proj.GlobalProperties[CONFIG]; var previousPlatform = proj.GlobalProperties[PLATFORM]; foreach (var config in configs) { foreach (var platform in platforms) { proj.SetGlobalProperty(CONFIG, config); proj.SetGlobalProperty(PLATFORM, platform); proj.ReevaluateIfNecessary(); ProjectProperty p = proj.GetProperty(this.Name); if (p != null && (!p.IsImported) && (!p.IsEnvironmentProperty) && (!p.IsGlobalProperty) && (!p.IsReservedProperty)) { //Debug.Print("\tRemoving {0} for {1}|{2}", this.Name, config, platform); bool removed = proj.RemoveProperty(p); Debug.Assert(removed); proj.MarkDirty(); proj.ReevaluateIfNecessary(); } } } proj.SetGlobalProperty(CONFIG, previousConfig); proj.SetGlobalProperty(PLATFORM, previousPlatform); proj.ReevaluateIfNecessary(); proj.MarkDirty(); }); RemoveProjects(val.Projects); string key = val.EvaluatedValue; if (_PropertyValues.ContainsKey(key)) { _PropertyValues.Remove(key); } OnPropertyChanged("PropertyValues"); }
public void RemoveProjectNumber_Subdivision() { // Arrange var projectProperty = new ProjectProperty() { PropertyType = PropertyTypes.Subdivision, }; // Act var result = projectProperty.RemoveProjectNumber("5"); // Assert result.Should().BeNull(); }
/// <summary> /// Gets a property value as a tri-state checkbox value. /// </summary> /// <param name="propertyName">Name of the property to get.</param> /// <returns>Boolean check state, or Indeterminate if the property is /// inconsistent across configurations.</returns> public virtual CheckState GetPropertyCheckState(string propertyName) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName); bool? value = property.GetBooleanValue(this.projectConfigs); if (!value.HasValue) { return(CheckState.Indeterminate); } else { return(value.Value ? CheckState.Checked : CheckState.Unchecked); } }
public IProjectProperty AddProperty(string itemGroupName, string propertyName) { var propertyNode = new XElement(Xmlns.GetName(propertyName)); var groupNode = Node.Elements().FirstOrDefault(n => n.Name.LocalName == itemGroupName) ?? Node.AddElement(new XElement(Xmlns.GetName(itemGroupName))); groupNode.AddElement(propertyNode); var property = new ProjectProperty(ProjectFile, this, propertyNode, groupNode.Name.LocalName + "." + propertyNode.Name.LocalName); Items.Add(property); return(property); }
public ProjectProperty <T> GetProperty <T>(string propertyName, T defaultValue, PropertyStorageLocations defaultLocation = PropertyStorageLocations.Base) { IProjectProperty existingProperty; if (projectProperties.TryGetValue(propertyName, out existingProperty)) { return((ProjectProperty <T>)existingProperty); } ProjectProperty <T> newProperty = new ProjectProperty <T>(this, propertyName, defaultValue, defaultLocation, true); projectProperties.Add(propertyName, newProperty); return(newProperty); }
public string GetPropertyName(string propertyName) { ProjectProperty prop = LoadedProj.GetProperty(propertyName); UtilLogger.LogInfo(MessageImportance.Low, "Retrieved Property - '{0}'", prop?.Name); if (prop == null) { return(string.Empty); } else { return(prop.Name); } }
public MSBuildProperties(ProjectProperty property) { this.Name = property.Name; this.InitialValue = property.UnevaluatedValue; this.EvaluatedValue = property.EvaluatedValue; this.IsEnvironmentProperty = property.IsEnvironmentProperty; this.IsGlobalProperty = property.IsGlobalProperty; this.IsImported = property.IsImported; this.IsReservedProperty = property.IsReservedProperty; if (property.Xml != null) { this.Condition = property.Xml.Condition; this.ContainingProject = property.Xml.ContainingProject.FullPath; } }
public void SetValueEnvironmentProperty() { Project project = new Project(); ProjectProperty property = project.GetProperty("Username"); property.UnevaluatedValue = "v"; Assert.AreEqual("v", property.EvaluatedValue); Assert.AreEqual("v", property.UnevaluatedValue); project.ReevaluateIfNecessary(); property = project.GetProperty("Username"); Assert.AreEqual("v", property.UnevaluatedValue); }
dynamic IPropertyProvider.GetPropertyValue(string propertyName) { string value; if (!_properties.TryGetValue(propertyName, out value)) { ProjectProperty property = _project.GetProperty(propertyName); if (property != null) { value = property.EvaluatedValue; } } return(value); }
public void UpdateProjectNumbers_Land_NoProjects() { // Arrange var parcel = new Parcel(); var projectProperty = new ProjectProperty() { PropertyType = PropertyTypes.Land, Parcel = parcel }; // Act var result = projectProperty.UpdateProjectNumbers("3"); // Assert result.ProjectNumbers.Should().Be("[\"3\"]"); }
public void SetValueEnvironmentProperty() { Project project = new Project(); string varName = NativeMethodsShared.IsWindows ? "username" : "USER"; ProjectProperty property = project.GetProperty(varName); property.UnevaluatedValue = "v"; Assert.Equal("v", property.EvaluatedValue); Assert.Equal("v", property.UnevaluatedValue); project.ReevaluateIfNecessary(); property = project.GetProperty(varName); Assert.Equal("v", property.UnevaluatedValue); }
/// <summary> /// Gets a property value as a tri-state checkbox value. /// </summary> /// <param name="propertyName">Name of the property to get.</param> /// <returns>Boolean check state, or Indeterminate if the property is /// inconsistent across configurations.</returns> public virtual CheckState GetPropertyCheckState(string propertyName) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName); bool? value = property.GetBooleanValue(this.projectConfigs); if (!value.HasValue) { return CheckState.Indeterminate; } else { return value.Value ? CheckState.Checked : CheckState.Unchecked; } }
// ========================================================================================= // Public Methods // ========================================================================================= /// <summary> /// Gets a project property. /// </summary> /// <param name="propertyName">The name of the property to get.</param> /// <returns> /// Value of the property, or null if the property is unset or inconsistent across configurations. /// </returns> public virtual string GetProperty(string propertyName) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, propertyName); return property.GetValue(false, this.projectConfigs); }
/// <summary> /// Gets a property value as a tri-state checkbox value. /// </summary> /// <param name="propertyName">Name of the property to get.</param> /// <returns>Boolean check state, or Indeterminate if the property is /// inconsistent across configurations.</returns> public override CheckState GetPropertyCheckState(string propertyName) { if (propertyName == WixProjectFileConstants.DefineDebugConstant) { CheckState unifiedCheckState = CheckState.Indeterminate; ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); for (int i = 0; i < this.ProjectConfigs.Count; i++) { ProjectConfig config = this.ProjectConfigs[i]; CheckState checkState = CheckState.Unchecked; string constantsString = property.GetValue(false, new ProjectConfig[] { config }); if (constantsString != null) { List<string> constants = new List<string>(constantsString.Split(';')); checkState = constants.Contains(DebugDefine) ? CheckState.Checked : CheckState.Unchecked; } if (i == 0) { unifiedCheckState = checkState; } else if (checkState != unifiedCheckState) { unifiedCheckState = CheckState.Indeterminate; } } return unifiedCheckState; } else { return base.GetPropertyCheckState(propertyName); } }
public IProjectProperty AddProperty(string propertyName) { var node = new XElement(_xmlns.GetName(propertyName)); var lastNode = _propertyGroupNode.LastNode; if (lastNode?.NodeType == XmlNodeType.Text) { var lastDelimiter = lastNode.PreviousNode?.PreviousNode as XText; var whiteSpace = new XText(lastDelimiter?.Value ?? "\n "); lastNode.AddBeforeSelf(whiteSpace, node); } else { _propertyGroupNode.Add(node); } var property = new ProjectProperty(_projectFile, node); _properties.Add(property); return property; }
void LoadPropertyGroup(XmlElement propertyGroupElement) { string configuration = propertyGroupElement.GetAttribute("configuration"); string platform = propertyGroupElement.GetAttribute("platform"); PropertyStorageLocations storageLocation; if (string.IsNullOrEmpty(configuration) && string.IsNullOrEmpty(platform)) { storageLocation = PropertyStorageLocations.Base; } else { storageLocation = 0; if (!string.IsNullOrEmpty(configuration)) storageLocation |= PropertyStorageLocations.ConfigurationSpecific; if (!string.IsNullOrEmpty(platform)) storageLocation |= PropertyStorageLocations.PlatformSpecific; } if (string.Equals(propertyGroupElement.GetAttribute("userFile"), "true", StringComparison.OrdinalIgnoreCase)) { storageLocation |= PropertyStorageLocations.UserFile; } foreach (XmlElement propertyElement in ChildElements(propertyGroupElement)) { ProjectProperty p = new ProjectProperty(propertyElement.Name, propertyElement.InnerText, configuration, platform, storageLocation); if (string.Equals(propertyGroupElement.GetAttribute("escapeValue"), "false", StringComparison.OrdinalIgnoreCase)) { p.ValueIsLiteral = false; } else { p.ValueIsLiteral = true; } projectProperties.Add(p); } }
public static Property FindProperty(this Project project,ProjectProperty projectProperty) { return project.Properties.Cast<Property>().Where(property => property.Name == projectProperty.ToString()).Single(); }
/// <summary> /// Sets a project property. /// </summary> /// <param name="propertyName">Name of the property to set.</param> /// <param name="value">Value of the property.</param> public override void SetProperty(string propertyName, string value) { if (propertyName == WixProjectFileConstants.DefineConstants) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); foreach (ProjectConfig config in this.ProjectConfigs) { string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config }); if (existingConstantsString == null) { existingConstantsString = String.Empty; } List<string> existingConstants = new List<string>(existingConstantsString.Split(';')); string constantsString = value.Trim(); List<string> constants = new List<string>(constantsString.Split(';')); if (WixHelperMethods.RemoveAllMatch(constants, DebugDefine) > 0 || existingConstants.Contains(DebugDefine)) { constants.Insert(0, DebugDefine); } constantsString = String.Join(";", constants.ToArray()); if (constantsString != existingConstantsString) { property.SetValue(constantsString, new ProjectConfig[] { config }); this.IsDirty = true; } } } else if (propertyName == WixProjectFileConstants.DefineDebugConstant) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); foreach (ProjectConfig config in this.ProjectConfigs) { string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config }); if (existingConstantsString == null) { existingConstantsString = String.Empty; } List<string> constants = new List<string>(existingConstantsString.Split(';')); WixHelperMethods.RemoveAllMatch(constants, DebugDefine); if (value == Boolean.TrueString) { constants.Insert(0, DebugDefine); } string constantsString = String.Join(";", constants.ToArray()); if (constantsString != existingConstantsString) { property.SetValue(constantsString, new ProjectConfig[] { config }); this.IsDirty = true; } } } else if (propertyName == WixProjectFileConstants.WarningLevel) { WixWarningLevel warningLevel = (WixWarningLevel)Int32.Parse(value, CultureInfo.InvariantCulture); if (warningLevel == WixWarningLevel.None) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.TrueString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString); } else if (warningLevel == WixWarningLevel.Normal) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString); } else if (warningLevel == WixWarningLevel.Pedantic) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.TrueString); } } else { base.SetProperty(propertyName, value); } }