What definable static code checking rule do you wish to see added to FxCop and/or Gendarme?
Why to do you wish to see the rule added, e.g what are the benefits etc?
How could your rule be implemented?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Personally, I would prefer to see not using
IDisposableimplementations inusingstatements.So if you had code like this:
It would tell you to use it in a
usingstatement.The benefit would be that it would alert you to cases you might not be aware of where objects that should be disposed are not being disposed in a timely manner.
However, there are enough times where it’s a valid situation to NOT declare
IDisposableimplementations in a using statement for a rule like this to become a pain very quickly. Most often, this case is taking anIDisposableimplementation as a parameter to a method.What I do not mean is usages of classes where the implementation details remove the need for calling
Dispose, (e.g.MemoryStreamorDataContext); those implementIDisposableand should always haveDisposecalled on them, regardless of the implementation details, as it is always better to code against the contract exposed.