#if preprocessor directive doesn't always collapse

c#, preprocessor-directive, visual-studio-2010

Solution

If the `#If` test is false, then obviously all of the code within (no matter what it's structure may be) is dead code. It makes sense to offer to collapse these sections.

If the `#If` test is true, then arbitrary code may be contained within. So the collapse options are based on the code structure. And no collapse is offered on the arbitrary `#If` test.

Problem

Say I define two #define preprocessor directives: ``` #define TEST #define TESTOFF ``` Now my code is organized in TEST and TESTOFF #if directives, e.g.: ``` #if TEST ... #endif ...MORE CODE... #if TESTOFF ... #endif ``` It often happens that one `#if` region, say the `#if TEST` region, becomes collapsible while the other (`#if TESTOFF` region) is not. Since this is a strange phenomenon that some might've never encountered, I'm appending a snapshot of the issue in question: Does anyone know what parameters define this behavior behavior of the `#if` preprocessor directive?

Original source