Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does VB.Net have an equivalent to #pragma warning disable/restore?

I've found a way to disable warnings for an entire VB.NET project, but that is very undesirable. I would like to disable a certain warning for the scope of one method at most. A line-by-line disable and restore would be better. For example, C# has #pragma warning disable (and restore). Does VB.NET have anything like this?

like image 508
default.kramer Avatar asked Oct 13 '15 18:10

default.kramer


2 Answers

If you are using Visual Studio 2015, the answer is yes, yes it does. The syntax is #Disable Warning BC40000 and #Enable Warning BC40000

https://github.com/dotnet/roslyn/wiki/Languages-features-in-C%23-6-and-VB-14

like image 84
jmoreno Avatar answered Oct 11 '22 10:10

jmoreno


Unfortunately the answer is no, the VB.NET compiler doesn't support suppression of warnings in such a manner. You would have to re-factor your VB.NET code or look at some other alternative like writing some of the code in C#.

like image 38
Don Avatar answered Oct 11 '22 12:10

Don