在错误列表C#vsix扩展名中显示自定义消息

问题描述 投票:0回答:1

我正在创建VSIX扩展名。在这里,我在错误列表中添加了错误,但是问题栏(仅在错误列表的上方)仍然显示未发现问题,后跟绿色标记(在所附的图像上) :

Image 1

这些7错误必须像VS IDE通常一样显示在issue bar上,如下图所示:

Image 2

现在,我希望我的项目能够工作/显示类似第二张图片的错误。以下是我的代码,用于添加这些自定义错误:

internal static class ErrorListManager
{
    public static ErrorListProvider errorListProvider;

    public static void Initialize(IServiceProvider serviceProvider) 
    {
        errorListProvider = new ErrorListProvider(serviceProvider);
    }

    public static void AddError(string errorMsg) {
        AddTask(errorMsg, TaskErrorCategory.Error);
    }

    private static void AddTask(string errorMsg, TaskErrorCategory category)
    {
        errorListProvider.Tasks.Add(new ErrorTask
        {
            Category = TaskCategory.User,
            ErrorCategory = category,
            Text = errorMsg
        });
    }
}
private void CreateVisualsCall(List<string> templist2, int markCountLoc)
{
    //if (this.checkCountIfMarked <= markCountLoc)
    if (markCountLoc > 0)
    {
        //this.markthis.Clear();
        //CreateVisuals(templist2[templist2.Count - this.checkCountIfMarked],markCountLoc,templist2);
        CreateVisuals(templist2[templist2.Count - markCountLoc], markCountLoc, templist2);
    }
    else
    {
            foreach (Image img in this.drawingImageList) { 

            // Align the image with the top of the bounds of the text geometry
            //Canvas.SetLeft(img, this.geometry.Bounds.Left);
            //Canvas.SetTop(img, this.geometry.Bounds.Top);

            this.layer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, span, null, img, null);
        }

        -------
        ErrorListManager.AddError("Test  Message");//only this line is calling and creating custom error!
        ------- 
    }
}

我的问题是:如何删除“未发现问题(如img 1)”并将错误放置在上面(如img 2)

我遵循this tutorial创建了此文件。

c# plugins vsix error-list
1个回答
0
投票

请从该线程中查看我的答案:Find specific patterns in project via VS extension

我认为您可以在那里找到所需的所有说明。如有其他问题,我会在这里提供帮助。

幸福的祝福!

© www.soinside.com 2019 - 2024. All rights reserved.