當前位置: 首頁>>代碼示例>>C#>>正文


C# Shell.ErrorTask類代碼示例

本文整理匯總了C#中Microsoft.VisualStudio.Shell.ErrorTask的典型用法代碼示例。如果您正苦於以下問題:C# ErrorTask類的具體用法?C# ErrorTask怎麽用?C# ErrorTask使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ErrorTask類屬於Microsoft.VisualStudio.Shell命名空間,在下文中一共展示了ErrorTask類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddError

        public void AddError(DiagnosticBase diagnostic, TextSpan span)
        {
            lock (_lockObject)
            {
                if (_disposed)
                    return;

                var sourceText = span.SourceText as VisualStudioSourceText;
                if (sourceText == null)
                    return;

                var line = sourceText.Snapshot.GetLineFromPosition(span.Start);

                var task = new ErrorTask
                {
                    Text = diagnostic.Message,
                    Line = line.LineNumber,
                    Column = span.Start - line.Start.Position,
                    Category = TaskCategory.CodeSense,
                    ErrorCategory = (diagnostic.Severity == DiagnosticSeverity.Error)
                        ? TaskErrorCategory.Error
                        : TaskErrorCategory.Warning,
                    Priority = TaskPriority.Normal,
                    Document = span.Filename ?? _textDocument.FilePath
                };

                task.Navigate += OnTaskNavigate;

                _errorListProvider.Tasks.Add(task);
            }
        }
開發者ID:tgjones,項目名稱:HlslTools,代碼行數:31,代碼來源:ErrorListHelper.cs

示例2: AddError

        public void AddError(Project project, string path, string errorText, TaskErrorCategory category, int iLine, int iColumn)
        {
            ErrorTask task;
              IVsSolution solution;
              IVsHierarchy hierarchy;

              if (project != null)
              {
              try
              {
              solution = (IVsSolution)GetService(typeof(IVsSolution));
              ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy));

              task = new ErrorTask();
              task.ErrorCategory = category;
              task.HierarchyItem = hierarchy;
              task.Document = path;

              // VS uses indexes starting at 0 while the automation model uses indexes starting at 1
              task.Line = iLine - 1;
              task.Column = iColumn;
              task.Text = errorText;
              task.Navigate += ErrorTaskNavigate;
              if (ContainsLink(errorText))
              {
                  task.Help += new EventHandler(task_Help);
              }
              _errorListProvider.Tasks.Add(task);
              }
              catch (Exception ex)
              {
              MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
              }
        }
開發者ID:sunday-out,項目名稱:SharePoint-Software-Factory,代碼行數:35,代碼來源:ErrorListProvider.cs

示例3: CreateErrors

        private void CreateErrors()
        {
            var errors = errorListProvider.GetErrors(textView.TextBuffer);

            // Check if we should update the error list based on the error count to avoid refreshing the list without changes
            if (errors.Count != this.previousErrors.Count)
            {
                // remove any previously created errors to get a clean start
                ClearErrors();

                foreach (ValidationError error in errors)
                {
                    // creates the instance that will be added to the Error List
                    ErrorTask task = new ErrorTask();
                    task.Category = TaskCategory.All;
                    task.Priority = TaskPriority.Normal;
                    task.Document = textView.TextBuffer.Properties.GetProperty<ITextDocument>(typeof(ITextDocument)).FilePath;
                    task.ErrorCategory = TranslateErrorCategory(error.Severity);
                    task.Text = error.Description;
                    task.Line = textView.TextSnapshot.GetLineNumberFromPosition(error.Span.Start);
                    task.Column = error.Span.Start - textView.TextSnapshot.GetLineFromLineNumber(task.Line).Start;
                    task.Navigate += OnTaskNavigate;
                    errorList.Tasks.Add(task);
                    previousErrors.Add(task);

                    ITrackingSpan span = textView.TextSnapshot.CreateTrackingSpan(error.Span, SpanTrackingMode.EdgeNegative);
                    squiggleTagger.CreateTagSpan(span, new ErrorTag("syntax error", error.Description));
                    previousSquiggles.Add(new TrackingTagSpan<IErrorTag>(span, new ErrorTag("syntax error", error.Description)));
                }
            }
        }
開發者ID:smartmobili,項目名稱:parsing,代碼行數:31,代碼來源:ErrorListPresenter.cs

示例4: LogError

 public void LogError(Exception ex)
 {
     ErrorTask task = new ErrorTask(ex);
     task.ErrorCategory = TaskErrorCategory.Error;
     task.Category = TaskCategory.Misc;
     m_errorListPrivider.Tasks.Add(task);
 }
開發者ID:vandro,項目名稱:MVCVisualDesigner,代碼行數:7,代碼來源:Logger.cs

示例5: AddHierarchyItem

        public static void AddHierarchyItem(ErrorTask task, EnvDTE.Project project)
        {
            IVsHierarchy hierarchyItem = null;
            IVsSolution solution = BundlerMinifierPackage.GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            if (solution != null && project != null)
            {
                int flag = -1;

                try
                {
                    flag = solution.GetProjectOfUniqueName(project.FullName, out hierarchyItem);
                }
                catch (COMException ex)
                {
                    if ((uint)ex.ErrorCode != DISP_E_MEMBERNOTFOUND)
                    {
                        throw;
                    }
                }

                if (0 == flag)
                {
                    task.HierarchyItem = hierarchyItem;
                }
            }
        }
開發者ID:rsaladrigas,項目名稱:BundlerMinifier,代碼行數:27,代碼來源:ErrorList.cs

示例6: Show

        public static void Show(Diagnostic diag)
        {
            var task = new ErrorTask
                           {
                               Text = string.Format(@"[N] {0,4} : {1}", diag.ID, diag.Message),
                               Category = TaskCategory.CodeSense,
                               ErrorCategory =
                                   diag.Level == DiagnosticLevel.Warning
                                       ? TaskErrorCategory.Warning
                                       : TaskErrorCategory.Error,
                               Column = diag.StartColumn,
                               Line = diag.StartLine - 1,
                               Document = diag.FilePath,
                               HierarchyItem = (IVsHierarchy)(AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject != null ? AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject.Object : null),
                           };

            task.Navigate += (sender, args) =>
                                 {
                                     task.Line++;
                                     errorListProvider.Navigate(task, Guid.Parse(EnvDTE.Constants.vsViewKindCode));
                                     task.Line--;
                                 };

            errorListProvider.Tasks.Add(task);
        }
開發者ID:saaadhu,項目名稱:naggy,代碼行數:25,代碼來源:ErrorList.cs

示例7: ShowError

 public virtual void ShowError(string error)
 {
     var errorTask = new ErrorTask
                         {
                             Category = TaskCategory.Misc,
                             Text = error,
                             CanDelete = true,
                         };
     errorProvider.Tasks.Add(errorTask);
 }
開發者ID:paulcbetts,項目名稱:Fody,代碼行數:10,代碼來源:MessageDisplayer.cs

示例8: Add

 public void Add(Project project, TaskErrorCategory category, string file, int line, int column, string description)
 {
     var task = new ErrorTask
     {
         ErrorCategory = category,
         Document = file,
         Line = Math.Max(line - 1, 0),
         Column = Math.Max(column - 1, 0),
         Text = description,
     };
     this.Add(project, task);
 }
開發者ID:cbilson,項目名稱:chirpy,代碼行數:12,代碼來源:TaskList.cs

示例9: AddMessage

        /// <summary>
        /// Adds a message of the given document to the error list.
        /// </summary>
        public void AddMessage(string message, string document, ErrorCategory errorCategory)
        {
            var errorTask = new ErrorTask
                {
                    ErrorCategory = (TaskErrorCategory)errorCategory,
                    Text = message,
                    Document = document,
                };

            this.ErrorListProvider.Tasks.Add(errorTask);
            this.ErrorListProvider.Show();
            this.ErrorListProvider.BringToFront();
        }
開發者ID:NuPattern,項目名稱:NuPattern,代碼行數:16,代碼來源:ErrorList.cs

示例10: Can_add_clear_error_list_tasks

        public void Can_add_clear_error_list_tasks()
        {
            var mockServiceProvider = new Mock<IServiceProvider>();
            mockServiceProvider.Setup(p => p.GetService(typeof(SVsTaskList))).Returns(new Mock<IVsTaskList>().Object);

            var task = new ErrorTask();
            var errorList = new DesignerErrorList(mockServiceProvider.Object);

            Assert.Empty(errorList.Provider.Tasks);
            errorList.AddItem(task);
            Assert.Equal(new[] { task }, errorList.Provider.Tasks.Cast<ErrorTask>());
            errorList.Clear();
            Assert.Empty(errorList.Provider.Tasks);
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:14,代碼來源:DesignerErrorListTests.cs

示例11: CreateTask

 /// <summary>
 /// Creates task from occurence
 /// </summary>
 /// <param name="occurence"> occurence of defect</param>
 /// <param name="fileName">file name of occurence</param>
 /// <returns></returns>
 Task CreateTask(Occurence occurence, string fileName)
 {
     var defectTask = new ErrorTask()
     {
         Category = TaskCategory.User,
         ErrorCategory = TaskErrorCategory.Warning,
         CanDelete = false,
         Text = occurence.Message,
         Document = fileName,
         Line = int.Parse(occurence.StartLine)
     };
     defectTask.Navigate += navigateEventHandler;
     return defectTask;
 }
開發者ID:KarolAntczak,項目名稱:Dexter,代碼行數:20,代碼來源:DexterTaskProvider.cs

示例12: ShowError

        /// <summary>
        /// Adds an error message to the Visual Studio tasks pane
        /// </summary>
        private void ShowError(string path, string text)
        {
            _message = new ErrorTask
            {
                ErrorCategory = TaskErrorCategory.Error,
                Category = TaskCategory.Comments,
                Document = path,
                Line = 0,
                Column = 0,
                Text = text
            };

            _messageList.Tasks.Add(_message);
            _messageList.Show();
        }
開發者ID:octoberclub,項目名稱:editorconfig-visualstudio,代碼行數:18,代碼來源:SettingsManager.cs

示例13: AddHierarchyItem

        public void AddHierarchyItem(ErrorTask task)
        {
            IVsHierarchy HierarchyItem;
            IVsSolution solution = EditorExtensionsPackage.GetGlobalService<IVsSolution>(typeof(SVsSolution));

            if (solution != null)
            {
                int flag = solution.GetProjectOfUniqueName(_connection.Project.FullName, out HierarchyItem);

                if (0 == flag)
                {
                    task.HierarchyItem = HierarchyItem;
                }
            }
        }
開發者ID:ncl-dmoreira,項目名稱:WebEssentials2013,代碼行數:15,代碼來源:BestPracticesBrowserLink.cs

示例14: ProduceErrorListTask

        public static Task ProduceErrorListTask(this IStylingRule rule, TaskErrorCategory category, Project project, string format)
        {
            var item = ResolveVsHierarchyItem(project.UniqueName);

            var task = new ErrorTask
            {
                Document = rule.File,
                Line = rule.Line - 1,
                Column = rule.Column,
                ErrorCategory = category,
                Category = TaskCategory.Html,
                Text = string.Format(format, project.Name, rule.DisplaySelectorName, rule.File, rule.Line, rule.Column),
                HierarchyItem = item
            };

            task.Navigate += NavigateToItem;
            return task;
        }
開發者ID:robert-hoffmann,項目名稱:WebEssentials2013,代碼行數:18,代碼來源:RuleExtensions.cs

示例15: AddError

        public void AddError(ITextSnapshot snapshot, Diagnostic diagnostic, TextSpan span)
        {
            var line = snapshot.GetLineFromPosition(span.Start);

            var task = new ErrorTask
            {
                Text = diagnostic.Message,
                Line = line.LineNumber,
                Column = span.Start - line.Start.Position,
                Category = TaskCategory.CodeSense,
                ErrorCategory = TaskErrorCategory.Error,
                Priority = TaskPriority.Normal,
                Document = span.Filename
            };

            task.Navigate += OnTaskNavigate;

            _errorListProvider.Tasks.Add(task);
        }
開發者ID:davidlee80,項目名稱:HlslTools,代碼行數:19,代碼來源:ErrorListHelper.cs


注:本文中的Microsoft.VisualStudio.Shell.ErrorTask類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。