How to create green (or blue) squiggle adornments with a Visual Studio extension

I have a Visual Studio extension that show red error squiggles. I also like to provide squiggles with other colors, for example yellow for warnings.

Creating red squiggles can be done by extending the ITagger class, along the lines:

internal sealed class MySquigglesTagger : ITagger<IErrorTag> {
    public IEnumerable<ITagSpan<IErrorTag>> GetTags(NormalizedSnapshotSpanCollection spans) {
        foreach (IMappingTagSpan<MyTokenTag> myTokenTag in this._aggregator.GetTags(spans))        
            SnapshotSpan tagSpan = myTokenTag.Span.GetSpans(this._sourceBuffer)[0];
            yield return new TagSpan<IErrorTag>(tagSpan, new ErrorTag("Error", "some info about the error"));
        }
    }
}

What I have tried:

  • My intuition (incorrectly) says that returning an ErrorTag with an different errorType may yield a different type of tag, but whatever string you pass it, the squiggles remain red. Eg. new ErrorTag("Warning") gives red squiggles. The MSDN documentation is almost nonexistent. See ErrorTag.
  • In the Tagging namespace there is no mention of a different Tag class implementing ITag. I hoped a WarningTag or InfoTag existed.
  • Asked a question on MSDN forum here.
  • Question : how to create green (or blue or yellow) squiggle adornments? Sadly, even arcane or convoluted solutions are appreciated...

    I'm targeting VS2015 and VS2017.

    Edit: While typing this question someone at the MSDN forum replied that it cannot be done with the current API. Is it really impossible to make yellow squiggles in Visual Studio?!


    The PredefinedErrorTypeNames contains the supported values for the ErrorType property of the ErrorTag .

    You got close with "Warning", but the value of PredefinedErrorTypeNames.Warning appears to be "compiler warning".

    链接地址: http://www.djcxy.com/p/39152.html

    上一篇: 如何使用Visual Studio 2017配置ASP.NET IIS Web应用程序?

    下一篇: 如何使用Visual Studio扩展创建绿色(或蓝色)扭曲装饰