Skip to content

Exclude code when running in a test #2530

Answered by bradwilson
Symbai asked this question in Question
Discussion options

You must be logged in to vote

We don't emit any compiler directives during builds (and it's outside the scope of what we do).

Assuming you're building the code twice (once for production and once for testing), you could do this yourself by defining this only during the test builds. If you're not building it twice, then I'd suggest you start doing so, because the only way to get this kind of compilation change is by building the code twice.

Alternatively, you could leverage Lazy<T> to stop running all your static startup code until the first time the value in question is needed.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Symbai
Comment options

@bradwilson
Comment options

@Symbai
Comment options

@bradwilson
Comment options

Answer selected by bradwilson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants