locked
Migrating rules from 2005 to 2008 RRS feed

  • Question

  •  

    Hi.

     

    I have some custom rules that works on Visual Studio 2005. I installed VS 2008 on a box and opened my custom rules library to see what I would need to change. Some parts of the code I could find how to change but others don't. As an example, I have a Check function written this way:

     

    Code Snippet

    Public Overrides Function Check(ByVal tipo As TypeNode) As ProblemCollection

    If tipo Is Nothing Then

       Return Nothing

    End If

     

    Select Case tipo.NodeType

           Case NodeType.Struct

                Return Check(TryCast(tipo, Struct))

     

           Case NodeType.EnumNode

                Return Check(TryCast(tipo, EnumNode))

     

           Case NodeType.Class

                Return Check(TryCast(tipo, Microsoft.Cci.Class))

     

           Case NodeType.Module

                Return Check(TryCast(tipo, Microsoft.Cci.Interface))

    End Select

     

    Return MyBase.Check(tipo)

    End Function

     

     

    I receive several erros on Microsoft.Cci and could not find how to change that.

     

    Another point of error is the LocalList element. Where is it? What element replaced it?

     

    As a suggestion, a topic covering the changes between the 2005 and 2008 versions would help us to solve these problems more quickly.

     

    Regards,

    Rinaldo

    Wednesday, June 4, 2008 9:32 PM

Answers

  • The Microsoft.Cci namespace has merged into the Microsoft.FxCop.Sdk namespace. You should replace all references to the Microsoft.Cci namespace with Microsoft.FxCop.Sdk.

     

    Look at the Method.Locals property for the LocalsCollection.

     

    -Todd

     

    Wednesday, June 4, 2008 10:28 PM
    Moderator
  •  

    Hello Rinaldo,

     

    Can you give more information on what you try to do? Usually, you don't need to do any convert.

     

    For example:

     

    public override ProblemCollection Check(Member member)
    {
      Method methd = member as Method;
      if (methd != null)
      {
        VisitStatements(methd.Body.Statements);
      }
      return this.Problems;
    }

     

    With thanks,

    Haiying

    Friday, June 27, 2008 9:21 PM

All replies

  • The Microsoft.Cci namespace has merged into the Microsoft.FxCop.Sdk namespace. You should replace all references to the Microsoft.Cci namespace with Microsoft.FxCop.Sdk.

     

    Look at the Method.Locals property for the LocalsCollection.

     

    -Todd

     

    Wednesday, June 4, 2008 10:28 PM
    Moderator
  • Hi Todd,

     

    thanks for your answer. I have another one... I make use of RuleUtilities.GetMethod that also is gone. So how can I convert a MethodInfo object to a Method? When using GetMethod it was easy but is there a way to convert it now?

     

    Regards,

     

    Rinaldo

    Thursday, June 5, 2008 8:48 PM
  •  

    Hello Rinaldo,

     

    Can you give more information on what you try to do? Usually, you don't need to do any convert.

     

    For example:

     

    public override ProblemCollection Check(Member member)
    {
      Method methd = member as Method;
      if (methd != null)
      {
        VisitStatements(methd.Body.Statements);
      }
      return this.Problems;
    }

     

    With thanks,

    Haiying

    Friday, June 27, 2008 9:21 PM