tags:

views:

1058

answers:

4

How do you go about finding unused icons, images, strings in .resx files that may have become 'orphaned' and are no longer required?

+3  A: 

This is no information an algorithm can reliably compute. The inspected program could fetch a list of all resources and do something with them, like letting the user choose from several icons.

Your best bet is probably to search for all references to your resource-access API of choice and inspect those manually. Using grep/sed you might be able to reduce the sites you have to inspect manually by handling all "easy" ones where a simple string is used.

David Schmitt
A: 

I've been considering this myself and I believe I have two options. Both of these rely on the fact that I use a helper method to extract the required resource from the resource files.

  1. Logging
    Add some code to the "getresource" method or methods so that every time a resource is accessed, the resource key is written to a log. Then try to access every part of the site (a testing script might be helpful here). The resultant log entries should give a list of all the active resource keys, the rest can be junked.

  2. Code Analysis
    I am looking at whether T4 is capable of working through the solution and creating a list of all references to the "getresource" helper method. The resultant list of keys will be active, the rest can be deleted.

There are limitations of both methods. The logging method is only as good as the code covered by the test and the code analysis might not always find keys rather than strings containg the keys so there will be some extra manual work required there.

I think I'll try both. I'll let you know how it goes.

Chris Simpson
A: 

Did anyone find a solution to this yet?

Remy
You really shouldn't post a request as an answer. Certain people are going to hate and downvote you.
Jouke van der Maas
Fair enough, didn't realize that.
Remy
@Remy I posted an answer you might be interested in.
Robert Greiner
A: 

There's a script that will do this for you.

Robert Greiner