Attribute annotation for individual indexer position

Hi

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 {
          [LocalizatonRequired]
          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

Thanks
Jens

1 comment

You should fire up dotPeek, point it at ReSharper's bin directory and look for LocalizableElementDaemonStage (you can read more about daemon stages here: http://confluence.jetbrains.com/display/NETCOM/2.04+Daemons+and+Daemon+Stages+%28R8%29). 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: http://youtrack.jetbrains.com/issue/RSRP-392187

0

Please sign in to leave a comment.