Is there an inverse of System.Diagnostics.ConditionalAttribute?

Is there an analogous conditional-not-present attribute or maybe a way to use the Conditional attribute to only include a method if that symbol is not defined?

What I'm looking for is something that works like this:

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

Such that the method will not be included if the symbol SILVERLIGHT does exist.

The reason I don't want to use a simple #ifdef is so that I can take advantage of the compiler removing the calling statements without having to wrap every individual call in an #ifdef.

Answers


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

#if !SILVERLIGHT
#define NOT_SILVERLIGHT
#endif

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

What could be done however, is to have a build configuration for whatever platform you are using that will /define the needed symbol (NOT_SILVERLIGHT in that case).


Need Your Help

Coverity, Enumerable.Where(this …), and IDisposable

c# .net linq ienumerable idisposable

So code analysis is telling me that Enumarble.Where(this ...) is returning an instance of WhereListIterator<T>, which is (looks to be) an internal type within the .NET framework that implements

Is there a good scripting Pascal-like language for Delphi?

delphi scripting pascal scripting-language remobjects

I'm looking for a good free scripting engine for Delphi. I want to add scripting to an application so that I can write small test scripts. Specifically I need:

Reading source code

java design design-patterns discovery

If you read other people's source code, how do you approach the code? What patterns are you looking for (datatypes, loops, use of control flow, ... )? How long can you read other people's code with...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.