Is there an inversion of System.Diagnostics.ConditionalAttribute?

Is there a similar conditionally non-real attribute, or perhaps a way to use the Conditional attribute to include only the method if this character is not defined?

What I'm looking for is what works as follows:

[Conditional("!SILVERLIGHT")] private void DoStuffThatSilverlightCant() {...} 

Therefore, the method will not be included if the SILVERLIGHT symbol exists.

The reason I don't want to use a simple #ifdef is because I can use a compiler that removes the calling statements without having to wrap each individual call in #ifdef .

+6
c # symbols visual-studio attributes
source share
1 answer

Update: The following code snippet only works if #if is in each calling file, which is not very practical.

 #if !SILVERLIGHT #define NOT_SILVERLIGHT #endif [Conditional("NOT_SILVERLIGHT")] private void DoStuffThatSilverlightCant() {...} 

However, it can be done to have an assembly configuration for any platform that you use that will / defines the required character (in this case NOT_SILVERLIGHT).

+8
source share

All Articles