public void AddResult(IScanResult result, string projectFile) { string fullPath = result.FilePath; if (!Path.IsPathRooted(fullPath)) { fullPath = Utilities.AbsolutePathFromRelative(fullPath, Path.GetDirectoryName(projectFile)); } if (result.Scanned) { foreach (IScanHit hit in result.Results) { if (!string.IsNullOrEmpty(hit.Warning)) { // See if we've warned about this term before; if so, don't warn again. if (null == _termsWithDuplicateWarning.Find( item => string.Compare(item, hit.Term.Text, StringComparison.OrdinalIgnoreCase) == 0)) { _tasks.Add(new Task(hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Warning, string.Empty, string.Empty, -1, -1, string.Empty, string.Empty, this, _serviceProvider, _currentProject)); _termsWithDuplicateWarning.Add(hit.Term.Text); } } _tasks.Add(new Task(hit.Term.Text, hit.Term.Severity, hit.Term.Class, hit.Term.Comment, hit.Term.RecommendedTerm, fullPath, hit.Line, hit.Column, projectFile, hit.LineText, this, _serviceProvider, _currentProject)); } } else { _tasks.Add(new Task(string.Empty, 1, string.Empty, string.Format(CultureInfo.CurrentUICulture, Resources.FileNotScannedError, fullPath), string.Empty, fullPath, -1, -1, projectFile, string.Empty, this, _serviceProvider, _currentProject)); } Refresh(); }
/// <summary> /// Enumerates all items in the project except those in the "Reference" group. /// </summary> /// <param name="project">The project from which to retrieve the items.</param> /// <returns>A list of item "Include" values. For items that specify files, these will be the file names.</returns> /// <exception cref="System.ArgumentNullException">Thrown if <c>project</c> is null.</exception> public IEnumerable <string> AllItemsInProject(IVsProject project) { if (project == null) { throw new ArgumentNullException("project"); } string projectDir = Path.GetDirectoryName(ProjectUtilities.GetProjectFilePath(project)); IVsHierarchy hierarchy = project as IVsHierarchy; return (ChildrenOf(hierarchy, VSConstants.VSITEMID.Root) .Select( id => { string name = null; project.GetMkDocument((uint)id, out name); if (name != null && name.Length > 0 && !Path.IsPathRooted(name)) { name = Utilities.AbsolutePathFromRelative(name, projectDir); } return name; }) .Where(File.Exists)); }
/// <summary> /// Enumerates all items in the project except those in the "Reference" group. /// </summary> /// <param name="project">The project from which to retrieve the items.</param> /// <returns>A list of item "Include" values. For items that specify files, these will be the file names.</returns> /// <exception cref="System.ArgumentNullException">Thrown if <c>project</c> is null.</exception> public ICollection <string> AllItemsInProject(IVsProject project) { if (project == null) { throw new ArgumentNullException("project"); } string projectDir = Path.GetDirectoryName(ProjectUtilities.GetProjectFilePath(project)); IVsHierarchy hierarchy = project as IVsHierarchy; List <string> allNames = ChildrenOf(hierarchy, HierarchyConstants.VSITEMID_ROOT).ConvertAll <string>( delegate(uint id) { string name = null; project.GetMkDocument(id, out name); if (name != null && name.Length > 0 && !Path.IsPathRooted(name)) { name = Utilities.AbsolutePathFromRelative(name, projectDir); } return(name); }); allNames.RemoveAll( delegate(string name) { return(!File.Exists(name)); }); return(allNames); }
/// <summary> /// Creates an IgnoreInstance object from a serialized representation. /// </summary> /// <param name="serialization">The file, term, column, and line text, separated by commas.</param> /// <param name="projectFolderForDerelativization">The project folder used to convert the serialized relative file path to a rooted file path.</param> /// <exception cref="System.ArgumentNullException">Thrown if <c>serialization</c> or <c>projectFolderForDerelativization</c> is null.</exception> /// <exception cref="System.ArgumentException">Thrown if <c>serialization</c> does not contain four comma-delimited fields; if any of the string fields is empty; if the column field cannot be parsed; or if the column field is less than zero or greater than or equal to the line text length.</exception> public IgnoreInstance(string serialization, string projectFolderForDerelativization) { if (serialization == null) { throw new ArgumentNullException("serialization"); } IList <string> fields = Utilities.ParseEscaped(serialization, ','); if (fields.Count != 4) { throw new ArgumentException(Resources.InvalidSerializationStringForIgnoreInstance); } if (fields[0].Length == 0) { throw new ArgumentException(Resources.EmptyFileField); } int column; if (Int32.TryParse(fields[2], out column)) { Init(Utilities.AbsolutePathFromRelative(fields[0], projectFolderForDerelativization), fields[3], fields[1], column); } else { throw new ArgumentException(Resources.BadColumnField, "serialization"); } }
private void ReadConfigFromProject() { string projectFolder = Path.GetDirectoryName(ProjectUtilities.GetProjectFilePath(_project)); Project dteProject = GetDTEProject(_project); if (dteProject.Globals.get_VariableExists(_termTablesName)) { string termTables = (string)dteProject.Globals[_termTablesName]; foreach (string table in termTables.Split(';')) { if (table != null && table.Length > 0) { if (Path.IsPathRooted(table)) { _termTableFiles.Add(table); } else { _termTableFiles.Add(Utilities.AbsolutePathFromRelative(table, projectFolder)); } } } } if (dteProject.Globals.get_VariableExists(_ignoreInstancesName)) { string ignoreInstances = (string)dteProject.Globals[_ignoreInstancesName]; _ignoreInstances.AddRange(BuildTask.Factory.DeserializeIgnoreInstances(ignoreInstances, projectFolder)); } }
private void ReadConfigFromBuildTask() { string projectFolder = Path.GetDirectoryName(ProjectUtilities.GetProjectFilePath(_project)); _ignoreInstances.AddRange(BuildTask.Factory.DeserializeIgnoreInstances(_buildTask.GetParameter("IgnoreInstances"), projectFolder)); foreach (string termTable in _buildTask.GetParameter("TermTables").Split(';')) { if (termTable != null && termTable.Length > 0) { if (Path.IsPathRooted(termTable)) { _termTableFiles.Add(termTable); } else { _termTableFiles.Add(Utilities.AbsolutePathFromRelative(termTable, projectFolder)); } } } }