Browse Source

Added a Status Bar which shows a number of nodes (namespaces, types and so on).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6280 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Tomáš Linhart 15 years ago
parent
commit
8b44d44532
  1. 2
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln
  2. 138
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  3. 1
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  4. 159
      src/AddIns/Analysis/CodeQuality/Src/Module.cs

2
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.6218
# SharpDevelop 4.0.0.6261
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"

138
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml

@ -5,7 +5,9 @@ @@ -5,7 +5,9 @@
xmlns:GraphSharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:Graph="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
xmlns:src="clr-namespace:ICSharpCode.CodeQualityAnalysis"
xmlns:debug="clr-namespace:System.Diagnostics;assembly=System"
Title="Code Quality Analysis"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
x:Name="root">
<Window.Resources>
<ResourceDictionary>
@ -49,50 +51,94 @@ @@ -49,50 +51,94 @@
</ResourceDictionary>
</Window.Resources>
<TabControl>
<TabItem Header="Dependency Graph">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250px" />
<ColumnDefinition />
<ColumnDefinition Width="200px" />
</Grid.ColumnDefinitions>
<ToolBarTray Background="White" Grid.Row="0" Grid.ColumnSpan="2">
<ToolBar>
<Button Name="btnOpenAssembly" Click="btnOpenAssembly_Click" Margin="0 0 5 0">Open Assembly</Button>
<Button Name="btnRelayout" Click="btnRelayout_Click" Margin="0 0 5 0">Relayout</Button>
<Button Name="btnContinueLayout" Click="btnContinueLayout_Click" Margin="0 0 5 0">Continue Layout</Button>
<Button Name="btnResetGraph" Click="btnResetGraph_Click" Margin="0 0 5 0">Reset Graph</Button>
<Button Name="btnSaveImageGraph" Click="btnSaveImageGraph_Click">Save an Image of Graph</Button>
</ToolBar>
</ToolBarTray>
<TreeView Name="definitionTree" Grid.Row="1" Grid.Column="0"
SelectedItemChanged="definitionTree_SelectedItemChanged"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ModuleTemplate}">
</TreeView>
<Controls:ZoomControl Grid.Row="1" Grid.Column="1" Name="zoom" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
<Graph:DependencyGraphLayout x:Name="graphLayout"
LayoutAlgorithmType="LinLog"
OverlapRemovalAlgorithmType="FSA"
HighlightAlgorithmType="Simple"
VertexClick="graphLayout_VertexClick"
/>
</Controls:ZoomControl>
<TextBlock Name="txbTypeInfo" Grid.Column="3" Grid.Row="1"/>
</Grid>
</TabItem>
<TabItem Header="Dependency Matrix">
<Graph:TreeMatrixControl x:Name="matrixControl"></Graph:TreeMatrixControl>
</TabItem>
</TabControl>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TabControl Grid.Row="0">
<TabItem Header="Dependency Graph">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250px" />
<ColumnDefinition />
<ColumnDefinition Width="200px" />
</Grid.ColumnDefinitions>
<ToolBarTray Background="White" Grid.Row="0" Grid.ColumnSpan="2">
<ToolBar>
<Button Name="btnOpenAssembly" Click="btnOpenAssembly_Click" Margin="0 0 5 0">Open Assembly</Button>
<Button Name="btnRelayout" Click="btnRelayout_Click" Margin="0 0 5 0">Relayout</Button>
<Button Name="btnContinueLayout" Click="btnContinueLayout_Click" Margin="0 0 5 0">Continue Layout</Button>
<Button Name="btnResetGraph" Click="btnResetGraph_Click" Margin="0 0 5 0">Reset Graph</Button>
<Button Name="btnSaveImageGraph" Click="btnSaveImageGraph_Click">Save an Image of Graph</Button>
</ToolBar>
</ToolBarTray>
<TreeView Name="definitionTree" Grid.Row="1" Grid.Column="0"
SelectedItemChanged="definitionTree_SelectedItemChanged"
ItemsSource="{Binding}"
DataContext="{Binding Path=MetricsReader.Modules}"
ItemTemplate="{StaticResource ModuleTemplate}">
</TreeView>
<Controls:ZoomControl Grid.Row="1" Grid.Column="1" Name="zoom" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
<Graph:DependencyGraphLayout x:Name="graphLayout"
LayoutAlgorithmType="LinLog"
OverlapRemovalAlgorithmType="FSA"
HighlightAlgorithmType="Simple"
VertexClick="graphLayout_VertexClick"
/>
</Controls:ZoomControl>
<TextBlock Name="txbTypeInfo" Grid.Column="3" Grid.Row="1"/>
</Grid>
</TabItem>
<TabItem Header="Dependency Matrix">
<Graph:TreeMatrixControl x:Name="matrixControl"></Graph:TreeMatrixControl>
</TabItem>
</TabControl>
<StatusBar Grid.Row="1">
<StatusBarItem HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Namespaces: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.Namespaces.Count}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Types: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.TypesCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Methods: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.MethodsCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Fields: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.FieldsCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="IL instructions: " />
<TextBlock Text="TBD" />
</StackPanel>
</StatusBarItem>
</StackPanel>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>

1
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs

@ -74,7 +74,6 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -74,7 +74,6 @@ namespace ICSharpCode.CodeQualityAnalysis
definitionTree.Items.Clear();
MetricsReader = new MetricsReader(fileDialog.FileName);
definitionTree.ItemsSource = metricsReader.Modules;
FillMatrix();
}

159
src/AddIns/Analysis/CodeQuality/Src/Module.cs

@ -9,86 +9,107 @@ using QuickGraph; @@ -9,86 +9,107 @@ using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Module : IDependency, INode
{
private DependencyGraph _graphCache;
/// <summary>
/// Namespaces within module
/// </summary>
public ISet<Namespace> Namespaces { get; private set; }
public class Module : IDependency, INode
{
private DependencyGraph _graphCache;
/// <summary>
/// Namespaces within module
/// </summary>
public ISet<Namespace> Namespaces { get; private set; }
/// <summary>
/// Name of module
/// </summary>
public string Name { get; set; }
/// <summary>
/// Name of module
/// </summary>
public string Name { get; set; }
public Module()
{
Namespaces = new HashSet<Namespace>();
public Module()
{
Namespaces = new HashSet<Namespace>();
Dependency = this;
}
Dependency = this;
}
public DependencyGraph BuildDependencyGraph()
{
if (_graphCache != null)
return _graphCache;
public DependencyGraph BuildDependencyGraph()
{
if (_graphCache != null)
return _graphCache;
var g = new DependencyGraph();
var g = new DependencyGraph();
foreach (var ns in Namespaces)
{
g.AddVertex(new DependencyVertex(ns));
}
foreach (var ns in Namespaces)
{
g.AddVertex(new DependencyVertex(ns));
}
foreach (var ns in Namespaces)
{
foreach (var type in ns.Types)
{
var types = type.GetUses();
foreach (var ns in Namespaces)
{
foreach (var type in ns.Types)
{
var types = type.GetUses();
foreach (var dependType in types)
{
if (dependType != type && dependType.Namespace.Module == type.Namespace.Module)
g.AddEdge(new DependencyEdge(new DependencyVertex(type.Namespace),
new DependencyVertex(dependType.Namespace)));
}
}
}
foreach (var dependType in types)
{
if (dependType != type && dependType.Namespace.Module == type.Namespace.Module)
g.AddEdge(new DependencyEdge(new DependencyVertex(type.Namespace),
new DependencyVertex(dependType.Namespace)));
}
}
}
_graphCache = g;
return g;
}
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
_graphCache = g;
return g;
}
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
public override string ToString()
{
return Name;
}
public override string ToString()
{
return Name;
}
public IDependency Dependency { get; set; }
public IDependency Dependency { get; set; }
public int MethodsCount
{
get {
return Namespaces.Sum(ns => ns.Types.Sum(type => type.Methods.Count));
}
}
public int FieldsCount
{
get {
return Namespaces.Sum(ns => ns.Types.Sum(type => type.Fields.Count));
}
}
public int TypesCount
{
get {
return Namespaces.Sum(ns => ns.Types.Count);
}
}
public string GetInfo()
{
var builder = new StringBuilder();
builder.AppendLine("Module Summary");
builder.Append(Environment.NewLine);
builder.AppendLine(String.Format("Name: {0}", Name));
builder.AppendLine(String.Format("Methods: {0}", Namespaces.Sum(ns => ns.Types.Sum(type => type.Methods.Count))));
builder.AppendLine(String.Format("Fields: {0}", Namespaces.Sum(ns => ns.Types.Sum(type => type.Fields.Count))));
builder.AppendLine(String.Format("Types: {0}", Namespaces.Sum(ns => ns.Types.Count)));
builder.AppendLine(String.Format("Namespaces: {0}", Namespaces.Count));
// more to come
public string GetInfo()
{
var builder = new StringBuilder();
builder.AppendLine("Module Summary");
builder.Append(Environment.NewLine);
builder.AppendLine(String.Format("Name: {0}", Name));
builder.AppendLine(String.Format("Methods: {0}", MethodsCount));
builder.AppendLine(String.Format("Fields: {0}", FieldsCount));
builder.AppendLine(String.Format("Types: {0}", TypesCount));
builder.AppendLine(String.Format("Namespaces: {0}", Namespaces.Count));
// more to come
return builder.ToString();
}
public BitmapSource Icon { get { return NodeIconService.GetIcon(this); } }
}
return builder.ToString();
}
public BitmapSource Icon { get { return NodeIconService.GetIcon(this); } }
}
}

Loading…
Cancel
Save