Search Amazon:

Page 6 of 10               << Previous  1  2  3  4  5  6  7  8  9  10  Next >>

 

Custom FxCop Rule - Do not use MSFlexGrid Interop

All of the older VB6 and even VB5 ActiveX controls can be used in VB.NET. To use these older COM controls, .NET uses the interoperability layer and creates an interop dll. If you add an older control, such as the MS FlexGrid in this example, to a VB.NET application and compile it, you will see an Interop.MSFlexGrid.dll in the bin folder. To spot a reference to an older component in FxCop, look at the list of referenced assemblies.

C# code for custom FxCop rule:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Cci;
using Microsoft.FxCop.Sdk;
using Microsoft.FxCop.Sdk.Introspection;

public class DoNotUseMSFlexGridInterop : BaseMigrationIntrospectionRule
{
    public DoNotUseMSFlexGridInterop()
        : base("DoNotUseMSFlexGridInterop")
    {
    }
    public override ProblemCollection Check(Module module)
    {
        if (module == null)
            return base.Check(module);

        AssemblyReferenceList asmRefList = module.AssemblyReferences;
        foreach (AssemblyReference asmReference in asmRefList)
        {
            if (asmReference.Name.ToUpper().Contains("MSFLEXGRIDLIB"))
            {
                base.Problems.Add(new Problem(GetResolution(module.Name), module));
            }
        }

        return base.Problems;
    }
}

Rule definition in the XML rules file:

<Rule TypeName="DoNotUseMSFlexGridInterop" 
          Category="VBMigration" CheckId="AA1001">
    <Name>
        Do not use 'Interop.MSFlexGridLib' namespace
    </Name>
    <Description>
        Avoid dependency on the COM Interop for the older MSFlexGrid
    </Description>
    <Url>
        http://www.thescarms.com/
    </Url>
    <Resolution>
        '{0}' has imported the namespace 'Interop.MSFlexGridLib'. 
         Replace the Microsoft FlexGrid 6.0 with equivalent .NET control.
    </Resolution>
    <MessageLevel Certainty="99">
        Warning
    </MessageLevel>
    <FixCategories>
        NonBreaking
    </FixCategories>
    <Owner />
<Rule>

 

Page 6 of 10               << Previous  1  2  3  4  5  6  7  8  9  10  Next >>

Sign In
  User Id 
  Password 


Submit Your Own Code and Articles




About TheScarms
About TheScarms

Ask me your programming questions

I read every email and answer all I can.

User Feedback: Comments: 1 Items to Show:     

     
Id:  1 Posted:  5/6/2007 4:42:06 PM By:  PSMACCHIA
With the CQL language provided with NDepend, coding this rule is as simple as:

WARN IF Count > 0 IN SELECT ASSEMBLIES WHERE NameLike "MSFlexGrid"

http://www.NDepend.com
 
You must log in to post feedback.
Comment:    
 

If you use this code, please mention "www.TheScarms.com"

Email this page


TheScarms AppSentinel lets you securely copy protect and create evaluation versions of your software

TheScarms(tm) AppSentinel lets you quickly and easily create evaluation versions of your software and stop unauthorized copying and unregistered use of your programs!

Get your free
trial copy today!


      The World's Number 1 Web Host

© Copyright 2008 TheScarms