What rule do you want fxcop / gendarme?

What specific static code verification rule do you want to add to FxCop and / or the gendarme?

Why do you need to add a rule, for example, what are the advantages, etc.?

How can your rule be implemented?

+7
fxcop static-code-analysis gendarme
source share
4 answers

Personally, I would prefer not to use IDisposable implementations in using statements.

So, if you have code like this:

 var fs = new FileStream(...); // Other code. fs.Dispose(); 

He would tell you to use it in a using .

The advantage will be that it will warn you about cases where you do not know where the objects to be removed will not be placed in a timely manner.

However, there is enough time when this is a valid situation to NOT declare IDisposable implementations in the using statement for such a rule so that it becomes very fast. Most often, this case accepts the implementation of IDisposable as a parameter of the method.

What I don't mean are class classes in which implementation details eliminate the need to call Dispose (for example, MemoryStream or DataContext ); those that implement IDisposable and should always have Dispose invoked on them, regardless of implementation details, since it is always better to code against the exposed contract.

+1
source share

I want to quickly identify and implement my rules. I tried this once for FxCop, but I found the API not very clear - and there was not too much documentation. I used FxCop 1.36, maybe everything has changed ...

So, I would like to see that FxCop has a clear and easy to use interface ... that would be great :)

The rules that I tried to implement were:

  • DocumentInternalMethods
  • DocumentInternalTypes
  • ...

Basically, I would like to enforce xml comments for non-public users.

+2
source share

I would really like the binary analysis to be smart enough to recognize the ability of the interface.

If he could determine the approximation to certain types and their members, if there are domains that can be extrapolated to the interface.

It is clear that this should not be more than a warning, since sometimes he obviously does not need an interface.

+1
source share

Thinking about this, I would also like the binary analysis to be smart enough to check for a possible lowering of access modifiers.

It should not be difficult to determine if a class, property or method can be more limited.

+1
source share

All Articles