optimize using and preprocessor

Is it possible for the "optimize using" reformater to treat all preprocessor #IFs as being true?

using System;
public class test
{
#if DEBUG
private DateTime _date;
#end if
}


if you optmize using, the "using System" will be removed, and the code won't compile in release mode.

Karl

3 comments
Comment actions Permalink

No, we can't :(
Your example of preprocessor usage is a very simple case.
Consider the following code:

class C :
#if DEBUG
DebugBase {
#else
ReleaseBase {
#endif

This case is a real pain to treat :(

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"karl" <no_mail@jetbrains.com> wrote in message
news:28957927.1136389393010.JavaMail.itn@is.intellij.net...

Is it possible for the "optimize using" reformater to treat all
preprocessor #IFs as being true?

>

using System;
public class test
{
#if DEBUG
private DateTime _date;
#end if
}

>
>

if you optmize using, the "using System" will be removed, and the code
won't compile in release mode.

>

Karl



0
Comment actions Permalink

Maybe analyzing all possible combinations of #if/#else to see if a
particular namespace is used in any of them ?
It would be slower and not error-free in all cases, but it might reduce the
risks to break the code when the #defines change.

Or adding a warning or something in the output pane to show which files
should be checked.

Or having an option to ignore files containing #if/#else when doing a
'massive' reformatting (anything other than on a single file). Or ignore
them altogether. Personally, I'd rather have to reformat manually some files
rather than risking having a broken build and not realizing it before
building the code with another configuration, potentially much later :)


Lionel


"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:dq0ur1$uj3$1@is.intellij.net...

No, we can't :(
Your example of preprocessor usage is a very simple case.
Consider the following code:

>

class C :
#if DEBUG
DebugBase {
#else
ReleaseBase {
#endif

>

This case is a real pain to treat :(

>

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"karl" <no_mail@jetbrains.com> wrote in message
news:28957927.1136389393010.JavaMail.itn@is.intellij.net...

Is it possible for the "optimize using" reformater to treat all
preprocessor #IFs as being true?

>

using System;
public class test
{
#if DEBUG
private DateTime _date;
#end if
}

>
>

if you optmize using, the "using System" will be removed, and the code
won't compile in release mode.

>

Karl

>
>


0
Comment actions Permalink

I agree. I rather the code not optimize at all and risk having useless usings, that break my build. I'd think it would be trivial to handle simple cases.

0

Please sign in to leave a comment.