1

I have the following: Debug.Writeline(Properties.Resources.DEBUG_MSG_1);

This works fine, and I can't imagine it hurting me in any way, shape, or form when compiling in Debug mode. However, I worry that although this is a nice and convenient way to manage my messages, it might be unnecessary overhead to include extra useless items in a resource file when I compile in Release. Is my assumption correct?

michael
  • 14,844
  • 28
  • 89
  • 177
  • 2
    Why do your debug messages actually need to be in resources? DO you localize them? – Joey Jan 10 '11 at 16:31
  • Hmm, good point. I guess I was just trying to find a nice place to keep them all grouped. Perhaps I'll just place them as private consts and wrap them in a #if DEBUG directive. – michael Jan 10 '11 at 16:56

2 Answers2

2

The WriteLine method has the attribute

[Conditional("DEBUG")]

set. Thus I strongly assume that the compiler removes the function call automatically for release builds.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    +1 The call is removed, but not the resource string which the OP is asking about. – Tim Lloyd Jan 10 '11 at 16:33
  • But not the resource entries, which means that all the messages still end up being shipped with a production version... – Lucero Jan 10 '11 at 16:33
  • In "good old" Visual C++ there was an option to conditionally define resources/resource symbols, too. Seems that this does not apply in C#/.NET, from what I know. – Uwe Keim Jan 10 '11 at 16:37
1

Well... Resources are embedded to application. So in RELEASE you'll have some extra messages, which would not be used. The more you have them, the more will your application weights.

But I think that real problem might be someone reading DEBUG messages while she/he isn't supposed to do.

dzendras
  • 4,721
  • 1
  • 25
  • 20