How do I remove unnecessary resources from my project?

前端 未结 10 1668
深忆病人
深忆病人 2021-02-12 22:55

I am working with a very big project (a solution that contains 16 projects and each project contains about 100 files).

It is written in C++/C# with Visual Studio 2005.

相关标签:
10条回答
  • 2021-02-12 23:05

    I've never had one that bad. My method in compiled programs is to use a REXX script which emulates GREP looking for references to source that I suspect is not being used, remove them from the program and see what breaks. I use the REXX script because I can pre-filter the list of files I want to search. Which allows me to do a search across folders and computers.

    0 讨论(0)
  • 2021-02-12 23:05

    You may want to take a look at the tool Reflector (free), not to be confused with ReSharper (expensive). It can show you which DLLs are dependent on another. Then if you want you may be able to remove the DLL that is not being referenced by anything else. Watch out if you are using dependency injection or reflection which then could break your code without your knowledge.

    Reflector: http://www.red-gate.com/products/reflector/.

    This add-in draws assembly dependency graphs and IL graphs: http://reflectoraddins.codeplex.com/Wiki/View.aspx?title=Graph.

    0 讨论(0)
  • 2021-02-12 23:05

    Maybe Find Unused Resources in a .NET Solution helps here? Basically, you'll have to check which resources are used (e.g. by comprehensive code coverage checks) and remove the unused ones.

    And probably you should not be afraid by using the trail-and-error approach to cleaning up.

    0 讨论(0)
  • 2021-02-12 23:06

    What I would do is write a custom tool to search your source code.

    If you remove a resource ID from a header file (i.e. possibly called resource.h) and then recompile and get no warnings: then that's a good thing.

    Here is how I would go about writing the app. Take as input the resource file (resource.h) you want to scrutinize. Open the header file (*.h) and parse all the resource constants (Or at least the onces you are interested in). Store those in a hash table for quick look up later. For each code file in your project, search the text for instances of each of your resource ID's. When a resource ID is used, increment the value in the hash table otherwise leave it at zero. At the end, dump all the resource ID's that are zero out a log file or something. Then test that indeed you can remove those specified resource ID's safely. Once you do that, then write another tool that removes the specified resource ID's given the results of your log file.

    You could write such a tool in perl and it would execute in about 0.3 seconds: But would take days to debug. :) Or you could write this in .NET, and it would execute a little slower, but would take you an hour to debug. :)

    0 讨论(0)
  • 2021-02-12 23:07

    For C++ projects, check out The ResOrg from Riverblade.

    "The Resource ID Organiser (ResOrg for short) is an Add-in for Visual C++ designed to help overcome one of the most annoying (and unnecessary) chores of developing/maintaining Windows applications - maintaining resource symbol ID values"

    http://www.riverblade.co.uk/products/resorg/index.html

    0 讨论(0)
  • 2021-02-12 23:07

    In the "Resources View" of the Solution Explorer, right-click and select "Resource Symbols". Now you get a list where you can see which resources constants are used in the .RC-file. This help you might be a bit on the way to cleanup your Resource.h (although it does not show you which resources are not used in the actual C++ code).

    0 讨论(0)
提交回复
热议问题