How to throw compilation error from an attribute?
-
07-07-2019 - |
Question
there are attributes in .NET (e.g. ObsoleteAttribute
) which are able to prevent compilation or at least throw compile time warnings depending on their configuration.
How to write an attribute that is able to interfere with compilation? Is there a way to do this from outside Microsoft?
OTHER TIPS
Using PostSharp: Generating a custom compile time warning C#
Any attributes that exhibit this inside the compiler are special cases. The [Obsolete]
behaviour is described in the C# spec (17.4.3), for example.
You could write a custom FxCop rule?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow