Reshaper plugin sdk how to achieve coloring of special words inside a string...

I would like to achieve a functionality similar to String.Format suggestions from Resharper where unused {0},{1} ... are marked as dimmed.
I could not find an example of a similar feature.
Does anybody have an idea if this functionality is available for the plugins?

Thank you


I beleive it is possible. The first thing you need to do is create a classification format definition, similar to the following that is used for dead code:

[ClassificationType(ClassificationTypeNames = Name)]
   [Order(After = VsAnalysisPriorityClassificationDefinition.Name, Before = VsHighlightPriorityClassificationDefinition.Name)]
   internal class DeadCodeClassificationDefinition : ClassificationFormatDefinition
     private const string Name = HighlightingAttributeIds.DEADCODE_ATTRIBUTE;
     public DeadCodeClassificationDefinition()
       DisplayName = Name;
       //ForegroundColor = Colors.LightGray;
       ForegroundOpacity = 0.5;
     [Export, Name(Name), BaseDefinition("formal language")]
     internal ClassificationTypeDefinition ClassificationTypeDefinition;

The critical piece in the above is the value of

— this is the identifier you must use when creating a highlighting for your analysis, e.g.,
[ConfigurableSeverityHighlighting("RedundantStringFormatCall", "CSHARP",
   AttributeId=HighlightingAttributeIds.DEADCODE_ATTRIBUTE, // <-- here
   OverlapResolve=OverlapResolveKind.DEADCODE,ToolTipFormatString = MESSAGE)]

This is how a connection is made between the highlighting and a particular style. The style should also appear in Visual Studio settings:


Thank you for your answer.

Is there a problem with the samples that ship with Resharper 7 sdk?
I don;t seem to make any of them to run and do something.
They compile and are installed correctly but no daemon method is called...
Are they somehow out of date?


Hi, what exactly are you seeing? Do the plugins fail to load, or load but do not operate? If so, do they all fail, or only some of them?


I'll add a response to this post later.
My work is on my home development machine.

Thanks for asking


Please sign in to leave a comment.