Mark's Blog About Search Activity

Find unused resource strings

This handy tip lets the compiler warning you of any unused resource string references. Credit this blog.

Resources.Designer.cs file:

(1) Turn on Code Analysis warning CA1811
(2) In your Resources.Designer.CS file comment out the following lines:
     [global:: System.CodeDom.Compiler.GeneratedCodeAttribute( …
     [global:: System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
(3) Change the class to a static class by putting the word “static” in front of “class”:
     internal static class Resources {
(4) Comment out the default constructor.
(5) Compile your program. Now you should be warned about any unused resources.
(6) Remove your unused resources. (Changing any resources will regenerate the Resources.Designer.cs file.)

If you liked this post, you can share it with your followers or follow me on Twitter!
comments powered by Disqus