The following code is giving me this code analysis error
CA2000 : Microsoft.Reliability : In method 'SessionSummary.SessionSummary_Load(object, EventArgs)', call System.IDisposable.Dispose on object 'entities' before all references to it are out of scope.
I am using a 'using' statement, so I am surprised on this:
private v...
UPDATE
I reflected Microsoft.Cci.dll and build my rule. It works fine. However, I am facing some problem which I put here with all the details. Source code is here. I didn't want to increase the length of this question by putting all the details.
I am trying to write a code analysis rule which would raise warnings for methods having
m...
I'm writing a custom rule to verify the constructor of any control type calls initialize component.
But when I hit these 2 edge cases:
public Form1(int? testInt,bool testBool,bool testBool2)
: this(false)
{
Action init = ( ) => InitializeComponent( );
init();
}
public Form1(int? testInt, bool testBoo...
I'm hoping there is someway built into VS2010 to have custom rules involving preprocessor usage, and source-level style/member ordering.
Does it do source level, or catch preprocessor calls?
...
Is there a tool that calculates various LOC statistics? It would have to support popular languages like C++, C#, Python, PHP, JavaScript, ActionScript, etc and interpret code accordingly.
An example of the statistics I'm looking for:
350 Physical lines of code -- including braces
200 Logical lines of code -- actual code
190 Comment li...
I'm thinking of trying the following ideas:
System.IO
Package.GetGlobalService(typeof(EnvDTE.DTE))
public override Microsoft.FxCop.Sdk.ProblemCollection Check(Microsoft.FxCop.Sdk.Resource resource), while blocking on the thread that does Check(TypeNode type) until the resource reading completes.
Anyone know if any of these will be re...
I would like to validate our code and check if every Thread that we execute runs in try catch block.
A valid sample:
Thread loadDataThread = new Thread(new ThreadStart(LoadData));
public void LoadData()
{
try {/*do something*/}
catch(Exception ex) { /*Handle exception*/ }
}
Not valid sample:
Thread loadDataThread = new Thread(...
I'm maintaining/developing a platform for homework testing. It's mostly automatic. What I need to add now is code analysis. I need to check the code for specific constructs.
For example:
Does the file main.cpp contain a
class named user with a const method
get_name()?
Is there some tool out there that would allow me to do suc...
What is the simplest way to identify if a given method is reading or writing a member variable or property?
I am writing a tool to assist in an RPC system, in which access to remote objects is expensive. Being able to detect if a given object is not used in a method could allow us to avoid serializing its state. Doing it on source code ...
Hi there,
I have a small issue with the Code Analysis in Visual Studio 2010. I'm running an English version of Windows 7 with Visual Studio 2010 Premium (English version) and Code Analysis. The region, location, number format etc in Windows 7 are set to Switzerland (German).
If I use Code Analysis the messages are displayed in English....
I'd like to somehow create some kind of class that can read a source code file(ie java) and from that extract the method names, the method source-code, the methods description comment and such.
Is this possible in any simple way? I'd also like to avoid complicated parsers and such.
Is regexp any good for this?
Programming language = ja...
Consider the following code :
public class RandomClass
{
private readonly string randomString;
public RandomClass(string randomParameter)
{
Contract.Requires(randomParameter != null);
Contract.Ensures(this.randomString != null);
this.randomString = randomParameter;
}
public string R...
I use Visual Studio 2010 Premium Code Analysis (CA) capabilities and force them at every compile with my projects while also showing warnings as errors, so I keep my code nice and well... better.
But.
Since this CA is very nice and all I wouldn't want to use StyleCop as well. Because StyleCop gives me code style specification that CA d...
Source code analysis and exploration tools for C and C++ seem to be sorely lacking.
Are there any tools which I can use to gather information about C and/or C++ source files? cscope does part of what I would need, Doxygen looks closer.
At a minimum list of all function, callers, callees, variable references etc.
Perhaps Doxygen's xml ...
Hi,
I was looking for some kind of a solution for software development teams which spend too much time handling unit test regression problems (about 30% of the time in my case!!!), i.e., dealing with unit tests which fails on a day to day basis.
Following is one solution I'm familiar with, which analyzes which of the latest code change...
Hi,
I just downloaded a trial version of NDepend. What I'm looking for is a tool that helps in standardization of code. Not only in style of braces, spaces, naming conventions, etc, but also in cohesion & complexity.
Is anybody using it that can tell me if I can integrate cohesion & complexity into the build errors (in example, if comp...
I'm working my way through the online MIT lectures for the classic 6.001 course: The Structure and Interpretation of Computer Programs.
I'm trying to gain an understanding of analyzing code complexity in terms of memory usage vs. execution time. In the first few lectures, they present a solution in Scheme for the Fibonacci Series.
...
How do you determine what the cycle cost is for a given C library function?
Specifically, how expensive is it to call sqrt()?
I should clarify here, I'm just looking for a general idea of the cost associated with calling certain C library functions. I'm assuming that professional C programmers just have a basic idea of function cost f...
Hello,
I would like to manually run code analysis for an entire solution, not on building the project, and not using FXCop, if possible. I did enable CA on build but it really, really slowed down the build process, and we can't have that. But it seems weird to me that code analysis can only be run per project manually through the menu...
Try as I might to keep [SuppressMessage]s to a minimum in the codebase, new ones continue to get introduced. I would like some way to say in the code "I've reviewed this [SuppressMessage] and it is 'acceptable'".
One thought was to create my own My.CodeAnalysis.SuppressMessageAttribute class which inherits from System.Diagnostics.CodeA...