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:
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".