How to generate a compiler error based on an attribute being missing in C#?
- by RodH257
I create a number of add-ins for the Revit Structure API. Each tool has to habe a class which implements the interface IExternalCommand.
In the latest version of Revit, for your tool to work you need to have two attributes on the class that implements that interface:
[Regeneration(RegenerationOption.Manual)]
[Transaction(TransactionMode.Automatic)]
The values in brackets can change, but there must be something there. Often I am finding myself forgetting to put the attributes on, then when it comes to runtime it crashes. Is there any way in Visual Studio 2010 to add a compiler warning or error saying that if your class implements that interface it must have those 2 attributes? I have resharper if that helps.
Can anyone point me into the right direction?