DEBUG 与 RELEASE 和分发程序集

DEBUG vs RELEASE and distributing Assembly

我正在创建和分发供其他开发人员使用的程序集。 我正在分发我的程序集的发布版本(不是调试)。 在我的程序集的 类 之一中,我仅在调试模式下使用

将代码设置为 运行
#if DEBUG
    Console.WriteLine("Debug");
#else
    Console.WriteLine("Release");
#endif

如果其他开发人员从他们的项目中引用我的程序集,并且 运行 他们的项目在 Debug 模式下,我的 Debug only conditional 运行 还是没有条件?

If other developers reference my Assembly from their project and run their project in Debug mode, will my Debug only conditional run or not ?

不,因为 Console.WriteLine() 由于预处理器限制从未在 Release 模式下编译。

MSDN 对此有更多的说法:

When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified symbol is defined ... Tell me more...

此外,认为它已从程序集中删除是不正确的,因为它从来没有出现过。