I have a class (constructor) that I need exposed within a business-tier, but it needs careful thought and justification for use (of ANY of its members). I'd like it to generate a compiler warning by default, and establish our team process as recording inline usage justification and a pragma suppress
or similar.
Ideally the warning would be custom text, for example:
WARNING: This code circumvents user security filters. If you intended this, please comment here how this code precludes exposure of sensitive data, then follow with #pragma suppress.
Also ideally, the message displays without team members having to install anything into their VS. We use VS 2017
I currently have the code marked [Obsolete]
, but it's semantically inaccurate and requires wrapping one or more lines with #pragma warning disable 0618
followed by #pragma warning enable 0618
. I'd rather encourage individual resolution of each line, similar to the #pragma suppress
syntax.
If you suspect a duplicate question, please read this: Note that I've reviewed other "similar" questions. Some seek to mark code as needing review (the accepted answer is this is an inappropriate use of compiler warnings). Some truly represent Obsolete code, so the answer is obvious. Some see complex rules, like "you must also call a sibling method".