1 Replies Last post: Nov 11, 2013 7:06 PM by Matt Ellis  
Jens Odborg Newbie 12 posts since
Jul 17, 2013
Currently Being Moderated

Nov 8, 2013 7:28 PM

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




Matt Ellis Apprentice 571 posts since
Jul 5, 2009
Currently Being Moderated
Nov 11, 2013 7:06 PM in response to: Jens Odborg
Re: Attribute annotation for individual indexer position

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

More Like This

  • Retrieving data ...