I have some classes, which have several methods which I don't really want to be there, but are there simply because the XML Serializer needs them. Is there anyway to generate compile-time errors/warnings if they get called from user-code?
I am aware that I can implement IXmlSerializable, and I am also aware that I can separate out the classes into purely data storage classes, however, I am not asking a question about how I should design such a system, I am simply asking if there is a way to generate compile-time errors/warnings if they are called by anything that is not the XML serializer...
Even when a variable is declared auto, its type is fixed at compile time.
In computing, compile-time function execution (or compile time function evaluation, or general constant expressions) is the ability of a compiler, that would normally compile a function to machine code and execute it at run time, to execute the function at compile time.
All the template parameters are fixed+known at compile-time. If there are compiler errors due to template instantiation, they must be caught at compile-time!
You can add
[Obsolete]
to the method. The IsError
property of ObsoleteAttribute
controls whether an error or warning is generated, and you can provide an explanatory message too.
You could decorate the members in question with the ObsoleteAttribute. Its intention is a bit different, but it will generate compiler warnings (or errors) when called from user code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With