In Xamarin Studio, is it possible to have the compiler treat certain warnings as errors? I would like to elevate the severity of some warning so I am forced to see and deal with them. I am using the Mac version.
If your project is a normal C# project then you can select which warnings you want to be treated as errors in the Build/Compiler page in the project's properties. In the "Additional arguments" field enter:
-warnaserror:CS0123,CS3210
To make the warnings CS0123 and CS3210 be treated as errors.
Related
I installed the SonarLint extension for Visual Studio and connected successfully to our SonarQube server and successfully ran Code Analysis to display sonar issues in VS. So it was working OK but for some reason I am now no longer getting any sonar Sxxx warnings and instead now see the following 2 warnings:
> Warning CA0507 Post-build Code Analysis (FxCopCmd.exe) has been
> deprecated in favor of FxCop analyzers, which run during build. Refer
> to https://aka.ms/fxcopanalyzers to migrate to FxCop analyzers.
>
> Warning CA0064 : No analysis was performed because the
> specified rule set could not be loaded or did not contain any managed
> code analysis rules.
But I am not using FxCop and I am not aware of having done anything to turn it on.
If I check one rule inside "Managed Binary Analysis" the CA0064 warning will go away, but CA0507 remains and still no sonar Sxxx warnings.
The "Run Code Analysis" menu items only apply to the legacy FxCop rules. You don't need to use those menu items for Roslyn-based analyzers (like the C# and VB.NET rules in SonarLint) - Visual Studio will automatically trigger the analysis in the background. See the Microsoft docs for more info.
If you are not seeing Sxxx issues being reported there are a couple of things to look at:
Check whether you have the Enable full solution analysis option checked. If not, VS will only report issues in open files.
You've connected the solution to your SonarQube server so SonarLint will have generated a ruleset based on the Quality Profile. The ruleset will be in the solution-level .sonarlint folder. Check whether the rules you are expecting to report issues are enabled in the ruleset file. If not, update the Quality Profile on the server then close and re-open the solution. SonarLint will detect that the Quality Profile has changed and prompt you to update it.
Try to Compile again the project. With first compilation this errors will appear but with second compilation probably not.
No idea why, but it worked for me.
I have my visual studio 2017 display red lines under many statements although the code compile fine !! any idea why and how to fix this ?
here is a picture
hover over one of the errors:
Before actually compiling and linking the game UE4 runs its own Unreal Header Tool. It generates a great deal of extra code. Because of that Visual Studio sometimes doesn't find some of the symbols that will be available after generation. There's is a page that explains that it's normal when you work with UE4.
Also, consider this. UE4 may use a unity build so it will make a giant .cpp file out of all your source files. It may happen that all of your "false positive" errors are resolved by the order in which those source files are included. But since Visual Studio treats every source file as a separate translation unit (not unity build) it will make sure that you don't use any undefined symbols.
If squiggles bother you too much, try to include all of the headers with the necessary symbols (for example "Components/InputComponent.h") in your source file.
Is it possible to get the analyzer error to break the build, I've the rule severity to error which does flag as a red squiggle in the IDE with an accompanying intellisense error. However if possible can you raise it as a build error?
Thanks
You need to pass the analyzer to the compiler, instead of having it installed into VS as a VSIX in order for it to break the build.
I want to print all the warnings in my project built in VS2008. As has been suggested at other questions, the project properties only gives me up to /W4 level warnings when I want to enable /Wall. Below is a snapshot of properties. Is there a way to enable /Wall in VS2008 for a project?
I assume you are working with C++? In this case, you can add this flag in the "Command Line" options directly:
Notice that the output can be too verbose to be usable.
I have a visual studio project (VS2012) that just contains some configuration files. When I build I get the following warning:
CSC : warning CS2008: No source files specified [C:\Project\Config\Config.csproj]
Is there any way to disable this warning?
I experienced the same problem with VS2017 (<nowarn> attribute didn't work). Adding an empty VersionInfo.cs prevented the build warning.
Go to the project's property page in your Solution Explorer. On the build tab, you can disable the warning using its warning number.
This describes the options available there: http://msdn.microsoft.com/en-us/library/vstudio/kb4wyys2(v=vs.100).aspx
If you ever have actual code that triggers warnings, it can be disabled like so: http://msdn.microsoft.com/en-us/library/vstudio/441722ys(v=vs.120).aspx