Kilitli FxCop Custom rule for bool variables

  • 29 Şubat 2012 Çarşamba 12:55
     
     

    Hi

    Im writing a FxCop custom rule for identifying the prefix for a bool variable.

    It works fine for many cases, but fails for few lines like below

    lock(data)

    {

    }

    In the above line, a default bool  name "<>s__LockTaken0" is getting created  and my rule is firing for all such variables as well

    I've used IsComplierGenerated() to check for user defined variables alone but still the above varaible is not being ignored.Its being treated as bool.

    How can I identify such variables ?

Tüm Yanıtlar

  • 29 Şubat 2012 Çarşamba 14:08
     
     Yanıt

    There is nothing in released FxCop versions that will allow you to identify such a local as compiler-generated.  You will need to rely on the name pattern (e.g.: starts with "<>s__").  If it's any consolation, there's quite a bit of this sort of thing in the FxCop framework and built-in rules as well.

    Nicole