How do I remove unnecessary resources from my proj

2020-06-08 14:45发布

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.
One of the projects has around 2000 resources out of which only 400 are actually used.
How do I remove those unused resources?

I tried to accomplish the task by searching for used ones.
It worked and I was able to build the solution, but it broke at runtime.

I guess because enums are used. (IMPORTANT)

How can I make sure that it doesn't break at runtime?

EDIT:
I think one method could be to generate the resource (that is not found) on the fly at runtime (somehow).
But I have no idea about ... anything.

NOTE: It's okay if a few unnecessary resources are still there.

10条回答
叛逆
2楼-- · 2020-06-08 15:29

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.

查看更多
叼着烟拽天下
3楼-- · 2020-06-08 15:36

For C++ resources, did you try right-clicking the project in "Resource View" and then deleting the ones which do not have a tick mark next to them? It is unsafe to delete unused dialog resources since they are referenced as "enum"s in code (like the following).

enum { IDD = IDD_ABOUTBOX };

..however for all the others it should be safe.

查看更多
我想做一个坏孩纸
4楼-- · 2020-06-08 15:38

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

查看更多
戒情不戒烟
5楼-- · 2020-06-08 15:40

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.

查看更多
登录 后发表回答