Click here to Skip to main content
15,881,812 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.5K   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.
<Window x:Class="ToDoSample.Application.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:infra="clr-namespace:ToDoSample.Application.Infrastructure"
    Title="ToDo Sample Application" Height="365" Width="566"
		Loaded="WindowLoaded"
		x:Name="this"
		DataContext="{Binding ElementName=this}"
    >
    <Window.Resources>
        <infra:DateTimeFormatConverter x:Key="datetimeFormatter" />
    </Window.Resources>
    <Grid>
        <Border VerticalAlignment="Top" BorderThickness="8">
            <WrapPanel Margin="0,0,0,0" VerticalAlignment="Top">
                <Label>Select a family member :</Label>
                <ComboBox Height="23" Name="userlistComboBox" Width="120" ItemsSource="{Binding AllUsers}" SelectedItem="{Binding CurrentUser}" SelectionChanged="UserSelected">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </WrapPanel>
        </Border>
        <Border Margin="0,47,0,0" BorderThickness="8" Height="172" VerticalAlignment="Top">
            <Canvas Margin="0,0,0,0">
                <Label>ToDo items:</Label>
                <ListBox Canvas.Left="0" Canvas.Top="23" Width="528" Height="98" Margin="0,0,0,0" Name="todoListBox" ItemsSource="{Binding ToDoItems}" SelectionChanged="ToDoItemSelected">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="80" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="{Binding Path=DueDate, Converter={StaticResource datetimeFormatter}, ConverterParameter='dd-MM-yyyy'}" />
                                <TextBlock Grid.Column="1" Text="{Binding Text}" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <Button Canvas.Left="372" Canvas.Top="127" Height="23" Name="markDoneButton" Width="75" Click="MarkDoneClicked">Mark done</Button>
                <Button Canvas.Left="453" Canvas.Top="127" Height="23" Name="deleteButton" Width="75" Click="DeleteClicked">Delete</Button>
            </Canvas>
        </Border>
        <Border BorderThickness="8" Margin="0,225,0,0" Height="103" VerticalAlignment="Top">
            <Grid Margin="0,0,0,0">
                <Label Height="25" HorizontalAlignment="Left" VerticalAlignment="Top" Width="106">Description :</Label>
                <TextBox Height="23" Margin="112,2,0,0" Name="textBox1" VerticalAlignment="Top" Text="{Binding CurrentToDoItem.Text}" />
                <Label Margin="0,29,0,0" HorizontalAlignment="Left" Width="106" Height="25" VerticalAlignment="Top">Due data :</Label>
                <TextBox Margin="112,31,0,0" Name="textBox2" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Text="{Binding Path=CurrentToDoItem.DueDate, Converter={StaticResource datetimeFormatter}, ConverterParameter='dd-MM-yyyy'}"  />
                <Button Height="23" HorizontalAlignment="Right" Name="saveButton" VerticalAlignment="Bottom" Width="75" Click="SaveClicked" Margin="0,0,0,6">Save</Button>
                <Button Height="23" Name="createNewToDoItemButton" Width="75" HorizontalAlignment="Right" Margin="0,0,81,6" VerticalAlignment="Bottom" Click="CreateNewToDoItemClicked">New</Button>
            </Grid>
        </Border>
    </Grid>
</Window>

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