I have in a controller the following code to allow in the local environment not to use a token to authenticate, while in production environment a JWT token is necessary for authentication:
The “else” part needs a required import to make it work. However, it is in gray color because Visual Studio detects it is an import that is not being used (which is true in the local environment, but when compiling for another environment it is necessary in order to work).
The problem is that sometimes we clean up imports and remove those that are not being used. As this import is detected that it is not being used (when in fact it is necessary), the proccess deletes it. That action generates compilation errors when compiling for production environment.
It is a Visual Studio bug? Is there any way to avoid this, and to force that import to be used? Or another way to rewrite the “if DEBUG” statement so the code can detect the import is being used?