Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

Static Code Analysis

Rate me:
Please Sign up or sign in to vote.
4.97/5 (34 votes)
15 Mar 2010CPOL16 min read 85.8K   1.1K   63  
A static code analyzer building method call networks + sample applications
This article describes the operation of a method-based static code analyzer for .NET that constructs in-memory method call networks of compiled assemblies. You will also see a concrete application of static code analysis to generate a website providing easy insights on a sample application.
<?xml version="1.0"?>
<doc>
    <assembly>
        <name>Arebis.CodeAnalysis.Static</name>
    </assembly>
    <members>
        <member name="T:Arebis.CodeAnalysis.Static.StaticCodeAnalyzer">
            <summary>
            A StaticCodeAnalyzer constructs a codemodel containing an 
            in-memory method call networks for code analysis.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzer.Process(Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession)">
            <summary>
            Process the given session and return a codemodel containing
            the in-memory method call network.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.ModelMethod">
            <summary>
            A method node in a network of method calls.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.ModelMethod.HasAnyOfTags(System.Object[])">
            <summary>
            Whether this method has at least one of the given tags.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.ModelMethod.GetAllCallsMethods">
            <summary>
            Get all methods called by this one, directly and indirectly.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.ModelMethod.GetAllCalledByMethods">
            <summary>
            Get all methods that call this one directly or indirectly.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.ModelMethod.PathsTo(Arebis.CodeAnalysis.Static.ModelMethod)">
            <summary>
            The list of paths from this method to the given called target method.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.ModelMethod.Equals(System.Object)">
            <summary>
            Compares whether two ModelMethod objects reference the same CLR method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.Name">
            <summary>
            Name of the method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.DeclaringType">
            <summary>
            Declaring type of the method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.Signature">
            <summary>
            Signature of the method expressed in it's LanguageInfo, excluding parameter names.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.SignatureWithParamNames">
            <summary>
            Signature of the method expressed in it's LanguageInfo, including parameter names.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.Tags">
            <summary>
            Tags of the method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.MethodBase">
            <summary>
            MethodBase object.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.BaseMethodDefinition">
            <summary>
            The base definition of the method (the first declaration of a virtual method).
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.CallsMethods">
            <summary>
            The methods this method calls.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.CalledByMethods">
            <summary>
            The methods that call this method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsConstructor">
            <summary>
            Whether the method is an instance constructor method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsStaticConstructor">
            <summary>
            Whether the method is a static constructor method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsOverride">
            <summary>
            Whether this method is an override.
            The base method can then be retrieved using the BaseMethodDefinition property.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsAccessor">
            <summary>
            Whether the method is an accessor method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsGetAccessor">
            <summary>
            Whether the method is a get accessor method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsSetAccessor">
            <summary>
            Whether the method is a set accessor method.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsOperator">
            <summary>
            Whether the method is an operator overload.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsAnonymous">
            <summary>
            Whether the method is an anonymous delegate.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsPublic">
            <summary>
            Whether this method is public.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsStatic">
            <summary>
            Whether this method is static.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.ModelMethod.IsVirtual">
            <summary>
            Whether this method is virtual.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.ModelMethod.MethodCallsList">
            <summary>
            Represents a list of directly called methods.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.Rules.BaseMatchingRule">
            <summary>
            Base class for implementing RuleProcessor matching rules.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.Processors.Rules.BaseMatchingRule.Initialize(System.Xml.XmlNode)">
            <summary>
            Initializes the rule instance with it's XML definition.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.Processors.Rules.BaseMatchingRule.Matches(Arebis.CodeAnalysis.Static.ModelMethod)">
            <summary>
            Whether the given method positively matches this rule.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.Processors.Rules.BaseMatchingRule.Context">
            <summary>
            The context the rule runs in.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.CodeModel">
            <summary>
            A model of the analyzed code.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.DefaultMethodProcessor">
            <summary>
            Processor connects the methods tagged with "defaultmethod"
            to their constructors.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.VirtualMethodProcessor">
            <summary>
            A processor that connects overriding methods to
            their base methods having the "baseimplementation" tag.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.Rules.RuleRunContext">
            <summary>
            Represents the context of a processing run. Allows processor and
            processor component instances to share data for a processing session.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.LeafMethodProcessor">
            <summary>
            Processor breaking connection of methods tagged with "leafmethod"
            to calling methods.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.SpecialMethodsProcessor">
            <summary>
            Processor that tags special methods as constructors, 
            operator overloads and property accessor methods.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.Processors.Rules.NameMatchingRule.GetLikeRegex(System.String,System.Text.RegularExpressions.RegexOptions)">
            <summary>
            Returns a RegEx to match the given pattern with wildcards * and ?.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.Rules.CodeModelMatchingRuleAttribute">
            <summary>
            Marks a class as a CodeModelMatchingRule (the class must also inherit from BaseMatchingRule),
            defines the element name of the rule and documentation of the rule.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.MethodListExtensions">
            <summary>
            Extension methods for handling lists of Method objects.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.MethodListExtensions.ForMethodBase(System.Collections.Generic.IEnumerable{Arebis.CodeAnalysis.Static.ModelMethod},System.Reflection.MethodBase)">
            <summary>
            Returns the Method for the given MethodBase.
            Returns null if not found.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.MethodListExtensions.WhereDeclaringTypeIs(System.Collections.Generic.IEnumerable{Arebis.CodeAnalysis.Static.ModelMethod},System.Type)">
            <summary>
            Returns methods on given declaring type.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.MethodListExtensions.WhereTagsContains(System.Collections.Generic.IEnumerable{Arebis.CodeAnalysis.Static.ModelMethod},System.String)">
            <summary>
            Returns methods with given tag.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.Processors.DefaultImplementationProcessor">
            <summary>
            Processor that connects methods tagged with "defaultimplementation"
            to their interface declaration.
            </summary>
        </member>
        <member name="T:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession">
            <summary>
            A StaticCodeAnalyzerSession represents a session processable
            by a StaticCodeAnalyzer.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.#ctor">
            <summary>
            Constructs a blank session.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.#ctor(System.String)">
            <summary>
            Constructs a session given a definition file.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.#ctor(System.Xml.XmlDocument)">
            <summary>
            Constructs a session given a definition.
            </summary>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.AddAssembly(System.Reflection.Assembly)">
            <summary>
            Adds the given assembly to the analyzer session.
            </summary>
            <param name="asm">The assembly to add.</param>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.AddAssembly(System.Reflection.Assembly,System.Boolean)">
            <summary>
            Adds the given assembly to the analyzer session.
            </summary>
            <param name="asm">The assembly to add.</param>
            <param name="includeReferencedAssemblies">Whether all referenced assemblies
            of the given assembly must be added recursively.</param>
        </member>
        <member name="M:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.AddProcessor(Arebis.CodeAnalysis.Static.IProcessor)">
            <summary>
            Adds the given processor to the analyzer session.
            </summary>
            <param name="processor"></param>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.LanguageInfo">
            <summary>
            Language information associated with this analyzer session.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.AnalyzerFilter">
            <summary>
            Filter that can determine to skip processing of
            assemblies/types/methods.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.Assemblies">
            <summary>
            Assemblies loaded in this analyzer session.
            </summary>
        </member>
        <member name="P:Arebis.CodeAnalysis.Static.StaticCodeAnalyzerSession.Processors">
            <summary>
            Processors registered in this analyzer session.
            </summary>
        </member>
    </members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect AREBIS
Belgium Belgium
Senior Software Architect and independent consultant.

Comments and Discussions