On Dec 25, 2008, at 6:50 AM, Cedric Vivier wrote:

> +     /// <summary>
> +     /// This rule checks that disposable locals are always disposed  
> before the method returns.
> +     /// Use 'using' statement (or a try/finally block) to guarantee  
> local disposal even
> +     /// in the event an uncatched exception occurs.

"This rule checks that disposable locals are always disposed OF before  
the method returns. Use A 'using' statement (or a try/finally block)  
to guarantee local disposal even in the event an UNCAUGHT exception  
occurs." would be a bit better.
>
>
> +     [Solution ("Use 'using' statement or surround the local's usage  
> with a try/finally block.")]

"Use A 'using' statement or surround the local's usage with a try/ 
finally block."
>
> +     public class EnsureLocalDisposalRule : Rule, IMethodRule {

Should probably be sealed.
>
> +             static bool IsDispose (MethodReference call)
> +             {
> +                     if (!call.HasThis)
> +                             return false;
> +                     return MethodSignatures.Dispose.Matches (call) ||  
> MethodSignatures.DisposeExplicit.Matches (call);
> +             }

If the method's declaring type implements IDisposable you should  
probably treat a call to Close as a call to Dispose.
>
> +             public RuleResult CheckMethod (MethodDefinition method)
> +             {
> +                     if (!method.HasBody || method.IsGeneratedCode ())
> +                             return RuleResult.DoesNotApply;

method.IsGeneratedCode returns true for delegate methods so unless you  
have seen a problem with checking generated methods I don't think you  
should skip them.

   -- Jesse

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Gendarme" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/gendarme?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to