I have a lot of variables set up to be used later, and the list is growing. And every time I compile my code the editor returns these warning saying “variable such-and-such is assigned but the variable is never used!”
Is there a way I can tell the editor to not display those warnings? It’s gotten to the point where I could miss a new and relevant warning.
Yeah but that would clear ALL the warnings. It’s not too common, but every now and then I write something that generates a warning and not an error, and I don’t want to miss it.
I just want to miss these ones that tell me a variable is never used.
At least for the foreseeable future.
Generally speaking, if you do have a warning you want to ignore, simple look at it. It’ll give you a unique warning code aswell. For not assigned variable’s it is CS0649. Just put the four numbers into the above pragma and the compiler will ignore them.
It’s good practice to do a restore afterwards, though. Warnings are there for a reason, so while you want to suppress them where you’re making a deliberate choice, you do want them to appear when you’re not doing that.
It works! My code was CS0414 so I had to change the number at the end, but it works just like I wanted!
Oh yeah. I wouldn’t be hiding this one if it wasn’t for the exact nature of the warning in this circumstance. And even then I’m only hiding it so I don’t wind up missing other warnings.
Indeed, that’s the ideal reason to do this kind of thing. I was mostly posting to point out that there was a “restore” option too and that people should generally use it hand in hand with their “disable” calls.