Attribute annotation for individual indexer position


I am in the process of Localizating a large code base that use indexers heavily

Can anyone provide a starting point for a code analyzer (ReSharperPlugin) that can help in the following senario?

pseudo code:
     class MyClass {
          public string Caption { get; set; }

          public object Data { get; set; }

actual code:
   interface IMessage {
         object this[string index] { get; set; }
   IMessage message = GetMessage("MyClass");
   message["Caption"] = "Foo"; // Wanted: LocalizationRequired warning here
   message["Data"] = "Bar"; // No warning here

It is OK to add a new attribute to IMessage but converteing the code to use classes as in the pseudo code is a no go


1 comment
Comment actions Permalink

You should fire up dotPeek, point it at ReSharper's bin directory and look for LocalizableElementDaemonStage (you can read more about daemon stages here: There are two classes here, one for VB and one for C#. They are responsible for looking at the syntax trees of the file and looking to see if the current expression should be localised, and if they should, they assign a highlight. The quick fix is automatically assigned to those highlights and edits the code as appropriate. It looks like it's checking for property assignments, but it must be handling indexers differently, because they don't get flagged up.

I've raised an issue in YouTrack to get this addressed in a future version:


Please sign in to leave a comment.