Visual Studio does not throw a warning during build for events marked “Obsolete”

Vrijedi za: Visual Studio Professional 2010Visual Studio Premium 2012

Summary


Symptoms

You have a C# Class library project with a class containing an event and you marked the event with the "Obsolete" attribute. When you add reference to this class library in other project, for example a Console application and subscribe to that event, no warning is generated in the latter project.

Typically a warning (CS0618) should be generated during compilation in Visual Studio when a method, event or property is marked with the "Obsolete" attribute.

ObsoleteAttribute is applicable to all program elements except assemblies, modules, parameters or return values and works as expected.

Cause

This is a known issue with Microsoft C# compiler.

More Information


This issue is observed in all Editions of Visual Studio