code-analysis

Proper way to define the schema for 'CustomDictionary.xml' in Visual Studio (2013)?

血红的双手。 提交于 2019-12-05 06:50:54
I'm making use of a custom dictionary ( CustomDictionary.xml ) for Code Analysis, and it is working like it should. But, I keep getting warnings that indicate to me that the XML file is not defining its XSD schema location properly: I found the XSD ( CustomDictionary.xsd ) on my machine, and I specified the scheme of its URI as type file : file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2012.0/Team%20Tools/Static%20Analysis%20Tools/Schemas/CustomDictionary.xsd With this URI, Chrome is able to locate the XSD file just fine. That said, how do I properly reference CustomDictionary

C# lock and code analysis warning CA2002

梦想与她 提交于 2019-12-05 05:09:23
In my application I have a form that starts synchronization process and for number of reasons I want to allow only one synchronization to run at a time. So I've added a static bool field to my form indicating whether sync is in progress and added a lock to set this field to true if it wasn't already set so that first thread could start synchronization but when it's running every other thread that will try to start it will terminate. My code is something like this: internal partial class SynchronizationForm : Form { private static volatile bool workInProgress; private void SynchronizationForm

Code analysis in F#

喜欢而已 提交于 2019-12-05 05:06:27
As a C# developer I've benefited from Microsoft's Code Analysis. In F# however, Code Analysis doesn't seem to be an integrated part of the development cycle. It took me a while to enable CA on an F# project, but this blog helped . Now that I have CA enabled, it seems to produce "wrong" warnings. For instance, I have a declared a record type as type Account = {Number : string} for which I expect structural equality by default. This blog demonstrates that two instances of type Acccount, for which the number is the same, should be equal. Why does the code analysis then tell me that: 'Account'

Disadvantages of using the `-Wextra` flag when compiling in GCC

我的未来我决定 提交于 2019-12-05 04:29:41
I know that one should always compile with both -Wall and -Wextra as they enable warnings and help us to understand our mistake, if any. I've read that the -Wextra compiler flag is not recommended to use because it is too verbose with a lot of false positives. I was quite surprised on reading this. So I started googling about it but I didn't get any answer as all the search results showed was "what does the -Wextra flag do?". So, my questions are In which all situations does the -Wextra flag emit uneccessary warnings? Is it possible to stop the -Wextra flag from enabling the other flags that

Warning C26454: Arithmetic overflow: '-' operation produces a negative unsigned result at compile time (io.5)

丶灬走出姿态 提交于 2019-12-05 04:18:25
问题 Code analysis: ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_HISTORY_TYPE, &CAssignHistoryDlg::OnTcnSelchangeTabHistoryType) Warning C26454: Arithmetic overflow: '-' operation produces a negative unsigned result at compile time (io.5). The definition of TCN_SELCHANGE is: #define TCN_FIRST (0U-550U) #define TCN_SELCHANGE (TCN_FIRST - 1) I can't see what else I can do! 回答1: You are trying to subtract a larger unsigned value from a smaller unsigned value and it's causing the result to wrap past zero. In your

How do I fix PyDev “Method should have self as first parameter” errors

二次信任 提交于 2019-12-05 02:49:54
I'm developing in Python using PyDev in Eclipse, and some of my code generates errors in the code analysis tool. Specifically: class Group(object): def key(self, k): class Subkey(object): def __enter__(s): self._settings.beginGroup(k) return self def __exit__(s, type, value, tb): self._settings.endGroup() return Subkey() Gives me a "Method '__enter__- group' should have self as first parameter" error, and a similar error for __exit__ . Is there a way to solve this without assigning self to another variable and reusing the variable in the other method signatures? You could disable that error in

Accessing an implemented abstract property in the constructor causes CA2214: Do not call overridable methods in constructors

混江龙づ霸主 提交于 2019-12-05 02:36:22
public abstract class MyBase { public abstract bool MyProperty { get; protected set; } } public class MyClass : MyBase { public MyClass() { this.MyProperty = true; } public override bool MyProperty { get; protected set; } } The constructor MyClass() causes CA2214: Do not call overridable methods in constructors. This normally only shows if one calls a virtual method defined in the same class as the constructor. e.g. Accessing MyProperty inside MyBase 's constructor. Here I am calling a non-virtual overridden implementation of an inherited abstract property inside the derived class' constructor

CA1704 - Microsoft seems to be blocking the word 'Multi'?

依然范特西╮ 提交于 2019-12-05 01:12:36
public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly When I run Code Analysis, I get an error because the Microsoft does not recognize the word 'Multi' (go figure they use it in IMultiValueConverter ). So, what I did to correct this was to add a CodeAnalysisDictionary.xml file and followed the steps supplied here . However, it doesn't seem to solve the situation, I still get a Code Analysis warning message. To ensure that this isn't a bug with the recognized words section, I added another class and another exception. public class MultiSomething { } //CA1704

What is the best way to cleanup the resources used by a Crystal Reports ReportDocument object?

霸气de小男生 提交于 2019-12-05 00:52:58
I am working on an application that uses Crystal Reports for the reporting. It opens a given report in a ReportDocument object, does what it needs to do and then closes the report. using (var report = OpenReport(reportSourceInfo)) { // Do stuff with the report report.Close(); } The OpenReport method does some validation of the source file and returns an open ReportDocument object. Testing has shown that this code does what it's meant to do and appears to have no issues. The problem I'm really after advice on is when I do a code analysis (CA) build of the reporting project, I get the following

Referencing a custom code analysis rule library using a ruleset file

 ̄綄美尐妖づ 提交于 2019-12-05 00:42:49
问题 There is not much easy-to-find information regarding custom code analysis rules for Visual Studio 2010. Although this is what I have found in regards to my question... In the sample library on CodePlex it is shown how to deploy a custom code analysis rule library, which uses a Setup Project to dump the library's DLL into Program Files Folder -> Microsoft Visual Studio 10.0 -> Team Tools -> Static Analysis Tools -> FxCop -> Rules . Moreover, a very useful how-to blog post by Duke Kamstra also