Is it possible to disable specific compiler warnings? - visual-studio

I am trying to suppress specific compiler warnings, namely System.Data.OracleClient.OracleConnection' is obsolete. I came upon these questions here:
How to disable specific warnings for the entire solution?
Globally suppress c# compiler warnings
...but they don't seem to apply to VS2013. When I go to my project's properties, I don't see a Build tab. I see a Compile tab, but it doesn't appear to have a place to specify warning messages to suppress. I see a section there called Warning configurations, but I don't see the warning I am looking for.
Update: It turns out that I am trying to do this for VB.NET. Thanks to a link provided by the selected answer, you have to edit the project file's XML and supply the warning code in the <NoWarn></NoWarn> tag. However, you have to know the warning code which is hidden in the error list. One way to get it is to open the output window and build the project. In my case, the warnign code is 40000. It shows as BC40000, but I had to remove the BC. After rebuilding the project, the warning messages went away.

To suppress specific warnings for Visual C# or F#:
In Solution Explorer, choose the project in which you want to suppress warnings.
On the menu bar, choose View, Property Pages.
Choose the Build page.
In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons, and then rebuild the solution.
Check out here for more info on how to suppress specific warning for Visual C++ and Visual Basic.
Another ways is to use #pragma warning can enable or disable certain warnings.:
#pragma warning disable warning-list
#pragma warning restore warning-list
warning-list
A comma-separated list of warning numbers. Enter the numbers alone, without the "CS" prefix.
When no warning numbers are specified, disable disables all warnings and restore enables all warnings.

Yes, it is possible.
#pragma warning disable 'warning-number-list'
where warning-number-list is a comma separated list of warning numbers to disable, e.g. 1004
This will disable the warning from its point of declaration to the end of the current file unless re-enable with:
#pragma warning restore 'warning-number-list'.
These pragmas are placed inline in your code at the site of where you wish to disable/restore the warnings.
I believe there is also a place on the Project properties tabs to specify warnings to disable, as you mentioned.

Related

Disable storyboard warnings

I avoid getting warnings in my swift code. However when it comes to storyboard requirements it's a bit harder for me.
So for now i just want to disable xcode showing warnings regarding storyboard issues.
I have tried the following without success:
Disable show warnings option
As you have mentioned the option Show warnings under Interface Builder Storyboard Compiler -Options must be kept no, for suppressing warnings related to your storyboard.
What you missing to do
Also after that you can enable and disable this option from right bottom position of warnings tab in Issue navigator.
Example:
That way you can toggle easily.
If you just want to hide warnings for storyboard, it looks like you've done it correctly. However, you do need to restart Xcode for the updated preferences to take effect.
If that doesn't work, you can also try this:
Navigate to build settings and go to the Compile Sources phase. Double-click in the Compiler Flags column for the storyboard and enter -w to turn off all warnings for that file.

Ignore Reporting-Services Warnings in Visual Studio

I'm trying to get rid of the 'rsOverlappingReportItems'-Warnings in the Visual Studio, since we did the overlapping on purpose.
I did the usual proceeding by getting the warning-code:
SomeRDLC.rdlc : warning rsOverlappingReportItems: The text box
‘textbox236’ and the text box ‘textbox43’ overlap. Overlapping report
items are not supported in all renderers.
In this case, I just expected "rsOverlappingReportItems" to be the Code.
Then I added it on the Project under Build --> Support Warnings.
But this doesn't seem to work this way. As far as I've seen, there is no way to tell the Reporting-Services explictly to ignore this warning, but shouldn't it possible to tell that to the Compiler?
Thanks in advance.

Putting Resharper's ignored errors under version control

When I ignore specific errors in "Errors in Solution" window, Resharper remembers this setting.
I tried to reboot and restart Visual Studio, the ignored errors stayed ignored. Now I wanted to pass the ignored errors list to another programmers in the team by putting some setting file under version control. But I could not find where does Resharper store which errors are ignored.
I have the following versions of SW.
Visual Studio 2012
JetBrains ReSharper 8.2.1 Full Edition
Build 8.2.1000.4556 on 2014-05-19T10:12:38
Update:
I removed files in the following folder and the ignored errors reset, all errors became unignored.
%AppData%\..\Local\JetBrains\ReSharper\v8.2\SolutionCaches\
So it keeps the ignored errors somewhere in those files. Still I did not see the way to put it under version control.
Though not related to the exact issue of the original poster, you might have stumbled upon this question looking for the answer below :)
If you've changed the behavior of an inspection from the glyph like this and saved it to a configuration layer and set it to Do Not Show or something else and then saved it to the Team level:
Then depending on where you set the value, Computer, Solution personal or Solution Team, it's stored in a different settings file.
You can then add the Solution.sln.DotSettings file to source control to share these suppression between all team members.
To undo the supression of such warnings, you'll have to venture into the layered options structure of Resharper, which can be a little confusing if you haven't gone in there before.
Then depending on where it's saved, look under the wrench item for the selected layer:
Find the inspection and set it:
In the toolbar to the solution errors window, there should be an export button. You should be able to export all ignored items to xml or html here.

How can I disable javascript compile warnings in VS 2010?

Visual studio seems intent that my javascript code is bad, mostly because it has no knowledge of jquery or some plugins I am using. Therefore, every time I compile my product it gives me a lot of warnings, most of them are incorrect ($ is not defined, window is not defined, etc...).
I have /// <reference path="" /> tags setup in my javascript with intellisense working properly so I know these are just not real issues.
How can I disable these warnings?
edit to be clear, I need these disabled because it's causing 100+ warnings that are making me lose sight of REAL c# warnings.
I had the exact same issue you were having: 100s of incorrect errors every save. For me the issue was with Chirpy, which was a prerequisite for another extension. For whatever reason on my end, Chirpy was not in my Extension Manager so it took me a while to find.
Check and see if you have it installed. If so disable JSHint.
Tool -> Options
Chirpy -> JSHint
Uncheck: Run JS Hint
try this and let me know if it works.
Enter the options through Tools > Options.
In the tree to the left, choose Text Editor > JScript > Miscellaneous. Uncheck "Show syntax errors".
I don't have a javascript source file on the computer I'm on at the moment to test this, but you may be able to use the #pragma command to disable particular warnings:
#pragma warning disable will disable all warnings, and #pragma warning restore will restore all warnings when placed at the end of your code block. You can also tell it to disable only particular warnings, such as #pragma warning disable 0219,0168.
http://abhijitjana.net/2010/08/27/how-to-suppress-complier-warning-using-pragma-warning-directives-in-visual-studio/
Interesting I am not able to reproduce your issue in neither VS2010 "website" project nor vs2010 "web application" project. It has to do with the add-ons that you installed. Probably you may have a setting in that add-on (who ever is causing this) to disable warnings.
To me the warning sounds like the add-on (who ever is causing this) is not intelligent enough. Try the below changes and see if that helps.
If you have master page then try move the jquery*.js script reference from master page to your actual page
Move all your javascript code into a js file instead of writing it them under script tag
Thanks,
Esen
What about this one?
To disable a single compiler warning
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Compile tab.
In the Warning configurations table, set the Notification value for the warning to None.
or perhaps this one
Tools > Options > Text Editor > JScript > Misc > Show errors as warnings( uncheck only this )

Disabling and enabling warning in xcode

Is it possible to disable warnings for particular piecies of code in xcode?
I'm using a library I didn't write myself, and it creates hundreds of warnings. This makes it very unclear to find warnings related to my code. Is it possible to disable when #import-ing the headers and re-enabling warnings immediately after?
I remember this was possible in some other IDE, maybe Visual Studio, maybe with some #pragma. Anything similar in xcode?
Thanks!
Open your project in XCode, then right click on your target in the Targets folder. Select "Get Info" form the drop down menu and then scroll down to the section for the compiler warnings (GCC 4.0 Warnings on my box). Here you can disable the checkboxes for the various warnings you have active. Also check the value of "Other Warning Flags". This could include -Wall or -WMost which will enable other warnings. You can remove that and hopefully your warnings will not appear.

Resources