suppress-warnings

Suppress a warning for all projects in Visual Studio

不想你离开。 提交于 2019-12-05 00:02:38
I've seen answers showing how to suppress a warning for a specific line of code or for a specific project. I don't want that. I want to suppress a specific warning for all of my projects. (If it matters, the warning is IDE0044. And I'm using C#.) A recent update to Visual Studio 2017 (15.7.1) has an option for this now. Under the Tools->Options menu, select the TextEditor->C#->Code Style->General tab. Under Field preferences , there is a Prefer readonly option. Set that to No . There is also an editorconfig setting you can set if you want to check this preference in along side your code, so

Add @SuppressWarnings(“unchecked”) in generics to single line generates eclipse compiler error

試著忘記壹切 提交于 2019-12-04 22:15:22
I have stumbled upon a strange behavior that I don't understand. I have to cast a String to a generic and it's producing a warning. Type safety : Unchecked cast from String to T If I add @SuppressWarnings("unchecked") above the method declaration it works fine. If I add it above the assignment it produces a compiler error in eclipse. This works fine. @SuppressWarnings("unchecked") public <T> T search(final String query){ T returnValue = null; ... if(returnValue instanceof String){ returnValue = (T) collection.getString(attrName); } This don't work fine. public <T> T search(final String query){

What's the best strategy to get rid of “warning C4267 possible loss of data”?

前提是你 提交于 2019-12-04 19:33:38
问题 I ported some legacy code from win32 to win64. Not because the win32 object size was too small for our needs, but just because win64 is more standard now and we wish to port all our environments to this format (and we also use some 3rd party libs offering better performance in 64bits than in 32bits). We end up with tons of; warning C4267: 'argument': conversion from 'size_t' to '...', possible loss of data Mainly due to code like: unsigned int size = v.size(); where v is a STL container. I

Java generics SuppressWarnings(“unchecked”) mystery

杀马特。学长 韩版系。学妹 提交于 2019-12-04 18:57:56
问题 Why does code alternative(1) compile without warnings, and code alternative(2) produce an "unchecked cast" warning? Common for both: class Foo<T> { Foo( T [] arg ) { } } Alternative (1): class Bar<T> extends Foo<T> { protected static final Object [] EMPTY_ARRAY = {}; @SuppressWarnings("unchecked") Bar() { super( (T []) EMPTY_ARRAY ); } } Alternative (2): class Bar<T> extends Foo<T> { @SuppressWarnings("unchecked") Bar() { super( (T []) EMPTY_ARRAY ); } protected static final Object [] EMPTY

Visual Studio 2010 (C++): suppress C4706 warning temporarily

こ雲淡風輕ζ 提交于 2019-12-04 17:15:16
问题 When you compile the following C++ source file in Visual Studio 2010 with warning level /W4 enabled #include <cstdio> // for printf #include <cstring> // for strcmp char str0[] = "Hello"; char str1[] = "World"; int main() { int result; if (result = strcmp(str0, str1)) // line 11 { printf("Strings are different\n"); } } you get the following warning warning C4706: assignment within conditional expression for line 11. I want to suppress this warning exactly at this place. So I tried Google and

suppress warning for generated c# code

…衆ロ難τιáo~ 提交于 2019-12-04 15:47:11
问题 I have turned on "Treat warnings as errors" for my VS project which mean that I get errors for missing documentation (nice reminder for this particular project). However, part of the code is generated by a custom tool which does not insert xml documentation so I'm looking for away to ignore the missing xml documentation for the generated code only, not for the entire project. I have no influence on the actual file generated and cannot really insert anything in the file (as it is regenerated

IntelliJ IDEA @SuppressWarnings for inspection with name of tool

情到浓时终转凉″ 提交于 2019-12-04 11:36:27
I know I can suppress warnings from IntelliJ IDEA inspections like that: @SuppressWarnings("CollectionDeclaredAsConcreteClass") public PropertiesExpander(Properties properties) { this.properties.putAll(properties); } For person from outside it may not be clear for which tool this suppression is needed. PMD uses prefixes for that: @SuppressWarnings("PMD.UnusedLocalVariable") FindBugs uses dedicated annotation: @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") Is there any way to clearly indicate that this suppression is just for IntelliJ IDEA? A way of suppressing this for

FxCop behavior in VS2010, Code Analysis, and SuppressMessage

人盡茶涼 提交于 2019-12-04 11:28:05
I have a class like this one: [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Io")] public void ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709() { } public void ParaQueFalleCalidadCodigoDosIo_ReglaCA1709() { } I use a custom Ruleset file CustomRules.ruleset <RuleSet Name="RulesNet" ToolsVersion="10.0"> <RuleHintPaths> <Path>C:\Fxcop10.0\Rules</Path> </RuleHintPaths> <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed"> <Rule Id="CA1709" Action="Warning" /> </Rules> </RuleSet

How to suppress VB's “Iteration variable shouldn't been used in lambda expression”

北城余情 提交于 2019-12-04 09:11:30
I'm working with LINQ in VB.NET and sometimes I get to a query like For i = 0 To 10 Dim num = (From n In numbers Where n Mod i = 0 Select n).First() Next and then it comes the warning " Using the iteration variable in a lambda expression may have unexpected results. Instead, create a local variable within the loop and assign it the value of the iteration variable." I know it's not a good practice to use the iteration variable in the lambda expression, because lambda expressions are evaluated only when needed. ( This question is about that) Now my question is, how to suppress this warning in

Eclipse - @SuppressWarnings(“javadoc”) does not work

烂漫一生 提交于 2019-12-04 07:20:26
I have my Eclipse configured to show warnings on missing javadoc comments and tags for public elements. That comes very usefull for me in order to keep my code well documented. But sometimes I have a class, where I have several constants describing for example states of DFA or something.. theres no need to document theese constant, because they are self-explaining.. So I added annotation @SuppressWarnings("javadoc") to the class and here's my point - Eclipse does not concider the annotation and still shows warnings on missing javadocs.. @SuppressWarnings("all") does the job, but that has side