I am using an enum being exposed by a 3rd party assembly, e.g.,
public enum APIEnum
{
Val1,
Val2
}
. However, a number of these values cause incorrect behavior in my application. I want to generate a compiler warning if one of these "bad" enum values is used in code, e.g.,
APIEnum usedVal = APIEnum.Val2;
Compiler Warning: APIEnum.Val2 causes incorrect behavior.
My ultimate goal is to generate a warning that must be consciously #pragma'd if a bad value is used (2% of the overall cases). Otherwise, the warning occurs, and since we have Warnings as Errors, that breaks the compile until fixed or #pragma'd.
I've looked at the threads here and here on using the Obsolete attribute to solve this problem, but I fear the Obsolete will cause confusion since the value is not really obsolete.
I've considered the possibility of using a Resharper code analysis plugin to solve the problem, and that is definitely an option. I'm no expert on Resharper or how to best solve the problem via Resharper.