public static FindProperty ( Properties properties, string propertyName ) : System.Property | ||
properties | Properties | |
propertyName | string | |
return | System.Property |
public IEnumerable <RuleSetDeclaration> GetProjectRuleSetsDeclarations(Project project) { if (project == null) { throw new ArgumentNullException(nameof(project)); } bool found = false; foreach (Property ruleSetProperty in VsShellUtils.EnumerateProjectProperties(project, Constants.CodeAnalysisRuleSetPropertyKey).Where(p => p != null)) { found = true; string ruleSetDirectoriesValue = VsShellUtils.FindProperty(ruleSetProperty.Collection, Constants.CodeAnalysisRuleSetDirectoriesPropertyKey)?.Value as string; string[] ruleSetDirectories = ruleSetDirectoriesValue?.Split(new[] { RuleSetDirectoriesValueSpliter }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0]; string ruleSetValue = ruleSetProperty.Value as string; string activationContext = TryGetPropertyConfiguration(ruleSetProperty)?.ConfigurationName ?? string.Empty; yield return(new RuleSetDeclaration(project, ruleSetProperty, ruleSetValue, activationContext, ruleSetDirectories)); } if (!found) { VsShellUtils.WriteToSonarLintOutputPane(this.serviceProvider, Strings.CouldNotFindCodeAnalysisRuleSetPropertyOnProject, project.UniqueName); } }
public void AddFileToProject(Project project, string file, string itemType) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (string.IsNullOrWhiteSpace(file)) { throw new ArgumentNullException(nameof(file)); } if (string.IsNullOrWhiteSpace(itemType)) { throw new ArgumentNullException(nameof(itemType)); } if (!this.IsFileInProject(project, file)) { ProjectItem item = project.ProjectItems.AddFromFile(file); Property itemTypeProperty = VsShellUtils.FindProperty(item.Properties, Constants.ItemTypePropertyKey); if (itemTypeProperty != null) { itemTypeProperty.Value = itemType; } else { Debug.Fail("Failed to set the ItemType of the project item"); } } }