Throw an error at compile time if any particular external function is used anywhere in the code?

I am using an external library, and I want me to never call some functions in the library. I do not have the source code for this library, so I would like to make sure that at compile time it throws an error if I ever accidentally (or one of my developers) ever used this function. Is there any way to do this?

+4
source share
2 answers

You cannot do it easily. You can mark the method as deprecated, but of course, this requires access to the source code of the external library, after which you can also simply delete the methods.

, , - :

public class LibraryFacade
{
    //All the library methods as pass-through methods
    //Except the bad ones!
}

, , . , , .

, , , .

+4

, / . , , , .

: /, .

: , , 100% - .

+1

All Articles