In a Visual Studio extension I've built I need to highlight method invocations within the Visual Studio editor. For example:
I would like to use HSV colors to divide up the color spectrum according to to the number of unique invocations.
I can achieve the highlighting if I export each color as its own EditorFormatDefinition:
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "red-background")]
[Name("red-background")]
[UserVisible(true)]
[Order(After = Priority.High)]
public sealed class RedBackground : ClassificationFormatDefinition
{
public RedBackground()
{
DisplayName = "red-background";
BackgroundColor = Colors.Red;
}
}
However, this requires me to manually set up all the colors I'd like to use ahead of time. Is there a way to export EditorFormatDefinitions
at runtime?
Certain registries such at the IContentTypeRegistryService and the IClassificationTypeRegistryService
allow one to create new content types and classifications at runtime. Does a similar API exist for EditorFormatDefinitions
.
Alternatively, is it possible to dynamically MEF export an EditorFormatDefinition
within Visual Studio?