Created
July 26, 2012 23:59
-
-
Save DinisCruz/3185313 to your computer and use it in GitHub Desktop.
VisualStudio VSIX: Adding an item to the ErrorList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vsixPackage = O2_FluentSharp_VSIXPackage.vsixPackage; // this is a reference to an Package object | |
var ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution)); | |
var dte = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE)); | |
var errorListProvider = new ErrorListProvider(vsixPackage); | |
var errorText = "this is a test item"; | |
var errorCategory = TaskErrorCategory.Error; | |
//Get first project details | |
var proj = dte.Solution.Projects.Item(1); | |
var projectUniqueName = proj.FileName; | |
var firstFileInProject = proj.ProjectItems.Item(1).FileNames[0]; | |
//Get first project IVsHierarchy item (needed to link the task with a project) | |
IVsHierarchy hierarchyItem; | |
ivsSolution.GetProjectOfUniqueName(projectUniqueName, out hierarchyItem); | |
var newError = new ErrorTask() | |
{ | |
ErrorCategory = errorCategory, | |
Category = TaskCategory.BuildCompile, | |
Text = errorText, | |
Document = firstFileInProject, | |
Line = 2, | |
Column = 6, | |
HierarchyItem = hierarchyItem | |
}; | |
newError.Navigate += (sender,e)=> | |
{ | |
//there are two Bugs in the errorListProvider.Navigate method: | |
// Line number needs adjusting | |
// Column is not shown | |
newError.Line++; | |
errorListProvider.Navigate(newError, EnvDTE.Constants.vsViewKindCode.guid()); | |
newError.Line--; | |
}; | |
errorListProvider.Tasks.Clear(); // clear previously created | |
errorListProvider.Tasks.Add(newError); // add item | |
errorListProvider.Show(); // make sure it is visible | |
return errorListProvider; | |
//using Microsoft.VisualStudio.Shell | |
//using Microsoft.VisualStudio.Shell.Interop | |
//using O2.FluentSharp.VSIX; | |
//O2Ref:O2_FluentSharp_VSIX.dll | |
//O2Ref:EnvDTE.dll | |
//O2Ref:EnvDTE80.dll | |
//O2Ref:Microsoft.VisualStudio.Shell.10.0.dll | |
//O2Ref:Microsoft.VisualStudio.Shell.Interop.dll | |
//O2Ref:Microsoft.VisualStudio.OLE.Interop.dll | |
//O2Ref:Microsoft.VisualStudio.Shell.Interop.8.0.dll | |
//O2Ref:Microsoft.VisualStudio.Shell.Interop.9.0.dll | |
//O2Ref:Microsoft.VisualStudio.Shell.Interop.10.0.dll | |
//generateDebugSymbols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which command did you use to write to VS output window ?