Browse Source

Very simple Report in CQA

pull/18/head
PeterForstmeier 14 years ago
parent
commit
698bd2e873
  1. 2
      SharpDevelop.sln
  2. 1
      src/AddIns/Analysis/CodeQuality/CodeQuality.addin
  3. 9
      src/AddIns/Analysis/CodeQuality/CodeQuality.csproj
  4. 14
      src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml
  5. 23
      src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs
  6. 90
      src/AddIns/Analysis/CodeQuality/Reporting/Overview.cs
  7. 273
      src/AddIns/Analysis/CodeQuality/Reporting/Report1.srd

2
SharpDevelop.sln

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

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.2.0.8267-alpha
# SharpDevelop 4.2.0.8544-beta
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection

1
src/AddIns/Analysis/CodeQuality/CodeQuality.addin

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
<Manifest>
<Identity name = "ICSharpCode.CodeQuality"/>
<Dependency addin = "ICSharpCode.Reports.Addin" requirePreload = "true"/>
</Manifest>
<Runtime>

9
src/AddIns/Analysis/CodeQuality/CodeQuality.csproj

@ -91,6 +91,7 @@ @@ -91,6 +91,7 @@
<Compile Include="Gui\NodeDescriptionViewModel.cs" />
<Compile Include="Gui\NodeIconService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reporting\Overview.cs" />
<Compile Include="Utils\DependencyColorizer.cs" />
<Compile Include="Utils\Extensions.cs" />
<Compile Include="Utils\IColorizer.cs" />
@ -100,6 +101,9 @@ @@ -100,6 +101,9 @@
<None Include="CodeQuality.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Reporting\Report1.srd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\Mono.Cecil\Mono.Cecil.csproj">
@ -141,6 +145,10 @@ @@ -141,6 +145,10 @@
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Misc\Reports\ICSharpCode.Reports.Core\ICSharpCode.Reports.Core.csproj">
<Project>{4B2239FF-8FD6-431D-9D22-1B8049BA6917}</Project>
<Name>ICSharpCode.Reports.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Engine\Dom" />
@ -148,6 +156,7 @@ @@ -148,6 +156,7 @@
<Folder Include="Engine" />
<Folder Include="Gui\Commands" />
<Folder Include="Gui\Controls" />
<Folder Include="Reporting" />
<Folder Include="Utils" />
</ItemGroup>
<ItemGroup>

14
src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
<UserControl x:Class="ICSharpCode.CodeQuality.Gui.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:gui="clr-namespace:ICSharpCode.CodeQuality.Gui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rep="clr-namespace:ICSharpCode.Reports.Core.WpfReportViewer;assembly=ICSharpCode.Reports.Core">
<DockPanel>
<ToolBar DockPanel.Dock="Top">
<Button Click="AddAssemblyClick">Add Assembly</Button>
<!--
<Button Click="RefreshClick">Refresh</Button>
-->
<Button x:Name="print" Click="Button_Click" IsEnabled="False" >Print Overview</Button>
</ToolBar>
<TabControl>
<TabItem Header="Dependency Matrix">
@ -16,6 +16,12 @@ @@ -16,6 +16,12 @@
<gui:DependencyMatrixView Visibility="Collapsed" x:Name="matrix" />
</Grid>
</TabItem>
<TabItem Header="ReportPreview" x:Name="reportTab" IsEnabled="False">
<Grid>
<rep:WpfReportViewer x:Name="viewer" >
</rep:WpfReportViewer>
</Grid>
</TabItem>
</TabControl>
</DockPanel>
</UserControl>

23
src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs

@ -14,6 +14,8 @@ using System.Windows.Media; @@ -14,6 +14,8 @@ using System.Windows.Media;
using ICSharpCode.CodeQuality.Engine;
using ICSharpCode.CodeQuality.Engine.Dom;
using ICSharpCode.CodeQuality.Reporting;
using ICSharpCode.Reports.Core.WpfReportViewer;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32;
@ -25,13 +27,14 @@ namespace ICSharpCode.CodeQuality.Gui @@ -25,13 +27,14 @@ namespace ICSharpCode.CodeQuality.Gui
public partial class MainView : UserControl
{
AssemblyAnalyzer context;
List<string> fileNames;
public MainView()
{
InitializeComponent();
context = new AssemblyAnalyzer();
this.DataContext = context;
fileNames = new List<string>();
}
void AddAssemblyClick(object sender, RoutedEventArgs e)
@ -44,6 +47,10 @@ namespace ICSharpCode.CodeQuality.Gui @@ -44,6 +47,10 @@ namespace ICSharpCode.CodeQuality.Gui
if (fileDialog.ShowDialog() != true || fileDialog.FileNames.Length == 0)
return;
introBlock.Visibility = Visibility.Collapsed;
print.IsEnabled = true;
reportTab.IsEnabled = true;
this.fileNames.AddRange(fileDialog.FileNames);
context.AddAssemblyFiles(fileDialog.FileNames);
RefreshClick(null, null);
}
@ -55,12 +62,16 @@ namespace ICSharpCode.CodeQuality.Gui @@ -55,12 +62,16 @@ namespace ICSharpCode.CodeQuality.Gui
introBlock.Visibility = Visibility.Collapsed;
using (context.progressMonitor = AsynchronousWaitDialog.ShowWaitDialog("Analysis"))
list = context.Analyze();
Report(list);
matrix.Update(list);
matrix.Visibility = Visibility.Visible;
}
/*
*
* TreeTraversal.PreOrder(node, n => n.Children).OfType<MethodNode>().Count()
*
*
void RefreshClick(object sender, RoutedEventArgs e)
{
introBlock.Visibility = Visibility.Collapsed;
@ -86,5 +97,13 @@ namespace ICSharpCode.CodeQuality.Gui @@ -86,5 +97,13 @@ namespace ICSharpCode.CodeQuality.Gui
}
}
}
void Button_Click(object sender, RoutedEventArgs e)
{
OverviewReport o = new OverviewReport(fileNames);
var reportCreator = o.Run(list);
var previewViewModel = new PreviewViewModel(o.ReportSettings,reportCreator.Pages);
viewer.SetBinding(previewViewModel);
}
}
}

90
src/AddIns/Analysis/CodeQuality/Reporting/Overview.cs

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 13.02.2012
* Time: 19:46
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Linq;
using ICSharpCode.CodeQuality.Engine.Dom;
using ICSharpCode.Reports.Core;
using ICSharpCode.Reports.Core.Exporter.ExportRenderer;
using ICSharpCode.Reports.Core.WpfReportViewer;
using Microsoft.Win32;
namespace ICSharpCode.CodeQuality.Reporting
{
/// <summary>
/// Description of Overview.
/// </summary>
public class OverviewReport
{
List<string> fileNames;
public OverviewReport(List<string> fileNames)
{
if (fileNames.Count > 0)
{
this.fileNames = new List<string>();
this.fileNames.AddRange(fileNames);
}
}
public IReportCreator Run(ReadOnlyCollection<AssemblyNode> list)
{
var r = from c in list
select new OverviewViewModel { Node = c};
Uri uri = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase);
var fullname = uri.LocalPath;
var reportFileName = Path.GetDirectoryName(fullname) + Path.DirectorySeparatorChar + "Reporting" + Path.DirectorySeparatorChar + "Report1.srd";
var model = ReportEngine.LoadReportModel(reportFileName);
var p = new ReportParameters();
p.Parameters.Add(new BasicParameter ("param1",fileNames[0]));
ReportSettings = model.ReportSettings;
IReportCreator creator = ReportEngine.CreatePageBuilder(model,r.ToList(),p);
creator.BuildExportList();
return creator;
}
public ReportSettings ReportSettings {get;private set;}
}
internal class OverviewViewModel
{
public OverviewViewModel ()
{
}
public AssemblyNode Node {get;set;}
public string Name
{
get {return Node.Name;}
}
public int ChildCount
{
get {
return Node.Children.Count;}
}
}
}

273
src/AddIns/Analysis/CodeQuality/Reporting/Report1.srd

@ -0,0 +1,273 @@ @@ -0,0 +1,273 @@
<?xml version="1.0" encoding="utf-8"?>
<ReportModel>
<ReportSettings>
<ReportSettings>
<ReportName>Overview</ReportName>
<ReportType>DataReport</ReportType>
<BottomMargin>50</BottomMargin>
<TopMargin>50</TopMargin>
<LeftMargin>50</LeftMargin>
<RightMargin>50</RightMargin>
<PageSize>827, 1169</PageSize>
<Landscape>False</Landscape>
<GraphicsUnit>Millimeter</GraphicsUnit>
<Padding>5, 5, 5, 5</Padding>
<AvailableFieldsCollection />
<SortColumnsCollection />
<GroupColumnsCollection />
<ParameterCollection>
<BasicParameter>
<ParameterName>param1</ParameterName>
<Type>System.String</Type>
</BasicParameter>
</ParameterCollection>
<SqlParameters />
<ConnectionString />
<CommandText />
<CommandType>Text</CommandType>
<DataModel>PushData</DataModel>
<NoDataMessage>No Data for this Report</NoDataMessage>
<DefaultFont>Microsoft Sans Serif, 10pt</DefaultFont>
<UseStandardPrinter>True</UseStandardPrinter>
</ReportSettings>
</ReportSettings>
<SectionCollection>
<BaseSection>
<Location>50, 50</Location>
<Size>727, 60</Size>
<BackColor>White</BackColor>
<VisibleInReport>False</VisibleInReport>
<SectionOffset>0</SectionOffset>
<SectionMargin>0</SectionMargin>
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items>
<BaseTextItem>
<Location>130, 32</Location>
<Size>542, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>=Parameters!param1</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>ControlText</ForeColor>
<Name>Param1</Name>
</BaseTextItem>
<BaseTextItem>
<Location>18, 32</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>AssemblyAnalyzer</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>ControlText</ForeColor>
<Name>BaseTextItem2147483646</Name>
</BaseTextItem>
<BaseTextItem>
<Location>313, 5</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Microsoft Sans Serif, 10pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<DataType>System.String</DataType>
<RTL>No</RTL>
<Text>Overview Report</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<Name>Overview</Name>
</BaseTextItem>
</Items>
<FrameColor>Black</FrameColor>
<Name>ReportHeader</Name>
</BaseSection>
<BaseSection>
<Location>50, 125</Location>
<Size>727, 60</Size>
<BackColor>White</BackColor>
<VisibleInReport>False</VisibleInReport>
<SectionOffset>0</SectionOffset>
<SectionMargin>0</SectionMargin>
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items>
<BaseRowItem>
<Location>14, 16</Location>
<Size>658, 30</Size>
<BackColor>LightGray</BackColor>
<VisibleInReport>True</VisibleInReport>
<DrawBorder>False</DrawBorder>
<ForeColor>ControlText</ForeColor>
<FrameColor>Black</FrameColor>
<Items>
<BaseTextItem>
<Location>363, 7</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>Children</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>ControlText</ForeColor>
<Name>BaseTextItem2147483645</Name>
</BaseTextItem>
<BaseTextItem>
<Location>4, 7</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>Assembly:</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>ControlText</ForeColor>
<Name>BaseTextItem2147483645</Name>
</BaseTextItem>
</Items>
<AlternateBackColor />
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow>
<Name>BaseRowItem2147483646</Name>
</BaseRowItem>
</Items>
<FrameColor>Black</FrameColor>
<Name>ReportPageHeader</Name>
</BaseSection>
<BaseSection>
<Location>50, 200</Location>
<Size>727, 60</Size>
<BackColor>White</BackColor>
<VisibleInReport>False</VisibleInReport>
<SectionOffset>0</SectionOffset>
<SectionMargin>0</SectionMargin>
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items>
<BaseRowItem>
<Location>14, 14</Location>
<Size>658, 30</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<DrawBorder>False</DrawBorder>
<ForeColor>Black</ForeColor>
<FrameColor>Black</FrameColor>
<Items>
<BaseDataItem>
<Location>363, 4</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>BaseDataItem2147483645</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<ColumnName>ChildCount</ColumnName>
<Name>BaseDataItem2147483645</Name>
</BaseDataItem>
<BaseDataItem>
<Location>3, 7</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Microsoft Sans Serif, 10pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>BaseDataItem1</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<ColumnName>Name</ColumnName>
<Name>BaseDataItem1</Name>
</BaseDataItem>
</Items>
<AlternateBackColor />
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow>
<Name>BaseRowItem1</Name>
</BaseRowItem>
</Items>
<FrameColor>Black</FrameColor>
<Name>ReportDetail</Name>
</BaseSection>
<BaseSection>
<Location>50, 275</Location>
<Size>727, 60</Size>
<BackColor>White</BackColor>
<VisibleInReport>False</VisibleInReport>
<SectionOffset>0</SectionOffset>
<SectionMargin>0</SectionMargin>
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items>
<BaseTextItem>
<Location>622, 5</Location>
<Size>100, 20</Size>
<BackColor>White</BackColor>
<VisibleInReport>True</VisibleInReport>
<Font>Microsoft Sans Serif, 10pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanShrink>False</CanShrink>
<DataType>System.String</DataType>
<RTL>No</RTL>
<Text>=Globals!PageNumber</Text>
<DrawBorder>False</DrawBorder>
<FrameColor>Black</FrameColor>
<ForeColor>Black</ForeColor>
<Name>PageNumber1</Name>
</BaseTextItem>
</Items>
<FrameColor>Black</FrameColor>
<Name>ReportPageFooter</Name>
</BaseSection>
<BaseSection>
<Location>50, 350</Location>
<Size>727, 60</Size>
<BackColor>White</BackColor>
<VisibleInReport>False</VisibleInReport>
<SectionOffset>0</SectionOffset>
<SectionMargin>0</SectionMargin>
<DrawBorder>False</DrawBorder>
<PageBreakAfter>False</PageBreakAfter>
<Items />
<FrameColor>Black</FrameColor>
<Name>ReportFooter</Name>
</BaseSection>
</SectionCollection>
</ReportModel>
Loading…
Cancel
Save